github.com/jdgcs/sqlite3@v1.12.1-0.20210908114423-bc5f96e4dd51/internal/testfixture/testfixture_linux_s390x.go (about) 1 // Code generated by 'ccgo -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_SERIES_CONSTRAINT_VERIFY=1 -DSQLITE_SERVER=1 -DTCLSH_INIT_PROC=sqlite3TestInit -D_HAVE_SQLITE_CONFIG_H -I/usr/include/tcl8.6 -export-defines "" -export-fields F -trace-translation-units -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 -lmodernc.org/sqlite/libtest -lmodernc.org/tcl/lib -lmodernc.org/z/lib -o internal/testfixture/testfixture_linux_s390x.go -Itestdata/sqlite-src-3350500/ext/async -Itestdata/sqlite-src-3350500/ext/fts3 -Itestdata/sqlite-src-3350500/ext/icu -Itestdata/sqlite-src-3350500/ext/rtree -Itestdata/sqlite-src-3350500/ext/session -Itestdata/sqlite-src-3350500/ext/userauth -Itestdata/sqlite-src-3350500/src -Itestdata/sqlite-amalgamation-3350500 -Itestdata/sqlite-src-3350500 testdata/sqlite-src-3350500/ext/expert/sqlite3expert.c testdata/sqlite-src-3350500/ext/expert/test_expert.c testdata/sqlite-src-3350500/ext/fts3/fts3_term.c testdata/sqlite-src-3350500/ext/fts3/fts3_test.c testdata/sqlite-src-3350500/ext/fts5/fts5_tcl.c testdata/sqlite-src-3350500/ext/fts5/fts5_test_mi.c testdata/sqlite-src-3350500/ext/fts5/fts5_test_tok.c testdata/sqlite-src-3350500/ext/misc/appendvfs.c testdata/sqlite-src-3350500/ext/misc/amatch.c testdata/sqlite-src-3350500/ext/misc/carray.c testdata/sqlite-src-3350500/ext/misc/cksumvfs.c testdata/sqlite-src-3350500/ext/misc/closure.c testdata/sqlite-src-3350500/ext/misc/csv.c testdata/sqlite-src-3350500/ext/misc/decimal.c testdata/sqlite-src-3350500/ext/misc/eval.c testdata/sqlite-src-3350500/ext/misc/explain.c testdata/sqlite-src-3350500/ext/misc/fileio.c testdata/sqlite-src-3350500/ext/misc/fuzzer.c testdata/sqlite-src-3350500/ext/misc/ieee754.c testdata/sqlite-src-3350500/ext/misc/mmapwarm.c testdata/sqlite-src-3350500/ext/misc/nextchar.c testdata/sqlite-src-3350500/ext/misc/normalize.c testdata/sqlite-src-3350500/ext/misc/percentile.c testdata/sqlite-src-3350500/ext/misc/prefixes.c testdata/sqlite-src-3350500/ext/misc/regexp.c testdata/sqlite-src-3350500/ext/misc/remember.c testdata/sqlite-src-3350500/ext/misc/series.c testdata/sqlite-src-3350500/ext/misc/spellfix.c testdata/sqlite-src-3350500/ext/misc/totype.c testdata/sqlite-src-3350500/ext/misc/unionvtab.c testdata/sqlite-src-3350500/ext/misc/wholenumber.c testdata/sqlite-src-3350500/ext/misc/zipfile.c testdata/sqlite-src-3350500/ext/rbu/test_rbu.c testdata/sqlite-src-3350500/ext/userauth/userauth.c testdata/sqlite-src-3350500/src/tclsqlite.c testdata/sqlite-src-3350500/src/test1.c testdata/sqlite-src-3350500/src/test2.c testdata/sqlite-src-3350500/src/test3.c testdata/sqlite-src-3350500/src/test4.c testdata/sqlite-src-3350500/src/test5.c testdata/sqlite-src-3350500/src/test6.c testdata/sqlite-src-3350500/src/test7.c testdata/sqlite-src-3350500/src/test8.c testdata/sqlite-src-3350500/src/test9.c testdata/sqlite-src-3350500/src/test_async.c testdata/sqlite-src-3350500/src/test_autoext.c testdata/sqlite-src-3350500/src/test_backup.c testdata/sqlite-src-3350500/src/test_bestindex.c testdata/sqlite-src-3350500/src/test_blob.c testdata/sqlite-src-3350500/src/test_btree.c testdata/sqlite-src-3350500/src/test_config.c testdata/sqlite-src-3350500/src/test_delete.c testdata/sqlite-src-3350500/src/test_demovfs.c testdata/sqlite-src-3350500/src/test_devsym.c testdata/sqlite-src-3350500/src/test_fs.c testdata/sqlite-src-3350500/src/test_func.c testdata/sqlite-src-3350500/src/test_hexio.c testdata/sqlite-src-3350500/src/test_init.c testdata/sqlite-src-3350500/src/test_intarray.c testdata/sqlite-src-3350500/src/test_journal.c testdata/sqlite-src-3350500/src/test_malloc.c testdata/sqlite-src-3350500/src/test_md5.c testdata/sqlite-src-3350500/src/test_multiplex.c testdata/sqlite-src-3350500/src/test_mutex.c testdata/sqlite-src-3350500/src/test_onefile.c testdata/sqlite-src-3350500/src/test_osinst.c testdata/sqlite-src-3350500/src/test_pcache.c testdata/sqlite-src-3350500/src/test_quota.c testdata/sqlite-src-3350500/src/test_rtree.c testdata/sqlite-src-3350500/src/test_schema.c testdata/sqlite-src-3350500/src/test_server.c testdata/sqlite-src-3350500/src/test_superlock.c testdata/sqlite-src-3350500/src/test_syscall.c testdata/sqlite-src-3350500/src/test_tclsh.c testdata/sqlite-src-3350500/src/test_tclvar.c testdata/sqlite-src-3350500/src/test_thread.c testdata/sqlite-src-3350500/src/test_vdbecov.c testdata/sqlite-src-3350500/src/test_vfs.c testdata/sqlite-src-3350500/src/test_windirent.c testdata/sqlite-src-3350500/src/test_window.c testdata/sqlite-src-3350500/src/test_wsd.c -DNDEBUG -DHAVE_USLEEP -DLONGDOUBLE_TYPE=double -DSQLITE_CKSUMVFS_STATIC -DSQLITE_CORE -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_PAGE_SIZE=1024 -DSQLITE_ENABLE_BYTECODE_VTAB -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_DESERIALIZE -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_GEOPOLY -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_OFFSET_SQL_FUNC -DSQLITE_ENABLE_PREUPDATE_HOOK -DSQLITE_ENABLE_RBU -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_SNAPSHOT -DSQLITE_ENABLE_STAT4 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_ENABLE_UNLOCK_NOTIFY -DSQLITE_HAVE_ZLIB=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_MUTEX_APPDEF=1 -DSQLITE_SOUNDEX -DSQLITE_TEMP_STORE=1 -DSQLITE_TEST -DSQLITE_THREADSAFE=1 -DSQLITE_MUTEX_NOOP -lmodernc.org/sqlite/internal/libc2', DO NOT EDIT. 2 3 package main 4 5 import ( 6 "math" 7 "reflect" 8 "sync/atomic" 9 "unsafe" 10 11 "modernc.org/libc" 12 "modernc.org/libc/sys/types" 13 "modernc.org/sqlite/internal/libc2" 14 "modernc.org/sqlite/libtest" 15 "modernc.org/tcl/lib" 16 ) 17 18 var _ = math.Pi 19 var _ reflect.Kind 20 var _ atomic.Value 21 var _ unsafe.Pointer 22 var _ types.Size_t 23 24 func main() { libc.Start(main1) } 25 26 const ( 27 BUFSIZ = 8192 28 EOF = -1 29 EXPERT_CONFIG_SAMPLE = 1 30 EXPERT_REPORT_CANDIDATES = 4 31 EXPERT_REPORT_INDEXES = 2 32 EXPERT_REPORT_PLAN = 3 33 EXPERT_REPORT_SQL = 1 34 FILENAME_MAX = 4096 35 FOPEN_MAX = 16 36 FTS5_TOKENIZE_AUX = 0x0008 37 FTS5_TOKENIZE_DOCUMENT = 0x0004 38 FTS5_TOKENIZE_PREFIX = 0x0002 39 FTS5_TOKENIZE_QUERY = 0x0001 40 FTS5_TOKEN_COLOCATED = 0x0001 41 FULLY_WITHIN = 2 42 HAVE_USLEEP = 1 43 IDX_HASH_SIZE = 1023 44 L_ctermid = 9 45 L_tmpnam = 20 46 NDEBUG = 1 47 NOT_WITHIN = 0 48 PARTLY_WITHIN = 1 49 P_tmpdir = "/tmp" 50 SEEK_CUR = 1 51 SEEK_END = 2 52 SEEK_SET = 0 53 SQLITE3_H = 0 54 SQLITE3_TEXT = 3 55 SQLITEEXPERT_H = 1 56 SQLITE_ABORT = 4 57 SQLITE_ABORT_ROLLBACK = 516 58 SQLITE_ACCESS_EXISTS = 0 59 SQLITE_ACCESS_READ = 2 60 SQLITE_ACCESS_READWRITE = 1 61 SQLITE_ALTER_TABLE = 26 62 SQLITE_ANALYZE = 28 63 SQLITE_ANY = 5 64 SQLITE_API = 0 65 SQLITE_APICALL = 0 66 SQLITE_ATTACH = 24 67 SQLITE_AUTH = 23 68 SQLITE_AUTH_USER = 279 69 SQLITE_BLOB = 4 70 SQLITE_BUSY = 5 71 SQLITE_BUSY_RECOVERY = 261 72 SQLITE_BUSY_SNAPSHOT = 517 73 SQLITE_BUSY_TIMEOUT = 773 74 SQLITE_CALLBACK = 0 75 SQLITE_CANTOPEN = 14 76 SQLITE_CANTOPEN_CONVPATH = 1038 77 SQLITE_CANTOPEN_DIRTYWAL = 1294 78 SQLITE_CANTOPEN_FULLPATH = 782 79 SQLITE_CANTOPEN_ISDIR = 526 80 SQLITE_CANTOPEN_NOTEMPDIR = 270 81 SQLITE_CANTOPEN_SYMLINK = 1550 82 SQLITE_CDECL = 0 83 SQLITE_CHECKPOINT_FULL = 1 84 SQLITE_CHECKPOINT_PASSIVE = 0 85 SQLITE_CHECKPOINT_RESTART = 2 86 SQLITE_CHECKPOINT_TRUNCATE = 3 87 SQLITE_CKSUMVFS_STATIC = 1 88 SQLITE_CONFIG_COVERING_INDEX_SCAN = 20 89 SQLITE_CONFIG_GETMALLOC = 5 90 SQLITE_CONFIG_GETMUTEX = 11 91 SQLITE_CONFIG_GETPCACHE = 15 92 SQLITE_CONFIG_GETPCACHE2 = 19 93 SQLITE_CONFIG_HEAP = 8 94 SQLITE_CONFIG_LOG = 16 95 SQLITE_CONFIG_LOOKASIDE = 13 96 SQLITE_CONFIG_MALLOC = 4 97 SQLITE_CONFIG_MEMDB_MAXSIZE = 29 98 SQLITE_CONFIG_MEMSTATUS = 9 99 SQLITE_CONFIG_MMAP_SIZE = 22 100 SQLITE_CONFIG_MULTITHREAD = 2 101 SQLITE_CONFIG_MUTEX = 10 102 SQLITE_CONFIG_PAGECACHE = 7 103 SQLITE_CONFIG_PCACHE = 14 104 SQLITE_CONFIG_PCACHE2 = 18 105 SQLITE_CONFIG_PCACHE_HDRSZ = 24 106 SQLITE_CONFIG_PMASZ = 25 107 SQLITE_CONFIG_SCRATCH = 6 108 SQLITE_CONFIG_SERIALIZED = 3 109 SQLITE_CONFIG_SINGLETHREAD = 1 110 SQLITE_CONFIG_SMALL_MALLOC = 27 111 SQLITE_CONFIG_SORTERREF_SIZE = 28 112 SQLITE_CONFIG_SQLLOG = 21 113 SQLITE_CONFIG_STMTJRNL_SPILL = 26 114 SQLITE_CONFIG_URI = 17 115 SQLITE_CONFIG_WIN32_HEAPSIZE = 23 116 SQLITE_CONSTRAINT = 19 117 SQLITE_CONSTRAINT_CHECK = 275 118 SQLITE_CONSTRAINT_COMMITHOOK = 531 119 SQLITE_CONSTRAINT_FOREIGNKEY = 787 120 SQLITE_CONSTRAINT_FUNCTION = 1043 121 SQLITE_CONSTRAINT_NOTNULL = 1299 122 SQLITE_CONSTRAINT_PINNED = 2835 123 SQLITE_CONSTRAINT_PRIMARYKEY = 1555 124 SQLITE_CONSTRAINT_ROWID = 2579 125 SQLITE_CONSTRAINT_TRIGGER = 1811 126 SQLITE_CONSTRAINT_UNIQUE = 2067 127 SQLITE_CONSTRAINT_VTAB = 2323 128 SQLITE_COPY = 0 129 SQLITE_CORE = 1 130 SQLITE_CORRUPT = 11 131 SQLITE_CORRUPT_INDEX = 779 132 SQLITE_CORRUPT_SEQUENCE = 523 133 SQLITE_CORRUPT_VTAB = 267 134 SQLITE_CREATE_INDEX = 1 135 SQLITE_CREATE_TABLE = 2 136 SQLITE_CREATE_TEMP_INDEX = 3 137 SQLITE_CREATE_TEMP_TABLE = 4 138 SQLITE_CREATE_TEMP_TRIGGER = 5 139 SQLITE_CREATE_TEMP_VIEW = 6 140 SQLITE_CREATE_TRIGGER = 7 141 SQLITE_CREATE_VIEW = 8 142 SQLITE_CREATE_VTABLE = 29 143 SQLITE_DBCONFIG_DEFENSIVE = 1010 144 SQLITE_DBCONFIG_DQS_DDL = 1014 145 SQLITE_DBCONFIG_DQS_DML = 1013 146 SQLITE_DBCONFIG_ENABLE_FKEY = 1002 147 SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER = 1004 148 SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION = 1005 149 SQLITE_DBCONFIG_ENABLE_QPSG = 1007 150 SQLITE_DBCONFIG_ENABLE_TRIGGER = 1003 151 SQLITE_DBCONFIG_ENABLE_VIEW = 1015 152 SQLITE_DBCONFIG_LEGACY_ALTER_TABLE = 1012 153 SQLITE_DBCONFIG_LEGACY_FILE_FORMAT = 1016 154 SQLITE_DBCONFIG_LOOKASIDE = 1001 155 SQLITE_DBCONFIG_MAINDBNAME = 1000 156 SQLITE_DBCONFIG_MAX = 1017 157 SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE = 1006 158 SQLITE_DBCONFIG_RESET_DATABASE = 1009 159 SQLITE_DBCONFIG_TRIGGER_EQP = 1008 160 SQLITE_DBCONFIG_TRUSTED_SCHEMA = 1017 161 SQLITE_DBCONFIG_WRITABLE_SCHEMA = 1011 162 SQLITE_DBSTATUS_CACHE_HIT = 7 163 SQLITE_DBSTATUS_CACHE_MISS = 8 164 SQLITE_DBSTATUS_CACHE_SPILL = 12 165 SQLITE_DBSTATUS_CACHE_USED = 1 166 SQLITE_DBSTATUS_CACHE_USED_SHARED = 11 167 SQLITE_DBSTATUS_CACHE_WRITE = 9 168 SQLITE_DBSTATUS_DEFERRED_FKS = 10 169 SQLITE_DBSTATUS_LOOKASIDE_HIT = 4 170 SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL = 6 171 SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE = 5 172 SQLITE_DBSTATUS_LOOKASIDE_USED = 0 173 SQLITE_DBSTATUS_MAX = 12 174 SQLITE_DBSTATUS_SCHEMA_USED = 2 175 SQLITE_DBSTATUS_STMT_USED = 3 176 SQLITE_DEFAULT_MEMSTATUS = 0 177 SQLITE_DEFAULT_PAGE_SIZE = 1024 178 SQLITE_DELETE = 9 179 SQLITE_DENY = 1 180 SQLITE_DEPRECATED = 0 181 SQLITE_DESERIALIZE_FREEONCLOSE = 1 182 SQLITE_DESERIALIZE_READONLY = 4 183 SQLITE_DESERIALIZE_RESIZEABLE = 2 184 SQLITE_DETACH = 25 185 SQLITE_DETERMINISTIC = 0x000000800 186 SQLITE_DIRECTONLY = 0x000080000 187 SQLITE_DONE = 101 188 SQLITE_DROP_INDEX = 10 189 SQLITE_DROP_TABLE = 11 190 SQLITE_DROP_TEMP_INDEX = 12 191 SQLITE_DROP_TEMP_TABLE = 13 192 SQLITE_DROP_TEMP_TRIGGER = 14 193 SQLITE_DROP_TEMP_VIEW = 15 194 SQLITE_DROP_TRIGGER = 16 195 SQLITE_DROP_VIEW = 17 196 SQLITE_DROP_VTABLE = 30 197 SQLITE_EMPTY = 16 198 SQLITE_ENABLE_BYTECODE_VTAB = 1 199 SQLITE_ENABLE_COLUMN_METADATA = 1 200 SQLITE_ENABLE_DBPAGE_VTAB = 1 201 SQLITE_ENABLE_DBSTAT_VTAB = 1 202 SQLITE_ENABLE_DESERIALIZE = 1 203 SQLITE_ENABLE_EXPLAIN_COMMENTS = 1 204 SQLITE_ENABLE_FTS5 = 1 205 SQLITE_ENABLE_GEOPOLY = 1 206 SQLITE_ENABLE_JSON1 = 1 207 SQLITE_ENABLE_MEMORY_MANAGEMENT = 1 208 SQLITE_ENABLE_OFFSET_SQL_FUNC = 1 209 SQLITE_ENABLE_PREUPDATE_HOOK = 1 210 SQLITE_ENABLE_RBU = 1 211 SQLITE_ENABLE_RTREE = 1 212 SQLITE_ENABLE_SNAPSHOT = 1 213 SQLITE_ENABLE_STAT4 = 1 214 SQLITE_ENABLE_STMTVTAB = 1 215 SQLITE_ENABLE_UNLOCK_NOTIFY = 1 216 SQLITE_ERROR = 1 217 SQLITE_ERROR_MISSING_COLLSEQ = 257 218 SQLITE_ERROR_RETRY = 513 219 SQLITE_ERROR_SNAPSHOT = 769 220 SQLITE_EXPERIMENTAL = 0 221 SQLITE_FAIL = 3 222 SQLITE_FCNTL_BEGIN_ATOMIC_WRITE = 31 223 SQLITE_FCNTL_BUSYHANDLER = 15 224 SQLITE_FCNTL_CHUNK_SIZE = 6 225 SQLITE_FCNTL_CKPT_DONE = 37 226 SQLITE_FCNTL_CKPT_START = 39 227 SQLITE_FCNTL_COMMIT_ATOMIC_WRITE = 32 228 SQLITE_FCNTL_COMMIT_PHASETWO = 22 229 SQLITE_FCNTL_DATA_VERSION = 35 230 SQLITE_FCNTL_FILE_POINTER = 7 231 SQLITE_FCNTL_GET_LOCKPROXYFILE = 2 232 SQLITE_FCNTL_HAS_MOVED = 20 233 SQLITE_FCNTL_JOURNAL_POINTER = 28 234 SQLITE_FCNTL_LAST_ERRNO = 4 235 SQLITE_FCNTL_LOCKSTATE = 1 236 SQLITE_FCNTL_LOCK_TIMEOUT = 34 237 SQLITE_FCNTL_MMAP_SIZE = 18 238 SQLITE_FCNTL_OVERWRITE = 11 239 SQLITE_FCNTL_PDB = 30 240 SQLITE_FCNTL_PERSIST_WAL = 10 241 SQLITE_FCNTL_POWERSAFE_OVERWRITE = 13 242 SQLITE_FCNTL_PRAGMA = 14 243 SQLITE_FCNTL_RBU = 26 244 SQLITE_FCNTL_RESERVE_BYTES = 38 245 SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE = 33 246 SQLITE_FCNTL_SET_LOCKPROXYFILE = 3 247 SQLITE_FCNTL_SIZE_HINT = 5 248 SQLITE_FCNTL_SIZE_LIMIT = 36 249 SQLITE_FCNTL_SYNC = 21 250 SQLITE_FCNTL_SYNC_OMITTED = 8 251 SQLITE_FCNTL_TEMPFILENAME = 16 252 SQLITE_FCNTL_TRACE = 19 253 SQLITE_FCNTL_VFSNAME = 12 254 SQLITE_FCNTL_VFS_POINTER = 27 255 SQLITE_FCNTL_WAL_BLOCK = 24 256 SQLITE_FCNTL_WIN32_AV_RETRY = 9 257 SQLITE_FCNTL_WIN32_GET_HANDLE = 29 258 SQLITE_FCNTL_WIN32_SET_HANDLE = 23 259 SQLITE_FCNTL_ZIPVFS = 25 260 SQLITE_FLOAT = 2 261 SQLITE_FORMAT = 24 262 SQLITE_FULL = 13 263 SQLITE_FUNCTION = 31 264 SQLITE_GET_LOCKPROXYFILE = 2 265 SQLITE_HAVE_ZLIB = 1 266 SQLITE_IGNORE = 2 267 SQLITE_INDEX_CONSTRAINT_EQ = 2 268 SQLITE_INDEX_CONSTRAINT_FUNCTION = 150 269 SQLITE_INDEX_CONSTRAINT_GE = 32 270 SQLITE_INDEX_CONSTRAINT_GLOB = 66 271 SQLITE_INDEX_CONSTRAINT_GT = 4 272 SQLITE_INDEX_CONSTRAINT_IS = 72 273 SQLITE_INDEX_CONSTRAINT_ISNOT = 69 274 SQLITE_INDEX_CONSTRAINT_ISNOTNULL = 70 275 SQLITE_INDEX_CONSTRAINT_ISNULL = 71 276 SQLITE_INDEX_CONSTRAINT_LE = 8 277 SQLITE_INDEX_CONSTRAINT_LIKE = 65 278 SQLITE_INDEX_CONSTRAINT_LT = 16 279 SQLITE_INDEX_CONSTRAINT_MATCH = 64 280 SQLITE_INDEX_CONSTRAINT_NE = 68 281 SQLITE_INDEX_CONSTRAINT_REGEXP = 67 282 SQLITE_INDEX_SCAN_UNIQUE = 1 283 SQLITE_INNOCUOUS = 0x000200000 284 SQLITE_INSERT = 18 285 SQLITE_INTEGER = 1 286 SQLITE_INTERNAL = 2 287 SQLITE_INTERRUPT = 9 288 SQLITE_IOCAP_ATOMIC = 0x00000001 289 SQLITE_IOCAP_ATOMIC16K = 0x00000040 290 SQLITE_IOCAP_ATOMIC1K = 0x00000004 291 SQLITE_IOCAP_ATOMIC2K = 0x00000008 292 SQLITE_IOCAP_ATOMIC32K = 0x00000080 293 SQLITE_IOCAP_ATOMIC4K = 0x00000010 294 SQLITE_IOCAP_ATOMIC512 = 0x00000002 295 SQLITE_IOCAP_ATOMIC64K = 0x00000100 296 SQLITE_IOCAP_ATOMIC8K = 0x00000020 297 SQLITE_IOCAP_BATCH_ATOMIC = 0x00004000 298 SQLITE_IOCAP_IMMUTABLE = 0x00002000 299 SQLITE_IOCAP_POWERSAFE_OVERWRITE = 0x00001000 300 SQLITE_IOCAP_SAFE_APPEND = 0x00000200 301 SQLITE_IOCAP_SEQUENTIAL = 0x00000400 302 SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN = 0x00000800 303 SQLITE_IOERR = 10 304 SQLITE_IOERR_ACCESS = 3338 305 SQLITE_IOERR_AUTH = 7178 306 SQLITE_IOERR_BEGIN_ATOMIC = 7434 307 SQLITE_IOERR_BLOCKED = 2826 308 SQLITE_IOERR_CHECKRESERVEDLOCK = 3594 309 SQLITE_IOERR_CLOSE = 4106 310 SQLITE_IOERR_COMMIT_ATOMIC = 7690 311 SQLITE_IOERR_CONVPATH = 6666 312 SQLITE_IOERR_CORRUPTFS = 8458 313 SQLITE_IOERR_DATA = 8202 314 SQLITE_IOERR_DELETE = 2570 315 SQLITE_IOERR_DELETE_NOENT = 5898 316 SQLITE_IOERR_DIR_CLOSE = 4362 317 SQLITE_IOERR_DIR_FSYNC = 1290 318 SQLITE_IOERR_FSTAT = 1802 319 SQLITE_IOERR_FSYNC = 1034 320 SQLITE_IOERR_GETTEMPPATH = 6410 321 SQLITE_IOERR_LOCK = 3850 322 SQLITE_IOERR_MMAP = 6154 323 SQLITE_IOERR_NOMEM = 3082 324 SQLITE_IOERR_RDLOCK = 2314 325 SQLITE_IOERR_READ = 266 326 SQLITE_IOERR_ROLLBACK_ATOMIC = 7946 327 SQLITE_IOERR_SEEK = 5642 328 SQLITE_IOERR_SHMLOCK = 5130 329 SQLITE_IOERR_SHMMAP = 5386 330 SQLITE_IOERR_SHMOPEN = 4618 331 SQLITE_IOERR_SHMSIZE = 4874 332 SQLITE_IOERR_SHORT_READ = 522 333 SQLITE_IOERR_TRUNCATE = 1546 334 SQLITE_IOERR_UNLOCK = 2058 335 SQLITE_IOERR_VNODE = 6922 336 SQLITE_IOERR_WRITE = 778 337 SQLITE_LAST_ERRNO = 4 338 SQLITE_LIKE_DOESNT_MATCH_BLOBS = 1 339 SQLITE_LIMIT_ATTACHED = 7 340 SQLITE_LIMIT_COLUMN = 2 341 SQLITE_LIMIT_COMPOUND_SELECT = 4 342 SQLITE_LIMIT_EXPR_DEPTH = 3 343 SQLITE_LIMIT_FUNCTION_ARG = 6 344 SQLITE_LIMIT_LENGTH = 0 345 SQLITE_LIMIT_LIKE_PATTERN_LENGTH = 8 346 SQLITE_LIMIT_SQL_LENGTH = 1 347 SQLITE_LIMIT_TRIGGER_DEPTH = 10 348 SQLITE_LIMIT_VARIABLE_NUMBER = 9 349 SQLITE_LIMIT_VDBE_OP = 5 350 SQLITE_LIMIT_WORKER_THREADS = 11 351 SQLITE_LOCKED = 6 352 SQLITE_LOCKED_SHAREDCACHE = 262 353 SQLITE_LOCKED_VTAB = 518 354 SQLITE_LOCK_EXCLUSIVE = 4 355 SQLITE_LOCK_NONE = 0 356 SQLITE_LOCK_PENDING = 3 357 SQLITE_LOCK_RESERVED = 2 358 SQLITE_LOCK_SHARED = 1 359 SQLITE_MISMATCH = 20 360 SQLITE_MISUSE = 21 361 SQLITE_MUTEX_APPDEF = 1 362 SQLITE_MUTEX_FAST = 0 363 SQLITE_MUTEX_NOOP = 1 364 SQLITE_MUTEX_RECURSIVE = 1 365 SQLITE_MUTEX_STATIC_APP1 = 8 366 SQLITE_MUTEX_STATIC_APP2 = 9 367 SQLITE_MUTEX_STATIC_APP3 = 10 368 SQLITE_MUTEX_STATIC_LRU = 6 369 SQLITE_MUTEX_STATIC_LRU2 = 7 370 SQLITE_MUTEX_STATIC_MAIN = 2 371 SQLITE_MUTEX_STATIC_MASTER = 2 372 SQLITE_MUTEX_STATIC_MEM = 3 373 SQLITE_MUTEX_STATIC_MEM2 = 4 374 SQLITE_MUTEX_STATIC_OPEN = 4 375 SQLITE_MUTEX_STATIC_PMEM = 7 376 SQLITE_MUTEX_STATIC_PRNG = 5 377 SQLITE_MUTEX_STATIC_VFS1 = 11 378 SQLITE_MUTEX_STATIC_VFS2 = 12 379 SQLITE_MUTEX_STATIC_VFS3 = 13 380 SQLITE_NOLFS = 22 381 SQLITE_NOMEM = 7 382 SQLITE_NOTADB = 26 383 SQLITE_NOTFOUND = 12 384 SQLITE_NOTICE = 27 385 SQLITE_NOTICE_RECOVER_ROLLBACK = 539 386 SQLITE_NOTICE_RECOVER_WAL = 283 387 SQLITE_NULL = 5 388 SQLITE_OK = 0 389 SQLITE_OK_LOAD_PERMANENTLY = 256 390 SQLITE_OK_SYMLINK = 512 391 SQLITE_OMIT_LOAD_EXTENSION = 1 392 SQLITE_OPEN_AUTOPROXY = 0x00000020 393 SQLITE_OPEN_CREATE = 0x00000004 394 SQLITE_OPEN_DELETEONCLOSE = 0x00000008 395 SQLITE_OPEN_EXCLUSIVE = 0x00000010 396 SQLITE_OPEN_FULLMUTEX = 0x00010000 397 SQLITE_OPEN_MAIN_DB = 0x00000100 398 SQLITE_OPEN_MAIN_JOURNAL = 0x00000800 399 SQLITE_OPEN_MASTER_JOURNAL = 0x00004000 400 SQLITE_OPEN_MEMORY = 0x00000080 401 SQLITE_OPEN_NOFOLLOW = 0x01000000 402 SQLITE_OPEN_NOMUTEX = 0x00008000 403 SQLITE_OPEN_PRIVATECACHE = 0x00040000 404 SQLITE_OPEN_READONLY = 0x00000001 405 SQLITE_OPEN_READWRITE = 0x00000002 406 SQLITE_OPEN_SHAREDCACHE = 0x00020000 407 SQLITE_OPEN_SUBJOURNAL = 0x00002000 408 SQLITE_OPEN_SUPER_JOURNAL = 0x00004000 409 SQLITE_OPEN_TEMP_DB = 0x00000200 410 SQLITE_OPEN_TEMP_JOURNAL = 0x00001000 411 SQLITE_OPEN_TRANSIENT_DB = 0x00000400 412 SQLITE_OPEN_URI = 0x00000040 413 SQLITE_OPEN_WAL = 0x00080000 414 SQLITE_PERM = 3 415 SQLITE_PRAGMA = 19 416 SQLITE_PREPARE_NORMALIZE = 0x02 417 SQLITE_PREPARE_NO_VTAB = 0x04 418 SQLITE_PREPARE_PERSISTENT = 0x01 419 SQLITE_PROTOCOL = 15 420 SQLITE_RANGE = 25 421 SQLITE_READ = 20 422 SQLITE_READONLY = 8 423 SQLITE_READONLY_CANTINIT = 1288 424 SQLITE_READONLY_CANTLOCK = 520 425 SQLITE_READONLY_DBMOVED = 1032 426 SQLITE_READONLY_DIRECTORY = 1544 427 SQLITE_READONLY_RECOVERY = 264 428 SQLITE_READONLY_ROLLBACK = 776 429 SQLITE_RECURSIVE = 33 430 SQLITE_REINDEX = 27 431 SQLITE_REPLACE = 5 432 SQLITE_ROLLBACK = 1 433 SQLITE_ROW = 100 434 SQLITE_SAVEPOINT = 32 435 SQLITE_SCANSTAT_EST = 2 436 SQLITE_SCANSTAT_EXPLAIN = 4 437 SQLITE_SCANSTAT_NAME = 3 438 SQLITE_SCANSTAT_NLOOP = 0 439 SQLITE_SCANSTAT_NVISIT = 1 440 SQLITE_SCANSTAT_SELECTID = 5 441 SQLITE_SCHEMA = 17 442 SQLITE_SELECT = 21 443 SQLITE_SERIALIZE_NOCOPY = 0x001 444 SQLITE_SERIES_CONSTRAINT_VERIFY = 1 445 SQLITE_SERVER = 1 446 SQLITE_SET_LOCKPROXYFILE = 3 447 SQLITE_SHM_EXCLUSIVE = 8 448 SQLITE_SHM_LOCK = 2 449 SQLITE_SHM_NLOCK = 8 450 SQLITE_SHM_SHARED = 4 451 SQLITE_SHM_UNLOCK = 1 452 SQLITE_SOUNDEX = 1 453 SQLITE_SOURCE_ID = "2021-04-19 18:32:05 1b256d97b553a9611efca188a3d995a2fff712759044ba480f9a0c9e98fae886" 454 SQLITE_STATUS_MALLOC_COUNT = 9 455 SQLITE_STATUS_MALLOC_SIZE = 5 456 SQLITE_STATUS_MEMORY_USED = 0 457 SQLITE_STATUS_PAGECACHE_OVERFLOW = 2 458 SQLITE_STATUS_PAGECACHE_SIZE = 7 459 SQLITE_STATUS_PAGECACHE_USED = 1 460 SQLITE_STATUS_PARSER_STACK = 6 461 SQLITE_STATUS_SCRATCH_OVERFLOW = 4 462 SQLITE_STATUS_SCRATCH_SIZE = 8 463 SQLITE_STATUS_SCRATCH_USED = 3 464 SQLITE_STDCALL = 0 465 SQLITE_STMTSTATUS_AUTOINDEX = 3 466 SQLITE_STMTSTATUS_FULLSCAN_STEP = 1 467 SQLITE_STMTSTATUS_MEMUSED = 99 468 SQLITE_STMTSTATUS_REPREPARE = 5 469 SQLITE_STMTSTATUS_RUN = 6 470 SQLITE_STMTSTATUS_SORT = 2 471 SQLITE_STMTSTATUS_VM_STEP = 4 472 SQLITE_SUBTYPE = 0x000100000 473 SQLITE_SYNC_DATAONLY = 0x00010 474 SQLITE_SYNC_FULL = 0x00003 475 SQLITE_SYNC_NORMAL = 0x00002 476 SQLITE_SYSAPI = 0 477 SQLITE_TEMP_STORE = 1 478 SQLITE_TEST = 1 479 SQLITE_TESTCTRL_ALWAYS = 13 480 SQLITE_TESTCTRL_ASSERT = 12 481 SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS = 10 482 SQLITE_TESTCTRL_BITVEC_TEST = 8 483 SQLITE_TESTCTRL_BYTEORDER = 22 484 SQLITE_TESTCTRL_EXPLAIN_STMT = 19 485 SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS = 29 486 SQLITE_TESTCTRL_FAULT_INSTALL = 9 487 SQLITE_TESTCTRL_FIRST = 5 488 SQLITE_TESTCTRL_IMPOSTER = 25 489 SQLITE_TESTCTRL_INTERNAL_FUNCTIONS = 17 490 SQLITE_TESTCTRL_ISINIT = 23 491 SQLITE_TESTCTRL_ISKEYWORD = 16 492 SQLITE_TESTCTRL_LAST = 31 493 SQLITE_TESTCTRL_LOCALTIME_FAULT = 18 494 SQLITE_TESTCTRL_NEVER_CORRUPT = 20 495 SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD = 19 496 SQLITE_TESTCTRL_OPTIMIZATIONS = 15 497 SQLITE_TESTCTRL_PARSER_COVERAGE = 26 498 SQLITE_TESTCTRL_PENDING_BYTE = 11 499 SQLITE_TESTCTRL_PRNG_RESET = 7 500 SQLITE_TESTCTRL_PRNG_RESTORE = 6 501 SQLITE_TESTCTRL_PRNG_SAVE = 5 502 SQLITE_TESTCTRL_PRNG_SEED = 28 503 SQLITE_TESTCTRL_RESERVE = 14 504 SQLITE_TESTCTRL_RESULT_INTREAL = 27 505 SQLITE_TESTCTRL_SCRATCHMALLOC = 17 506 SQLITE_TESTCTRL_SEEK_COUNT = 30 507 SQLITE_TESTCTRL_SORTER_MMAP = 24 508 SQLITE_TESTCTRL_TRACEFLAGS = 31 509 SQLITE_TESTCTRL_VDBE_COVERAGE = 21 510 SQLITE_TEXT = 3 511 SQLITE_THREADSAFE = 1 512 SQLITE_TOOBIG = 18 513 SQLITE_TRACE_CLOSE = 0x08 514 SQLITE_TRACE_PROFILE = 0x02 515 SQLITE_TRACE_ROW = 0x04 516 SQLITE_TRACE_STMT = 0x01 517 SQLITE_TRANSACTION = 22 518 SQLITE_TXN_NONE = 0 519 SQLITE_TXN_READ = 1 520 SQLITE_TXN_WRITE = 2 521 SQLITE_UPDATE = 23 522 SQLITE_UTF16 = 4 523 SQLITE_UTF16BE = 3 524 SQLITE_UTF16LE = 2 525 SQLITE_UTF16_ALIGNED = 8 526 SQLITE_UTF8 = 1 527 SQLITE_VERSION = "3.35.5" 528 SQLITE_VERSION_NUMBER = 3035005 529 SQLITE_VTAB_CONSTRAINT_SUPPORT = 1 530 SQLITE_VTAB_DIRECTONLY = 3 531 SQLITE_VTAB_INNOCUOUS = 2 532 SQLITE_WARNING = 28 533 SQLITE_WARNING_AUTOINDEX = 284 534 SQLITE_WIN32_DATA_DIRECTORY_TYPE = 1 535 SQLITE_WIN32_TEMP_DIRECTORY_TYPE = 2 536 TMP_MAX = 238328 537 UNIQUE_TABLE_NAME = "t592690916721053953805701627921227776" 538 X_ANSI_STDARG_H_ = 0 539 X_ASSERT_H = 1 540 X_ATFILE_SOURCE = 1 541 X_BITS_STDIO_LIM_H = 1 542 X_BITS_TYPESIZES_H = 1 543 X_BITS_TYPES_H = 1 544 X_BITS_TYPES_LOCALE_T_H = 1 545 X_BITS_TYPES___LOCALE_T_H = 1 546 X_BSD_SIZE_T_ = 0 547 X_BSD_SIZE_T_DEFINED_ = 0 548 X_DEFAULT_SOURCE = 1 549 X_FEATURES_H = 1 550 X_FILE_OFFSET_BITS = 64 551 X_FTS5_H = 0 552 X_GCC_SIZE_T = 0 553 X_HAVE_SQLITE_CONFIG_H = 1 554 X_IOFBF = 0 555 X_IOLBF = 1 556 X_IONBF = 2 557 X_IO_EOF_SEEN = 0x0010 558 X_IO_ERR_SEEN = 0x0020 559 X_IO_USER_LOCK = 0x8000 560 X_LP64 = 1 561 X_POSIX_C_SOURCE = 200809 562 X_POSIX_SOURCE = 1 563 X_SIZET_ = 0 564 X_SIZE_T = 0 565 X_SIZE_T_ = 0 566 X_SIZE_T_DECLARED = 0 567 X_SIZE_T_DEFINED = 0 568 X_SIZE_T_DEFINED_ = 0 569 X_SQLITE3RTREE_H_ = 0 570 X_STDARG_H = 0 571 X_STDC_PREDEF_H = 1 572 X_STDIO_H = 1 573 X_STRINGS_H = 1 574 X_STRING_H = 1 575 X_SYS_CDEFS_H = 1 576 X_SYS_SIZE_T_H = 0 577 X_T_SIZE = 0 578 X_T_SIZE_ = 0 579 X_VA_LIST = 0 580 X_VA_LIST_ = 0 581 X_VA_LIST_DEFINED = 0 582 X_VA_LIST_T_H = 0 583 Linux = 1 584 Unix = 1 585 CRTIMPORT = 0 586 DLLIMPORT = 0 587 INLINE = 0 588 MP_DIGIT_DECLARED = 0 589 MP_INT_DECLARED = 0 590 NUM_STATIC_TOKENS = 20 591 SQLITE_TCLAPI = 0 592 TCL_ALLOW_INLINE_COMPILATION = 0x20000 593 TCL_ALL_EVENTS = -3 594 TCL_ALPHA_RELEASE = 0 595 TCL_APPEND_VALUE = 4 596 TCL_ARGV_CONSTANT = 15 597 TCL_ARGV_END = 23 598 TCL_ARGV_FLOAT = 19 599 TCL_ARGV_FUNC = 20 600 TCL_ARGV_GENFUNC = 21 601 TCL_ARGV_HELP = 22 602 TCL_ARGV_INT = 16 603 TCL_ARGV_REST = 18 604 TCL_ARGV_STRING = 17 605 TCL_BETA_RELEASE = 1 606 TCL_BREAK = 3 607 TCL_CANCEL_UNWIND = 0x100000 608 TCL_CHANNEL_THREAD_INSERT = 0 609 TCL_CHANNEL_THREAD_REMOVE = 1 610 TCL_CLOSE_READ = 2 611 TCL_CLOSE_WRITE = 4 612 TCL_CONTINUE = 4 613 TCL_CONVERT_MULTIBYTE = -1 614 TCL_CONVERT_NOSPACE = -4 615 TCL_CONVERT_SYNTAX = -2 616 TCL_CONVERT_UNKNOWN = -3 617 TCL_CREATE_HARD_LINK = 0x02 618 TCL_CREATE_SYMBOLIC_LINK = 0x01 619 TCL_CUSTOM_PTR_KEYS = -1 620 TCL_CUSTOM_TYPE_KEYS = -2 621 TCL_DONT_QUOTE_HASH = 8 622 TCL_DONT_USE_BRACES = 1 623 TCL_DONT_WAIT = 2 624 TCL_DOUBLE_SPACE = 27 625 TCL_DSTRING_STATIC_SIZE = 200 626 TCL_ENCODING_CHAR_LIMIT = 0x10 627 TCL_ENCODING_END = 0x02 628 TCL_ENCODING_NO_TERMINATE = 0x08 629 TCL_ENCODING_START = 0x01 630 TCL_ENCODING_STOPONERROR = 0x04 631 TCL_ENFORCE_MODE = 16 632 TCL_ENSEMBLE_PREFIX = 0x02 633 TCL_ERROR = 1 634 TCL_EVAL_DIRECT = 0x040000 635 TCL_EVAL_GLOBAL = 0x020000 636 TCL_EVAL_INVOKE = 0x080000 637 TCL_EVAL_NOERR = 0x200000 638 TCL_EXACT = 1 639 TCL_EXCEPTION = 8 640 TCL_FILE_EVENTS = 8 641 TCL_FINAL_RELEASE = 2 642 TCL_GLOBAL_ONLY = 1 643 TCL_GLOB_PERM_HIDDEN = 2 644 TCL_GLOB_PERM_R = 4 645 TCL_GLOB_PERM_RONLY = 1 646 TCL_GLOB_PERM_W = 8 647 TCL_GLOB_PERM_X = 16 648 TCL_GLOB_TYPE_BLOCK = 1 649 TCL_GLOB_TYPE_CHAR = 2 650 TCL_GLOB_TYPE_DIR = 4 651 TCL_GLOB_TYPE_FILE = 16 652 TCL_GLOB_TYPE_LINK = 32 653 TCL_GLOB_TYPE_MOUNT = 128 654 TCL_GLOB_TYPE_PIPE = 8 655 TCL_GLOB_TYPE_SOCK = 64 656 TCL_HASH_KEY_RANDOMIZE_HASH = 0x1 657 TCL_HASH_KEY_STORE_HASH = 1 658 TCL_HASH_KEY_SYSTEM_HASH = 0x2 659 TCL_HASH_KEY_TYPE_VERSION = 1 660 TCL_IDLE_EVENTS = 32 661 TCL_INTEGER_SPACE = 24 662 TCL_INTERP_DESTROYED = 0x100 663 TCL_LEAVE_ERR_MSG = 0x200 664 TCL_LIMIT_COMMANDS = 0x01 665 TCL_LIMIT_TIME = 0x02 666 TCL_LINK_BOOLEAN = 3 667 TCL_LINK_CHAR = 6 668 TCL_LINK_DOUBLE = 2 669 TCL_LINK_FLOAT = 13 670 TCL_LINK_INT = 1 671 TCL_LINK_LONG = 11 672 TCL_LINK_READ_ONLY = 0x80 673 TCL_LINK_SHORT = 8 674 TCL_LINK_STRING = 4 675 TCL_LINK_UCHAR = 7 676 TCL_LINK_UINT = 10 677 TCL_LINK_ULONG = 12 678 TCL_LINK_USHORT = 9 679 TCL_LINK_WIDE_INT = 5 680 TCL_LINK_WIDE_UINT = 14 681 TCL_LIST_ELEMENT = 8 682 TCL_LL_MODIFIER = "ll" 683 TCL_LOAD_GLOBAL = 1 684 TCL_LOAD_LAZY = 2 685 TCL_MAJOR_VERSION = 8 686 TCL_MATCH_NOCASE = 1 687 TCL_MAX_PREC = 17 688 TCL_MINOR_VERSION = 6 689 TCL_MODE_BLOCKING = 0 690 TCL_MODE_NONBLOCKING = 1 691 TCL_NAMESPACE_ONLY = 2 692 TCL_NORETURN1 = 0 693 TCL_NO_EVAL = 0x010000 694 TCL_OK = 0 695 TCL_ONE_WORD_KEYS = 1 696 TCL_PARSE_BAD_NUMBER = 9 697 TCL_PARSE_BRACE_EXTRA = 2 698 TCL_PARSE_MISSING_BRACE = 3 699 TCL_PARSE_MISSING_BRACKET = 4 700 TCL_PARSE_MISSING_PAREN = 5 701 TCL_PARSE_MISSING_QUOTE = 6 702 TCL_PARSE_MISSING_VAR_BRACE = 7 703 TCL_PARSE_PART1 = 0x400 704 TCL_PARSE_QUOTE_EXTRA = 1 705 TCL_PARSE_SUCCESS = 0 706 TCL_PARSE_SYNTAX = 8 707 TCL_PATCH_LEVEL = "8.6.9" 708 TCL_READABLE = 2 709 TCL_REG_ADVANCED = 000003 710 TCL_REG_ADVF = 000002 711 TCL_REG_BASIC = 000000 712 TCL_REG_CANMATCH = 001000 713 TCL_REG_EXPANDED = 000040 714 TCL_REG_EXTENDED = 000001 715 TCL_REG_NEWLINE = 000300 716 TCL_REG_NLANCH = 000200 717 TCL_REG_NLSTOP = 000100 718 TCL_REG_NOCASE = 000010 719 TCL_REG_NOSUB = 000020 720 TCL_REG_NOTBOL = 0001 721 TCL_REG_NOTEOL = 0002 722 TCL_REG_QUOTE = 000004 723 TCL_RELEASE_LEVEL = 2 724 TCL_RELEASE_SERIAL = 9 725 TCL_RESULT_SIZE = 200 726 TCL_RETURN = 2 727 TCL_SERVICE_ALL = 1 728 TCL_SERVICE_NONE = 0 729 TCL_SMALL_HASH_TABLE = 4 730 TCL_STDERR = 8 731 TCL_STDIN = 2 732 TCL_STDOUT = 4 733 TCL_STORAGE_CLASS = 0 734 TCL_STRING_KEYS = 0 735 TCL_SUBST_ALL = 007 736 TCL_SUBST_BACKSLASHES = 004 737 TCL_SUBST_COMMANDS = 001 738 TCL_SUBST_VARIABLES = 002 739 TCL_THREAD_CREATE_RETURN = 0 740 TCL_THREAD_JOINABLE = 1 741 TCL_THREAD_NOFLAGS = 0 742 TCL_THREAD_STACK_DEFAULT = 0 743 TCL_TIMER_EVENTS = 16 744 TCL_TOKEN_BS = 8 745 TCL_TOKEN_COMMAND = 16 746 TCL_TOKEN_EXPAND_WORD = 256 747 TCL_TOKEN_OPERATOR = 128 748 TCL_TOKEN_SIMPLE_WORD = 2 749 TCL_TOKEN_SUB_EXPR = 64 750 TCL_TOKEN_TEXT = 4 751 TCL_TOKEN_VARIABLE = 32 752 TCL_TOKEN_WORD = 1 753 TCL_TRACE_ARRAY = 0x800 754 TCL_TRACE_DELETE = 0x4000 755 TCL_TRACE_DESTROYED = 0x80 756 TCL_TRACE_OLD_STYLE = 0x1000 757 TCL_TRACE_READS = 0x10 758 TCL_TRACE_RENAME = 0x2000 759 TCL_TRACE_RESULT_DYNAMIC = 0x8000 760 TCL_TRACE_RESULT_OBJECT = 0x10000 761 TCL_TRACE_UNSETS = 0x40 762 TCL_TRACE_WRITES = 0x20 763 TCL_UNLOAD_DETACH_FROM_INTERPRETER = 1 764 TCL_UNLOAD_DETACH_FROM_PROCESS = 2 765 TCL_UTF_MAX = 3 766 TCL_VERSION = "8.6" 767 TCL_WINDOW_EVENTS = 4 768 TCL_WRITABLE = 4 769 TCL_ZLIB_COMPRESS_BEST = 9 770 TCL_ZLIB_COMPRESS_DEFAULT = -1 771 TCL_ZLIB_COMPRESS_FAST = 1 772 TCL_ZLIB_COMPRESS_NONE = 0 773 TCL_ZLIB_FINALIZE = 4 774 TCL_ZLIB_FLUSH = 2 775 TCL_ZLIB_FORMAT_AUTO = 8 776 TCL_ZLIB_FORMAT_GZIP = 4 777 TCL_ZLIB_FORMAT_RAW = 1 778 TCL_ZLIB_FORMAT_ZLIB = 2 779 TCL_ZLIB_FULLFLUSH = 3 780 TCL_ZLIB_NO_FLUSH = 0 781 TCL_ZLIB_STREAM_DEFLATE = 16 782 TCL_ZLIB_STREAM_INFLATE = 32 783 X_CLIENTDATA = 0 784 X_TCL = 0 785 X_TCLDECLS = 0 786 X_TCLPLATDECLS = 0 787 X_FTSINT_H = 0 788 FTS3_TOK_SCHEMA = "CREATE TABLE x(input HIDDEN, token, start, end, position)" 789 APND_MARK_FOS_SZ = 8 790 APND_MARK_PREFIX = "Start-Of-SQLite3-" 791 APND_MARK_PREFIX_SZ = 17 792 APND_MARK_SIZE = 25 793 APND_MAX_SIZE = 1073741824 794 APND_ROUNDUP = 4096 795 SQLITE3EXT_H = 0 796 SQLITE_EXTENSION_INIT1 = 0 797 SQLITE_EXTENSION_INIT3 = 0 798 AMATCH_COL_COMMAND = 3 799 AMATCH_COL_DISTANCE = 1 800 AMATCH_COL_LANGUAGE = 2 801 AMATCH_COL_NWORD = 4 802 AMATCH_COL_WORD = 0 803 AMATCH_MX_COST = 1000 804 AMATCH_MX_LANGID = 2147483647 805 AMATCH_MX_LENGTH = 50 806 BIG_ENDIAN = 4321 807 BYTE_ORDER = 4321 808 EXIT_FAILURE = 1 809 EXIT_SUCCESS = 0 810 FD_SETSIZE = 1024 811 LITTLE_ENDIAN = 1234 812 PDP_ENDIAN = 3412 813 RAND_MAX = 2147483647 814 WCONTINUED = 8 815 WEXITED = 4 816 WNOHANG = 1 817 WNOWAIT = 0x01000000 818 WSTOPPED = 2 819 WUNTRACED = 2 820 X_ALLOCA_H = 1 821 X_BITS_BYTESWAP_H = 1 822 X_BITS_FLOATN_COMMON_H = 0 823 X_BITS_FLOATN_H = 0 824 X_BITS_PTHREADTYPES_ARCH_H = 1 825 X_BITS_PTHREADTYPES_COMMON_H = 1 826 X_BITS_STDINT_INTN_H = 1 827 X_BITS_UINTN_IDENTITY_H = 1 828 X_CTYPE_H = 1 829 X_ENDIAN_H = 1 830 X_GCC_WCHAR_T = 0 831 X_STDLIB_H = 1 832 X_STRUCT_TIMESPEC = 1 833 X_SYS_SELECT_H = 1 834 X_SYS_TYPES_H = 1 835 X_THREAD_SHARED_TYPES_H = 1 836 X_T_WCHAR = 0 837 X_T_WCHAR_ = 0 838 X_WCHAR_T = 0 839 X_WCHAR_T_ = 0 840 X_WCHAR_T_DECLARED = 0 841 X_WCHAR_T_DEFINED = 0 842 X_WCHAR_T_DEFINED_ = 0 843 X_WCHAR_T_H = 0 844 CARRAY_COLUMN_COUNT = 2 845 CARRAY_COLUMN_CTYPE = 3 846 CARRAY_COLUMN_POINTER = 1 847 CARRAY_COLUMN_VALUE = 0 848 CARRAY_DOUBLE = 2 849 CARRAY_INT32 = 0 850 CARRAY_INT64 = 1 851 CARRAY_TEXT = 3 852 CLOSURE_COL_DEPTH = 1 853 CLOSURE_COL_ID = 0 854 CLOSURE_COL_IDCOLUMN = 4 855 CLOSURE_COL_PARENTCOLUMN = 5 856 CLOSURE_COL_ROOT = 2 857 CLOSURE_COL_TABLENAME = 3 858 CSVTEST_FIDX = 0x0001 859 CSV_INBUFSZ = 1024 860 CSV_MXERR = 200 861 EXPLN_COLUMN_ADDR = 0 862 EXPLN_COLUMN_COMMENT = 7 863 EXPLN_COLUMN_OPCODE = 1 864 EXPLN_COLUMN_P1 = 2 865 EXPLN_COLUMN_P2 = 3 866 EXPLN_COLUMN_P3 = 4 867 EXPLN_COLUMN_P4 = 5 868 EXPLN_COLUMN_P5 = 6 869 EXPLN_COLUMN_SQL = 8 870 ACCESSPERMS = 511 871 AIO_PRIO_DELTA_MAX = 20 872 ALLPERMS = 4095 873 AT_EACCESS = 0x200 874 AT_FDCWD = -100 875 AT_REMOVEDIR = 0x200 876 AT_SYMLINK_FOLLOW = 0x400 877 AT_SYMLINK_NOFOLLOW = 0x100 878 CLOCK_BOOTTIME = 7 879 CLOCK_BOOTTIME_ALARM = 9 880 CLOCK_MONOTONIC = 1 881 CLOCK_MONOTONIC_COARSE = 6 882 CLOCK_MONOTONIC_RAW = 4 883 CLOCK_PROCESS_CPUTIME_ID = 2 884 CLOCK_REALTIME = 0 885 CLOCK_REALTIME_ALARM = 8 886 CLOCK_REALTIME_COARSE = 5 887 CLOCK_TAI = 11 888 CLOCK_THREAD_CPUTIME_ID = 3 889 DEFFILEMODE = 438 890 DELAYTIMER_MAX = 2147483647 891 E2BIG = 7 892 EACCES = 13 893 EADDRINUSE = 98 894 EADDRNOTAVAIL = 99 895 EADV = 68 896 EAFNOSUPPORT = 97 897 EAGAIN = 11 898 EALREADY = 114 899 EBADE = 52 900 EBADF = 9 901 EBADFD = 77 902 EBADMSG = 74 903 EBADR = 53 904 EBADRQC = 56 905 EBADSLT = 57 906 EBFONT = 59 907 EBUSY = 16 908 ECANCELED = 125 909 ECHILD = 10 910 ECHRNG = 44 911 ECOMM = 70 912 ECONNABORTED = 103 913 ECONNREFUSED = 111 914 ECONNRESET = 104 915 EDEADLK = 35 916 EDEADLOCK = 35 917 EDESTADDRREQ = 89 918 EDOM = 33 919 EDOTDOT = 73 920 EDQUOT = 122 921 EEXIST = 17 922 EFAULT = 14 923 EFBIG = 27 924 EHOSTDOWN = 112 925 EHOSTUNREACH = 113 926 EHWPOISON = 133 927 EIDRM = 43 928 EILSEQ = 84 929 EINPROGRESS = 115 930 EINTR = 4 931 EINVAL = 22 932 EIO = 5 933 EISCONN = 106 934 EISDIR = 21 935 EISNAM = 120 936 EKEYEXPIRED = 127 937 EKEYREJECTED = 129 938 EKEYREVOKED = 128 939 EL2HLT = 51 940 EL2NSYNC = 45 941 EL3HLT = 46 942 EL3RST = 47 943 ELIBACC = 79 944 ELIBBAD = 80 945 ELIBEXEC = 83 946 ELIBMAX = 82 947 ELIBSCN = 81 948 ELNRNG = 48 949 ELOOP = 40 950 EMEDIUMTYPE = 124 951 EMFILE = 24 952 EMLINK = 31 953 EMSGSIZE = 90 954 EMULTIHOP = 72 955 ENAMETOOLONG = 36 956 ENAVAIL = 119 957 ENETDOWN = 100 958 ENETRESET = 102 959 ENETUNREACH = 101 960 ENFILE = 23 961 ENOANO = 55 962 ENOBUFS = 105 963 ENOCSI = 50 964 ENODATA = 61 965 ENODEV = 19 966 ENOENT = 2 967 ENOEXEC = 8 968 ENOKEY = 126 969 ENOLCK = 37 970 ENOLINK = 67 971 ENOMEDIUM = 123 972 ENOMEM = 12 973 ENOMSG = 42 974 ENONET = 64 975 ENOPKG = 65 976 ENOPROTOOPT = 92 977 ENOSPC = 28 978 ENOSR = 63 979 ENOSTR = 60 980 ENOSYS = 38 981 ENOTBLK = 15 982 ENOTCONN = 107 983 ENOTDIR = 20 984 ENOTEMPTY = 39 985 ENOTNAM = 118 986 ENOTRECOVERABLE = 131 987 ENOTSOCK = 88 988 ENOTSUP = 95 989 ENOTTY = 25 990 ENOTUNIQ = 76 991 ENXIO = 6 992 EOPNOTSUPP = 95 993 EOVERFLOW = 75 994 EOWNERDEAD = 130 995 EPERM = 1 996 EPFNOSUPPORT = 96 997 EPIPE = 32 998 EPROTO = 71 999 EPROTONOSUPPORT = 93 1000 EPROTOTYPE = 91 1001 ERANGE = 34 1002 EREMCHG = 78 1003 EREMOTE = 66 1004 EREMOTEIO = 121 1005 ERESTART = 85 1006 ERFKILL = 132 1007 EROFS = 30 1008 ESHUTDOWN = 108 1009 ESOCKTNOSUPPORT = 94 1010 ESPIPE = 29 1011 ESRCH = 3 1012 ESRMNT = 69 1013 ESTALE = 116 1014 ESTRPIPE = 86 1015 ETIME = 62 1016 ETIMEDOUT = 110 1017 ETOOMANYREFS = 109 1018 ETXTBSY = 26 1019 EUCLEAN = 117 1020 EUNATCH = 49 1021 EUSERS = 87 1022 EWOULDBLOCK = 11 1023 EXDEV = 18 1024 EXFULL = 54 1025 FAPPEND = 1024 1026 FASYNC = 8192 1027 FD_CLOEXEC = 1 1028 FFSYNC = 1052672 1029 FNDELAY = 2048 1030 FNONBLOCK = 2048 1031 FSDIR_COLUMN_DATA = 3 1032 FSDIR_COLUMN_DIR = 5 1033 FSDIR_COLUMN_MODE = 1 1034 FSDIR_COLUMN_MTIME = 2 1035 FSDIR_COLUMN_NAME = 0 1036 FSDIR_COLUMN_PATH = 4 1037 FSDIR_SCHEMA = "(name,mode,mtime,data,path HIDDEN,dir HIDDEN)" 1038 F_DUPFD = 0 1039 F_DUPFD_CLOEXEC = 1030 1040 F_EXLCK = 4 1041 F_GETFD = 1 1042 F_GETFL = 3 1043 F_GETLK = 5 1044 F_GETLK64 = 5 1045 F_GETOWN = 9 1046 F_LOCK = 1 1047 F_OK = 0 1048 F_RDLCK = 0 1049 F_SETFD = 2 1050 F_SETFL = 4 1051 F_SETLK = 6 1052 F_SETLK64 = 6 1053 F_SETLKW = 7 1054 F_SETLKW64 = 7 1055 F_SETOWN = 8 1056 F_SHLCK = 8 1057 F_TEST = 3 1058 F_TLOCK = 2 1059 F_ULOCK = 0 1060 F_UNLCK = 2 1061 F_WRLCK = 1 1062 HOST_NAME_MAX = 64 1063 LOCK_EX = 2 1064 LOCK_NB = 4 1065 LOCK_SH = 1 1066 LOCK_UN = 8 1067 LOGIN_NAME_MAX = 256 1068 L_INCR = 1 1069 L_SET = 0 1070 L_XTND = 2 1071 MAXNAMLEN = 255 1072 MAX_CANON = 255 1073 MAX_INPUT = 255 1074 MQ_PRIO_MAX = 32768 1075 NAME_MAX = 255 1076 NGROUPS_MAX = 65536 1077 O_ACCMODE = 0003 1078 O_APPEND = 02000 1079 O_ASYNC = 020000 1080 O_CLOEXEC = 524288 1081 O_CREAT = 0100 1082 O_DIRECTORY = 65536 1083 O_DSYNC = 4096 1084 O_EXCL = 0200 1085 O_FSYNC = 1052672 1086 O_NDELAY = 2048 1087 O_NOCTTY = 0400 1088 O_NOFOLLOW = 131072 1089 O_NONBLOCK = 04000 1090 O_RDONLY = 00 1091 O_RDWR = 02 1092 O_RSYNC = 1052672 1093 O_SYNC = 04010000 1094 O_TRUNC = 01000 1095 O_WRONLY = 01 1096 PATH_MAX = 4096 1097 PIPE_BUF = 4096 1098 POSIX_FADV_DONTNEED = 6 1099 POSIX_FADV_NOREUSE = 7 1100 POSIX_FADV_NORMAL = 0 1101 POSIX_FADV_RANDOM = 1 1102 POSIX_FADV_SEQUENTIAL = 2 1103 POSIX_FADV_WILLNEED = 3 1104 PTHREAD_DESTRUCTOR_ITERATIONS = 4 1105 PTHREAD_KEYS_MAX = 1024 1106 PTHREAD_STACK_MIN = 16384 1107 RTSIG_MAX = 32 1108 R_OK = 4 1109 SEM_VALUE_MAX = 2147483647 1110 STDERR_FILENO = 2 1111 STDIN_FILENO = 0 1112 STDOUT_FILENO = 1 1113 S_BLKSIZE = 512 1114 S_IEXEC = 64 1115 S_IFBLK = 24576 1116 S_IFCHR = 8192 1117 S_IFDIR = 16384 1118 S_IFIFO = 4096 1119 S_IFLNK = 40960 1120 S_IFMT = 61440 1121 S_IFREG = 32768 1122 S_IFSOCK = 49152 1123 S_IREAD = 256 1124 S_IRGRP = 32 1125 S_IROTH = 4 1126 S_IRUSR = 256 1127 S_IRWXG = 56 1128 S_IRWXO = 7 1129 S_IRWXU = 448 1130 S_ISGID = 1024 1131 S_ISUID = 2048 1132 S_ISVTX = 512 1133 S_IWGRP = 16 1134 S_IWOTH = 2 1135 S_IWRITE = 128 1136 S_IWUSR = 128 1137 S_IXGRP = 8 1138 S_IXOTH = 1 1139 S_IXUSR = 64 1140 TIMER_ABSTIME = 1 1141 TIME_UTC = 1 1142 TTY_NAME_MAX = 32 1143 UTIME_NOW = 1073741823 1144 UTIME_OMIT = 1073741822 1145 W_OK = 2 1146 XATTR_LIST_MAX = 65536 1147 XATTR_NAME_MAX = 255 1148 XATTR_SIZE_MAX = 65536 1149 X_OK = 1 1150 X_ASM_GENERIC_ERRNO_BASE_H = 0 1151 X_ASM_GENERIC_ERRNO_H = 0 1152 X_BITS_ERRNO_H = 1 1153 X_BITS_POSIX1_LIM_H = 1 1154 X_BITS_POSIX_OPT_H = 1 1155 X_BITS_STAT_H = 1 1156 X_BITS_TIME_H = 1 1157 X_DIRENT_H = 1 1158 X_DIRENT_HAVE_D_OFF = 0 1159 X_DIRENT_HAVE_D_RECLEN = 0 1160 X_DIRENT_HAVE_D_TYPE = 0 1161 X_DIRENT_MATCHES_DIRENT64 = 1 1162 X_ERRNO_H = 1 1163 X_FCNTL_H = 1 1164 X_GETOPT_CORE_H = 1 1165 X_GETOPT_POSIX_H = 1 1166 X_LFS64_ASYNCHRONOUS_IO = 1 1167 X_LFS64_LARGEFILE = 1 1168 X_LFS64_STDIO = 1 1169 X_LFS_ASYNCHRONOUS_IO = 1 1170 X_LFS_LARGEFILE = 1 1171 X_LINUX_LIMITS_H = 0 1172 X_MKNOD_VER = 0 1173 X_MKNOD_VER_LINUX = 0 1174 X_POSIX2_CHAR_TERM = 200809 1175 X_POSIX2_C_BIND = 200809 1176 X_POSIX2_C_DEV = 200809 1177 X_POSIX2_C_VERSION = 200809 1178 X_POSIX2_LOCALEDEF = 200809 1179 X_POSIX2_SW_DEV = 200809 1180 X_POSIX2_VERSION = 200809 1181 X_POSIX_ADVISORY_INFO = 200809 1182 X_POSIX_AIO_LISTIO_MAX = 2 1183 X_POSIX_AIO_MAX = 1 1184 X_POSIX_ARG_MAX = 4096 1185 X_POSIX_ASYNCHRONOUS_IO = 200809 1186 X_POSIX_ASYNC_IO = 1 1187 X_POSIX_BARRIERS = 200809 1188 X_POSIX_CHILD_MAX = 25 1189 X_POSIX_CHOWN_RESTRICTED = 0 1190 X_POSIX_CLOCKRES_MIN = 20000000 1191 X_POSIX_CLOCK_SELECTION = 200809 1192 X_POSIX_CPUTIME = 0 1193 X_POSIX_DELAYTIMER_MAX = 32 1194 X_POSIX_FSYNC = 200809 1195 X_POSIX_HOST_NAME_MAX = 255 1196 X_POSIX_IPV6 = 200809 1197 X_POSIX_JOB_CONTROL = 1 1198 X_POSIX_LINK_MAX = 8 1199 X_POSIX_LOGIN_NAME_MAX = 9 1200 X_POSIX_MAPPED_FILES = 200809 1201 X_POSIX_MAX_CANON = 255 1202 X_POSIX_MAX_INPUT = 255 1203 X_POSIX_MEMLOCK = 200809 1204 X_POSIX_MEMLOCK_RANGE = 200809 1205 X_POSIX_MEMORY_PROTECTION = 200809 1206 X_POSIX_MESSAGE_PASSING = 200809 1207 X_POSIX_MONOTONIC_CLOCK = 0 1208 X_POSIX_MQ_OPEN_MAX = 8 1209 X_POSIX_MQ_PRIO_MAX = 32 1210 X_POSIX_NAME_MAX = 14 1211 X_POSIX_NGROUPS_MAX = 8 1212 X_POSIX_NO_TRUNC = 1 1213 X_POSIX_OPEN_MAX = 20 1214 X_POSIX_PATH_MAX = 256 1215 X_POSIX_PIPE_BUF = 512 1216 X_POSIX_PRIORITIZED_IO = 200809 1217 X_POSIX_PRIORITY_SCHEDULING = 200809 1218 X_POSIX_RAW_SOCKETS = 200809 1219 X_POSIX_READER_WRITER_LOCKS = 200809 1220 X_POSIX_REALTIME_SIGNALS = 200809 1221 X_POSIX_REENTRANT_FUNCTIONS = 1 1222 X_POSIX_REGEXP = 1 1223 X_POSIX_RE_DUP_MAX = 255 1224 X_POSIX_RTSIG_MAX = 8 1225 X_POSIX_SAVED_IDS = 1 1226 X_POSIX_SEMAPHORES = 200809 1227 X_POSIX_SEM_NSEMS_MAX = 256 1228 X_POSIX_SEM_VALUE_MAX = 32767 1229 X_POSIX_SHARED_MEMORY_OBJECTS = 200809 1230 X_POSIX_SHELL = 1 1231 X_POSIX_SIGQUEUE_MAX = 32 1232 X_POSIX_SPAWN = 200809 1233 X_POSIX_SPIN_LOCKS = 200809 1234 X_POSIX_SPORADIC_SERVER = -1 1235 X_POSIX_SSIZE_MAX = 32767 1236 X_POSIX_STREAM_MAX = 8 1237 X_POSIX_SYMLINK_MAX = 255 1238 X_POSIX_SYMLOOP_MAX = 8 1239 X_POSIX_SYNCHRONIZED_IO = 200809 1240 X_POSIX_THREADS = 200809 1241 X_POSIX_THREAD_ATTR_STACKADDR = 200809 1242 X_POSIX_THREAD_ATTR_STACKSIZE = 200809 1243 X_POSIX_THREAD_CPUTIME = 0 1244 X_POSIX_THREAD_DESTRUCTOR_ITERATIONS = 4 1245 X_POSIX_THREAD_KEYS_MAX = 128 1246 X_POSIX_THREAD_PRIORITY_SCHEDULING = 200809 1247 X_POSIX_THREAD_PRIO_INHERIT = 200809 1248 X_POSIX_THREAD_PRIO_PROTECT = 200809 1249 X_POSIX_THREAD_PROCESS_SHARED = 200809 1250 X_POSIX_THREAD_ROBUST_PRIO_INHERIT = 200809 1251 X_POSIX_THREAD_ROBUST_PRIO_PROTECT = -1 1252 X_POSIX_THREAD_SAFE_FUNCTIONS = 200809 1253 X_POSIX_THREAD_SPORADIC_SERVER = -1 1254 X_POSIX_THREAD_THREADS_MAX = 64 1255 X_POSIX_TIMEOUTS = 200809 1256 X_POSIX_TIMERS = 200809 1257 X_POSIX_TIMER_MAX = 32 1258 X_POSIX_TRACE = -1 1259 X_POSIX_TRACE_EVENT_FILTER = -1 1260 X_POSIX_TRACE_INHERIT = -1 1261 X_POSIX_TRACE_LOG = -1 1262 X_POSIX_TTY_NAME_MAX = 9 1263 X_POSIX_TYPED_MEMORY_OBJECTS = -1 1264 X_POSIX_TZNAME_MAX = 6 1265 X_POSIX_V6_LP64_OFF64 = 1 1266 X_POSIX_V6_LPBIG_OFFBIG = -1 1267 X_POSIX_V7_LP64_OFF64 = 1 1268 X_POSIX_V7_LPBIG_OFFBIG = -1 1269 X_POSIX_VDISABLE = 0 1270 X_POSIX_VERSION = 200809 1271 X_STATBUF_ST_BLKSIZE = 0 1272 X_STATBUF_ST_NSEC = 0 1273 X_STATBUF_ST_RDEV = 0 1274 X_STAT_VER = 1 1275 X_STAT_VER_KERNEL = 0 1276 X_STAT_VER_LINUX = 1 1277 X_SYS_STAT_H = 1 1278 X_SYS_TIME_H = 1 1279 X_TIME_H = 1 1280 X_UNISTD_H = 1 1281 X_UTIME_H = 1 1282 X_XBS5_LP64_OFF64 = 1 1283 X_XBS5_LPBIG_OFFBIG = -1 1284 X_XOPEN_ENH_I18N = 1 1285 X_XOPEN_LEGACY = 1 1286 X_XOPEN_REALTIME = 1 1287 X_XOPEN_REALTIME_THREADS = 1 1288 X_XOPEN_SHM = 1 1289 X_XOPEN_UNIX = 1 1290 X_XOPEN_VERSION = 700 1291 X_XOPEN_XCU_VERSION = 4 1292 X_XOPEN_XPG2 = 1 1293 X_XOPEN_XPG3 = 1 1294 X_XOPEN_XPG4 = 1 1295 FUZZER_HASH = 4001 1296 FUZZER_MX_COST = 1000 1297 FUZZER_MX_LENGTH = 50 1298 FUZZER_MX_OUTPUT_LENGTH = 100 1299 FUZZER_MX_RULEID = 2147483647 1300 FUZZER_NQUEUE = 20 1301 CC_AND = 24 1302 CC_BANG = 15 1303 CC_COMMA = 23 1304 CC_DIGIT = 3 1305 CC_DOLLAR = 4 1306 CC_DOT = 26 1307 CC_EQ = 14 1308 CC_GT = 13 1309 CC_ID = 2 1310 CC_ILLEGAL = 27 1311 CC_KYWD = 1 1312 CC_LP = 17 1313 CC_LT = 12 1314 CC_MINUS = 11 1315 CC_PERCENT = 22 1316 CC_PIPE = 10 1317 CC_PLUS = 20 1318 CC_QUOTE = 8 1319 CC_QUOTE2 = 9 1320 CC_RP = 18 1321 CC_SEMI = 19 1322 CC_SLASH = 16 1323 CC_SPACE = 7 1324 CC_STAR = 21 1325 CC_TILDA = 25 1326 CC_VARALPHA = 5 1327 CC_VARNUM = 6 1328 CC_X = 0 1329 TK_BITAND = 3 1330 TK_BITNOT = 3 1331 TK_BITOR = 3 1332 TK_BLOB = 2 1333 TK_COMMA = 3 1334 TK_CONCAT = 3 1335 TK_DOT = 3 1336 TK_EQ = 3 1337 TK_ERROR = 4 1338 TK_FLOAT = 2 1339 TK_GE = 3 1340 TK_GT = 3 1341 TK_ID = 1 1342 TK_ILLEGAL = 4 1343 TK_INTEGER = 2 1344 TK_LE = 3 1345 TK_LITERAL = 2 1346 TK_LP = 3 1347 TK_LSHIFT = 3 1348 TK_LT = 3 1349 TK_MINUS = 3 1350 TK_NAME = 1 1351 TK_NE = 3 1352 TK_PLUS = 3 1353 TK_PUNCT = 3 1354 TK_REM = 3 1355 TK_RP = 3 1356 TK_RSHIFT = 3 1357 TK_SEMI = 3 1358 TK_SLASH = 3 1359 TK_SPACE = 0 1360 TK_STAR = 3 1361 TK_STRING = 2 1362 TK_VARIABLE = 2 1363 Deliberate_fall_through = 0 1364 RE_EOF = 0 1365 RE_OP_ACCEPT = 6 1366 RE_OP_ANY = 2 1367 RE_OP_ANYSTAR = 3 1368 RE_OP_BOUNDARY = 17 1369 RE_OP_CC_EXC = 8 1370 RE_OP_CC_INC = 7 1371 RE_OP_CC_RANGE = 10 1372 RE_OP_CC_VALUE = 9 1373 RE_OP_DIGIT = 13 1374 RE_OP_FORK = 4 1375 RE_OP_GOTO = 5 1376 RE_OP_MATCH = 1 1377 RE_OP_NOTDIGIT = 14 1378 RE_OP_NOTSPACE = 16 1379 RE_OP_NOTWORD = 12 1380 RE_OP_SPACE = 15 1381 RE_OP_WORD = 11 1382 SERIES_COLUMN_START = 1 1383 SERIES_COLUMN_STEP = 3 1384 SERIES_COLUMN_STOP = 2 1385 SERIES_COLUMN_VALUE = 0 1386 CCLASS_B = 2 1387 CCLASS_C = 3 1388 CCLASS_D = 4 1389 CCLASS_DIGIT = 10 1390 CCLASS_H = 5 1391 CCLASS_L = 6 1392 CCLASS_M = 8 1393 CCLASS_OTHER = 12 1394 CCLASS_R = 7 1395 CCLASS_SILENT = 0 1396 CCLASS_SPACE = 11 1397 CCLASS_VOWEL = 1 1398 CCLASS_Y = 9 1399 FINAL_INS_COST_DIV = 4 1400 SCRIPT_ARABIC = 0x0010 1401 SCRIPT_CYRILLIC = 0x0002 1402 SCRIPT_GREEK = 0x0004 1403 SCRIPT_HEBREW = 0x0008 1404 SCRIPT_LATIN = 0x0001 1405 SPELLFIX_COL_COMMAND = 11 1406 SPELLFIX_COL_DISTANCE = 2 1407 SPELLFIX_COL_LANGID = 3 1408 SPELLFIX_COL_MATCHLEN = 5 1409 SPELLFIX_COL_PHONEHASH = 6 1410 SPELLFIX_COL_RANK = 1 1411 SPELLFIX_COL_SCOPE = 8 1412 SPELLFIX_COL_SCORE = 4 1413 SPELLFIX_COL_SOUNDSLIKE = 10 1414 SPELLFIX_COL_SRCHCNT = 9 1415 SPELLFIX_COL_TOP = 7 1416 SPELLFIX_COL_WORD = 0 1417 SPELLFIX_IDXNUM_DIST = 48 1418 SPELLFIX_IDXNUM_DISTLE = 0x20 1419 SPELLFIX_IDXNUM_DISTLT = 0x10 1420 SPELLFIX_IDXNUM_LANGID = 0x02 1421 SPELLFIX_IDXNUM_MATCH = 0x01 1422 SPELLFIX_IDXNUM_ROWID = 0x40 1423 SPELLFIX_IDXNUM_SCOPE = 0x08 1424 SPELLFIX_IDXNUM_TOP = 0x04 1425 SPELLFIX_MX_HASH = 32 1426 SPELLFIX_MX_RUN = 1 1427 SQLITE_SPELLFIX_STACKALLOC_SZ = 1024 1428 SWARMVTAB_MAX_OPEN = 9 1429 BC_BASE_MAX = 99 1430 BC_DIM_MAX = 2048 1431 BC_SCALE_MAX = 99 1432 BC_STRING_MAX = 1000 1433 CHARCLASS_NAME_MAX = 2048 1434 CHAR_BIT = 8 1435 CHAR_MAX = 255 1436 CHAR_MIN = 0 1437 COLL_WEIGHTS_MAX = 255 1438 EXPR_NEST_MAX = 32 1439 FAR = 0 1440 INT_MAX = 2147483647 1441 INT_MIN = -2147483648 1442 LINE_MAX = 2048 1443 LLONG_MAX = 9223372036854775807 1444 LLONG_MIN = -9223372036854775808 1445 LONG_MAX = 9223372036854775807 1446 LONG_MIN = -9223372036854775808 1447 MAX_MEM_LEVEL = 9 1448 MAX_WBITS = 15 1449 MB_LEN_MAX = 16 1450 RE_DUP_MAX = 32767 1451 SCHAR_MAX = 127 1452 SCHAR_MIN = -128 1453 SHRT_MAX = 32767 1454 SHRT_MIN = -32768 1455 STDC = 0 1456 STDC99 = 0 1457 UCHAR_MAX = 255 1458 UINT_MAX = 4294967295 1459 ULLONG_MAX = 18446744073709551615 1460 ULONG_MAX = 18446744073709551615 1461 USHRT_MAX = 65535 1462 ZCONF_H = 0 1463 ZEXPORT = 0 1464 ZEXPORTVA = 0 1465 ZIPFILE_BUFFER_SIZE = 65536 1466 ZIPFILE_CDS_FIXED_SZ = 46 1467 ZIPFILE_CDS_NFILE_OFF = 28 1468 ZIPFILE_CDS_SZCOMPRESSED_OFF = 20 1469 ZIPFILE_EOCD_FIXED_SZ = 22 1470 ZIPFILE_EXTRA_TIMESTAMP = 0x5455 1471 ZIPFILE_F_COLUMN_IDX = 7 1472 ZIPFILE_LFH_FIXED_SZ = 30 1473 ZIPFILE_NEWENTRY_FLAGS = 0x800 1474 ZIPFILE_NEWENTRY_MADEBY = 798 1475 ZIPFILE_NEWENTRY_REQUIRED = 20 1476 ZIPFILE_SIGNATURE_CDS = 0x02014b50 1477 ZIPFILE_SIGNATURE_EOCD = 0x06054b50 1478 ZIPFILE_SIGNATURE_LFH = 0x04034b50 1479 ZLIB_H = 0 1480 ZLIB_VERNUM = 0x12b0 1481 ZLIB_VERSION = "1.2.11" 1482 ZLIB_VER_MAJOR = 1 1483 ZLIB_VER_MINOR = 2 1484 ZLIB_VER_REVISION = 11 1485 ZLIB_VER_SUBREVISION = 0 1486 Z_ASCII = 1 1487 Z_BEST_COMPRESSION = 9 1488 Z_BEST_SPEED = 1 1489 Z_BINARY = 0 1490 Z_BLOCK = 5 1491 Z_BUF_ERROR = -5 1492 Z_DATA_ERROR = -3 1493 Z_DEFAULT_COMPRESSION = -1 1494 Z_DEFAULT_STRATEGY = 0 1495 Z_DEFLATED = 8 1496 Z_ERRNO = -1 1497 Z_FILTERED = 1 1498 Z_FINISH = 4 1499 Z_FIXED = 4 1500 Z_FULL_FLUSH = 3 1501 Z_HAVE_STDARG_H = 0 1502 Z_HAVE_UNISTD_H = 0 1503 Z_HUFFMAN_ONLY = 2 1504 Z_LFS64 = 0 1505 Z_MEM_ERROR = -4 1506 Z_NEED_DICT = 2 1507 Z_NO_COMPRESSION = 0 1508 Z_NO_FLUSH = 0 1509 Z_NULL = 0 1510 Z_OK = 0 1511 Z_PARTIAL_FLUSH = 1 1512 Z_RLE = 3 1513 Z_STREAM_END = 1 1514 Z_STREAM_ERROR = -2 1515 Z_SYNC_FLUSH = 2 1516 Z_TEXT = 1 1517 Z_TREES = 6 1518 Z_UNKNOWN = 2 1519 Z_VERSION_ERROR = -6 1520 Z_WANT64 = 0 1521 X_ANSI_STDDEF_H = 0 1522 X_BITS_POSIX2_LIM_H = 1 1523 X_BSD_PTRDIFF_T_ = 0 1524 X_GCC_LIMITS_H_ = 0 1525 X_GCC_MAX_ALIGN_T = 0 1526 X_GCC_PTRDIFF_T = 0 1527 X_LIBC_LIMITS_H_ = 1 1528 X_LIMITS_H___ = 0 1529 X_POSIX2_BC_BASE_MAX = 99 1530 X_POSIX2_BC_DIM_MAX = 2048 1531 X_POSIX2_BC_SCALE_MAX = 99 1532 X_POSIX2_BC_STRING_MAX = 1000 1533 X_POSIX2_CHARCLASS_NAME_MAX = 14 1534 X_POSIX2_COLL_WEIGHTS_MAX = 2 1535 X_POSIX2_EXPR_NEST_MAX = 32 1536 X_POSIX2_LINE_MAX = 2048 1537 X_POSIX2_RE_DUP_MAX = 255 1538 X_PTRDIFF_T = 0 1539 X_PTRDIFF_T_ = 0 1540 X_PTRDIFF_T_DECLARED = 0 1541 X_STDDEF_H = 0 1542 X_STDDEF_H_ = 0 1543 X_T_PTRDIFF = 0 1544 X_T_PTRDIFF_ = 0 1545 Z_const = 0 1546 SQLITE_RBU_STATE_CHECKPOINT = 3 1547 SQLITE_RBU_STATE_DONE = 4 1548 SQLITE_RBU_STATE_ERROR = 5 1549 SQLITE_RBU_STATE_MOVE = 2 1550 SQLITE_RBU_STATE_OAL = 1 1551 X_SQLITE3RBU_H = 0 1552 MAX_PREPARED_STMTS = 100 1553 MINSIGSTKSZ = 2048 1554 NGREG = 27 1555 NSIG = 65 1556 NUM_PREPARED_STMTS = 10 1557 SA_INTERRUPT = 0x20000000 1558 SA_NOCLDSTOP = 1 1559 SA_NOCLDWAIT = 2 1560 SA_NODEFER = 0x40000000 1561 SA_NOMASK = 1073741824 1562 SA_ONESHOT = 2147483648 1563 SA_ONSTACK = 0x08000000 1564 SA_RESETHAND = 0x80000000 1565 SA_RESTART = 0x10000000 1566 SA_SIGINFO = 4 1567 SA_STACK = 134217728 1568 SIGABRT = 6 1569 SIGALRM = 14 1570 SIGBUS = 7 1571 SIGCHLD = 17 1572 SIGCLD = 17 1573 SIGCONT = 18 1574 SIGFPE = 8 1575 SIGHUP = 1 1576 SIGILL = 4 1577 SIGINT = 2 1578 SIGIO = 29 1579 SIGIOT = 6 1580 SIGKILL = 9 1581 SIGPIPE = 13 1582 SIGPOLL = 29 1583 SIGPROF = 27 1584 SIGPWR = 30 1585 SIGQUIT = 3 1586 SIGSEGV = 11 1587 SIGSTKFLT = 16 1588 SIGSTKSZ = 8192 1589 SIGSTOP = 19 1590 SIGSYS = 31 1591 SIGTERM = 15 1592 SIGTRAP = 5 1593 SIGTSTP = 20 1594 SIGTTIN = 21 1595 SIGTTOU = 22 1596 SIGURG = 23 1597 SIGUSR1 = 10 1598 SIGUSR2 = 12 1599 SIGVTALRM = 26 1600 SIGWINCH = 28 1601 SIGXCPU = 24 1602 SIGXFSZ = 25 1603 SIG_BLOCK = 0 1604 SIG_SETMASK = 2 1605 SIG_UNBLOCK = 1 1606 SQLITE_EVAL_WITHOUTNULLS = 0x00001 1607 SQLITE_TCL_NRE = 1 1608 TCLSH = 1 1609 X_ASM_GENERIC_INT_LL64_H = 0 1610 X_ASM_S390_SIGCONTEXT_H = 0 1611 X_BITS_SIGACTION_H = 1 1612 X_BITS_SIGCONTEXT_H = 1 1613 X_BITS_SIGEVENT_CONSTS_H = 1 1614 X_BITS_SIGINFO_ARCH_H = 1 1615 X_BITS_SIGINFO_CONSTS_H = 1 1616 X_BITS_SIGNUM_GENERIC_H = 1 1617 X_BITS_SIGNUM_H = 1 1618 X_BITS_SIGSTACK_H = 1 1619 X_BITS_SIGTHREAD_H = 1 1620 X_BITS_SS_FLAGS_H = 1 1621 X_LINUX_POSIX_TYPES_H = 0 1622 X_LINUX_TYPES_H = 0 1623 X_NSIG = 65 1624 X_S390_TYPES_H = 0 1625 X_SIGCONTEXT_NSIG = 64 1626 X_SIGCONTEXT_NSIG_BPW = 64 1627 X_SIGCONTEXT_NSIG_WORDS = 1 1628 X_SIGNAL_H = 0 1629 X_SYS_UCONTEXT_H = 1 1630 ALT_SCHEMA_TABLE = "sqlite_schema" 1631 ALT_TEMP_SCHEMA_TABLE = "sqlite_temp_schema" 1632 BTREE_APPEND = 0x08 1633 BTREE_APPLICATION_ID = 8 1634 BTREE_AUTOVACUUM_FULL = 1 1635 BTREE_AUTOVACUUM_INCR = 2 1636 BTREE_AUTOVACUUM_NONE = 0 1637 BTREE_AUXDELETE = 0x04 1638 BTREE_BLOBKEY = 2 1639 BTREE_BULKLOAD = 0x00000001 1640 BTREE_DATA_VERSION = 15 1641 BTREE_DEFAULT_CACHE_SIZE = 3 1642 BTREE_FILE_FORMAT = 2 1643 BTREE_FORDELETE = 0x00000008 1644 BTREE_FREE_PAGE_COUNT = 0 1645 BTREE_HINT_RANGE = 0 1646 BTREE_INCR_VACUUM = 7 1647 BTREE_INTKEY = 1 1648 BTREE_LARGEST_ROOT_PAGE = 4 1649 BTREE_MEMORY = 2 1650 BTREE_OMIT_JOURNAL = 1 1651 BTREE_PREFORMAT = 0x80 1652 BTREE_SAVEPOSITION = 0x02 1653 BTREE_SCHEMA_VERSION = 1 1654 BTREE_SEEK_EQ = 0x00000002 1655 BTREE_SINGLE = 4 1656 BTREE_TEXT_ENCODING = 5 1657 BTREE_UNORDERED = 8 1658 BTREE_USER_VERSION = 6 1659 BTREE_WRCSR = 0x00000004 1660 CACHE_STALE = 0 1661 COLFLAG_BUSY = 0x0100 1662 COLFLAG_GENERATED = 0x0060 1663 COLFLAG_HASTYPE = 0x0004 1664 COLFLAG_HIDDEN = 0x0002 1665 COLFLAG_NOINSERT = 0x0062 1666 COLFLAG_NOTAVAIL = 0x0080 1667 COLFLAG_PRIMKEY = 0x0001 1668 COLFLAG_SORTERREF = 0x0010 1669 COLFLAG_STORED = 0x0040 1670 COLFLAG_UNIQUE = 0x0008 1671 COLFLAG_VIRTUAL = 0x0020 1672 COLNAME_COLUMN = 4 1673 COLNAME_DATABASE = 2 1674 COLNAME_DECLTYPE = 1 1675 COLNAME_N = 5 1676 COLNAME_NAME = 0 1677 COLNAME_TABLE = 3 1678 CURTYPE_BTREE = 0 1679 CURTYPE_PSEUDO = 3 1680 CURTYPE_SORTER = 1 1681 CURTYPE_VTAB = 2 1682 DBFLAG_EncodingFixed = 0x0040 1683 DBFLAG_InternalFunc = 0x0020 1684 DBFLAG_PreferBuiltin = 0x0002 1685 DBFLAG_SchemaChange = 0x0001 1686 DBFLAG_SchemaKnownOk = 0x0010 1687 DBFLAG_Vacuum = 0x0004 1688 DBFLAG_VacuumInto = 0x0008 1689 DB_ResetWanted = 0x0008 1690 DB_SchemaLoaded = 0x0001 1691 DB_UnresetViews = 0x0002 1692 DFLT_SCHEMA_TABLE = "sqlite_master" 1693 DFLT_TEMP_SCHEMA_TABLE = "sqlite_temp_master" 1694 ENAME_NAME = 0 1695 ENAME_SPAN = 1 1696 ENAME_TAB = 2 1697 EP_Agg = 0x000010 1698 EP_CanBeNull = 0x100000 1699 EP_Collate = 0x000100 1700 EP_Commuted = 0x000200 1701 EP_ConstFunc = 0x080000 1702 EP_DblQuoted = 0x000040 1703 EP_Distinct = 0x000002 1704 EP_FixedCol = 0x000008 1705 EP_FromDDL = 0x40000000 1706 EP_FromJoin = 0x000001 1707 EP_HasFunc = 0x000004 1708 EP_IfNullRow = 0x020000 1709 EP_Immutable = 0x02 1710 EP_InfixFunc = 0x000080 1711 EP_IntValue = 0x000400 1712 EP_IsFalse = 0x20000000 1713 EP_IsTrue = 0x10000000 1714 EP_Leaf = 0x800000 1715 EP_MemToken = 0x010000 1716 EP_NoReduce = 0x01 1717 EP_Propagate = 2097412 1718 EP_Quoted = 0x4000000 1719 EP_Reduced = 0x002000 1720 EP_Skip = 0x001000 1721 EP_Static = 0x8000000 1722 EP_Subquery = 0x200000 1723 EP_Subrtn = 0x2000000 1724 EP_TokenOnly = 0x004000 1725 EP_Unlikely = 0x040000 1726 EP_VarSelect = 0x000020 1727 EP_Win = 0x008000 1728 EP_WinFunc = 0x1000000 1729 EP_xIsSelect = 0x000800 1730 EXCLUSIVE_LOCK = 4 1731 EXPRDUP_REDUCE = 0x0001 1732 GCC_VERSION = 8003000 1733 HAVE_DLFCN_H = 1 1734 HAVE_FCHOWN = 1 1735 HAVE_FDATASYNC = 1 1736 HAVE_GMTIME_R = 1 1737 HAVE_INT16_T = 1 1738 HAVE_INT32_T = 1 1739 HAVE_INT64_T = 1 1740 HAVE_INT8_T = 1 1741 HAVE_INTPTR_T = 1 1742 HAVE_INTTYPES_H = 1 1743 HAVE_ISNAN = 1 1744 HAVE_LOCALTIME_R = 1 1745 HAVE_LSTAT = 1 1746 HAVE_MALLOC_H = 1 1747 HAVE_MALLOC_USABLE_SIZE = 1 1748 HAVE_MEMORY_H = 1 1749 HAVE_PREAD = 1 1750 HAVE_PREAD64 = 1 1751 HAVE_PWRITE = 1 1752 HAVE_PWRITE64 = 1 1753 HAVE_READLINK = 1 1754 HAVE_STDINT_H = 1 1755 HAVE_STDLIB_H = 1 1756 HAVE_STRCHRNUL = 1 1757 HAVE_STRINGS_H = 1 1758 HAVE_STRING_H = 1 1759 HAVE_SYS_STAT_H = 1 1760 HAVE_SYS_TYPES_H = 1 1761 HAVE_UINT16_T = 1 1762 HAVE_UINT32_T = 1 1763 HAVE_UINT64_T = 1 1764 HAVE_UINT8_T = 1 1765 HAVE_UINTPTR_T = 1 1766 HAVE_UNISTD_H = 1 1767 HAVE_UTIME = 1 1768 INITFLAG_AlterDrop = 0x0002 1769 INITFLAG_AlterRename = 0x0001 1770 INLINEFUNC_affinity = 4 1771 INLINEFUNC_coalesce = 0 1772 INLINEFUNC_expr_compare = 3 1773 INLINEFUNC_expr_implies_expr = 2 1774 INLINEFUNC_iif = 5 1775 INLINEFUNC_implies_nonnull_row = 1 1776 INLINEFUNC_unlikely = 99 1777 INT16_MAX = 32767 1778 INT16_MIN = -32768 1779 INT16_WIDTH = 16 1780 INT32_MAX = 2147483647 1781 INT32_MIN = -2147483648 1782 INT32_WIDTH = 32 1783 INT64_MAX = 9223372036854775807 1784 INT64_MIN = -9223372036854775808 1785 INT64_WIDTH = 64 1786 INT8_MAX = 127 1787 INT8_MIN = -128 1788 INT8_WIDTH = 8 1789 INTMAX_MAX = 9223372036854775807 1790 INTMAX_MIN = -9223372036854775808 1791 INTMAX_WIDTH = 64 1792 INTPTR_MAX = 9223372036854775807 1793 INTPTR_MIN = -9223372036854775808 1794 INTPTR_WIDTH = 64 1795 INT_FAST16_MAX = 9223372036854775807 1796 INT_FAST16_MIN = -9223372036854775808 1797 INT_FAST16_WIDTH = 64 1798 INT_FAST32_MAX = 9223372036854775807 1799 INT_FAST32_MIN = -9223372036854775808 1800 INT_FAST32_WIDTH = 64 1801 INT_FAST64_MAX = 9223372036854775807 1802 INT_FAST64_MIN = -9223372036854775808 1803 INT_FAST64_WIDTH = 64 1804 INT_FAST8_MAX = 127 1805 INT_FAST8_MIN = -128 1806 INT_FAST8_WIDTH = 8 1807 INT_LEAST16_MAX = 32767 1808 INT_LEAST16_MIN = -32768 1809 INT_LEAST16_WIDTH = 16 1810 INT_LEAST32_MAX = 2147483647 1811 INT_LEAST32_MIN = -2147483648 1812 INT_LEAST32_WIDTH = 32 1813 INT_LEAST64_MAX = 9223372036854775807 1814 INT_LEAST64_MIN = -9223372036854775808 1815 INT_LEAST64_WIDTH = 64 1816 INT_LEAST8_MAX = 127 1817 INT_LEAST8_MIN = -128 1818 INT_LEAST8_WIDTH = 8 1819 IN_INDEX_EPH = 2 1820 IN_INDEX_INDEX_ASC = 3 1821 IN_INDEX_INDEX_DESC = 4 1822 IN_INDEX_LOOP = 0x0004 1823 IN_INDEX_MEMBERSHIP = 0x0002 1824 IN_INDEX_NOOP = 5 1825 IN_INDEX_NOOP_OK = 0x0001 1826 IN_INDEX_ROWID = 1 1827 JT_CROSS = 0x0002 1828 JT_ERROR = 0x0040 1829 JT_INNER = 0x0001 1830 JT_LEFT = 0x0008 1831 JT_NATURAL = 0x0004 1832 JT_OUTER = 0x0020 1833 JT_RIGHT = 0x0010 1834 KEYINFO_ORDER_BIGNULL = 0x02 1835 KEYINFO_ORDER_DESC = 0x01 1836 LOCATE_NOERR = 0x02 1837 LOCATE_VIEW = 0x01 1838 LOOKASIDE_SMALL = 128 1839 LT_OBJDIR = ".libs/" 1840 L_cuserid = 9 1841 M10d_Any = 1 1842 M10d_No = 2 1843 M10d_Yes = 0 1844 MEMTYPE_HEAP = 0x01 1845 MEMTYPE_LOOKASIDE = 0x02 1846 MEMTYPE_PCACHE = 0x04 1847 MEM_AffMask = 0x003f 1848 MEM_Agg = 0x2000 1849 MEM_Blob = 0x0010 1850 MEM_Cleared = 0x0100 1851 MEM_Dyn = 0x0400 1852 MEM_Ephem = 0x1000 1853 MEM_FromBind = 0x0040 1854 MEM_Int = 0x0004 1855 MEM_IntReal = 0x0020 1856 MEM_Null = 0x0001 1857 MEM_Real = 0x0008 1858 MEM_Static = 0x0800 1859 MEM_Str = 0x0002 1860 MEM_Subtype = 0x8000 1861 MEM_Term = 0x0200 1862 MEM_TypeMask = 0xc1bf 1863 MEM_Undefined = 0x0080 1864 MEM_Zero = 0x4000 1865 MSVC_VERSION = 0 1866 NC_AllowAgg = 0x00001 1867 NC_AllowWin = 0x04000 1868 NC_Complex = 0x02000 1869 NC_FromDDL = 0x40000 1870 NC_GenCol = 0x00008 1871 NC_HasAgg = 0x00010 1872 NC_HasWin = 0x08000 1873 NC_IdxExpr = 0x00020 1874 NC_InAggFunc = 0x20000 1875 NC_IsCheck = 0x00004 1876 NC_IsDDL = 0x10000 1877 NC_MinMaxAgg = 0x01000 1878 NC_PartIdx = 0x00002 1879 NC_SelfRef = 0x0002e 1880 NC_UAggInfo = 0x00100 1881 NC_UBaseReg = 0x00400 1882 NC_UEList = 0x00080 1883 NC_UUpsert = 0x00200 1884 NC_VarSelect = 0x00040 1885 NO_LOCK = 0 1886 OE_Abort = 2 1887 OE_Cascade = 10 1888 OE_Default = 11 1889 OE_Fail = 3 1890 OE_Ignore = 4 1891 OE_None = 0 1892 OE_Replace = 5 1893 OE_Restrict = 7 1894 OE_Rollback = 1 1895 OE_SetDflt = 9 1896 OE_SetNull = 8 1897 OE_Update = 6 1898 OMIT_TEMPDB = 0 1899 ONEPASS_MULTI = 2 1900 ONEPASS_OFF = 0 1901 ONEPASS_SINGLE = 1 1902 OPFLAG_APPEND = 0x08 1903 OPFLAG_AUXDELETE = 0x04 1904 OPFLAG_BULKCSR = 0x01 1905 OPFLAG_EPHEM = 0x01 1906 OPFLAG_FORDELETE = 0x08 1907 OPFLAG_ISNOOP = 0x40 1908 OPFLAG_ISUPDATE = 0x04 1909 OPFLAG_LASTROWID = 0x20 1910 OPFLAG_LENGTHARG = 0x40 1911 OPFLAG_NCHANGE = 0x01 1912 OPFLAG_NOCHNG = 0x01 1913 OPFLAG_NOCHNG_MAGIC = 0x6d 1914 OPFLAG_P2ISREG = 0x10 1915 OPFLAG_PERMUTE = 0x01 1916 OPFLAG_PREFORMAT = 0x80 1917 OPFLAG_SAVEPOSITION = 0x02 1918 OPFLAG_SEEKEQ = 0x02 1919 OPFLAG_TYPEOFARG = 0x80 1920 OPFLAG_USESEEKRESULT = 0x10 1921 OPFLG_IN1 = 0x02 1922 OPFLG_IN2 = 0x04 1923 OPFLG_IN3 = 0x08 1924 OPFLG_JUMP = 0x01 1925 OPFLG_OUT2 = 0x10 1926 OPFLG_OUT3 = 0x20 1927 OP_Abortable = 178 1928 OP_Add = 106 1929 OP_AddImm = 83 1930 OP_Affinity = 91 1931 OP_AggFinal = 160 1932 OP_AggInverse = 156 1933 OP_AggStep = 157 1934 OP_AggStep1 = 158 1935 OP_AggValue = 159 1936 OP_And = 44 1937 OP_AutoCommit = 1 1938 OP_BitAnd = 102 1939 OP_BitNot = 113 1940 OP_BitOr = 103 1941 OP_Blob = 74 1942 OP_Cast = 85 1943 OP_Checkpoint = 6 1944 OP_ChngCntRow = 80 1945 OP_Clear = 140 1946 OP_Close = 117 1947 OP_CollSeq = 82 1948 OP_Column = 90 1949 OP_ColumnsUsed = 118 1950 OP_Compare = 87 1951 OP_Concat = 111 1952 OP_Copy = 77 1953 OP_Count = 93 1954 OP_CreateBtree = 142 1955 OP_CursorHint = 174 1956 OP_CursorLock = 162 1957 OP_CursorUnlock = 163 1958 OP_DecrJumpZero = 59 1959 OP_DeferredSeek = 136 1960 OP_Delete = 125 1961 OP_Destroy = 139 1962 OP_Divide = 109 1963 OP_DropIndex = 147 1964 OP_DropTable = 146 1965 OP_DropTrigger = 148 1966 OP_ElseNotEq = 58 1967 OP_EndCoroutine = 66 1968 OP_Eq = 53 1969 OP_Expire = 161 1970 OP_Explain = 177 1971 OP_FinishSeek = 138 1972 OP_FkCounter = 153 1973 OP_FkIfZero = 47 1974 OP_Found = 30 1975 OP_Function = 64 1976 OP_Ge = 57 1977 OP_Gosub = 12 1978 OP_Goto = 11 1979 OP_Gt = 54 1980 OP_Halt = 68 1981 OP_HaltIfNull = 67 1982 OP_IdxDelete = 135 1983 OP_IdxGE = 41 1984 OP_IdxGT = 39 1985 OP_IdxInsert = 133 1986 OP_IdxLE = 38 1987 OP_IdxLT = 40 1988 OP_IdxRowid = 137 1989 OP_If = 18 1990 OP_IfNoHope = 27 1991 OP_IfNot = 20 1992 OP_IfNotOpen = 26 1993 OP_IfNotZero = 49 1994 OP_IfNullRow = 21 1995 OP_IfPos = 48 1996 OP_IfSmaller = 34 1997 OP_IncrVacuum = 60 1998 OP_Init = 62 1999 OP_InitCoroutine = 13 2000 OP_Insert = 123 2001 OP_Int64 = 70 2002 OP_IntCopy = 79 2003 OP_Integer = 69 2004 OP_IntegrityCk = 149 2005 OP_IsNull = 50 2006 OP_IsTrue = 88 2007 OP_JournalMode = 7 2008 OP_Jump = 16 2009 OP_Last = 33 2010 OP_Le = 55 2011 OP_LoadAnalysis = 145 2012 OP_Lt = 56 2013 OP_MakeRecord = 92 2014 OP_MaxPgcnt = 172 2015 OP_MemMax = 154 2016 OP_Move = 76 2017 OP_Multiply = 108 2018 OP_MustBeInt = 15 2019 OP_Ne = 52 2020 OP_NewRowid = 122 2021 OP_Next = 5 2022 OP_NoConflict = 28 2023 OP_Noop = 176 2024 OP_Not = 19 2025 OP_NotExists = 32 2026 OP_NotFound = 29 2027 OP_NotNull = 51 2028 OP_Null = 72 2029 OP_NullRow = 131 2030 OP_Offset = 89 2031 OP_OffsetLimit = 155 2032 OP_Once = 17 2033 OP_OpenAutoindex = 100 2034 OP_OpenDup = 99 2035 OP_OpenEphemeral = 101 2036 OP_OpenPseudo = 115 2037 OP_OpenRead = 97 2038 OP_OpenWrite = 98 2039 OP_Or = 43 2040 OP_Pagecount = 171 2041 OP_Param = 151 2042 OP_ParseSchema = 144 2043 OP_Permutation = 86 2044 OP_Prev = 4 2045 OP_Program = 46 2046 OP_PureFunc = 63 2047 OP_ReadCookie = 94 2048 OP_Real = 152 2049 OP_RealAffinity = 84 2050 OP_ReleaseReg = 175 2051 OP_Remainder = 110 2052 OP_ReopenIdx = 96 2053 OP_ResetCount = 126 2054 OP_ResetSorter = 141 2055 OP_ResultRow = 81 2056 OP_Return = 65 2057 OP_Rewind = 37 2058 OP_RowCell = 124 2059 OP_RowData = 129 2060 OP_RowSetAdd = 150 2061 OP_RowSetRead = 42 2062 OP_RowSetTest = 45 2063 OP_Rowid = 130 2064 OP_SCopy = 78 2065 OP_Savepoint = 0 2066 OP_SeekEnd = 132 2067 OP_SeekGE = 24 2068 OP_SeekGT = 25 2069 OP_SeekHit = 120 2070 OP_SeekLE = 23 2071 OP_SeekLT = 22 2072 OP_SeekRowid = 31 2073 OP_SeekScan = 119 2074 OP_Sequence = 121 2075 OP_SequenceTest = 114 2076 OP_SetCookie = 95 2077 OP_ShiftLeft = 104 2078 OP_ShiftRight = 105 2079 OP_SoftNull = 73 2080 OP_Sort = 36 2081 OP_SorterCompare = 127 2082 OP_SorterData = 128 2083 OP_SorterInsert = 134 2084 OP_SorterNext = 3 2085 OP_SorterOpen = 112 2086 OP_SorterSort = 35 2087 OP_SqlExec = 143 2088 OP_String = 71 2089 OP_String8 = 116 2090 OP_Subtract = 107 2091 OP_TableLock = 164 2092 OP_Trace = 173 2093 OP_Transaction = 2 2094 OP_VBegin = 165 2095 OP_VColumn = 169 2096 OP_VCreate = 166 2097 OP_VDestroy = 167 2098 OP_VFilter = 9 2099 OP_VNext = 61 2100 OP_VOpen = 168 2101 OP_VRename = 170 2102 OP_VUpdate = 10 2103 OP_Vacuum = 8 2104 OP_Variable = 75 2105 OP_Yield = 14 2106 OS_VXWORKS = 0 2107 P4_ADVANCE = -5 2108 P4_COLLSEQ = -2 2109 P4_DYNAMIC = -7 2110 P4_DYNBLOB = -17 2111 P4_EXPR = -10 2112 P4_FREE_IF_LE = -7 2113 P4_FUNCCTX = -16 2114 P4_FUNCDEF = -8 2115 P4_INT32 = -3 2116 P4_INT64 = -14 2117 P4_INTARRAY = -15 2118 P4_KEYINFO = -9 2119 P4_MEM = -11 2120 P4_NOTUSED = 0 2121 P4_REAL = -13 2122 P4_STATIC = -1 2123 P4_SUBPROGRAM = -4 2124 P4_TABLE = -6 2125 P4_TRANSIENT = 0 2126 P4_VTAB = -12 2127 P5_ConstraintCheck = 3 2128 P5_ConstraintFK = 4 2129 P5_ConstraintNotNull = 1 2130 P5_ConstraintUnique = 2 2131 PACKAGE_BUGREPORT = "" 2132 PACKAGE_NAME = "sqlite" 2133 PACKAGE_STRING = "sqlite 3.35.5" 2134 PACKAGE_TARNAME = "sqlite" 2135 PAGER_CACHESPILL = 0x20 2136 PAGER_CKPT_FULLFSYNC = 0x10 2137 PAGER_FLAGS_MASK = 0x38 2138 PAGER_FULLFSYNC = 0x08 2139 PAGER_GET_NOCONTENT = 0x01 2140 PAGER_GET_READONLY = 0x02 2141 PAGER_JOURNALMODE_DELETE = 0 2142 PAGER_JOURNALMODE_MEMORY = 4 2143 PAGER_JOURNALMODE_OFF = 2 2144 PAGER_JOURNALMODE_PERSIST = 1 2145 PAGER_JOURNALMODE_QUERY = -1 2146 PAGER_JOURNALMODE_TRUNCATE = 3 2147 PAGER_JOURNALMODE_WAL = 5 2148 PAGER_LOCKINGMODE_EXCLUSIVE = 1 2149 PAGER_LOCKINGMODE_NORMAL = 0 2150 PAGER_LOCKINGMODE_QUERY = -1 2151 PAGER_MEMORY = 0x0002 2152 PAGER_OMIT_JOURNAL = 0x0001 2153 PAGER_SYNCHRONOUS_EXTRA = 0x04 2154 PAGER_SYNCHRONOUS_FULL = 0x03 2155 PAGER_SYNCHRONOUS_MASK = 0x07 2156 PAGER_SYNCHRONOUS_NORMAL = 0x02 2157 PAGER_SYNCHRONOUS_OFF = 0x01 2158 PARSE_MODE_DECLARE_VTAB = 1 2159 PARSE_MODE_NORMAL = 0 2160 PARSE_MODE_RENAME = 2 2161 PARSE_MODE_UNMAP = 3 2162 PENDING_LOCK = 3 2163 PGHDR_CLEAN = 0x001 2164 PGHDR_DIRTY = 0x002 2165 PGHDR_DONT_WRITE = 0x010 2166 PGHDR_MMAP = 0x020 2167 PGHDR_NEED_SYNC = 0x008 2168 PGHDR_WAL_APPEND = 0x040 2169 PGHDR_WRITEABLE = 0x004 2170 PRIO_MAX = 20 2171 PRIO_MIN = -20 2172 PRIX16 = "X" 2173 PRIX32 = "X" 2174 PRIX8 = "X" 2175 PRIXFAST8 = "X" 2176 PRIXLEAST16 = "X" 2177 PRIXLEAST32 = "X" 2178 PRIXLEAST8 = "X" 2179 PRId16 = "d" 2180 PRId32 = "d" 2181 PRId8 = "d" 2182 PRIdFAST8 = "d" 2183 PRIdLEAST16 = "d" 2184 PRIdLEAST32 = "d" 2185 PRIdLEAST8 = "d" 2186 PRIi16 = "i" 2187 PRIi32 = "i" 2188 PRIi8 = "i" 2189 PRIiFAST8 = "i" 2190 PRIiLEAST16 = "i" 2191 PRIiLEAST32 = "i" 2192 PRIiLEAST8 = "i" 2193 PRIo16 = "o" 2194 PRIo32 = "o" 2195 PRIo8 = "o" 2196 PRIoFAST8 = "o" 2197 PRIoLEAST16 = "o" 2198 PRIoLEAST32 = "o" 2199 PRIoLEAST8 = "o" 2200 PRIu16 = "u" 2201 PRIu32 = "u" 2202 PRIu8 = "u" 2203 PRIuFAST8 = "u" 2204 PRIuLEAST16 = "u" 2205 PRIuLEAST32 = "u" 2206 PRIuLEAST8 = "u" 2207 PRIx16 = "x" 2208 PRIx32 = "x" 2209 PRIx8 = "x" 2210 PRIxFAST8 = "x" 2211 PRIxLEAST16 = "x" 2212 PRIxLEAST32 = "x" 2213 PRIxLEAST8 = "x" 2214 PTRDIFF_MAX = 9223372036854775807 2215 PTRDIFF_MIN = -9223372036854775808 2216 PTRDIFF_WIDTH = 64 2217 RENAME_EXCHANGE = 2 2218 RENAME_NOREPLACE = 1 2219 RENAME_WHITEOUT = 4 2220 RESERVED_LOCK = 2 2221 RLIM64_INFINITY = 0xffffffffffffffff 2222 RLIM_INFINITY = 0xffffffffffffffff 2223 RLIM_SAVED_CUR = 18446744073709551615 2224 RLIM_SAVED_MAX = 18446744073709551615 2225 SAVEPOINT_BEGIN = 0 2226 SAVEPOINT_RELEASE = 1 2227 SAVEPOINT_ROLLBACK = 2 2228 SCHEMA_ROOT = 1 2229 SCNd16 = "hd" 2230 SCNd32 = "d" 2231 SCNd8 = "hhd" 2232 SCNdFAST8 = "hhd" 2233 SCNdLEAST16 = "hd" 2234 SCNdLEAST32 = "d" 2235 SCNdLEAST8 = "hhd" 2236 SCNi16 = "hi" 2237 SCNi32 = "i" 2238 SCNi8 = "hhi" 2239 SCNiFAST8 = "hhi" 2240 SCNiLEAST16 = "hi" 2241 SCNiLEAST32 = "i" 2242 SCNiLEAST8 = "hhi" 2243 SCNo16 = "ho" 2244 SCNo32 = "o" 2245 SCNo8 = "hho" 2246 SCNoFAST8 = "hho" 2247 SCNoLEAST16 = "ho" 2248 SCNoLEAST32 = "o" 2249 SCNoLEAST8 = "hho" 2250 SCNu16 = "hu" 2251 SCNu32 = "u" 2252 SCNu8 = "hhu" 2253 SCNuFAST8 = "hhu" 2254 SCNuLEAST16 = "hu" 2255 SCNuLEAST32 = "u" 2256 SCNuLEAST8 = "hhu" 2257 SCNx16 = "hx" 2258 SCNx32 = "x" 2259 SCNx8 = "hhx" 2260 SCNxFAST8 = "hhx" 2261 SCNxLEAST16 = "hx" 2262 SCNxLEAST32 = "x" 2263 SCNxLEAST8 = "hhx" 2264 SEEK_DATA = 3 2265 SEEK_HOLE = 4 2266 SELECTTRACE_ENABLED = 0 2267 SF_Aggregate = 0x0000008 2268 SF_All = 0x0000002 2269 SF_ComplexResult = 0x0040000 2270 SF_Compound = 0x0000100 2271 SF_Converted = 0x0010000 2272 SF_Distinct = 0x0000001 2273 SF_Expanded = 0x0000040 2274 SF_FixedLimit = 0x0004000 2275 SF_HasAgg = 0x0000010 2276 SF_HasTypeInfo = 0x0000080 2277 SF_IncludeHidden = 0x0020000 2278 SF_MaybeConvert = 0x0008000 2279 SF_MinMaxAgg = 0x0001000 2280 SF_MultiPart = 0x2000000 2281 SF_MultiValue = 0x0000400 2282 SF_NestedFrom = 0x0000800 2283 SF_NoopOrderBy = 0x0400000 2284 SF_PushDown = 0x1000000 2285 SF_Recursive = 0x0002000 2286 SF_Resolved = 0x0000004 2287 SF_UpdateFrom = 0x0800000 2288 SF_UsesEphemeral = 0x0000020 2289 SF_Values = 0x0000200 2290 SF_View = 0x0200000 2291 SF_WhereBegin = 0x0080000 2292 SF_WinRewrite = 0x0100000 2293 SHARED_LOCK = 1 2294 SHARED_SIZE = 510 2295 SIG_ATOMIC_MAX = 2147483647 2296 SIG_ATOMIC_MIN = -2147483648 2297 SIG_ATOMIC_WIDTH = 32 2298 SIZE_MAX = 18446744073709551615 2299 SIZE_WIDTH = 64 2300 SQLITECONFIG_H = 1 2301 SQLITEINT_H = 0 2302 SQLITE_AFF_BLOB = 0x41 2303 SQLITE_AFF_INTEGER = 0x44 2304 SQLITE_AFF_MASK = 0x47 2305 SQLITE_AFF_NONE = 0x40 2306 SQLITE_AFF_NUMERIC = 0x43 2307 SQLITE_AFF_REAL = 0x45 2308 SQLITE_AFF_TEXT = 0x42 2309 SQLITE_ASCII = 1 2310 SQLITE_AllOpts = 0xffffffff 2311 SQLITE_AutoIndex = 0x00008000 2312 SQLITE_BIG_DBL = 0 2313 SQLITE_BTREE_H = 0 2314 SQLITE_BYTEORDER = 0 2315 SQLITE_CacheSpill = 0x00000020 2316 SQLITE_CellSizeCk = 0x00200000 2317 SQLITE_CkptFullFSync = 0x00000010 2318 SQLITE_CountOfView = 0x00000200 2319 SQLITE_CoverIdxScan = 0x00000020 2320 SQLITE_CursorHints = 0x00000400 2321 SQLITE_DEFAULT_AUTOVACUUM = 0 2322 SQLITE_DEFAULT_CACHE_SIZE = -2000 2323 SQLITE_DEFAULT_FILE_FORMAT = 4 2324 SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT = -1 2325 SQLITE_DEFAULT_MMAP_SIZE = 0 2326 SQLITE_DEFAULT_PCACHE_INITSZ = 20 2327 SQLITE_DEFAULT_RECURSIVE_TRIGGERS = 0 2328 SQLITE_DEFAULT_SECTOR_SIZE = 4096 2329 SQLITE_DEFAULT_SORTERREF_SIZE = 0x7fffffff 2330 SQLITE_DEFAULT_SYNCHRONOUS = 2 2331 SQLITE_DEFAULT_WAL_AUTOCHECKPOINT = 1000 2332 SQLITE_DEFAULT_WAL_SYNCHRONOUS = 2 2333 SQLITE_DEFAULT_WORKER_THREADS = 0 2334 SQLITE_Defensive = 0x10000000 2335 SQLITE_DeferFKs = 0x00080000 2336 SQLITE_DistinctOpt = 0x00000010 2337 SQLITE_DqsDDL = 0x20000000 2338 SQLITE_DqsDML = 0x40000000 2339 SQLITE_ECEL_DUP = 0x01 2340 SQLITE_ECEL_FACTOR = 0x02 2341 SQLITE_ECEL_OMITREF = 0x08 2342 SQLITE_ECEL_REF = 0x04 2343 SQLITE_ENABLE_LOCKING_STYLE = 0 2344 SQLITE_EnableQPSG = 0x00800000 2345 SQLITE_EnableTrigger = 0x00040000 2346 SQLITE_EnableView = 0x80000000 2347 SQLITE_ExistsToIN = 0x00020000 2348 SQLITE_FAULTINJECTOR_COUNT = 1 2349 SQLITE_FAULTINJECTOR_MALLOC = 0 2350 SQLITE_FCNTL_DB_UNCHANGED = 0xca093fa0 2351 SQLITE_FRAME_MAGIC = 0x879fb71e 2352 SQLITE_FUNC_CASE = 0x0008 2353 SQLITE_FUNC_CONSTANT = 0x0800 2354 SQLITE_FUNC_COUNT = 0x0100 2355 SQLITE_FUNC_DIRECT = 0x00080000 2356 SQLITE_FUNC_ENCMASK = 0x0003 2357 SQLITE_FUNC_EPHEM = 0x0010 2358 SQLITE_FUNC_HASH_SZ = 23 2359 SQLITE_FUNC_INLINE = 0x00400000 2360 SQLITE_FUNC_INTERNAL = 0x00040000 2361 SQLITE_FUNC_LENGTH = 0x0040 2362 SQLITE_FUNC_LIKE = 0x0004 2363 SQLITE_FUNC_MINMAX = 0x1000 2364 SQLITE_FUNC_NEEDCOLL = 0x0020 2365 SQLITE_FUNC_OFFSET = 0x8000 2366 SQLITE_FUNC_SLOCHNG = 0x2000 2367 SQLITE_FUNC_SUBTYPE = 0x00100000 2368 SQLITE_FUNC_TEST = 0x4000 2369 SQLITE_FUNC_TYPEOF = 0x0080 2370 SQLITE_FUNC_UNLIKELY = 0x0400 2371 SQLITE_FUNC_UNSAFE = 0x00200000 2372 SQLITE_FUNC_WINDOW = 0x00010000 2373 SQLITE_FactorOutConst = 0x00000008 2374 SQLITE_ForeignKeys = 0x00004000 2375 SQLITE_Fts3Tokenizer = 0x00400000 2376 SQLITE_FullColNames = 0x00000004 2377 SQLITE_FullFSync = 0x00000008 2378 SQLITE_GroupByOrder = 0x00000004 2379 SQLITE_HASH_H = 0 2380 SQLITE_HAVE_C99_MATH_FUNCS = 1 2381 SQLITE_HAVE_OS_TRACE = 0 2382 SQLITE_IDXTYPE_APPDEF = 0 2383 SQLITE_IDXTYPE_IPK = 3 2384 SQLITE_IDXTYPE_PRIMARYKEY = 2 2385 SQLITE_IDXTYPE_UNIQUE = 1 2386 SQLITE_IOERR_NOMEM_BKPT = 3082 2387 SQLITE_IgnoreChecks = 0x00000200 2388 SQLITE_JUMPIFNULL = 0x10 2389 SQLITE_KEEPNULL = 0x08 2390 SQLITE_LegacyAlter = 0x04000000 2391 SQLITE_LegacyFileFmt = 0x00000002 2392 SQLITE_LoadExtFunc = 0x00020000 2393 SQLITE_LoadExtension = 0x00010000 2394 SQLITE_MAGIC_BUSY = 0xf03b7906 2395 SQLITE_MAGIC_CLOSED = 0x9f3c2d33 2396 SQLITE_MAGIC_ERROR = 0xb5357930 2397 SQLITE_MAGIC_OPEN = 0xa029a697 2398 SQLITE_MAGIC_SICK = 0x4b771290 2399 SQLITE_MAGIC_ZOMBIE = 0x64cffc7f 2400 SQLITE_MALLOC_SOFT_LIMIT = 1024 2401 SQLITE_MAX_ATTACHED = 10 2402 SQLITE_MAX_COLUMN = 2000 2403 SQLITE_MAX_COMPOUND_SELECT = 500 2404 SQLITE_MAX_DB = 12 2405 SQLITE_MAX_DEFAULT_PAGE_SIZE = 8192 2406 SQLITE_MAX_EXPR_DEPTH = 1000 2407 SQLITE_MAX_FILE_FORMAT = 4 2408 SQLITE_MAX_FUNCTION_ARG = 127 2409 SQLITE_MAX_LENGTH = 1000000000 2410 SQLITE_MAX_LIKE_PATTERN_LENGTH = 50000 2411 SQLITE_MAX_MMAP_SIZE = 0x7fff0000 2412 SQLITE_MAX_PAGE_COUNT = 1073741823 2413 SQLITE_MAX_PAGE_SIZE = 65536 2414 SQLITE_MAX_SCHEMA_RETRY = 50 2415 SQLITE_MAX_SQL_LENGTH = 1000000000 2416 SQLITE_MAX_TRIGGER_DEPTH = 1000 2417 SQLITE_MAX_VARIABLE_NUMBER = 32766 2418 SQLITE_MAX_VDBE_OP = 250000000 2419 SQLITE_MAX_WORKER_THREADS = 8 2420 SQLITE_MSVC_H = 0 2421 SQLITE_MX_JUMP_OPCODE = 62 2422 SQLITE_MinMaxOpt = 0x00010000 2423 SQLITE_NEED_ERR_NAME = 0 2424 SQLITE_NOMEM_BKPT = 7 2425 SQLITE_NOTNULL = 0x90 2426 SQLITE_NULLEQ = 0x80 2427 SQLITE_N_BTREE_META = 16 2428 SQLITE_N_LIMIT = 12 2429 SQLITE_NoCkptOnClose = 0x00000800 2430 SQLITE_NoSchemaError = 0x08000000 2431 SQLITE_NullCallback = 0x00000100 2432 SQLITE_OS_OTHER = 0 2433 SQLITE_OS_SETUP_H = 0 2434 SQLITE_OS_UNIX = 1 2435 SQLITE_OS_WIN = 0 2436 SQLITE_OmitNoopJoin = 0x00000100 2437 SQLITE_OrderByIdxJoin = 0x00000040 2438 SQLITE_PAGER_H = 0 2439 SQLITE_POWERSAFE_OVERWRITE = 1 2440 SQLITE_PREPARE_MASK = 0x0f 2441 SQLITE_PREPARE_SAVESQL = 0x80 2442 SQLITE_PRINTF_INTERNAL = 0x01 2443 SQLITE_PRINTF_MALLOCED = 0x04 2444 SQLITE_PRINTF_SQLFUNC = 0x02 2445 SQLITE_PTRSIZE = 8 2446 SQLITE_PropagateConst = 0x00008000 2447 SQLITE_PushDown = 0x00001000 2448 SQLITE_QueryFlattener = 0x00000001 2449 SQLITE_QueryOnly = 0x00100000 2450 SQLITE_ReadUncommit = 0x00000400 2451 SQLITE_RecTriggers = 0x00002000 2452 SQLITE_ResetDatabase = 0x02000000 2453 SQLITE_ReverseOrder = 0x00001000 2454 SQLITE_SO_ASC = 0 2455 SQLITE_SO_DESC = 1 2456 SQLITE_SO_UNDEFINED = -1 2457 SQLITE_STOREP2 = 0x20 2458 SQLITE_SYSTEM_MALLOC = 1 2459 SQLITE_ShortColNames = 0x00000040 2460 SQLITE_SimplifyJoin = 0x00002000 2461 SQLITE_SkipScan = 0x00004000 2462 SQLITE_Stat4 = 0x00000800 2463 SQLITE_TEMP_FILE_PREFIX = "etilqs_" 2464 SQLITE_TOKEN_KEYWORD = 0x2 2465 SQLITE_TOKEN_QUOTED = 0x1 2466 SQLITE_TRACE_LEGACY = 0x40 2467 SQLITE_TRACE_NONLEGACY_MASK = 0x0f 2468 SQLITE_TRACE_XPROFILE = 0x80 2469 SQLITE_Transitive = 0x00000080 2470 SQLITE_TriggerEQP = 0x01000000 2471 SQLITE_TrustedSchema = 0x00000080 2472 SQLITE_VDBEINT_H = 0 2473 SQLITE_VDBE_H = 0 2474 SQLITE_VTABRISK_High = 2 2475 SQLITE_VTABRISK_Low = 0 2476 SQLITE_VTABRISK_Normal = 1 2477 SQLITE_WSD = 0 2478 SQLITE_WindowFunc = 0x00000002 2479 SQLITE_WriteSchema = 0x00000001 2480 SRT_Coroutine = 13 2481 SRT_Discard = 4 2482 SRT_DistFifo = 5 2483 SRT_DistQueue = 6 2484 SRT_EphemTab = 12 2485 SRT_Except = 2 2486 SRT_Exists = 3 2487 SRT_Fifo = 8 2488 SRT_Mem = 10 2489 SRT_Output = 9 2490 SRT_Queue = 7 2491 SRT_Set = 11 2492 SRT_Table = 14 2493 SRT_Union = 1 2494 SRT_Upfrom = 15 2495 STDC_HEADERS = 1 2496 TF_Autoincrement = 0x0008 2497 TF_Ephemeral = 0x4000 2498 TF_HasGenerated = 0x0060 2499 TF_HasHidden = 0x0002 2500 TF_HasNotNull = 0x0800 2501 TF_HasPrimaryKey = 0x0004 2502 TF_HasStat1 = 0x0010 2503 TF_HasStat4 = 0x2000 2504 TF_HasStored = 0x0040 2505 TF_HasVirtual = 0x0020 2506 TF_NoVisibleRowid = 0x0200 2507 TF_OOOHidden = 0x0400 2508 TF_Readonly = 0x0001 2509 TF_Shadow = 0x1000 2510 TF_StatsUsed = 0x0100 2511 TF_WithoutRowid = 0x0080 2512 TK_ABORT = 27 2513 TK_ACTION = 28 2514 TK_ADD = 162 2515 TK_AFTER = 29 2516 TK_AGG_COLUMN = 168 2517 TK_AGG_FUNCTION = 167 2518 TK_ALL = 134 2519 TK_ALTER = 161 2520 TK_ALWAYS = 96 2521 TK_ANALYZE = 30 2522 TK_AND = 44 2523 TK_ANY = 101 2524 TK_AS = 24 2525 TK_ASC = 31 2526 TK_ASTERISK = 179 2527 TK_ATTACH = 32 2528 TK_AUTOINCR = 125 2529 TK_BEFORE = 33 2530 TK_BEGIN = 5 2531 TK_BETWEEN = 48 2532 TK_BY = 34 2533 TK_CASCADE = 35 2534 TK_CASE = 156 2535 TK_CAST = 36 2536 TK_CHECK = 123 2537 TK_COLLATE = 112 2538 TK_COLUMN = 166 2539 TK_COLUMNKW = 60 2540 TK_COMMIT = 10 2541 TK_CONFLICT = 37 2542 TK_CONSTRAINT = 118 2543 TK_CREATE = 17 2544 TK_CTIME_KW = 100 2545 TK_CURRENT = 85 2546 TK_DATABASE = 38 2547 TK_DEFAULT = 119 2548 TK_DEFERRABLE = 130 2549 TK_DEFERRED = 7 2550 TK_DELETE = 127 2551 TK_DESC = 39 2552 TK_DETACH = 40 2553 TK_DISTINCT = 139 2554 TK_DO = 61 2555 TK_DROP = 132 2556 TK_EACH = 41 2557 TK_ELSE = 159 2558 TK_END = 11 2559 TK_ESCAPE = 58 2560 TK_EXCEPT = 135 2561 TK_EXCLUDE = 91 2562 TK_EXCLUSIVE = 9 2563 TK_EXISTS = 20 2564 TK_EXPLAIN = 2 2565 TK_FAIL = 42 2566 TK_FILTER = 165 2567 TK_FIRST = 83 2568 TK_FOLLOWING = 86 2569 TK_FOR = 62 2570 TK_FOREIGN = 131 2571 TK_FROM = 141 2572 TK_FUNCTION = 171 2573 TK_GENERATED = 95 2574 TK_GROUP = 145 2575 TK_GROUPS = 92 2576 TK_HAVING = 146 2577 TK_IF = 18 2578 TK_IF_NULL_ROW = 178 2579 TK_IGNORE = 63 2580 TK_IMMEDIATE = 8 2581 TK_IN = 49 2582 TK_INDEX = 160 2583 TK_INDEXED = 115 2584 TK_INITIALLY = 64 2585 TK_INSERT = 126 2586 TK_INSTEAD = 65 2587 TK_INTERSECT = 136 2588 TK_INTO = 150 2589 TK_IS = 45 2590 TK_ISNOT = 170 2591 TK_ISNULL = 50 2592 TK_JOIN = 142 2593 TK_JOIN_KW = 117 2594 TK_KEY = 67 2595 TK_LAST = 84 2596 TK_LIKE_KW = 47 2597 TK_LIMIT = 147 2598 TK_MATCH = 46 2599 TK_MATERIALIZED = 97 2600 TK_NO = 66 2601 TK_NOT = 19 2602 TK_NOTHING = 151 2603 TK_NOTNULL = 51 2604 TK_NULL = 120 2605 TK_NULLS = 82 2606 TK_OF = 68 2607 TK_OFFSET = 69 2608 TK_ON = 114 2609 TK_OR = 43 2610 TK_ORDER = 144 2611 TK_OTHERS = 93 2612 TK_OVER = 164 2613 TK_PARTITION = 87 2614 TK_PLAN = 4 2615 TK_PRAGMA = 70 2616 TK_PRECEDING = 88 2617 TK_PRIMARY = 121 2618 TK_QUERY = 3 2619 TK_RAISE = 71 2620 TK_RANGE = 89 2621 TK_RECURSIVE = 72 2622 TK_REFERENCES = 124 2623 TK_REGISTER = 175 2624 TK_REINDEX = 98 2625 TK_RELEASE = 14 2626 TK_RENAME = 99 2627 TK_REPLACE = 73 2628 TK_RESTRICT = 74 2629 TK_RETURNING = 149 2630 TK_ROLLBACK = 12 2631 TK_ROW = 75 2632 TK_ROWS = 76 2633 TK_SAVEPOINT = 13 2634 TK_SELECT = 137 2635 TK_SELECT_COLUMN = 177 2636 TK_SET = 129 2637 TK_SPAN = 180 2638 TK_TABLE = 16 2639 TK_TEMP = 21 2640 TK_THEN = 158 2641 TK_TIES = 94 2642 TK_TO = 15 2643 TK_TRANSACTION = 6 2644 TK_TRIGGER = 77 2645 TK_TRUEFALSE = 169 2646 TK_TRUTH = 174 2647 TK_UMINUS = 172 2648 TK_UNBOUNDED = 90 2649 TK_UNION = 133 2650 TK_UNIQUE = 122 2651 TK_UPDATE = 128 2652 TK_UPLUS = 173 2653 TK_USING = 143 2654 TK_VACUUM = 78 2655 TK_VALUES = 138 2656 TK_VECTOR = 176 2657 TK_VIEW = 79 2658 TK_VIRTUAL = 80 2659 TK_WHEN = 157 2660 TK_WHERE = 148 2661 TK_WINDOW = 163 2662 TK_WITH = 81 2663 TK_WITHOUT = 25 2664 TRIGGER_AFTER = 2 2665 TRIGGER_BEFORE = 1 2666 UINT16_MAX = 65535 2667 UINT16_WIDTH = 16 2668 UINT32_MAX = 4294967295 2669 UINT32_WIDTH = 32 2670 UINT64_MAX = 18446744073709551615 2671 UINT64_WIDTH = 64 2672 UINT8_MAX = 255 2673 UINT8_WIDTH = 8 2674 UINTMAX_MAX = 18446744073709551615 2675 UINTMAX_WIDTH = 64 2676 UINTPTR_MAX = 18446744073709551615 2677 UINTPTR_WIDTH = 64 2678 UINT_FAST16_MAX = 18446744073709551615 2679 UINT_FAST16_WIDTH = 64 2680 UINT_FAST32_MAX = 18446744073709551615 2681 UINT_FAST32_WIDTH = 64 2682 UINT_FAST64_MAX = 18446744073709551615 2683 UINT_FAST64_WIDTH = 64 2684 UINT_FAST8_MAX = 255 2685 UINT_FAST8_WIDTH = 8 2686 UINT_LEAST16_MAX = 65535 2687 UINT_LEAST16_WIDTH = 16 2688 UINT_LEAST32_MAX = 4294967295 2689 UINT_LEAST32_WIDTH = 32 2690 UINT_LEAST64_MAX = 18446744073709551615 2691 UINT_LEAST64_WIDTH = 64 2692 UINT_LEAST8_MAX = 255 2693 UINT_LEAST8_WIDTH = 8 2694 VDBE_DISPLAY_P4 = 1 2695 VDBE_MAGIC_DEAD = 0x5606c3c8 2696 VDBE_MAGIC_HALT = 0x319c2973 2697 VDBE_MAGIC_INIT = 0x16bceaa5 2698 VDBE_MAGIC_RESET = 0x48fa9f76 2699 VDBE_MAGIC_RUN = 0x2df20da3 2700 WCHAR_MAX = 2147483647 2701 WCHAR_MIN = -2147483648 2702 WCHAR_WIDTH = 32 2703 WHERE_DISTINCTBY = 0x0080 2704 WHERE_DISTINCT_NOOP = 0 2705 WHERE_DISTINCT_ORDERED = 2 2706 WHERE_DISTINCT_UNIQUE = 1 2707 WHERE_DISTINCT_UNORDERED = 3 2708 WHERE_DUPLICATES_OK = 0x0010 2709 WHERE_GROUPBY = 0x0040 2710 WHERE_ONEPASS_DESIRED = 0x0004 2711 WHERE_ONEPASS_MULTIROW = 0x0008 2712 WHERE_ORDERBY_LIMIT = 0x0800 2713 WHERE_ORDERBY_MAX = 0x0002 2714 WHERE_ORDERBY_MIN = 0x0001 2715 WHERE_ORDERBY_NORMAL = 0x0000 2716 WHERE_OR_SUBCLAUSE = 0x0020 2717 WHERE_SORTBYGROUP = 0x0200 2718 WHERE_USE_LIMIT = 0x4000 2719 WHERE_WANT_DISTINCT = 0x0100 2720 WINT_MAX = 4294967295 2721 WINT_MIN = 0 2722 WINT_WIDTH = 32 2723 WRC_Abort = 2 2724 WRC_Continue = 0 2725 WRC_Prune = 1 2726 XN_EXPR = -2 2727 XN_ROWID = -1 2728 X_BITS_STDINT_UINTN_H = 1 2729 X_BITS_WCHAR_H = 1 2730 X_GCC_WRAP_STDINT_H = 0 2731 X_GNU_SOURCE = 0 2732 X_INTTYPES_H = 1 2733 X_ISOC11_SOURCE = 1 2734 X_ISOC95_SOURCE = 1 2735 X_ISOC99_SOURCE = 1 2736 X_LARGEFILE64_SOURCE = 1 2737 X_LARGEFILE_SOURCE = 1 2738 X_LARGE_FILE = 1 2739 X_SQLITE_OS_H_ = 0 2740 X_STDINT_H = 1 2741 X_SYS_RESOURCE_H = 1 2742 X_XOPEN_SOURCE = 700 2743 X_XOPEN_SOURCE_EXTENDED = 1 2744 BTCF_AtLast = 0x08 2745 BTCF_Incrblob = 0x10 2746 BTCF_Multiple = 0x20 2747 BTCF_Pinned = 0x40 2748 BTCF_ValidNKey = 0x02 2749 BTCF_ValidOvfl = 0x04 2750 BTCF_WriteFlag = 0x01 2751 BTCURSOR_MAX_DEPTH = 20 2752 BTS_EXCLUSIVE = 0x0040 2753 BTS_FAST_SECURE = 0x000c 2754 BTS_INITIALLY_EMPTY = 0x0010 2755 BTS_NO_WAL = 0x0020 2756 BTS_OVERWRITE = 0x0008 2757 BTS_PAGESIZE_FIXED = 0x0002 2758 BTS_PENDING = 0x0080 2759 BTS_READ_ONLY = 0x0001 2760 BTS_SECURE_DELETE = 0x0004 2761 CURSOR_FAULT = 4 2762 CURSOR_INVALID = 1 2763 CURSOR_REQUIRESEEK = 3 2764 CURSOR_SKIPNEXT = 2 2765 CURSOR_VALID = 0 2766 PTF_INTKEY = 0x01 2767 PTF_LEAF = 0x08 2768 PTF_LEAFDATA = 0x04 2769 PTF_ZERODATA = 0x02 2770 PTRMAP_BTREE = 5 2771 PTRMAP_FREEPAGE = 2 2772 PTRMAP_OVERFLOW1 = 3 2773 PTRMAP_OVERFLOW2 = 4 2774 PTRMAP_ROOTPAGE = 1 2775 READ_LOCK = 1 2776 SQLITE_FILE_HEADER = "SQLite format 3" 2777 TRANS_NONE = 0 2778 TRANS_READ = 1 2779 TRANS_WRITE = 2 2780 WRITE_LOCK = 2 2781 ADJ_ESTERROR = 0x0008 2782 ADJ_FREQUENCY = 0x0002 2783 ADJ_MAXERROR = 0x0004 2784 ADJ_MICRO = 0x1000 2785 ADJ_NANO = 0x2000 2786 ADJ_OFFSET = 0x0001 2787 ADJ_OFFSET_SINGLESHOT = 0x8001 2788 ADJ_OFFSET_SS_READ = 0xa001 2789 ADJ_SETOFFSET = 0x0100 2790 ADJ_STATUS = 0x0010 2791 ADJ_TAI = 0x0080 2792 ADJ_TICK = 0x4000 2793 ADJ_TIMECONST = 0x0020 2794 CLONE_CHILD_CLEARTID = 0x00200000 2795 CLONE_CHILD_SETTID = 0x01000000 2796 CLONE_DETACHED = 0x00400000 2797 CLONE_FILES = 0x00000400 2798 CLONE_FS = 0x00000200 2799 CLONE_IO = 0x80000000 2800 CLONE_NEWCGROUP = 0x02000000 2801 CLONE_NEWIPC = 0x08000000 2802 CLONE_NEWNET = 0x40000000 2803 CLONE_NEWNS = 0x00020000 2804 CLONE_NEWPID = 0x20000000 2805 CLONE_NEWUSER = 0x10000000 2806 CLONE_NEWUTS = 0x04000000 2807 CLONE_PARENT = 0x00008000 2808 CLONE_PARENT_SETTID = 0x00100000 2809 CLONE_PTRACE = 0x00002000 2810 CLONE_SETTLS = 0x00080000 2811 CLONE_SIGHAND = 0x00000800 2812 CLONE_SYSVSEM = 0x00040000 2813 CLONE_THREAD = 0x00010000 2814 CLONE_UNTRACED = 0x00800000 2815 CLONE_VFORK = 0x00004000 2816 CLONE_VM = 0x00000100 2817 CPU_SETSIZE = 1024 2818 CSIGNAL = 0x000000ff 2819 MOD_CLKA = 32769 2820 MOD_CLKB = 16384 2821 MOD_ESTERROR = 8 2822 MOD_FREQUENCY = 2 2823 MOD_MAXERROR = 4 2824 MOD_MICRO = 4096 2825 MOD_NANO = 8192 2826 MOD_OFFSET = 1 2827 MOD_STATUS = 16 2828 MOD_TAI = 128 2829 MOD_TIMECONST = 32 2830 N_THREAD = 26 2831 PTHREAD_BARRIER_SERIAL_THREAD = -1 2832 PTHREAD_ONCE_INIT = 0 2833 SCHED_BATCH = 3 2834 SCHED_DEADLINE = 6 2835 SCHED_FIFO = 1 2836 SCHED_IDLE = 5 2837 SCHED_ISO = 4 2838 SCHED_OTHER = 0 2839 SCHED_RESET_ON_FORK = 0x40000000 2840 SCHED_RR = 2 2841 STA_CLK = 0x8000 2842 STA_CLOCKERR = 0x1000 2843 STA_DEL = 0x0020 2844 STA_FLL = 0x0008 2845 STA_FREQHOLD = 0x0080 2846 STA_INS = 0x0010 2847 STA_MODE = 0x4000 2848 STA_NANO = 0x2000 2849 STA_PLL = 0x0001 2850 STA_PPSERROR = 0x0800 2851 STA_PPSFREQ = 0x0002 2852 STA_PPSJITTER = 0x0200 2853 STA_PPSSIGNAL = 0x0100 2854 STA_PPSTIME = 0x0004 2855 STA_PPSWANDER = 0x0400 2856 STA_RONLY = 65280 2857 STA_UNSYNC = 0x0040 2858 X_BITS_CPU_SET_H = 1 2859 X_BITS_SCHED_H = 1 2860 X_BITS_TIMEX_H = 1 2861 X_BITS_TYPES_STRUCT_SCHED_PARAM = 1 2862 X_PTHREAD_H = 1 2863 X_SCHED_H = 1 2864 TCL_THREADS = 0 2865 MX_CHUNK_NUMBER = 299 2866 SQLITE_MULTIPLEX_JOURNAL_8_3_OFFSET = 400 2867 SQLITE_MULTIPLEX_WAL_8_3_OFFSET = 700 2868 DEVSYM_MAX_PATHNAME = 512 2869 DEVSYM_VFS_NAME = "devsym" 2870 WRITECRASH_NAME = "writecrash" 2871 AT_EMPTY_PATH = 0x1000 2872 AT_NO_AUTOMOUNT = 0x800 2873 AT_STATX_DONT_SYNC = 0x4000 2874 AT_STATX_FORCE_SYNC = 0x2000 2875 AT_STATX_SYNC_AS_STAT = 0x0000 2876 AT_STATX_SYNC_TYPE = 0x6000 2877 DN_ACCESS = 0x00000001 2878 DN_ATTRIB = 0x00000020 2879 DN_CREATE = 0x00000004 2880 DN_DELETE = 0x00000008 2881 DN_MODIFY = 0x00000002 2882 DN_MULTISHOT = 0x80000000 2883 DN_RENAME = 0x00000010 2884 FALLOC_FL_COLLAPSE_RANGE = 0x08 2885 FALLOC_FL_INSERT_RANGE = 0x20 2886 FALLOC_FL_KEEP_SIZE = 0x01 2887 FALLOC_FL_NO_HIDE_STALE = 0x04 2888 FALLOC_FL_PUNCH_HOLE = 0x02 2889 FALLOC_FL_UNSHARE_RANGE = 0x40 2890 FALLOC_FL_ZERO_RANGE = 0x10 2891 F_ADD_SEALS = 1033 2892 F_GETLEASE = 1025 2893 F_GETOWN_EX = 16 2894 F_GETPIPE_SZ = 1032 2895 F_GETSIG = 11 2896 F_GET_FILE_RW_HINT = 1037 2897 F_GET_RW_HINT = 1035 2898 F_GET_SEALS = 1034 2899 F_NOTIFY = 1026 2900 F_OFD_GETLK = 36 2901 F_OFD_SETLK = 37 2902 F_OFD_SETLKW = 38 2903 F_SEAL_GROW = 0x0004 2904 F_SEAL_SEAL = 0x0001 2905 F_SEAL_SHRINK = 0x0002 2906 F_SEAL_WRITE = 0x0008 2907 F_SETLEASE = 1024 2908 F_SETOWN_EX = 15 2909 F_SETPIPE_SZ = 1031 2910 F_SETSIG = 10 2911 F_SET_FILE_RW_HINT = 1038 2912 F_SET_RW_HINT = 1036 2913 LOCK_MAND = 32 2914 LOCK_READ = 64 2915 LOCK_RW = 192 2916 LOCK_WRITE = 128 2917 MAX_HANDLE_SZ = 128 2918 O_DIRECT = 16384 2919 O_LARGEFILE = 0 2920 O_NOATIME = 262144 2921 O_PATH = 2097152 2922 O_TMPFILE = 4259840 2923 RWF_WRITE_LIFE_NOT_SET = 0 2924 RWH_WRITE_LIFE_EXTREME = 5 2925 RWH_WRITE_LIFE_LONG = 4 2926 RWH_WRITE_LIFE_MEDIUM = 3 2927 RWH_WRITE_LIFE_NONE = 1 2928 RWH_WRITE_LIFE_SHORT = 2 2929 SPLICE_F_GIFT = 8 2930 SPLICE_F_MORE = 4 2931 SPLICE_F_MOVE = 1 2932 SPLICE_F_NONBLOCK = 2 2933 STATX_ALL = 0x0fff 2934 STATX_ATIME = 0x0020 2935 STATX_ATTR_APPEND = 0x0020 2936 STATX_ATTR_AUTOMOUNT = 0x1000 2937 STATX_ATTR_COMPRESSED = 0x0004 2938 STATX_ATTR_ENCRYPTED = 0x0800 2939 STATX_ATTR_IMMUTABLE = 0x0010 2940 STATX_ATTR_NODUMP = 0x0040 2941 STATX_BASIC_STATS = 0x07ff 2942 STATX_BLOCKS = 0x0400 2943 STATX_BTIME = 0x0800 2944 STATX_CTIME = 0x0080 2945 STATX_GID = 0x0010 2946 STATX_INO = 0x0100 2947 STATX_MODE = 0x0002 2948 STATX_MTIME = 0x0040 2949 STATX_NLINK = 0x0004 2950 STATX_SIZE = 0x0200 2951 STATX_TYPE = 0x0001 2952 STATX_UID = 0x0008 2953 STATX__RESERVED = 0x80000000 2954 SYNC_FILE_RANGE_WAIT_AFTER = 4 2955 SYNC_FILE_RANGE_WAIT_BEFORE = 1 2956 SYNC_FILE_RANGE_WRITE = 2 2957 X_FALLOC_H_ = 0 2958 X_POSIX_FD_SETSIZE = 20 2959 X_POSIX_HIWAT = 512 2960 X_POSIX_QLIMIT = 1 2961 X_POSIX_UIO_MAXIOV = 16 2962 SQLITE_INTARRAY_H = 0 2963 JT_MAX_PATHNAME = 512 2964 JT_VFS_NAME = "jt" 2965 MALLOC_LOG_FRAMES = 10 2966 DEFAULT_SECTOR_SIZE = 0x1000 2967 MAX_PAGE_SIZE = 0x10000 2968 MULTIPLEX_CTRL_ENABLE = 214014 2969 MULTIPLEX_CTRL_SET_CHUNK_SIZE = 214015 2970 MULTIPLEX_CTRL_SET_MAX_CHUNKS = 214016 2971 SQLITE_MULTIPLEX_CHUNK_SIZE = 2147418112 2972 SQLITE_MULTIPLEX_MAX_CHUNKS = 12 2973 SQLITE_MULTIPLEX_VFS_NAME = "multiplex" 2974 SQLITE_TEST_MULTIPLEX_H = 0 2975 MAX_MUTEXES = 14 2976 STATIC_MUTEXES = 12 2977 BLOBSIZE = 10485760 2978 BLOCKSIZE = 512 2979 DATABASE_FILE = 1 2980 FS_VFS_NAME = "fs" 2981 JOURNAL_FILE = 2 2982 INST_MAX_PATHNAME = 512 2983 OS_ACCESS = 1 2984 OS_ANNOTATE = 28 2985 OS_CHECKRESERVEDLOCK = 2 2986 OS_CLOSE = 3 2987 OS_CURRENTTIME = 4 2988 OS_DELETE = 5 2989 OS_DEVCHAR = 6 2990 OS_FILECONTROL = 7 2991 OS_FILESIZE = 8 2992 OS_FULLPATHNAME = 9 2993 OS_LOCK = 11 2994 OS_NUMEVENTS = 29 2995 OS_OPEN = 12 2996 OS_RANDOMNESS = 13 2997 OS_READ = 14 2998 OS_SECTORSIZE = 15 2999 OS_SHMBARRIER = 26 3000 OS_SHMLOCK = 25 3001 OS_SHMMAP = 23 3002 OS_SHMUNMAP = 22 3003 OS_SLEEP = 16 3004 OS_SYNC = 17 3005 OS_TRUNCATE = 18 3006 OS_UNLOCK = 19 3007 OS_WRITE = 20 3008 VFSLOG_BUFFERSIZE = 8192 3009 TESTPCACHE_CLEAR = 0xd42670d4 3010 TESTPCACHE_NPAGE = 217 3011 TESTPCACHE_RESERVE = 17 3012 TESTPCACHE_VALID = 0x364585fd 3013 MSG_Close = 6 3014 MSG_Done = 7 3015 MSG_Finalize = 5 3016 MSG_Open = 1 3017 MSG_Prepare = 2 3018 MSG_Reset = 4 3019 MSG_Step = 3 3020 MADV_DODUMP = 17 3021 MADV_DOFORK = 11 3022 MADV_DONTDUMP = 16 3023 MADV_DONTFORK = 10 3024 MADV_DONTNEED = 4 3025 MADV_FREE = 8 3026 MADV_HUGEPAGE = 14 3027 MADV_HWPOISON = 100 3028 MADV_KEEPONFORK = 19 3029 MADV_MERGEABLE = 12 3030 MADV_NOHUGEPAGE = 15 3031 MADV_NORMAL = 0 3032 MADV_RANDOM = 1 3033 MADV_REMOVE = 9 3034 MADV_SEQUENTIAL = 2 3035 MADV_UNMERGEABLE = 13 3036 MADV_WILLNEED = 3 3037 MADV_WIPEONFORK = 18 3038 MAP_ANON = 32 3039 MAP_ANONYMOUS = 0x20 3040 MAP_DENYWRITE = 0x00800 3041 MAP_EXECUTABLE = 0x01000 3042 MAP_FILE = 0 3043 MAP_FIXED = 0x10 3044 MAP_FIXED_NOREPLACE = 0x100000 3045 MAP_GROWSDOWN = 0x00100 3046 MAP_HUGETLB = 0x40000 3047 MAP_HUGE_MASK = 0x3f 3048 MAP_HUGE_SHIFT = 26 3049 MAP_LOCKED = 0x02000 3050 MAP_NONBLOCK = 0x10000 3051 MAP_NORESERVE = 0x04000 3052 MAP_POPULATE = 0x08000 3053 MAP_PRIVATE = 0x02 3054 MAP_SHARED = 0x01 3055 MAP_SHARED_VALIDATE = 0x03 3056 MAP_STACK = 0x20000 3057 MAP_SYNC = 0x80000 3058 MAP_TYPE = 0x0f 3059 MCL_CURRENT = 1 3060 MCL_FUTURE = 2 3061 MCL_ONFAULT = 4 3062 MFD_ALLOW_SEALING = 2 3063 MFD_CLOEXEC = 1 3064 MFD_HUGETLB = 4 3065 MLOCK_ONFAULT = 1 3066 MREMAP_FIXED = 2 3067 MREMAP_MAYMOVE = 1 3068 MS_ASYNC = 1 3069 MS_INVALIDATE = 2 3070 MS_SYNC = 4 3071 PKEY_DISABLE_ACCESS = 0x1 3072 PKEY_DISABLE_WRITE = 0x2 3073 POSIX_MADV_DONTNEED = 4 3074 POSIX_MADV_NORMAL = 0 3075 POSIX_MADV_RANDOM = 1 3076 POSIX_MADV_SEQUENTIAL = 2 3077 POSIX_MADV_WILLNEED = 3 3078 PROT_EXEC = 0x4 3079 PROT_GROWSDOWN = 0x01000000 3080 PROT_GROWSUP = 0x02000000 3081 PROT_NONE = 0x0 3082 PROT_READ = 0x1 3083 PROT_WRITE = 0x2 3084 X_SYS_MMAN_H = 1 3085 TCLVAR_NAME_EQ = 101 3086 TCLVAR_NAME_MATCH = 109 3087 TCLVAR_VALUE_GLOB = 103 3088 TCLVAR_VALUE_LIKE = 108 3089 TCLVAR_VALUE_REGEXP = 114 3090 FAULT_INJECT_NONE = 0 3091 FAULT_INJECT_PERSISTENT = 2 3092 FAULT_INJECT_TRANSIENT = 1 3093 TESTVFS_ACCESS_MASK = 0x00004000 3094 TESTVFS_ALL_MASK = 0x001FFFFF 3095 TESTVFS_CKLOCK_MASK = 0x00080000 3096 TESTVFS_CLOSE_MASK = 0x00000800 3097 TESTVFS_DELETE_MASK = 0x00000400 3098 TESTVFS_FCNTL_MASK = 0x00100000 3099 TESTVFS_FULLPATHNAME_MASK = 0x00008000 3100 TESTVFS_LOCK_MASK = 0x00040000 3101 TESTVFS_MAX_ARGS = 12 3102 TESTVFS_MAX_PAGES = 1024 3103 TESTVFS_OPEN_MASK = 0x00000100 3104 TESTVFS_READ_MASK = 0x00010000 3105 TESTVFS_SHMBARRIER_MASK = 0x00000040 3106 TESTVFS_SHMCLOSE_MASK = 0x00000080 3107 TESTVFS_SHMLOCK_MASK = 0x00000010 3108 TESTVFS_SHMMAP_MASK = 0x00000020 3109 TESTVFS_SHMOPEN_MASK = 0x00000001 3110 TESTVFS_SYNC_MASK = 0x00000200 3111 TESTVFS_TRUNCATE_MASK = 0x00002000 3112 TESTVFS_UNLOCK_MASK = 0x00020000 3113 TESTVFS_WRITE_MASK = 0x00001000 3114 ) 3115 3116 // Positions to pass to Tcl_QueueEvent: 3117 3118 const ( /* tcl.h:1387:1: */ 3119 TCL_QUEUE_TAIL = 0 3120 TCL_QUEUE_HEAD = 1 3121 TCL_QUEUE_MARK = 2 3122 ) 3123 3124 // The following flags determine whether the blockModeProc above should set 3125 // the channel into blocking or nonblocking mode. They are passed as arguments 3126 // to the blockModeProc function in the above structure. 3127 3128 //---------------------------------------------------------------------------- 3129 // Enum for different types of file paths. 3130 3131 const ( /* tcl.h:1609:1: */ 3132 TCL_PATH_ABSOLUTE = 0 3133 TCL_PATH_RELATIVE = 1 3134 TCL_PATH_VOLUME_RELATIVE = 2 3135 ) 3136 3137 //---------------------------------------------------------------------------- 3138 // When a TCL command returns, the interpreter contains a result from the 3139 // command. Programmers are strongly encouraged to use one of the functions 3140 // Tcl_GetObjResult() or Tcl_GetStringResult() to read the interpreter's 3141 // result. See the SetResult man page for details. Besides this result, the 3142 // command function returns an integer code, which is one of the following: 3143 // 3144 // TCL_OK Command completed normally; the interpreter's result 3145 // contains the command's result. 3146 // TCL_ERROR The command couldn't be completed successfully; the 3147 // interpreter's result describes what went wrong. 3148 // TCL_RETURN The command requests that the current function return; 3149 // the interpreter's result contains the function's 3150 // return value. 3151 // TCL_BREAK The command requests that the innermost loop be 3152 // exited; the interpreter's result is meaningless. 3153 // TCL_CONTINUE Go on to the next iteration of the current loop; the 3154 // interpreter's result is meaningless. 3155 3156 //---------------------------------------------------------------------------- 3157 // Flags to control what substitutions are performed by Tcl_SubstObj(): 3158 3159 // Argument descriptors for math function callbacks in expressions: 3160 3161 const ( /* tcl.h:690:1: */ 3162 TCL_INT = 0 3163 TCL_DOUBLE = 1 3164 TCL_EITHER = 2 3165 TCL_WIDE_INT = 3 3166 ) 3167 3168 // Get the `_PC_*' symbols for the NAME argument to `pathconf' and `fpathconf'; 3169 // the `_SC_*' symbols for the NAME argument to `sysconf'; 3170 // and the `_CS_*' symbols for the NAME argument to `confstr'. 3171 // `sysconf', `pathconf', and `confstr' NAME values. Generic version. 3172 // Copyright (C) 1993-2018 Free Software Foundation, Inc. 3173 // This file is part of the GNU C Library. 3174 // 3175 // The GNU C Library is free software; you can redistribute it and/or 3176 // modify it under the terms of the GNU Lesser General Public 3177 // License as published by the Free Software Foundation; either 3178 // version 2.1 of the License, or (at your option) any later version. 3179 // 3180 // The GNU C Library is distributed in the hope that it will be useful, 3181 // but WITHOUT ANY WARRANTY; without even the implied warranty of 3182 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 3183 // Lesser General Public License for more details. 3184 // 3185 // You should have received a copy of the GNU Lesser General Public 3186 // License along with the GNU C Library; if not, see 3187 // <http://www.gnu.org/licenses/>. 3188 3189 // Values for the NAME argument to `pathconf' and `fpathconf'. 3190 const ( /* confname.h:24:1: */ 3191 _PC_LINK_MAX = 0 3192 _PC_MAX_CANON = 1 3193 _PC_MAX_INPUT = 2 3194 _PC_NAME_MAX = 3 3195 _PC_PATH_MAX = 4 3196 _PC_PIPE_BUF = 5 3197 _PC_CHOWN_RESTRICTED = 6 3198 _PC_NO_TRUNC = 7 3199 _PC_VDISABLE = 8 3200 _PC_SYNC_IO = 9 3201 _PC_ASYNC_IO = 10 3202 _PC_PRIO_IO = 11 3203 _PC_SOCK_MAXBUF = 12 3204 _PC_FILESIZEBITS = 13 3205 _PC_REC_INCR_XFER_SIZE = 14 3206 _PC_REC_MAX_XFER_SIZE = 15 3207 _PC_REC_MIN_XFER_SIZE = 16 3208 _PC_REC_XFER_ALIGN = 17 3209 _PC_ALLOC_SIZE_MIN = 18 3210 _PC_SYMLINK_MAX = 19 3211 _PC_2_SYMLINKS = 20 3212 ) 3213 3214 // Values for the NAME argument to `confstr'. 3215 const ( /* confname.h:533:1: */ 3216 _CS_PATH = 0 // The default search path. 3217 3218 _CS_V6_WIDTH_RESTRICTED_ENVS = 1 3219 3220 _CS_GNU_LIBC_VERSION = 2 3221 _CS_GNU_LIBPTHREAD_VERSION = 3 3222 3223 _CS_V5_WIDTH_RESTRICTED_ENVS = 4 3224 3225 _CS_V7_WIDTH_RESTRICTED_ENVS = 5 3226 3227 _CS_LFS_CFLAGS = 1000 3228 _CS_LFS_LDFLAGS = 1001 3229 _CS_LFS_LIBS = 1002 3230 _CS_LFS_LINTFLAGS = 1003 3231 _CS_LFS64_CFLAGS = 1004 3232 _CS_LFS64_LDFLAGS = 1005 3233 _CS_LFS64_LIBS = 1006 3234 _CS_LFS64_LINTFLAGS = 1007 3235 3236 _CS_XBS5_ILP32_OFF32_CFLAGS = 1100 3237 _CS_XBS5_ILP32_OFF32_LDFLAGS = 1101 3238 _CS_XBS5_ILP32_OFF32_LIBS = 1102 3239 _CS_XBS5_ILP32_OFF32_LINTFLAGS = 1103 3240 _CS_XBS5_ILP32_OFFBIG_CFLAGS = 1104 3241 _CS_XBS5_ILP32_OFFBIG_LDFLAGS = 1105 3242 _CS_XBS5_ILP32_OFFBIG_LIBS = 1106 3243 _CS_XBS5_ILP32_OFFBIG_LINTFLAGS = 1107 3244 _CS_XBS5_LP64_OFF64_CFLAGS = 1108 3245 _CS_XBS5_LP64_OFF64_LDFLAGS = 1109 3246 _CS_XBS5_LP64_OFF64_LIBS = 1110 3247 _CS_XBS5_LP64_OFF64_LINTFLAGS = 1111 3248 _CS_XBS5_LPBIG_OFFBIG_CFLAGS = 1112 3249 _CS_XBS5_LPBIG_OFFBIG_LDFLAGS = 1113 3250 _CS_XBS5_LPBIG_OFFBIG_LIBS = 1114 3251 _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS = 1115 3252 3253 _CS_POSIX_V6_ILP32_OFF32_CFLAGS = 1116 3254 _CS_POSIX_V6_ILP32_OFF32_LDFLAGS = 1117 3255 _CS_POSIX_V6_ILP32_OFF32_LIBS = 1118 3256 _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS = 1119 3257 _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS = 1120 3258 _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS = 1121 3259 _CS_POSIX_V6_ILP32_OFFBIG_LIBS = 1122 3260 _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS = 1123 3261 _CS_POSIX_V6_LP64_OFF64_CFLAGS = 1124 3262 _CS_POSIX_V6_LP64_OFF64_LDFLAGS = 1125 3263 _CS_POSIX_V6_LP64_OFF64_LIBS = 1126 3264 _CS_POSIX_V6_LP64_OFF64_LINTFLAGS = 1127 3265 _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS = 1128 3266 _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS = 1129 3267 _CS_POSIX_V6_LPBIG_OFFBIG_LIBS = 1130 3268 _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS = 1131 3269 3270 _CS_POSIX_V7_ILP32_OFF32_CFLAGS = 1132 3271 _CS_POSIX_V7_ILP32_OFF32_LDFLAGS = 1133 3272 _CS_POSIX_V7_ILP32_OFF32_LIBS = 1134 3273 _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS = 1135 3274 _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS = 1136 3275 _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS = 1137 3276 _CS_POSIX_V7_ILP32_OFFBIG_LIBS = 1138 3277 _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS = 1139 3278 _CS_POSIX_V7_LP64_OFF64_CFLAGS = 1140 3279 _CS_POSIX_V7_LP64_OFF64_LDFLAGS = 1141 3280 _CS_POSIX_V7_LP64_OFF64_LIBS = 1142 3281 _CS_POSIX_V7_LP64_OFF64_LINTFLAGS = 1143 3282 _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS = 1144 3283 _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS = 1145 3284 _CS_POSIX_V7_LPBIG_OFFBIG_LIBS = 1146 3285 _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS = 1147 3286 3287 _CS_V6_ENV = 1148 3288 _CS_V7_ENV = 1149 3289 ) 3290 3291 // Values for the argument to `sysconf'. 3292 const ( /* confname.h:71:1: */ 3293 _SC_ARG_MAX = 0 3294 _SC_CHILD_MAX = 1 3295 _SC_CLK_TCK = 2 3296 _SC_NGROUPS_MAX = 3 3297 _SC_OPEN_MAX = 4 3298 _SC_STREAM_MAX = 5 3299 _SC_TZNAME_MAX = 6 3300 _SC_JOB_CONTROL = 7 3301 _SC_SAVED_IDS = 8 3302 _SC_REALTIME_SIGNALS = 9 3303 _SC_PRIORITY_SCHEDULING = 10 3304 _SC_TIMERS = 11 3305 _SC_ASYNCHRONOUS_IO = 12 3306 _SC_PRIORITIZED_IO = 13 3307 _SC_SYNCHRONIZED_IO = 14 3308 _SC_FSYNC = 15 3309 _SC_MAPPED_FILES = 16 3310 _SC_MEMLOCK = 17 3311 _SC_MEMLOCK_RANGE = 18 3312 _SC_MEMORY_PROTECTION = 19 3313 _SC_MESSAGE_PASSING = 20 3314 _SC_SEMAPHORES = 21 3315 _SC_SHARED_MEMORY_OBJECTS = 22 3316 _SC_AIO_LISTIO_MAX = 23 3317 _SC_AIO_MAX = 24 3318 _SC_AIO_PRIO_DELTA_MAX = 25 3319 _SC_DELAYTIMER_MAX = 26 3320 _SC_MQ_OPEN_MAX = 27 3321 _SC_MQ_PRIO_MAX = 28 3322 _SC_VERSION = 29 3323 _SC_PAGESIZE = 30 3324 _SC_RTSIG_MAX = 31 3325 _SC_SEM_NSEMS_MAX = 32 3326 _SC_SEM_VALUE_MAX = 33 3327 _SC_SIGQUEUE_MAX = 34 3328 _SC_TIMER_MAX = 35 3329 3330 // Values for the argument to `sysconf' 3331 // corresponding to _POSIX2_* symbols. 3332 _SC_BC_BASE_MAX = 36 3333 _SC_BC_DIM_MAX = 37 3334 _SC_BC_SCALE_MAX = 38 3335 _SC_BC_STRING_MAX = 39 3336 _SC_COLL_WEIGHTS_MAX = 40 3337 _SC_EQUIV_CLASS_MAX = 41 3338 _SC_EXPR_NEST_MAX = 42 3339 _SC_LINE_MAX = 43 3340 _SC_RE_DUP_MAX = 44 3341 _SC_CHARCLASS_NAME_MAX = 45 3342 3343 _SC_2_VERSION = 46 3344 _SC_2_C_BIND = 47 3345 _SC_2_C_DEV = 48 3346 _SC_2_FORT_DEV = 49 3347 _SC_2_FORT_RUN = 50 3348 _SC_2_SW_DEV = 51 3349 _SC_2_LOCALEDEF = 52 3350 3351 _SC_PII = 53 3352 _SC_PII_XTI = 54 3353 _SC_PII_SOCKET = 55 3354 _SC_PII_INTERNET = 56 3355 _SC_PII_OSI = 57 3356 _SC_POLL = 58 3357 _SC_SELECT = 59 3358 _SC_UIO_MAXIOV = 60 3359 _SC_IOV_MAX = 60 3360 _SC_PII_INTERNET_STREAM = 61 3361 _SC_PII_INTERNET_DGRAM = 62 3362 _SC_PII_OSI_COTS = 63 3363 _SC_PII_OSI_CLTS = 64 3364 _SC_PII_OSI_M = 65 3365 _SC_T_IOV_MAX = 66 3366 3367 // Values according to POSIX 1003.1c (POSIX threads). 3368 _SC_THREADS = 67 3369 _SC_THREAD_SAFE_FUNCTIONS = 68 3370 _SC_GETGR_R_SIZE_MAX = 69 3371 _SC_GETPW_R_SIZE_MAX = 70 3372 _SC_LOGIN_NAME_MAX = 71 3373 _SC_TTY_NAME_MAX = 72 3374 _SC_THREAD_DESTRUCTOR_ITERATIONS = 73 3375 _SC_THREAD_KEYS_MAX = 74 3376 _SC_THREAD_STACK_MIN = 75 3377 _SC_THREAD_THREADS_MAX = 76 3378 _SC_THREAD_ATTR_STACKADDR = 77 3379 _SC_THREAD_ATTR_STACKSIZE = 78 3380 _SC_THREAD_PRIORITY_SCHEDULING = 79 3381 _SC_THREAD_PRIO_INHERIT = 80 3382 _SC_THREAD_PRIO_PROTECT = 81 3383 _SC_THREAD_PROCESS_SHARED = 82 3384 3385 _SC_NPROCESSORS_CONF = 83 3386 _SC_NPROCESSORS_ONLN = 84 3387 _SC_PHYS_PAGES = 85 3388 _SC_AVPHYS_PAGES = 86 3389 _SC_ATEXIT_MAX = 87 3390 _SC_PASS_MAX = 88 3391 3392 _SC_XOPEN_VERSION = 89 3393 _SC_XOPEN_XCU_VERSION = 90 3394 _SC_XOPEN_UNIX = 91 3395 _SC_XOPEN_CRYPT = 92 3396 _SC_XOPEN_ENH_I18N = 93 3397 _SC_XOPEN_SHM = 94 3398 3399 _SC_2_CHAR_TERM = 95 3400 _SC_2_C_VERSION = 96 3401 _SC_2_UPE = 97 3402 3403 _SC_XOPEN_XPG2 = 98 3404 _SC_XOPEN_XPG3 = 99 3405 _SC_XOPEN_XPG4 = 100 3406 3407 _SC_CHAR_BIT = 101 3408 _SC_CHAR_MAX = 102 3409 _SC_CHAR_MIN = 103 3410 _SC_INT_MAX = 104 3411 _SC_INT_MIN = 105 3412 _SC_LONG_BIT = 106 3413 _SC_WORD_BIT = 107 3414 _SC_MB_LEN_MAX = 108 3415 _SC_NZERO = 109 3416 _SC_SSIZE_MAX = 110 3417 _SC_SCHAR_MAX = 111 3418 _SC_SCHAR_MIN = 112 3419 _SC_SHRT_MAX = 113 3420 _SC_SHRT_MIN = 114 3421 _SC_UCHAR_MAX = 115 3422 _SC_UINT_MAX = 116 3423 _SC_ULONG_MAX = 117 3424 _SC_USHRT_MAX = 118 3425 3426 _SC_NL_ARGMAX = 119 3427 _SC_NL_LANGMAX = 120 3428 _SC_NL_MSGMAX = 121 3429 _SC_NL_NMAX = 122 3430 _SC_NL_SETMAX = 123 3431 _SC_NL_TEXTMAX = 124 3432 3433 _SC_XBS5_ILP32_OFF32 = 125 3434 _SC_XBS5_ILP32_OFFBIG = 126 3435 _SC_XBS5_LP64_OFF64 = 127 3436 _SC_XBS5_LPBIG_OFFBIG = 128 3437 3438 _SC_XOPEN_LEGACY = 129 3439 _SC_XOPEN_REALTIME = 130 3440 _SC_XOPEN_REALTIME_THREADS = 131 3441 3442 _SC_ADVISORY_INFO = 132 3443 _SC_BARRIERS = 133 3444 _SC_BASE = 134 3445 _SC_C_LANG_SUPPORT = 135 3446 _SC_C_LANG_SUPPORT_R = 136 3447 _SC_CLOCK_SELECTION = 137 3448 _SC_CPUTIME = 138 3449 _SC_THREAD_CPUTIME = 139 3450 _SC_DEVICE_IO = 140 3451 _SC_DEVICE_SPECIFIC = 141 3452 _SC_DEVICE_SPECIFIC_R = 142 3453 _SC_FD_MGMT = 143 3454 _SC_FIFO = 144 3455 _SC_PIPE = 145 3456 _SC_FILE_ATTRIBUTES = 146 3457 _SC_FILE_LOCKING = 147 3458 _SC_FILE_SYSTEM = 148 3459 _SC_MONOTONIC_CLOCK = 149 3460 _SC_MULTI_PROCESS = 150 3461 _SC_SINGLE_PROCESS = 151 3462 _SC_NETWORKING = 152 3463 _SC_READER_WRITER_LOCKS = 153 3464 _SC_SPIN_LOCKS = 154 3465 _SC_REGEXP = 155 3466 _SC_REGEX_VERSION = 156 3467 _SC_SHELL = 157 3468 _SC_SIGNALS = 158 3469 _SC_SPAWN = 159 3470 _SC_SPORADIC_SERVER = 160 3471 _SC_THREAD_SPORADIC_SERVER = 161 3472 _SC_SYSTEM_DATABASE = 162 3473 _SC_SYSTEM_DATABASE_R = 163 3474 _SC_TIMEOUTS = 164 3475 _SC_TYPED_MEMORY_OBJECTS = 165 3476 _SC_USER_GROUPS = 166 3477 _SC_USER_GROUPS_R = 167 3478 _SC_2_PBS = 168 3479 _SC_2_PBS_ACCOUNTING = 169 3480 _SC_2_PBS_LOCATE = 170 3481 _SC_2_PBS_MESSAGE = 171 3482 _SC_2_PBS_TRACK = 172 3483 _SC_SYMLOOP_MAX = 173 3484 _SC_STREAMS = 174 3485 _SC_2_PBS_CHECKPOINT = 175 3486 3487 _SC_V6_ILP32_OFF32 = 176 3488 _SC_V6_ILP32_OFFBIG = 177 3489 _SC_V6_LP64_OFF64 = 178 3490 _SC_V6_LPBIG_OFFBIG = 179 3491 3492 _SC_HOST_NAME_MAX = 180 3493 _SC_TRACE = 181 3494 _SC_TRACE_EVENT_FILTER = 182 3495 _SC_TRACE_INHERIT = 183 3496 _SC_TRACE_LOG = 184 3497 3498 _SC_LEVEL1_ICACHE_SIZE = 185 3499 _SC_LEVEL1_ICACHE_ASSOC = 186 3500 _SC_LEVEL1_ICACHE_LINESIZE = 187 3501 _SC_LEVEL1_DCACHE_SIZE = 188 3502 _SC_LEVEL1_DCACHE_ASSOC = 189 3503 _SC_LEVEL1_DCACHE_LINESIZE = 190 3504 _SC_LEVEL2_CACHE_SIZE = 191 3505 _SC_LEVEL2_CACHE_ASSOC = 192 3506 _SC_LEVEL2_CACHE_LINESIZE = 193 3507 _SC_LEVEL3_CACHE_SIZE = 194 3508 _SC_LEVEL3_CACHE_ASSOC = 195 3509 _SC_LEVEL3_CACHE_LINESIZE = 196 3510 _SC_LEVEL4_CACHE_SIZE = 197 3511 _SC_LEVEL4_CACHE_ASSOC = 198 3512 _SC_LEVEL4_CACHE_LINESIZE = 199 3513 // Leave room here, maybe we need a few more cache levels some day. 3514 3515 _SC_IPV6 = 235 3516 _SC_RAW_SOCKETS = 236 3517 3518 _SC_V7_ILP32_OFF32 = 237 3519 _SC_V7_ILP32_OFFBIG = 238 3520 _SC_V7_LP64_OFF64 = 239 3521 _SC_V7_LPBIG_OFFBIG = 240 3522 3523 _SC_SS_REPL_MAX = 241 3524 3525 _SC_TRACE_EVENT_NAME_MAX = 242 3526 _SC_TRACE_NAME_MAX = 243 3527 _SC_TRACE_SYS_MAX = 244 3528 _SC_TRACE_USER_EVENT_MAX = 245 3529 3530 _SC_XOPEN_STREAMS = 246 3531 3532 _SC_THREAD_ROBUST_PRIO_INHERIT = 247 3533 _SC_THREAD_ROBUST_PRIO_PROTECT = 248 3534 ) 3535 3536 // open/fcntl. 3537 3538 // open file description locks. 3539 // 3540 // Usually record locks held by a process are released on *any* close and are 3541 // not inherited across a fork. 3542 // 3543 // These cmd values will set locks that conflict with process-associated record 3544 // locks, but are "owned" by the opened file description, not the process. 3545 // This means that they are inherited across fork or clone with CLONE_FILES 3546 // like BSD (flock) locks, and they are only released automatically when the 3547 // last reference to the the file description against which they were acquired 3548 // is put. 3549 3550 // For now, Linux has no separate synchronicity options for read 3551 // operations. We define O_RSYNC therefore as the same as O_SYNC 3552 // since this is a superset. 3553 3554 // Values for the second argument to `fcntl'. 3555 3556 // Set / get write life time hints. 3557 3558 // For F_[GET|SET]FD. 3559 3560 // For posix fcntl() and `l_type' field of a `struct flock' for lockf(). 3561 3562 // For old implementation of BSD flock. 3563 3564 // Operations for BSD flock, also used by the kernel implementation. 3565 3566 // Types of directory notifications that may be requested with F_NOTIFY. 3567 3568 // Owner types. 3569 const ( /* fcntl-linux.h:265:1: */ 3570 F_OWNER_TID = 0 // Kernel thread. 3571 F_OWNER_PID = 1 // Process. 3572 F_OWNER_PGRP = 2 // Process group. 3573 F_OWNER_GID = 2 3574 ) 3575 3576 // Whose usage statistics do you want? 3577 const ( /* resource.h:158:1: */ 3578 // The calling process. 3579 RUSAGE_SELF = 0 3580 3581 // All of its terminated child processes. 3582 RUSAGE_CHILDREN = -1 3583 ) 3584 3585 // Whose usage statistics do you want? 3586 const ( /* resource.h:158:1: */ 3587 // The calling thread. 3588 RUSAGE_THREAD = 1 3589 ) 3590 3591 // Priority limits. 3592 3593 // The type of the WHICH argument to `getpriority' and `setpriority', 3594 // indicating what flavor of entity the WHO argument specifies. 3595 const ( /* resource.h:187:1: */ 3596 PRIO_PROCESS = 0 // WHO is a process ID. 3597 PRIO_PGRP = 1 // WHO is a process group ID. 3598 PRIO_USER = 2 3599 ) 3600 3601 // Convenience macros for operations on timevals. 3602 // NOTE: `timercmp' does not work for >= or <=. 3603 3604 // Copyright (C) 1992-2018 Free Software Foundation, Inc. 3605 // This file is part of the GNU C Library. 3606 // 3607 // The GNU C Library is free software; you can redistribute it and/or 3608 // modify it under the terms of the GNU Lesser General Public 3609 // License as published by the Free Software Foundation; either 3610 // version 2.1 of the License, or (at your option) any later version. 3611 // 3612 // The GNU C Library is distributed in the hope that it will be useful, 3613 // but WITHOUT ANY WARRANTY; without even the implied warranty of 3614 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 3615 // Lesser General Public License for more details. 3616 // 3617 // You should have received a copy of the GNU Lesser General Public 3618 // License along with the GNU C Library; if not, see 3619 // <http://www.gnu.org/licenses/>. 3620 3621 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 3622 // This file is part of the GNU C Library. 3623 // 3624 // The GNU C Library is free software; you can redistribute it and/or 3625 // modify it under the terms of the GNU Lesser General Public 3626 // License as published by the Free Software Foundation; either 3627 // version 2.1 of the License, or (at your option) any later version. 3628 // 3629 // The GNU C Library is distributed in the hope that it will be useful, 3630 // but WITHOUT ANY WARRANTY; without even the implied warranty of 3631 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 3632 // Lesser General Public License for more details. 3633 // 3634 // You should have received a copy of the GNU Lesser General Public 3635 // License along with the GNU C Library; if not, see 3636 // <http://www.gnu.org/licenses/>. 3637 3638 // Get the system-dependent definitions of structures and bit values. 3639 // Bit values & structures for resource limits. Linux version. 3640 // Copyright (C) 1994-2018 Free Software Foundation, Inc. 3641 // This file is part of the GNU C Library. 3642 // 3643 // The GNU C Library is free software; you can redistribute it and/or 3644 // modify it under the terms of the GNU Lesser General Public 3645 // License as published by the Free Software Foundation; either 3646 // version 2.1 of the License, or (at your option) any later version. 3647 // 3648 // The GNU C Library is distributed in the hope that it will be useful, 3649 // but WITHOUT ANY WARRANTY; without even the implied warranty of 3650 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 3651 // Lesser General Public License for more details. 3652 // 3653 // You should have received a copy of the GNU Lesser General Public 3654 // License along with the GNU C Library; if not, see 3655 // <http://www.gnu.org/licenses/>. 3656 3657 // bits/types.h -- definitions of __*_t types underlying *_t types. 3658 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 3659 // This file is part of the GNU C Library. 3660 // 3661 // The GNU C Library is free software; you can redistribute it and/or 3662 // modify it under the terms of the GNU Lesser General Public 3663 // License as published by the Free Software Foundation; either 3664 // version 2.1 of the License, or (at your option) any later version. 3665 // 3666 // The GNU C Library is distributed in the hope that it will be useful, 3667 // but WITHOUT ANY WARRANTY; without even the implied warranty of 3668 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 3669 // Lesser General Public License for more details. 3670 // 3671 // You should have received a copy of the GNU Lesser General Public 3672 // License along with the GNU C Library; if not, see 3673 // <http://www.gnu.org/licenses/>. 3674 3675 // Never include this file directly; use <sys/types.h> instead. 3676 3677 // Transmute defines to enumerations. The macro re-definitions are 3678 // necessary because some programs want to test for operating system 3679 // features with #ifdef RUSAGE_SELF. In ISO C the reflexive 3680 // definition is a no-op. 3681 3682 // Kinds of resource limit. 3683 const ( /* resource.h:31:1: */ 3684 // Per-process CPU limit, in seconds. 3685 RLIMIT_CPU = 0 3686 3687 // Largest file that can be created, in bytes. 3688 RLIMIT_FSIZE = 1 3689 3690 // Maximum size of data segment, in bytes. 3691 RLIMIT_DATA = 2 3692 3693 // Maximum size of stack segment, in bytes. 3694 RLIMIT_STACK = 3 3695 3696 // Largest core file that can be created, in bytes. 3697 RLIMIT_CORE = 4 3698 3699 // Largest resident set size, in bytes. 3700 // This affects swapping; processes that are exceeding their 3701 // resident set size will be more likely to have physical memory 3702 // taken from them. 3703 __RLIMIT_RSS = 5 3704 3705 // Number of open files. 3706 RLIMIT_NOFILE = 7 3707 __RLIMIT_OFILE = 7 // BSD name for same. 3708 3709 // Address space limit. 3710 RLIMIT_AS = 9 3711 3712 // Number of processes. 3713 __RLIMIT_NPROC = 6 3714 3715 // Locked-in-memory address space. 3716 __RLIMIT_MEMLOCK = 8 3717 3718 // Maximum number of file locks. 3719 __RLIMIT_LOCKS = 10 3720 3721 // Maximum number of pending signals. 3722 __RLIMIT_SIGPENDING = 11 3723 3724 // Maximum bytes in POSIX message queues. 3725 __RLIMIT_MSGQUEUE = 12 3726 3727 // Maximum nice priority allowed to raise to. 3728 // Nice levels 19 .. -20 correspond to 0 .. 39 3729 // values of this resource limit. 3730 __RLIMIT_NICE = 13 3731 3732 // Maximum realtime priority allowed for non-priviledged 3733 // processes. 3734 __RLIMIT_RTPRIO = 14 3735 3736 // Maximum CPU time in µs that a process scheduled under a real-time 3737 // scheduling policy may consume without making a blocking system 3738 // call before being forcibly descheduled. 3739 __RLIMIT_RTTIME = 15 3740 3741 __RLIMIT_NLIMITS = 16 3742 __RLIM_NLIMITS = 16 3743 ) 3744 3745 // POSIX names to access some of the members. 3746 3747 // sigevent constants. Linux version. 3748 // Copyright (C) 1997-2018 Free Software Foundation, Inc. 3749 // This file is part of the GNU C Library. 3750 // 3751 // The GNU C Library is free software; you can redistribute it and/or 3752 // modify it under the terms of the GNU Lesser General Public 3753 // License as published by the Free Software Foundation; either 3754 // version 2.1 of the License, or (at your option) any later version. 3755 // 3756 // The GNU C Library is distributed in the hope that it will be useful, 3757 // but WITHOUT ANY WARRANTY; without even the implied warranty of 3758 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 3759 // Lesser General Public License for more details. 3760 // 3761 // You should have received a copy of the GNU Lesser General Public 3762 // License along with the GNU C Library; if not, see 3763 // <http://www.gnu.org/licenses/>. 3764 3765 // `sigev_notify' values. 3766 const ( /* sigevent-consts.h:27:1: */ 3767 SIGEV_SIGNAL = 0 // Notify via signal. 3768 SIGEV_NONE = 1 // Other notification: meaningless. 3769 SIGEV_THREAD = 2 // Deliver via thread creation. 3770 3771 SIGEV_THREAD_ID = 4 3772 ) 3773 3774 // `si_code' values for SIGSEGV signal. 3775 const ( /* siginfo-consts.h:110:1: */ 3776 SEGV_MAPERR = 1 // Address not mapped to object. 3777 SEGV_ACCERR = 2 // Invalid permissions for mapped object. 3778 SEGV_BNDERR = 3 // Bounds checking failure. 3779 SEGV_PKUERR = 4 3780 ) 3781 3782 // `si_code' values for SIGBUS signal. 3783 const ( /* siginfo-consts.h:123:1: */ 3784 BUS_ADRALN = 1 // Invalid address alignment. 3785 BUS_ADRERR = 2 // Non-existant physical address. 3786 BUS_OBJERR = 3 // Object specific hardware error. 3787 BUS_MCEERR_AR = 4 // Hardware memory error: action required. 3788 BUS_MCEERR_AO = 5 3789 ) 3790 3791 // `si_code' values for SIGCHLD signal. 3792 const ( /* siginfo-consts.h:151:1: */ 3793 CLD_EXITED = 1 // Child has exited. 3794 CLD_KILLED = 2 // Child was killed. 3795 CLD_DUMPED = 3 // Child terminated abnormally. 3796 CLD_TRAPPED = 4 // Traced child has trapped. 3797 CLD_STOPPED = 5 // Child has stopped. 3798 CLD_CONTINUED = 6 3799 ) 3800 3801 // `si_code' values for SIGPOLL signal. 3802 const ( /* siginfo-consts.h:168:1: */ 3803 POLL_IN = 1 // Data input available. 3804 POLL_OUT = 2 // Output buffers available. 3805 POLL_MSG = 3 // Input message available. 3806 POLL_ERR = 4 // I/O error. 3807 POLL_PRI = 5 // High priority input available. 3808 POLL_HUP = 6 3809 ) 3810 3811 // X/Open requires some more fields with fixed names. 3812 3813 // siginfo constants. Linux version. 3814 // Copyright (C) 1997-2018 Free Software Foundation, Inc. 3815 // This file is part of the GNU C Library. 3816 // 3817 // The GNU C Library is free software; you can redistribute it and/or 3818 // modify it under the terms of the GNU Lesser General Public 3819 // License as published by the Free Software Foundation; either 3820 // version 2.1 of the License, or (at your option) any later version. 3821 // 3822 // The GNU C Library is distributed in the hope that it will be useful, 3823 // but WITHOUT ANY WARRANTY; without even the implied warranty of 3824 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 3825 // Lesser General Public License for more details. 3826 // 3827 // You should have received a copy of the GNU Lesser General Public 3828 // License along with the GNU C Library; if not, see 3829 // <http://www.gnu.org/licenses/>. 3830 3831 // Most of these constants are uniform across all architectures, but there 3832 // is one exception. 3833 // Architecture-specific adjustments to siginfo_t. 3834 3835 // Values for `si_code'. Positive values are reserved for kernel-generated 3836 // signals. 3837 const ( /* siginfo-consts.h:35:1: */ 3838 SI_ASYNCNL = -60 // Sent by asynch name lookup completion. 3839 SI_TKILL = -6 // Sent by tkill. 3840 SI_SIGIO = -5 // Sent by queued SIGIO. 3841 SI_ASYNCIO = -4 // Sent by AIO completion. 3842 SI_MESGQ = -3 // Sent by real time mesq state change. 3843 SI_TIMER = -2 // Sent by timer expiration. 3844 SI_QUEUE = -1 // Sent by sigqueue. 3845 SI_USER = 0 // Sent by kill, sigsend. 3846 SI_KERNEL = 128 3847 ) 3848 3849 // `si_code' values for SIGILL signal. 3850 const ( /* siginfo-consts.h:68:1: */ 3851 ILL_ILLOPC = 1 // Illegal opcode. 3852 ILL_ILLOPN = 2 // Illegal operand. 3853 ILL_ILLADR = 3 // Illegal addressing mode. 3854 ILL_ILLTRP = 4 // Illegal trap. 3855 ILL_PRVOPC = 5 // Privileged opcode. 3856 ILL_PRVREG = 6 // Privileged register. 3857 ILL_COPROC = 7 // Coprocessor error. 3858 ILL_BADSTK = 8 3859 ) 3860 3861 // `si_code' values for SIGFPE signal. 3862 const ( /* siginfo-consts.h:89:1: */ 3863 FPE_INTDIV = 1 // Integer divide by zero. 3864 FPE_INTOVF = 2 // Integer overflow. 3865 FPE_FLTDIV = 3 // Floating point divide by zero. 3866 FPE_FLTOVF = 4 // Floating point overflow. 3867 FPE_FLTUND = 5 // Floating point underflow. 3868 FPE_FLTRES = 6 // Floating point inexact result. 3869 FPE_FLTINV = 7 // Floating point invalid operation. 3870 FPE_FLTSUB = 8 3871 ) 3872 3873 // sigstack, sigaltstack definitions. 3874 // Copyright (C) 1998-2018 Free Software Foundation, Inc. 3875 // This file is part of the GNU C Library. 3876 // 3877 // The GNU C Library is free software; you can redistribute it and/or 3878 // modify it under the terms of the GNU Lesser General Public 3879 // License as published by the Free Software Foundation; either 3880 // version 2.1 of the License, or (at your option) any later version. 3881 // 3882 // The GNU C Library is distributed in the hope that it will be useful, 3883 // but WITHOUT ANY WARRANTY; without even the implied warranty of 3884 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 3885 // Lesser General Public License for more details. 3886 // 3887 // You should have received a copy of the GNU Lesser General Public 3888 // License along with the GNU C Library; if not, see 3889 // <http://www.gnu.org/licenses/>. 3890 3891 // Minimum stack size for a signal handler. 3892 3893 // System default stack size. 3894 3895 // ss_flags values for stack_t. Linux version. 3896 // Copyright (C) 1998-2018 Free Software Foundation, Inc. 3897 // This file is part of the GNU C Library. 3898 // 3899 // The GNU C Library is free software; you can redistribute it and/or 3900 // modify it under the terms of the GNU Lesser General Public 3901 // License as published by the Free Software Foundation; either 3902 // version 2.1 of the License, or (at your option) any later version. 3903 // 3904 // The GNU C Library is distributed in the hope that it will be useful, 3905 // but WITHOUT ANY WARRANTY; without even the implied warranty of 3906 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 3907 // Lesser General Public License for more details. 3908 // 3909 // You should have received a copy of the GNU Lesser General Public 3910 // License along with the GNU C Library; if not, see 3911 // <http://www.gnu.org/licenses/>. 3912 3913 // Possible values for `ss_flags'. 3914 const ( /* ss_flags.h:27:1: */ 3915 SS_ONSTACK = 1 3916 SS_DISABLE = 2 3917 ) 3918 3919 // In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. 3920 // are already defined. 3921 // BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. 3922 // NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here. 3923 3924 // A null pointer constant. 3925 3926 // XPG requires a few symbols from <sys/wait.h> being defined. 3927 // Definitions of flag bits for `waitpid' et al. 3928 // Copyright (C) 1992-2018 Free Software Foundation, Inc. 3929 // This file is part of the GNU C Library. 3930 // 3931 // The GNU C Library is free software; you can redistribute it and/or 3932 // modify it under the terms of the GNU Lesser General Public 3933 // License as published by the Free Software Foundation; either 3934 // version 2.1 of the License, or (at your option) any later version. 3935 // 3936 // The GNU C Library is distributed in the hope that it will be useful, 3937 // but WITHOUT ANY WARRANTY; without even the implied warranty of 3938 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 3939 // Lesser General Public License for more details. 3940 // 3941 // You should have received a copy of the GNU Lesser General Public 3942 // License along with the GNU C Library; if not, see 3943 // <http://www.gnu.org/licenses/>. 3944 3945 // Bits in the third argument to `waitpid'. 3946 3947 // Bits in the fourth argument to `waitid'. 3948 3949 // The following values are used by the `waitid' function. 3950 3951 // The Linux kernel defines these bare, rather than an enum, 3952 // which causes a conflict if the include order is reversed. 3953 3954 const ( /* waitflags.h:52:1: */ 3955 P_ALL = 0 // Wait for any child. 3956 P_PID = 1 // Wait for specified process. 3957 P_PGID = 2 3958 ) 3959 3960 // Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface. 3961 // Copyright (C) 1996-2018 Free Software Foundation, Inc. 3962 // This file is part of the GNU C Library. 3963 // 3964 // The GNU C Library is free software; you can redistribute it and/or 3965 // modify it under the terms of the GNU Lesser General Public 3966 // License as published by the Free Software Foundation; either 3967 // version 2.1 of the License, or (at your option) any later version. 3968 // 3969 // The GNU C Library is distributed in the hope that it will be useful, 3970 // but WITHOUT ANY WARRANTY; without even the implied warranty of 3971 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 3972 // Lesser General Public License for more details. 3973 // 3974 // You should have received a copy of the GNU Lesser General Public 3975 // License along with the GNU C Library; if not, see 3976 // <http://www.gnu.org/licenses/>. 3977 3978 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 3979 // This file is part of the GNU C Library. 3980 // 3981 // The GNU C Library is free software; you can redistribute it and/or 3982 // modify it under the terms of the GNU Lesser General Public 3983 // License as published by the Free Software Foundation; either 3984 // version 2.1 of the License, or (at your option) any later version. 3985 // 3986 // The GNU C Library is distributed in the hope that it will be useful, 3987 // but WITHOUT ANY WARRANTY; without even the implied warranty of 3988 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 3989 // Lesser General Public License for more details. 3990 // 3991 // You should have received a copy of the GNU Lesser General Public 3992 // License along with the GNU C Library; if not, see 3993 // <http://www.gnu.org/licenses/>. 3994 3995 // ISO C99 Standard 7.4: Character handling <ctype.h> 3996 3997 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 3998 // This file is part of the GNU C Library. 3999 // 4000 // The GNU C Library is free software; you can redistribute it and/or 4001 // modify it under the terms of the GNU Lesser General Public 4002 // License as published by the Free Software Foundation; either 4003 // version 2.1 of the License, or (at your option) any later version. 4004 // 4005 // The GNU C Library is distributed in the hope that it will be useful, 4006 // but WITHOUT ANY WARRANTY; without even the implied warranty of 4007 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 4008 // Lesser General Public License for more details. 4009 // 4010 // You should have received a copy of the GNU Lesser General Public 4011 // License along with the GNU C Library; if not, see 4012 // <http://www.gnu.org/licenses/>. 4013 4014 // bits/types.h -- definitions of __*_t types underlying *_t types. 4015 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 4016 // This file is part of the GNU C Library. 4017 // 4018 // The GNU C Library is free software; you can redistribute it and/or 4019 // modify it under the terms of the GNU Lesser General Public 4020 // License as published by the Free Software Foundation; either 4021 // version 2.1 of the License, or (at your option) any later version. 4022 // 4023 // The GNU C Library is distributed in the hope that it will be useful, 4024 // but WITHOUT ANY WARRANTY; without even the implied warranty of 4025 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 4026 // Lesser General Public License for more details. 4027 // 4028 // You should have received a copy of the GNU Lesser General Public 4029 // License along with the GNU C Library; if not, see 4030 // <http://www.gnu.org/licenses/>. 4031 4032 // Never include this file directly; use <sys/types.h> instead. 4033 4034 // These are all the characteristics of characters. 4035 // If there get to be more than 16 distinct characteristics, 4036 // many things must be changed that use `unsigned short int's. 4037 // 4038 // The characteristics are stored always in network byte order (big 4039 // endian). We define the bit value interpretations here dependent on the 4040 // machine's byte order. 4041 4042 // Copyright (C) 1992-2018 Free Software Foundation, Inc. 4043 // This file is part of the GNU C Library. 4044 // 4045 // The GNU C Library is free software; you can redistribute it and/or 4046 // modify it under the terms of the GNU Lesser General Public 4047 // License as published by the Free Software Foundation; either 4048 // version 2.1 of the License, or (at your option) any later version. 4049 // 4050 // The GNU C Library is distributed in the hope that it will be useful, 4051 // but WITHOUT ANY WARRANTY; without even the implied warranty of 4052 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 4053 // Lesser General Public License for more details. 4054 // 4055 // You should have received a copy of the GNU Lesser General Public 4056 // License along with the GNU C Library; if not, see 4057 // <http://www.gnu.org/licenses/>. 4058 4059 const ( /* ctype.h:46:1: */ 4060 _ISupper = 1 // UPPERCASE. 4061 _ISlower = 2 // lowercase. 4062 _ISalpha = 4 // Alphabetic. 4063 _ISdigit = 8 // Numeric. 4064 _ISxdigit = 16 // Hexadecimal numeric. 4065 _ISspace = 32 // Whitespace. 4066 _ISprint = 64 // Printing. 4067 _ISgraph = 128 // Graphical. 4068 _ISblank = 256 // Blank (usually SPC and TAB). 4069 _IScntrl = 512 // Control character. 4070 _ISpunct = 1024 // Punctuation. 4071 _ISalnum = 2048 4072 ) 4073 4074 // Inform libc code that these two types are effectively identical. 4075 4076 // These macros extract size information from a `struct dirent *'. 4077 // They may evaluate their argument multiple times, so it must not 4078 // have side effects. Each of these may involve a relatively costly 4079 // call to `strlen' on some systems, so these values should be cached. 4080 // 4081 // _D_EXACT_NAMLEN (DP) returns the length of DP->d_name, not including 4082 // its terminating null character. 4083 // 4084 // _D_ALLOC_NAMLEN (DP) returns a size at least (_D_EXACT_NAMLEN (DP) + 1); 4085 // that is, the allocation size needed to hold the DP->d_name string. 4086 // Use this macro when you don't need the exact length, just an upper bound. 4087 // This macro is less likely to require calling `strlen' than _D_EXACT_NAMLEN. 4088 // 4089 4090 // File types for `d_type'. 4091 const ( /* dirent.h:97:1: */ 4092 DT_UNKNOWN = 0 4093 DT_FIFO = 1 4094 DT_CHR = 2 4095 DT_DIR = 4 4096 DT_BLK = 6 4097 DT_REG = 8 4098 DT_LNK = 10 4099 DT_SOCK = 12 4100 DT_WHT = 14 4101 ) 4102 4103 // Read-write lock types. 4104 const ( /* pthread.h:115:1: */ 4105 PTHREAD_RWLOCK_PREFER_READER_NP = 0 4106 PTHREAD_RWLOCK_PREFER_WRITER_NP = 1 4107 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP = 2 4108 PTHREAD_RWLOCK_DEFAULT_NP = 0 4109 ) 4110 4111 // Define __PTHREAD_RWLOCK_INT_FLAGS_SHARED to 1 if pthread_rwlock_t 4112 // has the shared field. All 64-bit architectures have the shared field 4113 // in pthread_rwlock_t. 4114 4115 // Read-write lock initializers. 4116 4117 // Scheduler inheritance. 4118 const ( /* pthread.h:156:1: */ 4119 PTHREAD_INHERIT_SCHED = 0 4120 PTHREAD_EXPLICIT_SCHED = 1 4121 ) 4122 4123 // Scope handling. 4124 const ( /* pthread.h:166:1: */ 4125 PTHREAD_SCOPE_SYSTEM = 0 4126 PTHREAD_SCOPE_PROCESS = 1 4127 ) 4128 4129 // Process shared or private flag. 4130 const ( /* pthread.h:176:1: */ 4131 PTHREAD_PROCESS_PRIVATE = 0 4132 PTHREAD_PROCESS_SHARED = 1 4133 ) 4134 4135 // Cancellation 4136 const ( /* pthread.h:200:1: */ 4137 PTHREAD_CANCEL_ENABLE = 0 4138 PTHREAD_CANCEL_DISABLE = 1 4139 ) 4140 const ( /* pthread.h:207:1: */ 4141 PTHREAD_CANCEL_DEFERRED = 0 4142 PTHREAD_CANCEL_ASYNCHRONOUS = 1 4143 ) 4144 4145 // Determine the wordsize from the preprocessor defines. 4146 4147 // NB: Include guard matches what <linux/time.h> uses. 4148 4149 // Detach state. 4150 const ( /* pthread.h:33:1: */ 4151 PTHREAD_CREATE_JOINABLE = 0 4152 PTHREAD_CREATE_DETACHED = 1 4153 ) 4154 4155 // Mutex types. 4156 const ( /* pthread.h:43:1: */ 4157 PTHREAD_MUTEX_TIMED_NP = 0 4158 PTHREAD_MUTEX_RECURSIVE_NP = 1 4159 PTHREAD_MUTEX_ERRORCHECK_NP = 2 4160 PTHREAD_MUTEX_ADAPTIVE_NP = 3 4161 PTHREAD_MUTEX_NORMAL = 0 4162 PTHREAD_MUTEX_RECURSIVE = 1 4163 PTHREAD_MUTEX_ERRORCHECK = 2 4164 PTHREAD_MUTEX_DEFAULT = 0 4165 PTHREAD_MUTEX_FAST_NP = 0 4166 ) 4167 4168 // Robust mutex or not flags. 4169 const ( /* pthread.h:65:1: */ 4170 PTHREAD_MUTEX_STALLED = 0 4171 PTHREAD_MUTEX_STALLED_NP = 0 4172 PTHREAD_MUTEX_ROBUST = 1 4173 PTHREAD_MUTEX_ROBUST_NP = 1 4174 ) 4175 4176 // Mutex protocols. 4177 const ( /* pthread.h:77:1: */ 4178 PTHREAD_PRIO_NONE = 0 4179 PTHREAD_PRIO_INHERIT = 1 4180 PTHREAD_PRIO_PROTECT = 2 4181 ) 4182 4183 // Values for the first argument to `getitimer' and `setitimer'. 4184 const ( /* time.h:88:1: */ 4185 // Timers run in real time. 4186 ITIMER_REAL = 0 4187 // Timers run only when the process is executing. 4188 ITIMER_VIRTUAL = 1 4189 // Timers run when the process is executing and when 4190 // the system is executing on behalf of the process. 4191 ITIMER_PROF = 2 4192 ) 4193 4194 type ptrdiff_t = int64 /* <builtin>:3:26 */ 4195 4196 type size_t = uint64 /* <builtin>:9:23 */ 4197 4198 type wchar_t = int32 /* <builtin>:15:24 */ 4199 4200 // Define the standard macros for the user, 4201 // if this invocation was from the user program. 4202 4203 // Define va_list, if desired, from __gnuc_va_list. 4204 // We deliberately do not define va_list when called from 4205 // stdio.h, because ANSI C says that stdio.h is not supposed to define 4206 // va_list. stdio.h needs to have access to that data type, 4207 // but must not use that name. It should use the name __gnuc_va_list, 4208 // which is safe because it is reserved for the implementation. 4209 4210 // The macro _VA_LIST_ is the same thing used by this file in Ultrix. 4211 // But on BSD NET2 we must not test or define or undef it. 4212 // (Note that the comments in NET 2's ansi.h 4213 // are incorrect for _VA_LIST_--see stdio.h!) 4214 // The macro _VA_LIST_DEFINED is used in Windows NT 3.5 4215 // The macro _VA_LIST is used in SCO Unix 3.2. 4216 // The macro _VA_LIST_T_H is used in the Bull dpx2 4217 // The macro __va_list__ is used by BeOS. 4218 type va_list = uintptr /* stdarg.h:99:24 */ 4219 4220 // CAPI3REF: Database Connection Handle 4221 // KEYWORDS: {database connection} {database connections} 4222 // 4223 // Each open SQLite database is represented by a pointer to an instance of 4224 // the opaque structure named "sqlite3". It is useful to think of an sqlite3 4225 // pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and 4226 // [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] 4227 // and [sqlite3_close_v2()] are its destructors. There are many other 4228 // interfaces (such as 4229 // [sqlite3_prepare_v2()], [sqlite3_create_function()], and 4230 // [sqlite3_busy_timeout()] to name but three) that are methods on an 4231 // sqlite3 object. 4232 type sqlite32 = struct { 4233 FpVfs uintptr 4234 FpVdbe uintptr 4235 FpDfltColl uintptr 4236 Fmutex uintptr 4237 FaDb uintptr 4238 FnDb int32 4239 FmDbFlags u322 4240 Fflags u64 4241 FlastRowid i64 4242 FszMmap i64 4243 FnSchemaLock u322 4244 FopenFlags uint32 4245 FerrCode int32 4246 FerrMask int32 4247 FiSysErrno int32 4248 FdbOptFlags u322 4249 Fenc u8 4250 FautoCommit u8 4251 Ftemp_store u8 4252 FmallocFailed u8 4253 FbBenignMalloc u8 4254 FdfltLockMode u8 4255 FnextAutovac int8 4256 FsuppressErr u8 4257 FvtabOnConflict u8 4258 FisTransactionSavepoint u8 4259 FmTrace u8 4260 FnoSharedCache u8 4261 FnSqlExec u8 4262 _ [3]byte 4263 FnextPagesize int32 4264 Fmagic u322 4265 FnChange int32 4266 FnTotalChange int32 4267 FaLimit [12]int32 4268 FnMaxSorterMmap int32 4269 _ [4]byte 4270 Finit struct { 4271 FnewTnum Pgno 4272 FiDb u8 4273 Fbusy u8 4274 _ [2]byte 4275 ForphanTrigger uint8 /* unsigned orphanTrigger: 1, unsigned imposterTable: 1, unsigned reopenMemdb: 1, unsigned bDropColumn: 1 */ 4276 _ [7]byte 4277 FazInit uintptr 4278 } 4279 FnVdbeActive int32 4280 FnVdbeRead int32 4281 FnVdbeWrite int32 4282 FnVdbeExec int32 4283 FnVDestroy int32 4284 FnExtension int32 4285 FaExtension uintptr 4286 Ftrace struct{ FxLegacy uintptr } 4287 FpTraceArg uintptr 4288 FxProfile uintptr 4289 FpProfileArg uintptr 4290 FpCommitArg uintptr 4291 FxCommitCallback uintptr 4292 FpRollbackArg uintptr 4293 FxRollbackCallback uintptr 4294 FpUpdateArg uintptr 4295 FxUpdateCallback uintptr 4296 FpParse uintptr 4297 FpPreUpdateArg uintptr 4298 FxPreUpdateCallback uintptr 4299 FpPreUpdate uintptr 4300 FxWalCallback uintptr 4301 FpWalArg uintptr 4302 FxCollNeeded uintptr 4303 FxCollNeeded16 uintptr 4304 FpCollNeededArg uintptr 4305 FpErr uintptr 4306 Fu1 struct { 4307 _ [0]uint64 4308 FisInterrupted int32 4309 _ [4]byte 4310 } 4311 Flookaside Lookaside 4312 FxAuth sqlite3_xauth 4313 FpAuthArg uintptr 4314 FxProgress uintptr 4315 FpProgressArg uintptr 4316 FnProgressOps uint32 4317 FnVTrans int32 4318 FaModule Hash 4319 FpVtabCtx uintptr 4320 FaVTrans uintptr 4321 FpDisconnect uintptr 4322 FaFunc Hash 4323 FaCollSeq Hash 4324 FbusyHandler BusyHandler 4325 FaDbStatic [2]Db 4326 FpSavepoint uintptr 4327 FnAnalysisLimit int32 4328 FbusyTimeout int32 4329 FnSavepoint int32 4330 FnStatement int32 4331 FnDeferredCons i64 4332 FnDeferredImmCons i64 4333 FpnBytesFreed uintptr 4334 FpBlockingConnection uintptr 4335 FpUnlockConnection uintptr 4336 FpUnlockArg uintptr 4337 FxUnlockNotify uintptr 4338 FpNextBlocked uintptr 4339 } /* sqlite3.h:249:9 */ 4340 4341 // CAPI3REF: 64-Bit Integer Types 4342 // KEYWORDS: sqlite_int64 sqlite_uint64 4343 // 4344 // Because there is no cross-platform way to specify 64-bit integer types 4345 // SQLite includes typedefs for 64-bit signed and unsigned integers. 4346 // 4347 // The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions. 4348 // The sqlite_int64 and sqlite_uint64 types are supported for backwards 4349 // compatibility only. 4350 // 4351 // ^The sqlite3_int64 and sqlite_int64 types can store integer values 4352 // between -9223372036854775808 and +9223372036854775807 inclusive. ^The 4353 // sqlite3_uint64 and sqlite_uint64 types can store integer values 4354 // between 0 and +18446744073709551615 inclusive. 4355 type sqlite_int64 = int64 /* sqlite3.h:278:25 */ 4356 type sqlite_uint64 = uint64 /* sqlite3.h:279:34 */ 4357 type sqlite3_int64 = sqlite_int64 /* sqlite3.h:281:22 */ 4358 type sqlite3_uint64 = sqlite_uint64 /* sqlite3.h:282:23 */ 4359 4360 // The type for a callback function. 4361 // This is legacy and deprecated. It is included for historical 4362 // compatibility and is not documented. 4363 type sqlite3_callback = uintptr /* sqlite3.h:338:13 */ 4364 4365 // CAPI3REF: Result Codes 4366 // KEYWORDS: {result code definitions} 4367 // 4368 // Many SQLite functions return an integer result code from the set shown 4369 // here in order to indicate success or failure. 4370 // 4371 // New error codes may be added in future versions of SQLite. 4372 // 4373 // See also: [extended result code definitions] 4374 // beginning-of-error-codes 4375 // end-of-error-codes 4376 4377 // CAPI3REF: Extended Result Codes 4378 // KEYWORDS: {extended result code definitions} 4379 // 4380 // In its default configuration, SQLite API routines return one of 30 integer 4381 // [result codes]. However, experience has shown that many of 4382 // these result codes are too coarse-grained. They do not provide as 4383 // much information about problems as programmers might like. In an effort to 4384 // address this, newer versions of SQLite (version 3.3.8 [dateof:3.3.8] 4385 // and later) include 4386 // support for additional result codes that provide more detailed information 4387 // about errors. These [extended result codes] are enabled or disabled 4388 // on a per database connection basis using the 4389 // [sqlite3_extended_result_codes()] API. Or, the extended code for 4390 // the most recent error can be obtained using 4391 // [sqlite3_extended_errcode()]. 4392 4393 // CAPI3REF: Flags For File Open Operations 4394 // 4395 // These bit values are intended for use in the 4396 // 3rd parameter to the [sqlite3_open_v2()] interface and 4397 // in the 4th parameter to the [sqlite3_vfs.xOpen] method. 4398 4399 // Reserved: 0x00F00000 4400 // Legacy compatibility: 4401 4402 // CAPI3REF: Device Characteristics 4403 // 4404 // The xDeviceCharacteristics method of the [sqlite3_io_methods] 4405 // object returns an integer which is a vector of these 4406 // bit values expressing I/O characteristics of the mass storage 4407 // device that holds the file that the [sqlite3_io_methods] 4408 // refers to. 4409 // 4410 // The SQLITE_IOCAP_ATOMIC property means that all writes of 4411 // any size are atomic. The SQLITE_IOCAP_ATOMICnnn values 4412 // mean that writes of blocks that are nnn bytes in size and 4413 // are aligned to an address which is an integer multiple of 4414 // nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means 4415 // that when data is appended to a file, the data is appended 4416 // first then the size of the file is extended, never the other 4417 // way around. The SQLITE_IOCAP_SEQUENTIAL property means that 4418 // information is written to disk in the same order as calls 4419 // to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that 4420 // after reboot following a crash or power loss, the only bytes in a 4421 // file that were written at the application level might have changed 4422 // and that adjacent bytes, even bytes within the same sector are 4423 // guaranteed to be unchanged. The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 4424 // flag indicates that a file cannot be deleted when open. The 4425 // SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on 4426 // read-only media and cannot be changed even by processes with 4427 // elevated privileges. 4428 // 4429 // The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying 4430 // filesystem supports doing multiple write operations atomically when those 4431 // write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and 4432 // [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. 4433 4434 // CAPI3REF: File Locking Levels 4435 // 4436 // SQLite uses one of these integer values as the second 4437 // argument to calls it makes to the xLock() and xUnlock() methods 4438 // of an [sqlite3_io_methods] object. 4439 4440 // CAPI3REF: Synchronization Type Flags 4441 // 4442 // When SQLite invokes the xSync() method of an 4443 // [sqlite3_io_methods] object it uses a combination of 4444 // these integer values as the second argument. 4445 // 4446 // When the SQLITE_SYNC_DATAONLY flag is used, it means that the 4447 // sync operation only needs to flush data to mass storage. Inode 4448 // information need not be flushed. If the lower four bits of the flag 4449 // equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics. 4450 // If the lower four bits equal SQLITE_SYNC_FULL, that means 4451 // to use Mac OS X style fullsync instead of fsync(). 4452 // 4453 // Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags 4454 // with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL 4455 // settings. The [synchronous pragma] determines when calls to the 4456 // xSync VFS method occur and applies uniformly across all platforms. 4457 // The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how 4458 // energetic or rigorous or forceful the sync operations are and 4459 // only make a difference on Mac OSX for the default SQLite code. 4460 // (Third-party VFS implementations might also make the distinction 4461 // between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the 4462 // operating systems natively supported by SQLite, only Mac OSX 4463 // cares about the difference.) 4464 4465 // CAPI3REF: OS Interface Open File Handle 4466 // 4467 // An [sqlite3_file] object represents an open file in the 4468 // [sqlite3_vfs | OS interface layer]. Individual OS interface 4469 // implementations will 4470 // want to subclass this object by appending additional fields 4471 // for their own use. The pMethods entry is a pointer to an 4472 // [sqlite3_io_methods] object that defines methods for performing 4473 // I/O operations on the open file. 4474 type sqlite3_file1 = struct{ FpMethods uintptr } /* sqlite3.h:684:9 */ 4475 4476 // CAPI3REF: Result Codes 4477 // KEYWORDS: {result code definitions} 4478 // 4479 // Many SQLite functions return an integer result code from the set shown 4480 // here in order to indicate success or failure. 4481 // 4482 // New error codes may be added in future versions of SQLite. 4483 // 4484 // See also: [extended result code definitions] 4485 // beginning-of-error-codes 4486 // end-of-error-codes 4487 4488 // CAPI3REF: Extended Result Codes 4489 // KEYWORDS: {extended result code definitions} 4490 // 4491 // In its default configuration, SQLite API routines return one of 30 integer 4492 // [result codes]. However, experience has shown that many of 4493 // these result codes are too coarse-grained. They do not provide as 4494 // much information about problems as programmers might like. In an effort to 4495 // address this, newer versions of SQLite (version 3.3.8 [dateof:3.3.8] 4496 // and later) include 4497 // support for additional result codes that provide more detailed information 4498 // about errors. These [extended result codes] are enabled or disabled 4499 // on a per database connection basis using the 4500 // [sqlite3_extended_result_codes()] API. Or, the extended code for 4501 // the most recent error can be obtained using 4502 // [sqlite3_extended_errcode()]. 4503 4504 // CAPI3REF: Flags For File Open Operations 4505 // 4506 // These bit values are intended for use in the 4507 // 3rd parameter to the [sqlite3_open_v2()] interface and 4508 // in the 4th parameter to the [sqlite3_vfs.xOpen] method. 4509 4510 // Reserved: 0x00F00000 4511 // Legacy compatibility: 4512 4513 // CAPI3REF: Device Characteristics 4514 // 4515 // The xDeviceCharacteristics method of the [sqlite3_io_methods] 4516 // object returns an integer which is a vector of these 4517 // bit values expressing I/O characteristics of the mass storage 4518 // device that holds the file that the [sqlite3_io_methods] 4519 // refers to. 4520 // 4521 // The SQLITE_IOCAP_ATOMIC property means that all writes of 4522 // any size are atomic. The SQLITE_IOCAP_ATOMICnnn values 4523 // mean that writes of blocks that are nnn bytes in size and 4524 // are aligned to an address which is an integer multiple of 4525 // nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means 4526 // that when data is appended to a file, the data is appended 4527 // first then the size of the file is extended, never the other 4528 // way around. The SQLITE_IOCAP_SEQUENTIAL property means that 4529 // information is written to disk in the same order as calls 4530 // to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that 4531 // after reboot following a crash or power loss, the only bytes in a 4532 // file that were written at the application level might have changed 4533 // and that adjacent bytes, even bytes within the same sector are 4534 // guaranteed to be unchanged. The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 4535 // flag indicates that a file cannot be deleted when open. The 4536 // SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on 4537 // read-only media and cannot be changed even by processes with 4538 // elevated privileges. 4539 // 4540 // The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying 4541 // filesystem supports doing multiple write operations atomically when those 4542 // write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and 4543 // [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. 4544 4545 // CAPI3REF: File Locking Levels 4546 // 4547 // SQLite uses one of these integer values as the second 4548 // argument to calls it makes to the xLock() and xUnlock() methods 4549 // of an [sqlite3_io_methods] object. 4550 4551 // CAPI3REF: Synchronization Type Flags 4552 // 4553 // When SQLite invokes the xSync() method of an 4554 // [sqlite3_io_methods] object it uses a combination of 4555 // these integer values as the second argument. 4556 // 4557 // When the SQLITE_SYNC_DATAONLY flag is used, it means that the 4558 // sync operation only needs to flush data to mass storage. Inode 4559 // information need not be flushed. If the lower four bits of the flag 4560 // equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics. 4561 // If the lower four bits equal SQLITE_SYNC_FULL, that means 4562 // to use Mac OS X style fullsync instead of fsync(). 4563 // 4564 // Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags 4565 // with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL 4566 // settings. The [synchronous pragma] determines when calls to the 4567 // xSync VFS method occur and applies uniformly across all platforms. 4568 // The SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags determine how 4569 // energetic or rigorous or forceful the sync operations are and 4570 // only make a difference on Mac OSX for the default SQLite code. 4571 // (Third-party VFS implementations might also make the distinction 4572 // between SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL, but among the 4573 // operating systems natively supported by SQLite, only Mac OSX 4574 // cares about the difference.) 4575 4576 // CAPI3REF: OS Interface Open File Handle 4577 // 4578 // An [sqlite3_file] object represents an open file in the 4579 // [sqlite3_vfs | OS interface layer]. Individual OS interface 4580 // implementations will 4581 // want to subclass this object by appending additional fields 4582 // for their own use. The pMethods entry is a pointer to an 4583 // [sqlite3_io_methods] object that defines methods for performing 4584 // I/O operations on the open file. 4585 type sqlite3_file = sqlite3_file1 /* sqlite3.h:684:29 */ 4586 type sqlite3_io_methods1 = struct { 4587 FiVersion int32 4588 _ [4]byte 4589 FxClose uintptr 4590 FxRead uintptr 4591 FxWrite uintptr 4592 FxTruncate uintptr 4593 FxSync uintptr 4594 FxFileSize uintptr 4595 FxLock uintptr 4596 FxUnlock uintptr 4597 FxCheckReservedLock uintptr 4598 FxFileControl uintptr 4599 FxSectorSize uintptr 4600 FxDeviceCharacteristics uintptr 4601 FxShmMap uintptr 4602 FxShmLock uintptr 4603 FxShmBarrier uintptr 4604 FxShmUnmap uintptr 4605 FxFetch uintptr 4606 FxUnfetch uintptr 4607 } /* sqlite3.h:684:9 */ 4608 4609 // CAPI3REF: OS Interface File Virtual Methods Object 4610 // 4611 // Every file opened by the [sqlite3_vfs.xOpen] method populates an 4612 // [sqlite3_file] object (or, more commonly, a subclass of the 4613 // [sqlite3_file] object) with a pointer to an instance of this object. 4614 // This object defines the methods used to perform various operations 4615 // against the open file represented by the [sqlite3_file] object. 4616 // 4617 // If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element 4618 // to a non-NULL pointer, then the sqlite3_io_methods.xClose method 4619 // may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed. The 4620 // only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen] 4621 // is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element 4622 // to NULL. 4623 // 4624 // The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or 4625 // [SQLITE_SYNC_FULL]. The first choice is the normal fsync(). 4626 // The second choice is a Mac OS X style fullsync. The [SQLITE_SYNC_DATAONLY] 4627 // flag may be ORed in to indicate that only the data of the file 4628 // and not its inode needs to be synced. 4629 // 4630 // The integer values to xLock() and xUnlock() are one of 4631 // <ul> 4632 // <li> [SQLITE_LOCK_NONE], 4633 // <li> [SQLITE_LOCK_SHARED], 4634 // <li> [SQLITE_LOCK_RESERVED], 4635 // <li> [SQLITE_LOCK_PENDING], or 4636 // <li> [SQLITE_LOCK_EXCLUSIVE]. 4637 // </ul> 4638 // xLock() increases the lock. xUnlock() decreases the lock. 4639 // The xCheckReservedLock() method checks whether any database connection, 4640 // either in this process or in some other process, is holding a RESERVED, 4641 // PENDING, or EXCLUSIVE lock on the file. It returns true 4642 // if such a lock exists and false otherwise. 4643 // 4644 // The xFileControl() method is a generic interface that allows custom 4645 // VFS implementations to directly control an open file using the 4646 // [sqlite3_file_control()] interface. The second "op" argument is an 4647 // integer opcode. The third argument is a generic pointer intended to 4648 // point to a structure that may contain arguments or space in which to 4649 // write return values. Potential uses for xFileControl() might be 4650 // functions to enable blocking locks with timeouts, to change the 4651 // locking strategy (for example to use dot-file locks), to inquire 4652 // about the status of a lock, or to break stale locks. The SQLite 4653 // core reserves all opcodes less than 100 for its own use. 4654 // A [file control opcodes | list of opcodes] less than 100 is available. 4655 // Applications that define a custom xFileControl method should use opcodes 4656 // greater than 100 to avoid conflicts. VFS implementations should 4657 // return [SQLITE_NOTFOUND] for file control opcodes that they do not 4658 // recognize. 4659 // 4660 // The xSectorSize() method returns the sector size of the 4661 // device that underlies the file. The sector size is the 4662 // minimum write that can be performed without disturbing 4663 // other bytes in the file. The xDeviceCharacteristics() 4664 // method returns a bit vector describing behaviors of the 4665 // underlying device: 4666 // 4667 // <ul> 4668 // <li> [SQLITE_IOCAP_ATOMIC] 4669 // <li> [SQLITE_IOCAP_ATOMIC512] 4670 // <li> [SQLITE_IOCAP_ATOMIC1K] 4671 // <li> [SQLITE_IOCAP_ATOMIC2K] 4672 // <li> [SQLITE_IOCAP_ATOMIC4K] 4673 // <li> [SQLITE_IOCAP_ATOMIC8K] 4674 // <li> [SQLITE_IOCAP_ATOMIC16K] 4675 // <li> [SQLITE_IOCAP_ATOMIC32K] 4676 // <li> [SQLITE_IOCAP_ATOMIC64K] 4677 // <li> [SQLITE_IOCAP_SAFE_APPEND] 4678 // <li> [SQLITE_IOCAP_SEQUENTIAL] 4679 // <li> [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN] 4680 // <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE] 4681 // <li> [SQLITE_IOCAP_IMMUTABLE] 4682 // <li> [SQLITE_IOCAP_BATCH_ATOMIC] 4683 // </ul> 4684 // 4685 // The SQLITE_IOCAP_ATOMIC property means that all writes of 4686 // any size are atomic. The SQLITE_IOCAP_ATOMICnnn values 4687 // mean that writes of blocks that are nnn bytes in size and 4688 // are aligned to an address which is an integer multiple of 4689 // nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means 4690 // that when data is appended to a file, the data is appended 4691 // first then the size of the file is extended, never the other 4692 // way around. The SQLITE_IOCAP_SEQUENTIAL property means that 4693 // information is written to disk in the same order as calls 4694 // to xWrite(). 4695 // 4696 // If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill 4697 // in the unread portions of the buffer with zeros. A VFS that 4698 // fails to zero-fill short reads might seem to work. However, 4699 // failure to zero-fill short reads will eventually lead to 4700 // database corruption. 4701 type sqlite3_io_methods = sqlite3_io_methods1 /* sqlite3.h:783:35 */ 4702 4703 // CAPI3REF: Standard File Control Opcodes 4704 // KEYWORDS: {file control opcodes} {file control opcode} 4705 // 4706 // These integer constants are opcodes for the xFileControl method 4707 // of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] 4708 // interface. 4709 // 4710 // <ul> 4711 // <li>[[SQLITE_FCNTL_LOCKSTATE]] 4712 // The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This 4713 // opcode causes the xFileControl method to write the current state of 4714 // the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED], 4715 // [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE]) 4716 // into an integer that the pArg argument points to. This capability 4717 // is used during testing and is only available when the SQLITE_TEST 4718 // compile-time option is used. 4719 // 4720 // <li>[[SQLITE_FCNTL_SIZE_HINT]] 4721 // The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS 4722 // layer a hint of how large the database file will grow to be during the 4723 // current transaction. This hint is not guaranteed to be accurate but it 4724 // is often close. The underlying VFS might choose to preallocate database 4725 // file space based on this hint in order to help writes to the database 4726 // file run faster. 4727 // 4728 // <li>[[SQLITE_FCNTL_SIZE_LIMIT]] 4729 // The [SQLITE_FCNTL_SIZE_LIMIT] opcode is used by in-memory VFS that 4730 // implements [sqlite3_deserialize()] to set an upper bound on the size 4731 // of the in-memory database. The argument is a pointer to a [sqlite3_int64]. 4732 // If the integer pointed to is negative, then it is filled in with the 4733 // current limit. Otherwise the limit is set to the larger of the value 4734 // of the integer pointed to and the current database size. The integer 4735 // pointed to is set to the new limit. 4736 // 4737 // <li>[[SQLITE_FCNTL_CHUNK_SIZE]] 4738 // The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS 4739 // extends and truncates the database file in chunks of a size specified 4740 // by the user. The fourth argument to [sqlite3_file_control()] should 4741 // point to an integer (type int) containing the new chunk-size to use 4742 // for the nominated database. Allocating database file space in large 4743 // chunks (say 1MB at a time), may reduce file-system fragmentation and 4744 // improve performance on some systems. 4745 // 4746 // <li>[[SQLITE_FCNTL_FILE_POINTER]] 4747 // The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer 4748 // to the [sqlite3_file] object associated with a particular database 4749 // connection. See also [SQLITE_FCNTL_JOURNAL_POINTER]. 4750 // 4751 // <li>[[SQLITE_FCNTL_JOURNAL_POINTER]] 4752 // The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer 4753 // to the [sqlite3_file] object associated with the journal file (either 4754 // the [rollback journal] or the [write-ahead log]) for a particular database 4755 // connection. See also [SQLITE_FCNTL_FILE_POINTER]. 4756 // 4757 // <li>[[SQLITE_FCNTL_SYNC_OMITTED]] 4758 // No longer in use. 4759 // 4760 // <li>[[SQLITE_FCNTL_SYNC]] 4761 // The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and 4762 // sent to the VFS immediately before the xSync method is invoked on a 4763 // database file descriptor. Or, if the xSync method is not invoked 4764 // because the user has configured SQLite with 4765 // [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place 4766 // of the xSync method. In most cases, the pointer argument passed with 4767 // this file-control is NULL. However, if the database file is being synced 4768 // as part of a multi-database commit, the argument points to a nul-terminated 4769 // string containing the transactions super-journal file name. VFSes that 4770 // do not need this signal should silently ignore this opcode. Applications 4771 // should not call [sqlite3_file_control()] with this opcode as doing so may 4772 // disrupt the operation of the specialized VFSes that do require it. 4773 // 4774 // <li>[[SQLITE_FCNTL_COMMIT_PHASETWO]] 4775 // The [SQLITE_FCNTL_COMMIT_PHASETWO] opcode is generated internally by SQLite 4776 // and sent to the VFS after a transaction has been committed immediately 4777 // but before the database is unlocked. VFSes that do not need this signal 4778 // should silently ignore this opcode. Applications should not call 4779 // [sqlite3_file_control()] with this opcode as doing so may disrupt the 4780 // operation of the specialized VFSes that do require it. 4781 // 4782 // <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]] 4783 // ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic 4784 // retry counts and intervals for certain disk I/O operations for the 4785 // windows [VFS] in order to provide robustness in the presence of 4786 // anti-virus programs. By default, the windows VFS will retry file read, 4787 // file write, and file delete operations up to 10 times, with a delay 4788 // of 25 milliseconds before the first retry and with the delay increasing 4789 // by an additional 25 milliseconds with each subsequent retry. This 4790 // opcode allows these two values (10 retries and 25 milliseconds of delay) 4791 // to be adjusted. The values are changed for all database connections 4792 // within the same process. The argument is a pointer to an array of two 4793 // integers where the first integer is the new retry count and the second 4794 // integer is the delay. If either integer is negative, then the setting 4795 // is not changed but instead the prior value of that setting is written 4796 // into the array entry, allowing the current retry settings to be 4797 // interrogated. The zDbName parameter is ignored. 4798 // 4799 // <li>[[SQLITE_FCNTL_PERSIST_WAL]] 4800 // ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the 4801 // persistent [WAL | Write Ahead Log] setting. By default, the auxiliary 4802 // write ahead log ([WAL file]) and shared memory 4803 // files used for transaction control 4804 // are automatically deleted when the latest connection to the database 4805 // closes. Setting persistent WAL mode causes those files to persist after 4806 // close. Persisting the files is useful when other processes that do not 4807 // have write permission on the directory containing the database file want 4808 // to read the database file, as the WAL and shared memory files must exist 4809 // in order for the database to be readable. The fourth parameter to 4810 // [sqlite3_file_control()] for this opcode should be a pointer to an integer. 4811 // That integer is 0 to disable persistent WAL mode or 1 to enable persistent 4812 // WAL mode. If the integer is -1, then it is overwritten with the current 4813 // WAL persistence setting. 4814 // 4815 // <li>[[SQLITE_FCNTL_POWERSAFE_OVERWRITE]] 4816 // ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the 4817 // persistent "powersafe-overwrite" or "PSOW" setting. The PSOW setting 4818 // determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the 4819 // xDeviceCharacteristics methods. The fourth parameter to 4820 // [sqlite3_file_control()] for this opcode should be a pointer to an integer. 4821 // That integer is 0 to disable zero-damage mode or 1 to enable zero-damage 4822 // mode. If the integer is -1, then it is overwritten with the current 4823 // zero-damage mode setting. 4824 // 4825 // <li>[[SQLITE_FCNTL_OVERWRITE]] 4826 // ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening 4827 // a write transaction to indicate that, unless it is rolled back for some 4828 // reason, the entire database file will be overwritten by the current 4829 // transaction. This is used by VACUUM operations. 4830 // 4831 // <li>[[SQLITE_FCNTL_VFSNAME]] 4832 // ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of 4833 // all [VFSes] in the VFS stack. The names are of all VFS shims and the 4834 // final bottom-level VFS are written into memory obtained from 4835 // [sqlite3_malloc()] and the result is stored in the char* variable 4836 // that the fourth parameter of [sqlite3_file_control()] points to. 4837 // The caller is responsible for freeing the memory when done. As with 4838 // all file-control actions, there is no guarantee that this will actually 4839 // do anything. Callers should initialize the char* variable to a NULL 4840 // pointer in case this file-control is not implemented. This file-control 4841 // is intended for diagnostic use only. 4842 // 4843 // <li>[[SQLITE_FCNTL_VFS_POINTER]] 4844 // ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level 4845 // [VFSes] currently in use. ^(The argument X in 4846 // sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be 4847 // of type "[sqlite3_vfs] **". This opcodes will set *X 4848 // to a pointer to the top-level VFS.)^ 4849 // ^When there are multiple VFS shims in the stack, this opcode finds the 4850 // upper-most shim only. 4851 // 4852 // <li>[[SQLITE_FCNTL_PRAGMA]] 4853 // ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] 4854 // file control is sent to the open [sqlite3_file] object corresponding 4855 // to the database file to which the pragma statement refers. ^The argument 4856 // to the [SQLITE_FCNTL_PRAGMA] file control is an array of 4857 // pointers to strings (char**) in which the second element of the array 4858 // is the name of the pragma and the third element is the argument to the 4859 // pragma or NULL if the pragma has no argument. ^The handler for an 4860 // [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element 4861 // of the char** argument point to a string obtained from [sqlite3_mprintf()] 4862 // or the equivalent and that string will become the result of the pragma or 4863 // the error message if the pragma fails. ^If the 4864 // [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal 4865 // [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA] 4866 // file control returns [SQLITE_OK], then the parser assumes that the 4867 // VFS has handled the PRAGMA itself and the parser generates a no-op 4868 // prepared statement if result string is NULL, or that returns a copy 4869 // of the result string if the string is non-NULL. 4870 // ^If the [SQLITE_FCNTL_PRAGMA] file control returns 4871 // any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means 4872 // that the VFS encountered an error while handling the [PRAGMA] and the 4873 // compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA] 4874 // file control occurs at the beginning of pragma statement analysis and so 4875 // it is able to override built-in [PRAGMA] statements. 4876 // 4877 // <li>[[SQLITE_FCNTL_BUSYHANDLER]] 4878 // ^The [SQLITE_FCNTL_BUSYHANDLER] 4879 // file-control may be invoked by SQLite on the database file handle 4880 // shortly after it is opened in order to provide a custom VFS with access 4881 // to the connection's busy-handler callback. The argument is of type (void**) 4882 // - an array of two (void *) values. The first (void *) actually points 4883 // to a function of type (int (*)(void *)). In order to invoke the connection's 4884 // busy-handler, this function should be invoked with the second (void *) in 4885 // the array as the only argument. If it returns non-zero, then the operation 4886 // should be retried. If it returns zero, the custom VFS should abandon the 4887 // current operation. 4888 // 4889 // <li>[[SQLITE_FCNTL_TEMPFILENAME]] 4890 // ^Applications can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control 4891 // to have SQLite generate a 4892 // temporary filename using the same algorithm that is followed to generate 4893 // temporary filenames for TEMP tables and other internal uses. The 4894 // argument should be a char** which will be filled with the filename 4895 // written into memory obtained from [sqlite3_malloc()]. The caller should 4896 // invoke [sqlite3_free()] on the result to avoid a memory leak. 4897 // 4898 // <li>[[SQLITE_FCNTL_MMAP_SIZE]] 4899 // The [SQLITE_FCNTL_MMAP_SIZE] file control is used to query or set the 4900 // maximum number of bytes that will be used for memory-mapped I/O. 4901 // The argument is a pointer to a value of type sqlite3_int64 that 4902 // is an advisory maximum number of bytes in the file to memory map. The 4903 // pointer is overwritten with the old value. The limit is not changed if 4904 // the value originally pointed to is negative, and so the current limit 4905 // can be queried by passing in a pointer to a negative number. This 4906 // file-control is used internally to implement [PRAGMA mmap_size]. 4907 // 4908 // <li>[[SQLITE_FCNTL_TRACE]] 4909 // The [SQLITE_FCNTL_TRACE] file control provides advisory information 4910 // to the VFS about what the higher layers of the SQLite stack are doing. 4911 // This file control is used by some VFS activity tracing [shims]. 4912 // The argument is a zero-terminated string. Higher layers in the 4913 // SQLite stack may generate instances of this file control if 4914 // the [SQLITE_USE_FCNTL_TRACE] compile-time option is enabled. 4915 // 4916 // <li>[[SQLITE_FCNTL_HAS_MOVED]] 4917 // The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a 4918 // pointer to an integer and it writes a boolean into that integer depending 4919 // on whether or not the file has been renamed, moved, or deleted since it 4920 // was first opened. 4921 // 4922 // <li>[[SQLITE_FCNTL_WIN32_GET_HANDLE]] 4923 // The [SQLITE_FCNTL_WIN32_GET_HANDLE] opcode can be used to obtain the 4924 // underlying native file handle associated with a file handle. This file 4925 // control interprets its argument as a pointer to a native file handle and 4926 // writes the resulting value there. 4927 // 4928 // <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]] 4929 // The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This 4930 // opcode causes the xFileControl method to swap the file handle with the one 4931 // pointed to by the pArg argument. This capability is used during testing 4932 // and only needs to be supported when SQLITE_TEST is defined. 4933 // 4934 // <li>[[SQLITE_FCNTL_WAL_BLOCK]] 4935 // The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might 4936 // be advantageous to block on the next WAL lock if the lock is not immediately 4937 // available. The WAL subsystem issues this signal during rare 4938 // circumstances in order to fix a problem with priority inversion. 4939 // Applications should <em>not</em> use this file-control. 4940 // 4941 // <li>[[SQLITE_FCNTL_ZIPVFS]] 4942 // The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other 4943 // VFS should return SQLITE_NOTFOUND for this opcode. 4944 // 4945 // <li>[[SQLITE_FCNTL_RBU]] 4946 // The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by 4947 // the RBU extension only. All other VFS should return SQLITE_NOTFOUND for 4948 // this opcode. 4949 // 4950 // <li>[[SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]] 4951 // If the [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] opcode returns SQLITE_OK, then 4952 // the file descriptor is placed in "batch write mode", which 4953 // means all subsequent write operations will be deferred and done 4954 // atomically at the next [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. Systems 4955 // that do not support batch atomic writes will return SQLITE_NOTFOUND. 4956 // ^Following a successful SQLITE_FCNTL_BEGIN_ATOMIC_WRITE and prior to 4957 // the closing [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] or 4958 // [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE], SQLite will make 4959 // no VFS interface calls on the same [sqlite3_file] file descriptor 4960 // except for calls to the xWrite method and the xFileControl method 4961 // with [SQLITE_FCNTL_SIZE_HINT]. 4962 // 4963 // <li>[[SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]] 4964 // The [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] opcode causes all write 4965 // operations since the previous successful call to 4966 // [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be performed atomically. 4967 // This file control returns [SQLITE_OK] if and only if the writes were 4968 // all performed successfully and have been committed to persistent storage. 4969 // ^Regardless of whether or not it is successful, this file control takes 4970 // the file descriptor out of batch write mode so that all subsequent 4971 // write operations are independent. 4972 // ^SQLite will never invoke SQLITE_FCNTL_COMMIT_ATOMIC_WRITE without 4973 // a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]. 4974 // 4975 // <li>[[SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE]] 4976 // The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write 4977 // operations since the previous successful call to 4978 // [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back. 4979 // ^This file control takes the file descriptor out of batch write mode 4980 // so that all subsequent write operations are independent. 4981 // ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without 4982 // a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]. 4983 // 4984 // <li>[[SQLITE_FCNTL_LOCK_TIMEOUT]] 4985 // The [SQLITE_FCNTL_LOCK_TIMEOUT] opcode is used to configure a VFS 4986 // to block for up to M milliseconds before failing when attempting to 4987 // obtain a file lock using the xLock or xShmLock methods of the VFS. 4988 // The parameter is a pointer to a 32-bit signed integer that contains 4989 // the value that M is to be set to. Before returning, the 32-bit signed 4990 // integer is overwritten with the previous value of M. 4991 // 4992 // <li>[[SQLITE_FCNTL_DATA_VERSION]] 4993 // The [SQLITE_FCNTL_DATA_VERSION] opcode is used to detect changes to 4994 // a database file. The argument is a pointer to a 32-bit unsigned integer. 4995 // The "data version" for the pager is written into the pointer. The 4996 // "data version" changes whenever any change occurs to the corresponding 4997 // database file, either through SQL statements on the same database 4998 // connection or through transactions committed by separate database 4999 // connections possibly in other processes. The [sqlite3_total_changes()] 5000 // interface can be used to find if any database on the connection has changed, 5001 // but that interface responds to changes on TEMP as well as MAIN and does 5002 // not provide a mechanism to detect changes to MAIN only. Also, the 5003 // [sqlite3_total_changes()] interface responds to internal changes only and 5004 // omits changes made by other database connections. The 5005 // [PRAGMA data_version] command provides a mechanism to detect changes to 5006 // a single attached database that occur due to other database connections, 5007 // but omits changes implemented by the database connection on which it is 5008 // called. This file control is the only mechanism to detect changes that 5009 // happen either internally or externally and that are associated with 5010 // a particular attached database. 5011 // 5012 // <li>[[SQLITE_FCNTL_CKPT_START]] 5013 // The [SQLITE_FCNTL_CKPT_START] opcode is invoked from within a checkpoint 5014 // in wal mode before the client starts to copy pages from the wal 5015 // file to the database file. 5016 // 5017 // <li>[[SQLITE_FCNTL_CKPT_DONE]] 5018 // The [SQLITE_FCNTL_CKPT_DONE] opcode is invoked from within a checkpoint 5019 // in wal mode after the client has finished copying pages from the wal 5020 // file to the database file, but before the *-shm file is updated to 5021 // record the fact that the pages have been checkpointed. 5022 // </ul> 5023 5024 // deprecated names 5025 5026 // CAPI3REF: Mutex Handle 5027 // 5028 // The mutex module within SQLite defines [sqlite3_mutex] to be an 5029 // abstract type for a mutex object. The SQLite core never looks 5030 // at the internal representation of an [sqlite3_mutex]. It only 5031 // deals with pointers to the [sqlite3_mutex] object. 5032 // 5033 // Mutexes are created using [sqlite3_mutex_alloc()]. 5034 type sqlite3_mutex1 = struct { 5035 FpReal uintptr 5036 FeType int32 5037 _ [4]byte 5038 } /* sqlite3.h:1187:9 */ 5039 5040 // CAPI3REF: Loadable Extension Thunk 5041 // 5042 // A pointer to the opaque sqlite3_api_routines structure is passed as 5043 // the third parameter to entry points of [loadable extensions]. This 5044 // structure must be typedefed in order to work around compiler warnings 5045 // on some platforms. 5046 type sqlite3_api_routines1 = struct { 5047 Faggregate_context uintptr 5048 Faggregate_count uintptr 5049 Fbind_blob uintptr 5050 Fbind_double uintptr 5051 Fbind_int uintptr 5052 Fbind_int64 uintptr 5053 Fbind_null uintptr 5054 Fbind_parameter_count uintptr 5055 Fbind_parameter_index uintptr 5056 Fbind_parameter_name uintptr 5057 Fbind_text uintptr 5058 Fbind_text16 uintptr 5059 Fbind_value uintptr 5060 Fbusy_handler uintptr 5061 Fbusy_timeout uintptr 5062 Fchanges uintptr 5063 Fclose uintptr 5064 Fcollation_needed uintptr 5065 Fcollation_needed16 uintptr 5066 Fcolumn_blob uintptr 5067 Fcolumn_bytes uintptr 5068 Fcolumn_bytes16 uintptr 5069 Fcolumn_count uintptr 5070 Fcolumn_database_name uintptr 5071 Fcolumn_database_name16 uintptr 5072 Fcolumn_decltype uintptr 5073 Fcolumn_decltype16 uintptr 5074 Fcolumn_double uintptr 5075 Fcolumn_int uintptr 5076 Fcolumn_int64 uintptr 5077 Fcolumn_name uintptr 5078 Fcolumn_name16 uintptr 5079 Fcolumn_origin_name uintptr 5080 Fcolumn_origin_name16 uintptr 5081 Fcolumn_table_name uintptr 5082 Fcolumn_table_name16 uintptr 5083 Fcolumn_text uintptr 5084 Fcolumn_text16 uintptr 5085 Fcolumn_type uintptr 5086 Fcolumn_value uintptr 5087 Fcommit_hook uintptr 5088 Fcomplete uintptr 5089 Fcomplete16 uintptr 5090 Fcreate_collation uintptr 5091 Fcreate_collation16 uintptr 5092 Fcreate_function uintptr 5093 Fcreate_function16 uintptr 5094 Fcreate_module uintptr 5095 Fdata_count uintptr 5096 Fdb_handle uintptr 5097 Fdeclare_vtab uintptr 5098 Fenable_shared_cache uintptr 5099 Ferrcode uintptr 5100 Ferrmsg uintptr 5101 Ferrmsg16 uintptr 5102 Fexec uintptr 5103 Fexpired uintptr 5104 Ffinalize uintptr 5105 Ffree uintptr 5106 Ffree_table uintptr 5107 Fget_autocommit uintptr 5108 Fget_auxdata uintptr 5109 Fget_table uintptr 5110 Fglobal_recover uintptr 5111 Finterruptx uintptr 5112 Flast_insert_rowid uintptr 5113 Flibversion uintptr 5114 Flibversion_number uintptr 5115 Fmalloc uintptr 5116 Fmprintf uintptr 5117 Fopen uintptr 5118 Fopen16 uintptr 5119 Fprepare uintptr 5120 Fprepare16 uintptr 5121 Fprofile uintptr 5122 Fprogress_handler uintptr 5123 Frealloc uintptr 5124 Freset uintptr 5125 Fresult_blob uintptr 5126 Fresult_double uintptr 5127 Fresult_error uintptr 5128 Fresult_error16 uintptr 5129 Fresult_int uintptr 5130 Fresult_int64 uintptr 5131 Fresult_null uintptr 5132 Fresult_text uintptr 5133 Fresult_text16 uintptr 5134 Fresult_text16be uintptr 5135 Fresult_text16le uintptr 5136 Fresult_value uintptr 5137 Frollback_hook uintptr 5138 Fset_authorizer uintptr 5139 Fset_auxdata uintptr 5140 Fxsnprintf uintptr 5141 Fstep uintptr 5142 Ftable_column_metadata uintptr 5143 Fthread_cleanup uintptr 5144 Ftotal_changes uintptr 5145 Ftrace uintptr 5146 Ftransfer_bindings uintptr 5147 Fupdate_hook uintptr 5148 Fuser_data uintptr 5149 Fvalue_blob uintptr 5150 Fvalue_bytes uintptr 5151 Fvalue_bytes16 uintptr 5152 Fvalue_double uintptr 5153 Fvalue_int uintptr 5154 Fvalue_int64 uintptr 5155 Fvalue_numeric_type uintptr 5156 Fvalue_text uintptr 5157 Fvalue_text16 uintptr 5158 Fvalue_text16be uintptr 5159 Fvalue_text16le uintptr 5160 Fvalue_type uintptr 5161 Fvmprintf uintptr 5162 Foverload_function uintptr 5163 Fprepare_v2 uintptr 5164 Fprepare16_v2 uintptr 5165 Fclear_bindings uintptr 5166 Fcreate_module_v2 uintptr 5167 Fbind_zeroblob uintptr 5168 Fblob_bytes uintptr 5169 Fblob_close uintptr 5170 Fblob_open uintptr 5171 Fblob_read uintptr 5172 Fblob_write uintptr 5173 Fcreate_collation_v2 uintptr 5174 Ffile_control uintptr 5175 Fmemory_highwater uintptr 5176 Fmemory_used uintptr 5177 Fmutex_alloc uintptr 5178 Fmutex_enter uintptr 5179 Fmutex_free uintptr 5180 Fmutex_leave uintptr 5181 Fmutex_try uintptr 5182 Fopen_v2 uintptr 5183 Frelease_memory uintptr 5184 Fresult_error_nomem uintptr 5185 Fresult_error_toobig uintptr 5186 Fsleep uintptr 5187 Fsoft_heap_limit uintptr 5188 Fvfs_find uintptr 5189 Fvfs_register uintptr 5190 Fvfs_unregister uintptr 5191 Fxthreadsafe uintptr 5192 Fresult_zeroblob uintptr 5193 Fresult_error_code uintptr 5194 Ftest_control uintptr 5195 Frandomness uintptr 5196 Fcontext_db_handle uintptr 5197 Fextended_result_codes uintptr 5198 Flimit uintptr 5199 Fnext_stmt uintptr 5200 Fsql uintptr 5201 Fstatus uintptr 5202 Fbackup_finish uintptr 5203 Fbackup_init uintptr 5204 Fbackup_pagecount uintptr 5205 Fbackup_remaining uintptr 5206 Fbackup_step uintptr 5207 Fcompileoption_get uintptr 5208 Fcompileoption_used uintptr 5209 Fcreate_function_v2 uintptr 5210 Fdb_config uintptr 5211 Fdb_mutex uintptr 5212 Fdb_status uintptr 5213 Fextended_errcode uintptr 5214 Flog uintptr 5215 Fsoft_heap_limit64 uintptr 5216 Fsourceid uintptr 5217 Fstmt_status uintptr 5218 Fstrnicmp uintptr 5219 Funlock_notify uintptr 5220 Fwal_autocheckpoint uintptr 5221 Fwal_checkpoint uintptr 5222 Fwal_hook uintptr 5223 Fblob_reopen uintptr 5224 Fvtab_config uintptr 5225 Fvtab_on_conflict uintptr 5226 Fclose_v2 uintptr 5227 Fdb_filename uintptr 5228 Fdb_readonly uintptr 5229 Fdb_release_memory uintptr 5230 Ferrstr uintptr 5231 Fstmt_busy uintptr 5232 Fstmt_readonly uintptr 5233 Fstricmp uintptr 5234 Furi_boolean uintptr 5235 Furi_int64 uintptr 5236 Furi_parameter uintptr 5237 Fxvsnprintf uintptr 5238 Fwal_checkpoint_v2 uintptr 5239 Fauto_extension uintptr 5240 Fbind_blob64 uintptr 5241 Fbind_text64 uintptr 5242 Fcancel_auto_extension uintptr 5243 Fload_extension uintptr 5244 Fmalloc64 uintptr 5245 Fmsize uintptr 5246 Frealloc64 uintptr 5247 Freset_auto_extension uintptr 5248 Fresult_blob64 uintptr 5249 Fresult_text64 uintptr 5250 Fstrglob uintptr 5251 Fvalue_dup uintptr 5252 Fvalue_free uintptr 5253 Fresult_zeroblob64 uintptr 5254 Fbind_zeroblob64 uintptr 5255 Fvalue_subtype uintptr 5256 Fresult_subtype uintptr 5257 Fstatus64 uintptr 5258 Fstrlike uintptr 5259 Fdb_cacheflush uintptr 5260 Fsystem_errno uintptr 5261 Ftrace_v2 uintptr 5262 Fexpanded_sql uintptr 5263 Fset_last_insert_rowid uintptr 5264 Fprepare_v3 uintptr 5265 Fprepare16_v3 uintptr 5266 Fbind_pointer uintptr 5267 Fresult_pointer uintptr 5268 Fvalue_pointer uintptr 5269 Fvtab_nochange uintptr 5270 Fvalue_nochange uintptr 5271 Fvtab_collation uintptr 5272 Fkeyword_count uintptr 5273 Fkeyword_name uintptr 5274 Fkeyword_check uintptr 5275 Fstr_new uintptr 5276 Fstr_finish uintptr 5277 Fstr_appendf uintptr 5278 Fstr_vappendf uintptr 5279 Fstr_append uintptr 5280 Fstr_appendall uintptr 5281 Fstr_appendchar uintptr 5282 Fstr_reset uintptr 5283 Fstr_errcode uintptr 5284 Fstr_length uintptr 5285 Fstr_value uintptr 5286 Fcreate_window_function uintptr 5287 Fnormalized_sql uintptr 5288 Fstmt_isexplain uintptr 5289 Fvalue_frombind uintptr 5290 Fdrop_modules uintptr 5291 Fhard_heap_limit64 uintptr 5292 Furi_key uintptr 5293 Ffilename_database uintptr 5294 Ffilename_journal uintptr 5295 Ffilename_wal uintptr 5296 Fcreate_filename uintptr 5297 Ffree_filename uintptr 5298 Fdatabase_file_object uintptr 5299 Ftxn_state uintptr 5300 } /* sqlite3.h:1197:9 */ 5301 5302 // CAPI3REF: OS Interface Object 5303 // 5304 // An instance of the sqlite3_vfs object defines the interface between 5305 // the SQLite core and the underlying operating system. The "vfs" 5306 // in the name of the object stands for "virtual file system". See 5307 // the [VFS | VFS documentation] for further information. 5308 // 5309 // The VFS interface is sometimes extended by adding new methods onto 5310 // the end. Each time such an extension occurs, the iVersion field 5311 // is incremented. The iVersion value started out as 1 in 5312 // SQLite [version 3.5.0] on [dateof:3.5.0], then increased to 2 5313 // with SQLite [version 3.7.0] on [dateof:3.7.0], and then increased 5314 // to 3 with SQLite [version 3.7.6] on [dateof:3.7.6]. Additional fields 5315 // may be appended to the sqlite3_vfs object and the iVersion value 5316 // may increase again in future versions of SQLite. 5317 // Note that due to an oversight, the structure 5318 // of the sqlite3_vfs object changed in the transition from 5319 // SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0] 5320 // and yet the iVersion field was not increased. 5321 // 5322 // The szOsFile field is the size of the subclassed [sqlite3_file] 5323 // structure used by this VFS. mxPathname is the maximum length of 5324 // a pathname in this VFS. 5325 // 5326 // Registered sqlite3_vfs objects are kept on a linked list formed by 5327 // the pNext pointer. The [sqlite3_vfs_register()] 5328 // and [sqlite3_vfs_unregister()] interfaces manage this list 5329 // in a thread-safe way. The [sqlite3_vfs_find()] interface 5330 // searches the list. Neither the application code nor the VFS 5331 // implementation should use the pNext pointer. 5332 // 5333 // The pNext field is the only field in the sqlite3_vfs 5334 // structure that SQLite will ever modify. SQLite will only access 5335 // or modify this field while holding a particular static mutex. 5336 // The application should never modify anything within the sqlite3_vfs 5337 // object once the object has been registered. 5338 // 5339 // The zName field holds the name of the VFS module. The name must 5340 // be unique across all VFS modules. 5341 // 5342 // [[sqlite3_vfs.xOpen]] 5343 // ^SQLite guarantees that the zFilename parameter to xOpen 5344 // is either a NULL pointer or string obtained 5345 // from xFullPathname() with an optional suffix added. 5346 // ^If a suffix is added to the zFilename parameter, it will 5347 // consist of a single "-" character followed by no more than 5348 // 11 alphanumeric and/or "-" characters. 5349 // ^SQLite further guarantees that 5350 // the string will be valid and unchanged until xClose() is 5351 // called. Because of the previous sentence, 5352 // the [sqlite3_file] can safely store a pointer to the 5353 // filename if it needs to remember the filename for some reason. 5354 // If the zFilename parameter to xOpen is a NULL pointer then xOpen 5355 // must invent its own temporary name for the file. ^Whenever the 5356 // xFilename parameter is NULL it will also be the case that the 5357 // flags parameter will include [SQLITE_OPEN_DELETEONCLOSE]. 5358 // 5359 // The flags argument to xOpen() includes all bits set in 5360 // the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()] 5361 // or [sqlite3_open16()] is used, then flags includes at least 5362 // [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. 5363 // If xOpen() opens a file read-only then it sets *pOutFlags to 5364 // include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set. 5365 // 5366 // ^(SQLite will also add one of the following flags to the xOpen() 5367 // call, depending on the object being opened: 5368 // 5369 // <ul> 5370 // <li> [SQLITE_OPEN_MAIN_DB] 5371 // <li> [SQLITE_OPEN_MAIN_JOURNAL] 5372 // <li> [SQLITE_OPEN_TEMP_DB] 5373 // <li> [SQLITE_OPEN_TEMP_JOURNAL] 5374 // <li> [SQLITE_OPEN_TRANSIENT_DB] 5375 // <li> [SQLITE_OPEN_SUBJOURNAL] 5376 // <li> [SQLITE_OPEN_SUPER_JOURNAL] 5377 // <li> [SQLITE_OPEN_WAL] 5378 // </ul>)^ 5379 // 5380 // The file I/O implementation can use the object type flags to 5381 // change the way it deals with files. For example, an application 5382 // that does not care about crash recovery or rollback might make 5383 // the open of a journal file a no-op. Writes to this journal would 5384 // also be no-ops, and any attempt to read the journal would return 5385 // SQLITE_IOERR. Or the implementation might recognize that a database 5386 // file will be doing page-aligned sector reads and writes in a random 5387 // order and set up its I/O subsystem accordingly. 5388 // 5389 // SQLite might also add one of the following flags to the xOpen method: 5390 // 5391 // <ul> 5392 // <li> [SQLITE_OPEN_DELETEONCLOSE] 5393 // <li> [SQLITE_OPEN_EXCLUSIVE] 5394 // </ul> 5395 // 5396 // The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be 5397 // deleted when it is closed. ^The [SQLITE_OPEN_DELETEONCLOSE] 5398 // will be set for TEMP databases and their journals, transient 5399 // databases, and subjournals. 5400 // 5401 // ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction 5402 // with the [SQLITE_OPEN_CREATE] flag, which are both directly 5403 // analogous to the O_EXCL and O_CREAT flags of the POSIX open() 5404 // API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the 5405 // SQLITE_OPEN_CREATE, is used to indicate that file should always 5406 // be created, and that it is an error if it already exists. 5407 // It is <i>not</i> used to indicate the file should be opened 5408 // for exclusive access. 5409 // 5410 // ^At least szOsFile bytes of memory are allocated by SQLite 5411 // to hold the [sqlite3_file] structure passed as the third 5412 // argument to xOpen. The xOpen method does not have to 5413 // allocate the structure; it should just fill it in. Note that 5414 // the xOpen method must set the sqlite3_file.pMethods to either 5415 // a valid [sqlite3_io_methods] object or to NULL. xOpen must do 5416 // this even if the open fails. SQLite expects that the sqlite3_file.pMethods 5417 // element will be valid after xOpen returns regardless of the success 5418 // or failure of the xOpen call. 5419 // 5420 // [[sqlite3_vfs.xAccess]] 5421 // ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS] 5422 // to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to 5423 // test whether a file is readable and writable, or [SQLITE_ACCESS_READ] 5424 // to test whether a file is at least readable. The SQLITE_ACCESS_READ 5425 // flag is never actually used and is not implemented in the built-in 5426 // VFSes of SQLite. The file is named by the second argument and can be a 5427 // directory. The xAccess method returns [SQLITE_OK] on success or some 5428 // non-zero error code if there is an I/O error or if the name of 5429 // the file given in the second argument is illegal. If SQLITE_OK 5430 // is returned, then non-zero or zero is written into *pResOut to indicate 5431 // whether or not the file is accessible. 5432 // 5433 // ^SQLite will always allocate at least mxPathname+1 bytes for the 5434 // output buffer xFullPathname. The exact size of the output buffer 5435 // is also passed as a parameter to both methods. If the output buffer 5436 // is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is 5437 // handled as a fatal error by SQLite, vfs implementations should endeavor 5438 // to prevent this by setting mxPathname to a sufficiently large value. 5439 // 5440 // The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64() 5441 // interfaces are not strictly a part of the filesystem, but they are 5442 // included in the VFS structure for completeness. 5443 // The xRandomness() function attempts to return nBytes bytes 5444 // of good-quality randomness into zOut. The return value is 5445 // the actual number of bytes of randomness obtained. 5446 // The xSleep() method causes the calling thread to sleep for at 5447 // least the number of microseconds given. ^The xCurrentTime() 5448 // method returns a Julian Day Number for the current date and time as 5449 // a floating point value. 5450 // ^The xCurrentTimeInt64() method returns, as an integer, the Julian 5451 // Day Number multiplied by 86400000 (the number of milliseconds in 5452 // a 24-hour day). 5453 // ^SQLite will use the xCurrentTimeInt64() method to get the current 5454 // date and time if that method is available (if iVersion is 2 or 5455 // greater and the function pointer is not NULL) and will fall back 5456 // to xCurrentTime() if xCurrentTimeInt64() is unavailable. 5457 // 5458 // ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces 5459 // are not used by the SQLite core. These optional interfaces are provided 5460 // by some VFSes to facilitate testing of the VFS code. By overriding 5461 // system calls with functions under its control, a test program can 5462 // simulate faults and error conditions that would otherwise be difficult 5463 // or impossible to induce. The set of system calls that can be overridden 5464 // varies from one VFS to another, and from one version of the same VFS to the 5465 // next. Applications that use these interfaces must be prepared for any 5466 // or all of these interfaces to be NULL or for their behavior to change 5467 // from one release to the next. Applications must not attempt to access 5468 // any of these methods if the iVersion of the VFS is less than 3. 5469 type sqlite3_vfs1 = struct { 5470 FiVersion int32 5471 FszOsFile int32 5472 FmxPathname int32 5473 _ [4]byte 5474 FpNext uintptr 5475 FzName uintptr 5476 FpAppData uintptr 5477 FxOpen uintptr 5478 FxDelete uintptr 5479 FxAccess uintptr 5480 FxFullPathname uintptr 5481 FxDlOpen uintptr 5482 FxDlError uintptr 5483 FxDlSym uintptr 5484 FxDlClose uintptr 5485 FxRandomness uintptr 5486 FxSleep uintptr 5487 FxCurrentTime uintptr 5488 FxGetLastError uintptr 5489 FxCurrentTimeInt64 uintptr 5490 FxSetSystemCall uintptr 5491 FxGetSystemCall uintptr 5492 FxNextSystemCall uintptr 5493 } /* sqlite3.h:1368:9 */ 5494 5495 // CAPI3REF: OS Interface Object 5496 // 5497 // An instance of the sqlite3_vfs object defines the interface between 5498 // the SQLite core and the underlying operating system. The "vfs" 5499 // in the name of the object stands for "virtual file system". See 5500 // the [VFS | VFS documentation] for further information. 5501 // 5502 // The VFS interface is sometimes extended by adding new methods onto 5503 // the end. Each time such an extension occurs, the iVersion field 5504 // is incremented. The iVersion value started out as 1 in 5505 // SQLite [version 3.5.0] on [dateof:3.5.0], then increased to 2 5506 // with SQLite [version 3.7.0] on [dateof:3.7.0], and then increased 5507 // to 3 with SQLite [version 3.7.6] on [dateof:3.7.6]. Additional fields 5508 // may be appended to the sqlite3_vfs object and the iVersion value 5509 // may increase again in future versions of SQLite. 5510 // Note that due to an oversight, the structure 5511 // of the sqlite3_vfs object changed in the transition from 5512 // SQLite [version 3.5.9] to [version 3.6.0] on [dateof:3.6.0] 5513 // and yet the iVersion field was not increased. 5514 // 5515 // The szOsFile field is the size of the subclassed [sqlite3_file] 5516 // structure used by this VFS. mxPathname is the maximum length of 5517 // a pathname in this VFS. 5518 // 5519 // Registered sqlite3_vfs objects are kept on a linked list formed by 5520 // the pNext pointer. The [sqlite3_vfs_register()] 5521 // and [sqlite3_vfs_unregister()] interfaces manage this list 5522 // in a thread-safe way. The [sqlite3_vfs_find()] interface 5523 // searches the list. Neither the application code nor the VFS 5524 // implementation should use the pNext pointer. 5525 // 5526 // The pNext field is the only field in the sqlite3_vfs 5527 // structure that SQLite will ever modify. SQLite will only access 5528 // or modify this field while holding a particular static mutex. 5529 // The application should never modify anything within the sqlite3_vfs 5530 // object once the object has been registered. 5531 // 5532 // The zName field holds the name of the VFS module. The name must 5533 // be unique across all VFS modules. 5534 // 5535 // [[sqlite3_vfs.xOpen]] 5536 // ^SQLite guarantees that the zFilename parameter to xOpen 5537 // is either a NULL pointer or string obtained 5538 // from xFullPathname() with an optional suffix added. 5539 // ^If a suffix is added to the zFilename parameter, it will 5540 // consist of a single "-" character followed by no more than 5541 // 11 alphanumeric and/or "-" characters. 5542 // ^SQLite further guarantees that 5543 // the string will be valid and unchanged until xClose() is 5544 // called. Because of the previous sentence, 5545 // the [sqlite3_file] can safely store a pointer to the 5546 // filename if it needs to remember the filename for some reason. 5547 // If the zFilename parameter to xOpen is a NULL pointer then xOpen 5548 // must invent its own temporary name for the file. ^Whenever the 5549 // xFilename parameter is NULL it will also be the case that the 5550 // flags parameter will include [SQLITE_OPEN_DELETEONCLOSE]. 5551 // 5552 // The flags argument to xOpen() includes all bits set in 5553 // the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()] 5554 // or [sqlite3_open16()] is used, then flags includes at least 5555 // [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. 5556 // If xOpen() opens a file read-only then it sets *pOutFlags to 5557 // include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set. 5558 // 5559 // ^(SQLite will also add one of the following flags to the xOpen() 5560 // call, depending on the object being opened: 5561 // 5562 // <ul> 5563 // <li> [SQLITE_OPEN_MAIN_DB] 5564 // <li> [SQLITE_OPEN_MAIN_JOURNAL] 5565 // <li> [SQLITE_OPEN_TEMP_DB] 5566 // <li> [SQLITE_OPEN_TEMP_JOURNAL] 5567 // <li> [SQLITE_OPEN_TRANSIENT_DB] 5568 // <li> [SQLITE_OPEN_SUBJOURNAL] 5569 // <li> [SQLITE_OPEN_SUPER_JOURNAL] 5570 // <li> [SQLITE_OPEN_WAL] 5571 // </ul>)^ 5572 // 5573 // The file I/O implementation can use the object type flags to 5574 // change the way it deals with files. For example, an application 5575 // that does not care about crash recovery or rollback might make 5576 // the open of a journal file a no-op. Writes to this journal would 5577 // also be no-ops, and any attempt to read the journal would return 5578 // SQLITE_IOERR. Or the implementation might recognize that a database 5579 // file will be doing page-aligned sector reads and writes in a random 5580 // order and set up its I/O subsystem accordingly. 5581 // 5582 // SQLite might also add one of the following flags to the xOpen method: 5583 // 5584 // <ul> 5585 // <li> [SQLITE_OPEN_DELETEONCLOSE] 5586 // <li> [SQLITE_OPEN_EXCLUSIVE] 5587 // </ul> 5588 // 5589 // The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be 5590 // deleted when it is closed. ^The [SQLITE_OPEN_DELETEONCLOSE] 5591 // will be set for TEMP databases and their journals, transient 5592 // databases, and subjournals. 5593 // 5594 // ^The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction 5595 // with the [SQLITE_OPEN_CREATE] flag, which are both directly 5596 // analogous to the O_EXCL and O_CREAT flags of the POSIX open() 5597 // API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the 5598 // SQLITE_OPEN_CREATE, is used to indicate that file should always 5599 // be created, and that it is an error if it already exists. 5600 // It is <i>not</i> used to indicate the file should be opened 5601 // for exclusive access. 5602 // 5603 // ^At least szOsFile bytes of memory are allocated by SQLite 5604 // to hold the [sqlite3_file] structure passed as the third 5605 // argument to xOpen. The xOpen method does not have to 5606 // allocate the structure; it should just fill it in. Note that 5607 // the xOpen method must set the sqlite3_file.pMethods to either 5608 // a valid [sqlite3_io_methods] object or to NULL. xOpen must do 5609 // this even if the open fails. SQLite expects that the sqlite3_file.pMethods 5610 // element will be valid after xOpen returns regardless of the success 5611 // or failure of the xOpen call. 5612 // 5613 // [[sqlite3_vfs.xAccess]] 5614 // ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS] 5615 // to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to 5616 // test whether a file is readable and writable, or [SQLITE_ACCESS_READ] 5617 // to test whether a file is at least readable. The SQLITE_ACCESS_READ 5618 // flag is never actually used and is not implemented in the built-in 5619 // VFSes of SQLite. The file is named by the second argument and can be a 5620 // directory. The xAccess method returns [SQLITE_OK] on success or some 5621 // non-zero error code if there is an I/O error or if the name of 5622 // the file given in the second argument is illegal. If SQLITE_OK 5623 // is returned, then non-zero or zero is written into *pResOut to indicate 5624 // whether or not the file is accessible. 5625 // 5626 // ^SQLite will always allocate at least mxPathname+1 bytes for the 5627 // output buffer xFullPathname. The exact size of the output buffer 5628 // is also passed as a parameter to both methods. If the output buffer 5629 // is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is 5630 // handled as a fatal error by SQLite, vfs implementations should endeavor 5631 // to prevent this by setting mxPathname to a sufficiently large value. 5632 // 5633 // The xRandomness(), xSleep(), xCurrentTime(), and xCurrentTimeInt64() 5634 // interfaces are not strictly a part of the filesystem, but they are 5635 // included in the VFS structure for completeness. 5636 // The xRandomness() function attempts to return nBytes bytes 5637 // of good-quality randomness into zOut. The return value is 5638 // the actual number of bytes of randomness obtained. 5639 // The xSleep() method causes the calling thread to sleep for at 5640 // least the number of microseconds given. ^The xCurrentTime() 5641 // method returns a Julian Day Number for the current date and time as 5642 // a floating point value. 5643 // ^The xCurrentTimeInt64() method returns, as an integer, the Julian 5644 // Day Number multiplied by 86400000 (the number of milliseconds in 5645 // a 24-hour day). 5646 // ^SQLite will use the xCurrentTimeInt64() method to get the current 5647 // date and time if that method is available (if iVersion is 2 or 5648 // greater and the function pointer is not NULL) and will fall back 5649 // to xCurrentTime() if xCurrentTimeInt64() is unavailable. 5650 // 5651 // ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces 5652 // are not used by the SQLite core. These optional interfaces are provided 5653 // by some VFSes to facilitate testing of the VFS code. By overriding 5654 // system calls with functions under its control, a test program can 5655 // simulate faults and error conditions that would otherwise be difficult 5656 // or impossible to induce. The set of system calls that can be overridden 5657 // varies from one VFS to another, and from one version of the same VFS to the 5658 // next. Applications that use these interfaces must be prepared for any 5659 // or all of these interfaces to be NULL or for their behavior to change 5660 // from one release to the next. Applications must not attempt to access 5661 // any of these methods if the iVersion of the VFS is less than 3. 5662 type sqlite3_vfs = sqlite3_vfs1 /* sqlite3.h:1368:28 */ 5663 type sqlite3_syscall_ptr = uintptr /* sqlite3.h:1369:14 */ 5664 5665 // CAPI3REF: Memory Allocation Routines 5666 // 5667 // An instance of this object defines the interface between SQLite 5668 // and low-level memory allocation routines. 5669 // 5670 // This object is used in only one place in the SQLite interface. 5671 // A pointer to an instance of this object is the argument to 5672 // [sqlite3_config()] when the configuration option is 5673 // [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC]. 5674 // By creating an instance of this object 5675 // and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC]) 5676 // during configuration, an application can specify an alternative 5677 // memory allocation subsystem for SQLite to use for all of its 5678 // dynamic memory needs. 5679 // 5680 // Note that SQLite comes with several [built-in memory allocators] 5681 // that are perfectly adequate for the overwhelming majority of applications 5682 // and that this object is only useful to a tiny minority of applications 5683 // with specialized memory allocation requirements. This object is 5684 // also used during testing of SQLite in order to specify an alternative 5685 // memory allocator that simulates memory out-of-memory conditions in 5686 // order to verify that SQLite recovers gracefully from such 5687 // conditions. 5688 // 5689 // The xMalloc, xRealloc, and xFree methods must work like the 5690 // malloc(), realloc() and free() functions from the standard C library. 5691 // ^SQLite guarantees that the second argument to 5692 // xRealloc is always a value returned by a prior call to xRoundup. 5693 // 5694 // xSize should return the allocated size of a memory allocation 5695 // previously obtained from xMalloc or xRealloc. The allocated size 5696 // is always at least as big as the requested size but may be larger. 5697 // 5698 // The xRoundup method returns what would be the allocated size of 5699 // a memory allocation given a particular requested size. Most memory 5700 // allocators round up memory allocations at least to the next multiple 5701 // of 8. Some allocators round up to a larger multiple or to a power of 2. 5702 // Every memory allocation request coming in through [sqlite3_malloc()] 5703 // or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0, 5704 // that causes the corresponding memory allocation to fail. 5705 // 5706 // The xInit method initializes the memory allocator. For example, 5707 // it might allocate any required mutexes or initialize internal data 5708 // structures. The xShutdown method is invoked (indirectly) by 5709 // [sqlite3_shutdown()] and should deallocate any resources acquired 5710 // by xInit. The pAppData pointer is used as the only parameter to 5711 // xInit and xShutdown. 5712 // 5713 // SQLite holds the [SQLITE_MUTEX_STATIC_MAIN] mutex when it invokes 5714 // the xInit method, so the xInit method need not be threadsafe. The 5715 // xShutdown method is only called from [sqlite3_shutdown()] so it does 5716 // not need to be threadsafe either. For all other methods, SQLite 5717 // holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the 5718 // [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which 5719 // it is by default) and so the methods are automatically serialized. 5720 // However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other 5721 // methods must be threadsafe or else make their own arrangements for 5722 // serialization. 5723 // 5724 // SQLite will never invoke xInit() more than once without an intervening 5725 // call to xShutdown(). 5726 type sqlite3_mem_methods1 = struct { 5727 FxMalloc uintptr 5728 FxFree uintptr 5729 FxRealloc uintptr 5730 FxSize uintptr 5731 FxRoundup uintptr 5732 FxInit uintptr 5733 FxShutdown uintptr 5734 FpAppData uintptr 5735 } /* sqlite3.h:1666:9 */ 5736 5737 // CAPI3REF: Memory Allocation Routines 5738 // 5739 // An instance of this object defines the interface between SQLite 5740 // and low-level memory allocation routines. 5741 // 5742 // This object is used in only one place in the SQLite interface. 5743 // A pointer to an instance of this object is the argument to 5744 // [sqlite3_config()] when the configuration option is 5745 // [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC]. 5746 // By creating an instance of this object 5747 // and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC]) 5748 // during configuration, an application can specify an alternative 5749 // memory allocation subsystem for SQLite to use for all of its 5750 // dynamic memory needs. 5751 // 5752 // Note that SQLite comes with several [built-in memory allocators] 5753 // that are perfectly adequate for the overwhelming majority of applications 5754 // and that this object is only useful to a tiny minority of applications 5755 // with specialized memory allocation requirements. This object is 5756 // also used during testing of SQLite in order to specify an alternative 5757 // memory allocator that simulates memory out-of-memory conditions in 5758 // order to verify that SQLite recovers gracefully from such 5759 // conditions. 5760 // 5761 // The xMalloc, xRealloc, and xFree methods must work like the 5762 // malloc(), realloc() and free() functions from the standard C library. 5763 // ^SQLite guarantees that the second argument to 5764 // xRealloc is always a value returned by a prior call to xRoundup. 5765 // 5766 // xSize should return the allocated size of a memory allocation 5767 // previously obtained from xMalloc or xRealloc. The allocated size 5768 // is always at least as big as the requested size but may be larger. 5769 // 5770 // The xRoundup method returns what would be the allocated size of 5771 // a memory allocation given a particular requested size. Most memory 5772 // allocators round up memory allocations at least to the next multiple 5773 // of 8. Some allocators round up to a larger multiple or to a power of 2. 5774 // Every memory allocation request coming in through [sqlite3_malloc()] 5775 // or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0, 5776 // that causes the corresponding memory allocation to fail. 5777 // 5778 // The xInit method initializes the memory allocator. For example, 5779 // it might allocate any required mutexes or initialize internal data 5780 // structures. The xShutdown method is invoked (indirectly) by 5781 // [sqlite3_shutdown()] and should deallocate any resources acquired 5782 // by xInit. The pAppData pointer is used as the only parameter to 5783 // xInit and xShutdown. 5784 // 5785 // SQLite holds the [SQLITE_MUTEX_STATIC_MAIN] mutex when it invokes 5786 // the xInit method, so the xInit method need not be threadsafe. The 5787 // xShutdown method is only called from [sqlite3_shutdown()] so it does 5788 // not need to be threadsafe either. For all other methods, SQLite 5789 // holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the 5790 // [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which 5791 // it is by default) and so the methods are automatically serialized. 5792 // However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other 5793 // methods must be threadsafe or else make their own arrangements for 5794 // serialization. 5795 // 5796 // SQLite will never invoke xInit() more than once without an intervening 5797 // call to xShutdown(). 5798 type sqlite3_mem_methods = sqlite3_mem_methods1 /* sqlite3.h:1666:36 */ 5799 5800 // CAPI3REF: Dynamically Typed Value Object 5801 // KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} 5802 // 5803 // SQLite uses the sqlite3_value object to represent all values 5804 // that can be stored in a database table. SQLite uses dynamic typing 5805 // for the values it stores. ^Values stored in sqlite3_value objects 5806 // can be integers, floating point values, strings, BLOBs, or NULL. 5807 // 5808 // An sqlite3_value object may be either "protected" or "unprotected". 5809 // Some interfaces require a protected sqlite3_value. Other interfaces 5810 // will accept either a protected or an unprotected sqlite3_value. 5811 // Every interface that accepts sqlite3_value arguments specifies 5812 // whether or not it requires a protected sqlite3_value. The 5813 // [sqlite3_value_dup()] interface can be used to construct a new 5814 // protected sqlite3_value from an unprotected sqlite3_value. 5815 // 5816 // The terms "protected" and "unprotected" refer to whether or not 5817 // a mutex is held. An internal mutex is held for a protected 5818 // sqlite3_value object but no mutex is held for an unprotected 5819 // sqlite3_value object. If SQLite is compiled to be single-threaded 5820 // (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0) 5821 // or if SQLite is run in one of reduced mutex modes 5822 // [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD] 5823 // then there is no distinction between protected and unprotected 5824 // sqlite3_value objects and they can be used interchangeably. However, 5825 // for maximum code portability it is recommended that applications 5826 // still make the distinction between protected and unprotected 5827 // sqlite3_value objects even when not strictly required. 5828 // 5829 // ^The sqlite3_value objects that are passed as parameters into the 5830 // implementation of [application-defined SQL functions] are protected. 5831 // ^The sqlite3_value object returned by 5832 // [sqlite3_column_value()] is unprotected. 5833 // Unprotected sqlite3_value objects may only be used as arguments 5834 // to [sqlite3_result_value()], [sqlite3_bind_value()], and 5835 // [sqlite3_value_dup()]. 5836 // The [sqlite3_value_blob | sqlite3_value_type()] family of 5837 // interfaces require protected sqlite3_value objects. 5838 type sqlite3_value1 = struct { 5839 Fu struct{ Fr float64 } 5840 Fflags u16 5841 Fenc u8 5842 FeSubtype u8 5843 Fn int32 5844 Fz uintptr 5845 FzMalloc uintptr 5846 FszMalloc int32 5847 FuTemp u322 5848 Fdb uintptr 5849 FxDel uintptr 5850 } /* sqlite3.h:249:9 */ 5851 5852 // CAPI3REF: SQL Function Context Object 5853 // 5854 // The context in which an SQL function executes is stored in an 5855 // sqlite3_context object. ^A pointer to an sqlite3_context object 5856 // is always first parameter to [application-defined SQL functions]. 5857 // The application-defined SQL function implementation will pass this 5858 // pointer through into calls to [sqlite3_result_int | sqlite3_result()], 5859 // [sqlite3_aggregate_context()], [sqlite3_user_data()], 5860 // [sqlite3_context_db_handle()], [sqlite3_get_auxdata()], 5861 // and/or [sqlite3_set_auxdata()]. 5862 type sqlite3_context1 = struct { 5863 FpOut uintptr 5864 FpFunc uintptr 5865 FpMem uintptr 5866 FpVdbe uintptr 5867 FiOp int32 5868 FisError int32 5869 FskipFlag u8 5870 Fargc u8 5871 _ [6]byte 5872 Fargv [1]uintptr 5873 } /* sqlite3.h:249:9 */ 5874 5875 // CAPI3REF: Constants Defining Special Destructor Behavior 5876 // 5877 // These are special values for the destructor that is passed in as the 5878 // final argument to routines like [sqlite3_result_blob()]. ^If the destructor 5879 // argument is SQLITE_STATIC, it means that the content pointer is constant 5880 // and will never change. It does not need to be destroyed. ^The 5881 // SQLITE_TRANSIENT value means that the content will likely change in 5882 // the near future and that SQLite should make its own private copy of 5883 // the content before returning. 5884 // 5885 // The typedef is necessary to work around problems in certain 5886 // C++ compilers. 5887 type sqlite3_destructor_type = uintptr /* sqlite3.h:5635:14 */ 5888 5889 // The interface to the virtual-table mechanism is currently considered 5890 // to be experimental. The interface might change in incompatible ways. 5891 // If this is a problem for you, do not use the interface at this time. 5892 // 5893 // When the virtual-table mechanism stabilizes, we will declare the 5894 // interface fixed, support it indefinitely, and remove this comment. 5895 5896 // Structures used by the virtual table interface 5897 type sqlite3_vtab1 = struct { 5898 FpModule uintptr 5899 FnRef int32 5900 _ [4]byte 5901 FzErrMsg uintptr 5902 } /* sqlite3.h:6754:9 */ 5903 5904 // The interface to the virtual-table mechanism is currently considered 5905 // to be experimental. The interface might change in incompatible ways. 5906 // If this is a problem for you, do not use the interface at this time. 5907 // 5908 // When the virtual-table mechanism stabilizes, we will declare the 5909 // interface fixed, support it indefinitely, and remove this comment. 5910 5911 // Structures used by the virtual table interface 5912 type sqlite3_vtab = sqlite3_vtab1 /* sqlite3.h:6754:29 */ 5913 type sqlite3_index_info1 = struct { 5914 FnConstraint int32 5915 _ [4]byte 5916 FaConstraint uintptr 5917 FnOrderBy int32 5918 _ [4]byte 5919 FaOrderBy uintptr 5920 FaConstraintUsage uintptr 5921 FidxNum int32 5922 _ [4]byte 5923 FidxStr uintptr 5924 FneedToFreeIdxStr int32 5925 ForderByConsumed int32 5926 FestimatedCost float64 5927 FestimatedRows sqlite3_int64 5928 FidxFlags int32 5929 _ [4]byte 5930 FcolUsed sqlite3_uint64 5931 } /* sqlite3.h:6755:9 */ 5932 5933 type sqlite3_index_info = sqlite3_index_info1 /* sqlite3.h:6755:35 */ 5934 type sqlite3_vtab_cursor1 = struct{ FpVtab uintptr } /* sqlite3.h:6756:9 */ 5935 5936 type sqlite3_vtab_cursor = sqlite3_vtab_cursor1 /* sqlite3.h:6756:36 */ 5937 type sqlite3_module1 = struct { 5938 FiVersion int32 5939 _ [4]byte 5940 FxCreate uintptr 5941 FxConnect uintptr 5942 FxBestIndex uintptr 5943 FxDisconnect uintptr 5944 FxDestroy uintptr 5945 FxOpen uintptr 5946 FxClose uintptr 5947 FxFilter uintptr 5948 FxNext uintptr 5949 FxEof uintptr 5950 FxColumn uintptr 5951 FxRowid uintptr 5952 FxUpdate uintptr 5953 FxBegin uintptr 5954 FxSync uintptr 5955 FxCommit uintptr 5956 FxRollback uintptr 5957 FxFindFunction uintptr 5958 FxRename uintptr 5959 FxSavepoint uintptr 5960 FxRelease uintptr 5961 FxRollbackTo uintptr 5962 FxShadowName uintptr 5963 } /* sqlite3.h:6754:9 */ 5964 5965 type sqlite3_module = sqlite3_module1 /* sqlite3.h:6757:31 */ 5966 5967 // CAPI3REF: Virtual Table Indexing Information 5968 // KEYWORDS: sqlite3_index_info 5969 // 5970 // The sqlite3_index_info structure and its substructures is used as part 5971 // of the [virtual table] interface to 5972 // pass information into and receive the reply from the [xBestIndex] 5973 // method of a [virtual table module]. The fields under **Inputs** are the 5974 // inputs to xBestIndex and are read-only. xBestIndex inserts its 5975 // results into the **Outputs** fields. 5976 // 5977 // ^(The aConstraint[] array records WHERE clause constraints of the form: 5978 // 5979 // <blockquote>column OP expr</blockquote> 5980 // 5981 // where OP is =, <, <=, >, or >=.)^ ^(The particular operator is 5982 // stored in aConstraint[].op using one of the 5983 // [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^ 5984 // ^(The index of the column is stored in 5985 // aConstraint[].iColumn.)^ ^(aConstraint[].usable is TRUE if the 5986 // expr on the right-hand side can be evaluated (and thus the constraint 5987 // is usable) and false if it cannot.)^ 5988 // 5989 // ^The optimizer automatically inverts terms of the form "expr OP column" 5990 // and makes other simplifications to the WHERE clause in an attempt to 5991 // get as many WHERE clause terms into the form shown above as possible. 5992 // ^The aConstraint[] array only reports WHERE clause terms that are 5993 // relevant to the particular virtual table being queried. 5994 // 5995 // ^Information about the ORDER BY clause is stored in aOrderBy[]. 5996 // ^Each term of aOrderBy records a column of the ORDER BY clause. 5997 // 5998 // The colUsed field indicates which columns of the virtual table may be 5999 // required by the current scan. Virtual table columns are numbered from 6000 // zero in the order in which they appear within the CREATE TABLE statement 6001 // passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62), 6002 // the corresponding bit is set within the colUsed mask if the column may be 6003 // required by SQLite. If the table has at least 64 columns and any column 6004 // to the right of the first 63 is required, then bit 63 of colUsed is also 6005 // set. In other words, column iCol may be required if the expression 6006 // (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to 6007 // non-zero. 6008 // 6009 // The [xBestIndex] method must fill aConstraintUsage[] with information 6010 // about what parameters to pass to xFilter. ^If argvIndex>0 then 6011 // the right-hand side of the corresponding aConstraint[] is evaluated 6012 // and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit 6013 // is true, then the constraint is assumed to be fully handled by the 6014 // virtual table and might not be checked again by the byte code.)^ ^(The 6015 // aConstraintUsage[].omit flag is an optimization hint. When the omit flag 6016 // is left in its default setting of false, the constraint will always be 6017 // checked separately in byte code. If the omit flag is change to true, then 6018 // the constraint may or may not be checked in byte code. In other words, 6019 // when the omit flag is true there is no guarantee that the constraint will 6020 // not be checked again using byte code.)^ 6021 // 6022 // ^The idxNum and idxPtr values are recorded and passed into the 6023 // [xFilter] method. 6024 // ^[sqlite3_free()] is used to free idxPtr if and only if 6025 // needToFreeIdxPtr is true. 6026 // 6027 // ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in 6028 // the correct order to satisfy the ORDER BY clause so that no separate 6029 // sorting step is required. 6030 // 6031 // ^The estimatedCost value is an estimate of the cost of a particular 6032 // strategy. A cost of N indicates that the cost of the strategy is similar 6033 // to a linear scan of an SQLite table with N rows. A cost of log(N) 6034 // indicates that the expense of the operation is similar to that of a 6035 // binary search on a unique indexed field of an SQLite table with N rows. 6036 // 6037 // ^The estimatedRows value is an estimate of the number of rows that 6038 // will be returned by the strategy. 6039 // 6040 // The xBestIndex method may optionally populate the idxFlags field with a 6041 // mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag - 6042 // SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite 6043 // assumes that the strategy may visit at most one row. 6044 // 6045 // Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then 6046 // SQLite also assumes that if a call to the xUpdate() method is made as 6047 // part of the same statement to delete or update a virtual table row and the 6048 // implementation returns SQLITE_CONSTRAINT, then there is no need to rollback 6049 // any database changes. In other words, if the xUpdate() returns 6050 // SQLITE_CONSTRAINT, the database contents must be exactly as they were 6051 // before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not 6052 // set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by 6053 // the xUpdate method are automatically rolled back by SQLite. 6054 // 6055 // IMPORTANT: The estimatedRows field was added to the sqlite3_index_info 6056 // structure for SQLite [version 3.8.2] ([dateof:3.8.2]). 6057 // If a virtual table extension is 6058 // used with an SQLite version earlier than 3.8.2, the results of attempting 6059 // to read or write the estimatedRows field are undefined (but are likely 6060 // to include crashing the application). The estimatedRows field should 6061 // therefore only be used if [sqlite3_libversion_number()] returns a 6062 // value greater than or equal to 3008002. Similarly, the idxFlags field 6063 // was added for [version 3.9.0] ([dateof:3.9.0]). 6064 // It may therefore only be used if 6065 // sqlite3_libversion_number() returns a value greater than or equal to 6066 // 3009000. 6067 type sqlite3_index_constraint = struct { 6068 FiColumn int32 6069 Fop uint8 6070 Fusable uint8 6071 _ [2]byte 6072 FiTermOffset int32 6073 } /* sqlite3.h:6755:9 */ 6074 6075 // CAPI3REF: Virtual Table Indexing Information 6076 // KEYWORDS: sqlite3_index_info 6077 // 6078 // The sqlite3_index_info structure and its substructures is used as part 6079 // of the [virtual table] interface to 6080 // pass information into and receive the reply from the [xBestIndex] 6081 // method of a [virtual table module]. The fields under **Inputs** are the 6082 // inputs to xBestIndex and are read-only. xBestIndex inserts its 6083 // results into the **Outputs** fields. 6084 // 6085 // ^(The aConstraint[] array records WHERE clause constraints of the form: 6086 // 6087 // <blockquote>column OP expr</blockquote> 6088 // 6089 // where OP is =, <, <=, >, or >=.)^ ^(The particular operator is 6090 // stored in aConstraint[].op using one of the 6091 // [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^ 6092 // ^(The index of the column is stored in 6093 // aConstraint[].iColumn.)^ ^(aConstraint[].usable is TRUE if the 6094 // expr on the right-hand side can be evaluated (and thus the constraint 6095 // is usable) and false if it cannot.)^ 6096 // 6097 // ^The optimizer automatically inverts terms of the form "expr OP column" 6098 // and makes other simplifications to the WHERE clause in an attempt to 6099 // get as many WHERE clause terms into the form shown above as possible. 6100 // ^The aConstraint[] array only reports WHERE clause terms that are 6101 // relevant to the particular virtual table being queried. 6102 // 6103 // ^Information about the ORDER BY clause is stored in aOrderBy[]. 6104 // ^Each term of aOrderBy records a column of the ORDER BY clause. 6105 // 6106 // The colUsed field indicates which columns of the virtual table may be 6107 // required by the current scan. Virtual table columns are numbered from 6108 // zero in the order in which they appear within the CREATE TABLE statement 6109 // passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62), 6110 // the corresponding bit is set within the colUsed mask if the column may be 6111 // required by SQLite. If the table has at least 64 columns and any column 6112 // to the right of the first 63 is required, then bit 63 of colUsed is also 6113 // set. In other words, column iCol may be required if the expression 6114 // (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to 6115 // non-zero. 6116 // 6117 // The [xBestIndex] method must fill aConstraintUsage[] with information 6118 // about what parameters to pass to xFilter. ^If argvIndex>0 then 6119 // the right-hand side of the corresponding aConstraint[] is evaluated 6120 // and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit 6121 // is true, then the constraint is assumed to be fully handled by the 6122 // virtual table and might not be checked again by the byte code.)^ ^(The 6123 // aConstraintUsage[].omit flag is an optimization hint. When the omit flag 6124 // is left in its default setting of false, the constraint will always be 6125 // checked separately in byte code. If the omit flag is change to true, then 6126 // the constraint may or may not be checked in byte code. In other words, 6127 // when the omit flag is true there is no guarantee that the constraint will 6128 // not be checked again using byte code.)^ 6129 // 6130 // ^The idxNum and idxPtr values are recorded and passed into the 6131 // [xFilter] method. 6132 // ^[sqlite3_free()] is used to free idxPtr if and only if 6133 // needToFreeIdxPtr is true. 6134 // 6135 // ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in 6136 // the correct order to satisfy the ORDER BY clause so that no separate 6137 // sorting step is required. 6138 // 6139 // ^The estimatedCost value is an estimate of the cost of a particular 6140 // strategy. A cost of N indicates that the cost of the strategy is similar 6141 // to a linear scan of an SQLite table with N rows. A cost of log(N) 6142 // indicates that the expense of the operation is similar to that of a 6143 // binary search on a unique indexed field of an SQLite table with N rows. 6144 // 6145 // ^The estimatedRows value is an estimate of the number of rows that 6146 // will be returned by the strategy. 6147 // 6148 // The xBestIndex method may optionally populate the idxFlags field with a 6149 // mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag - 6150 // SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite 6151 // assumes that the strategy may visit at most one row. 6152 // 6153 // Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then 6154 // SQLite also assumes that if a call to the xUpdate() method is made as 6155 // part of the same statement to delete or update a virtual table row and the 6156 // implementation returns SQLITE_CONSTRAINT, then there is no need to rollback 6157 // any database changes. In other words, if the xUpdate() returns 6158 // SQLITE_CONSTRAINT, the database contents must be exactly as they were 6159 // before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not 6160 // set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by 6161 // the xUpdate method are automatically rolled back by SQLite. 6162 // 6163 // IMPORTANT: The estimatedRows field was added to the sqlite3_index_info 6164 // structure for SQLite [version 3.8.2] ([dateof:3.8.2]). 6165 // If a virtual table extension is 6166 // used with an SQLite version earlier than 3.8.2, the results of attempting 6167 // to read or write the estimatedRows field are undefined (but are likely 6168 // to include crashing the application). The estimatedRows field should 6169 // therefore only be used if [sqlite3_libversion_number()] returns a 6170 // value greater than or equal to 3008002. Similarly, the idxFlags field 6171 // was added for [version 3.9.0] ([dateof:3.9.0]). 6172 // It may therefore only be used if 6173 // sqlite3_libversion_number() returns a value greater than or equal to 6174 // 3009000. 6175 type sqlite3_index_orderby = struct { 6176 FiColumn int32 6177 Fdesc uint8 6178 _ [3]byte 6179 } /* sqlite3.h:6755:9 */ 6180 6181 // CAPI3REF: Virtual Table Indexing Information 6182 // KEYWORDS: sqlite3_index_info 6183 // 6184 // The sqlite3_index_info structure and its substructures is used as part 6185 // of the [virtual table] interface to 6186 // pass information into and receive the reply from the [xBestIndex] 6187 // method of a [virtual table module]. The fields under **Inputs** are the 6188 // inputs to xBestIndex and are read-only. xBestIndex inserts its 6189 // results into the **Outputs** fields. 6190 // 6191 // ^(The aConstraint[] array records WHERE clause constraints of the form: 6192 // 6193 // <blockquote>column OP expr</blockquote> 6194 // 6195 // where OP is =, <, <=, >, or >=.)^ ^(The particular operator is 6196 // stored in aConstraint[].op using one of the 6197 // [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^ 6198 // ^(The index of the column is stored in 6199 // aConstraint[].iColumn.)^ ^(aConstraint[].usable is TRUE if the 6200 // expr on the right-hand side can be evaluated (and thus the constraint 6201 // is usable) and false if it cannot.)^ 6202 // 6203 // ^The optimizer automatically inverts terms of the form "expr OP column" 6204 // and makes other simplifications to the WHERE clause in an attempt to 6205 // get as many WHERE clause terms into the form shown above as possible. 6206 // ^The aConstraint[] array only reports WHERE clause terms that are 6207 // relevant to the particular virtual table being queried. 6208 // 6209 // ^Information about the ORDER BY clause is stored in aOrderBy[]. 6210 // ^Each term of aOrderBy records a column of the ORDER BY clause. 6211 // 6212 // The colUsed field indicates which columns of the virtual table may be 6213 // required by the current scan. Virtual table columns are numbered from 6214 // zero in the order in which they appear within the CREATE TABLE statement 6215 // passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62), 6216 // the corresponding bit is set within the colUsed mask if the column may be 6217 // required by SQLite. If the table has at least 64 columns and any column 6218 // to the right of the first 63 is required, then bit 63 of colUsed is also 6219 // set. In other words, column iCol may be required if the expression 6220 // (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to 6221 // non-zero. 6222 // 6223 // The [xBestIndex] method must fill aConstraintUsage[] with information 6224 // about what parameters to pass to xFilter. ^If argvIndex>0 then 6225 // the right-hand side of the corresponding aConstraint[] is evaluated 6226 // and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit 6227 // is true, then the constraint is assumed to be fully handled by the 6228 // virtual table and might not be checked again by the byte code.)^ ^(The 6229 // aConstraintUsage[].omit flag is an optimization hint. When the omit flag 6230 // is left in its default setting of false, the constraint will always be 6231 // checked separately in byte code. If the omit flag is change to true, then 6232 // the constraint may or may not be checked in byte code. In other words, 6233 // when the omit flag is true there is no guarantee that the constraint will 6234 // not be checked again using byte code.)^ 6235 // 6236 // ^The idxNum and idxPtr values are recorded and passed into the 6237 // [xFilter] method. 6238 // ^[sqlite3_free()] is used to free idxPtr if and only if 6239 // needToFreeIdxPtr is true. 6240 // 6241 // ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in 6242 // the correct order to satisfy the ORDER BY clause so that no separate 6243 // sorting step is required. 6244 // 6245 // ^The estimatedCost value is an estimate of the cost of a particular 6246 // strategy. A cost of N indicates that the cost of the strategy is similar 6247 // to a linear scan of an SQLite table with N rows. A cost of log(N) 6248 // indicates that the expense of the operation is similar to that of a 6249 // binary search on a unique indexed field of an SQLite table with N rows. 6250 // 6251 // ^The estimatedRows value is an estimate of the number of rows that 6252 // will be returned by the strategy. 6253 // 6254 // The xBestIndex method may optionally populate the idxFlags field with a 6255 // mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag - 6256 // SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite 6257 // assumes that the strategy may visit at most one row. 6258 // 6259 // Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then 6260 // SQLite also assumes that if a call to the xUpdate() method is made as 6261 // part of the same statement to delete or update a virtual table row and the 6262 // implementation returns SQLITE_CONSTRAINT, then there is no need to rollback 6263 // any database changes. In other words, if the xUpdate() returns 6264 // SQLITE_CONSTRAINT, the database contents must be exactly as they were 6265 // before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not 6266 // set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by 6267 // the xUpdate method are automatically rolled back by SQLite. 6268 // 6269 // IMPORTANT: The estimatedRows field was added to the sqlite3_index_info 6270 // structure for SQLite [version 3.8.2] ([dateof:3.8.2]). 6271 // If a virtual table extension is 6272 // used with an SQLite version earlier than 3.8.2, the results of attempting 6273 // to read or write the estimatedRows field are undefined (but are likely 6274 // to include crashing the application). The estimatedRows field should 6275 // therefore only be used if [sqlite3_libversion_number()] returns a 6276 // value greater than or equal to 3008002. Similarly, the idxFlags field 6277 // was added for [version 3.9.0] ([dateof:3.9.0]). 6278 // It may therefore only be used if 6279 // sqlite3_libversion_number() returns a value greater than or equal to 6280 // 3009000. 6281 type sqlite3_index_constraint_usage = struct { 6282 FargvIndex int32 6283 Fomit uint8 6284 _ [3]byte 6285 } /* sqlite3.h:6755:9 */ 6286 6287 // CAPI3REF: Mutex Methods Object 6288 // 6289 // An instance of this structure defines the low-level routines 6290 // used to allocate and use mutexes. 6291 // 6292 // Usually, the default mutex implementations provided by SQLite are 6293 // sufficient, however the application has the option of substituting a custom 6294 // implementation for specialized deployments or systems for which SQLite 6295 // does not provide a suitable implementation. In this case, the application 6296 // creates and populates an instance of this structure to pass 6297 // to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option. 6298 // Additionally, an instance of this structure can be used as an 6299 // output variable when querying the system for the current mutex 6300 // implementation, using the [SQLITE_CONFIG_GETMUTEX] option. 6301 // 6302 // ^The xMutexInit method defined by this structure is invoked as 6303 // part of system initialization by the sqlite3_initialize() function. 6304 // ^The xMutexInit routine is called by SQLite exactly once for each 6305 // effective call to [sqlite3_initialize()]. 6306 // 6307 // ^The xMutexEnd method defined by this structure is invoked as 6308 // part of system shutdown by the sqlite3_shutdown() function. The 6309 // implementation of this method is expected to release all outstanding 6310 // resources obtained by the mutex methods implementation, especially 6311 // those obtained by the xMutexInit method. ^The xMutexEnd() 6312 // interface is invoked exactly once for each call to [sqlite3_shutdown()]. 6313 // 6314 // ^(The remaining seven methods defined by this structure (xMutexAlloc, 6315 // xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and 6316 // xMutexNotheld) implement the following interfaces (respectively): 6317 // 6318 // <ul> 6319 // <li> [sqlite3_mutex_alloc()] </li> 6320 // <li> [sqlite3_mutex_free()] </li> 6321 // <li> [sqlite3_mutex_enter()] </li> 6322 // <li> [sqlite3_mutex_try()] </li> 6323 // <li> [sqlite3_mutex_leave()] </li> 6324 // <li> [sqlite3_mutex_held()] </li> 6325 // <li> [sqlite3_mutex_notheld()] </li> 6326 // </ul>)^ 6327 // 6328 // The only difference is that the public sqlite3_XXX functions enumerated 6329 // above silently ignore any invocations that pass a NULL pointer instead 6330 // of a valid mutex handle. The implementations of the methods defined 6331 // by this structure are not required to handle this case. The results 6332 // of passing a NULL pointer instead of a valid mutex handle are undefined 6333 // (i.e. it is acceptable to provide an implementation that segfaults if 6334 // it is passed a NULL pointer). 6335 // 6336 // The xMutexInit() method must be threadsafe. It must be harmless to 6337 // invoke xMutexInit() multiple times within the same process and without 6338 // intervening calls to xMutexEnd(). Second and subsequent calls to 6339 // xMutexInit() must be no-ops. 6340 // 6341 // xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()] 6342 // and its associates). Similarly, xMutexAlloc() must not use SQLite memory 6343 // allocation for a static mutex. ^However xMutexAlloc() may use SQLite 6344 // memory allocation for a fast or recursive mutex. 6345 // 6346 // ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is 6347 // called, but only if the prior call to xMutexInit returned SQLITE_OK. 6348 // If xMutexInit fails in any way, it is expected to clean up after itself 6349 // prior to returning. 6350 type sqlite3_mutex_methods1 = struct { 6351 FxMutexInit uintptr 6352 FxMutexEnd uintptr 6353 FxMutexAlloc uintptr 6354 FxMutexFree uintptr 6355 FxMutexEnter uintptr 6356 FxMutexTry uintptr 6357 FxMutexLeave uintptr 6358 FxMutexHeld uintptr 6359 FxMutexNotheld uintptr 6360 } /* sqlite3.h:7589:9 */ 6361 6362 // CAPI3REF: Mutex Methods Object 6363 // 6364 // An instance of this structure defines the low-level routines 6365 // used to allocate and use mutexes. 6366 // 6367 // Usually, the default mutex implementations provided by SQLite are 6368 // sufficient, however the application has the option of substituting a custom 6369 // implementation for specialized deployments or systems for which SQLite 6370 // does not provide a suitable implementation. In this case, the application 6371 // creates and populates an instance of this structure to pass 6372 // to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option. 6373 // Additionally, an instance of this structure can be used as an 6374 // output variable when querying the system for the current mutex 6375 // implementation, using the [SQLITE_CONFIG_GETMUTEX] option. 6376 // 6377 // ^The xMutexInit method defined by this structure is invoked as 6378 // part of system initialization by the sqlite3_initialize() function. 6379 // ^The xMutexInit routine is called by SQLite exactly once for each 6380 // effective call to [sqlite3_initialize()]. 6381 // 6382 // ^The xMutexEnd method defined by this structure is invoked as 6383 // part of system shutdown by the sqlite3_shutdown() function. The 6384 // implementation of this method is expected to release all outstanding 6385 // resources obtained by the mutex methods implementation, especially 6386 // those obtained by the xMutexInit method. ^The xMutexEnd() 6387 // interface is invoked exactly once for each call to [sqlite3_shutdown()]. 6388 // 6389 // ^(The remaining seven methods defined by this structure (xMutexAlloc, 6390 // xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and 6391 // xMutexNotheld) implement the following interfaces (respectively): 6392 // 6393 // <ul> 6394 // <li> [sqlite3_mutex_alloc()] </li> 6395 // <li> [sqlite3_mutex_free()] </li> 6396 // <li> [sqlite3_mutex_enter()] </li> 6397 // <li> [sqlite3_mutex_try()] </li> 6398 // <li> [sqlite3_mutex_leave()] </li> 6399 // <li> [sqlite3_mutex_held()] </li> 6400 // <li> [sqlite3_mutex_notheld()] </li> 6401 // </ul>)^ 6402 // 6403 // The only difference is that the public sqlite3_XXX functions enumerated 6404 // above silently ignore any invocations that pass a NULL pointer instead 6405 // of a valid mutex handle. The implementations of the methods defined 6406 // by this structure are not required to handle this case. The results 6407 // of passing a NULL pointer instead of a valid mutex handle are undefined 6408 // (i.e. it is acceptable to provide an implementation that segfaults if 6409 // it is passed a NULL pointer). 6410 // 6411 // The xMutexInit() method must be threadsafe. It must be harmless to 6412 // invoke xMutexInit() multiple times within the same process and without 6413 // intervening calls to xMutexEnd(). Second and subsequent calls to 6414 // xMutexInit() must be no-ops. 6415 // 6416 // xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()] 6417 // and its associates). Similarly, xMutexAlloc() must not use SQLite memory 6418 // allocation for a static mutex. ^However xMutexAlloc() may use SQLite 6419 // memory allocation for a fast or recursive mutex. 6420 // 6421 // ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is 6422 // called, but only if the prior call to xMutexInit returned SQLITE_OK. 6423 // If xMutexInit fails in any way, it is expected to clean up after itself 6424 // prior to returning. 6425 type sqlite3_mutex_methods = sqlite3_mutex_methods1 /* sqlite3.h:7589:38 */ 6426 6427 // CAPI3REF: Dynamic String Object 6428 // KEYWORDS: {dynamic string} 6429 // 6430 // An instance of the sqlite3_str object contains a dynamically-sized 6431 // string under construction. 6432 // 6433 // The lifecycle of an sqlite3_str object is as follows: 6434 // <ol> 6435 // <li> ^The sqlite3_str object is created using [sqlite3_str_new()]. 6436 // <li> ^Text is appended to the sqlite3_str object using various 6437 // methods, such as [sqlite3_str_appendf()]. 6438 // <li> ^The sqlite3_str object is destroyed and the string it created 6439 // is returned using the [sqlite3_str_finish()] interface. 6440 // </ol> 6441 type sqlite3_str1 = struct { 6442 Fdb uintptr 6443 FzText uintptr 6444 FnAlloc u322 6445 FmxAlloc u322 6446 FnChar u322 6447 FaccError u8 6448 FprintfFlags u8 6449 _ [2]byte 6450 } /* sqlite3.h:7851:9 */ 6451 6452 // CAPI3REF: Custom Page Cache Object 6453 // 6454 // The sqlite3_pcache_page object represents a single page in the 6455 // page cache. The page cache will allocate instances of this 6456 // object. Various methods of the page cache use pointers to instances 6457 // of this object as parameters or as their return value. 6458 // 6459 // See [sqlite3_pcache_methods2] for additional information. 6460 type sqlite3_pcache_page1 = struct { 6461 FpBuf uintptr 6462 FpExtra uintptr 6463 } /* sqlite3.h:8344:9 */ 6464 6465 // CAPI3REF: Custom Page Cache Object 6466 // 6467 // The sqlite3_pcache_page object represents a single page in the 6468 // page cache. The page cache will allocate instances of this 6469 // object. Various methods of the page cache use pointers to instances 6470 // of this object as parameters or as their return value. 6471 // 6472 // See [sqlite3_pcache_methods2] for additional information. 6473 type sqlite3_pcache_page = sqlite3_pcache_page1 /* sqlite3.h:8344:36 */ 6474 6475 // CAPI3REF: Application Defined Page Cache. 6476 // KEYWORDS: {page cache} 6477 // 6478 // ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE2], ...) interface can 6479 // register an alternative page cache implementation by passing in an 6480 // instance of the sqlite3_pcache_methods2 structure.)^ 6481 // In many applications, most of the heap memory allocated by 6482 // SQLite is used for the page cache. 6483 // By implementing a 6484 // custom page cache using this API, an application can better control 6485 // the amount of memory consumed by SQLite, the way in which 6486 // that memory is allocated and released, and the policies used to 6487 // determine exactly which parts of a database file are cached and for 6488 // how long. 6489 // 6490 // The alternative page cache mechanism is an 6491 // extreme measure that is only needed by the most demanding applications. 6492 // The built-in page cache is recommended for most uses. 6493 // 6494 // ^(The contents of the sqlite3_pcache_methods2 structure are copied to an 6495 // internal buffer by SQLite within the call to [sqlite3_config]. Hence 6496 // the application may discard the parameter after the call to 6497 // [sqlite3_config()] returns.)^ 6498 // 6499 // [[the xInit() page cache method]] 6500 // ^(The xInit() method is called once for each effective 6501 // call to [sqlite3_initialize()])^ 6502 // (usually only once during the lifetime of the process). ^(The xInit() 6503 // method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^ 6504 // The intent of the xInit() method is to set up global data structures 6505 // required by the custom page cache implementation. 6506 // ^(If the xInit() method is NULL, then the 6507 // built-in default page cache is used instead of the application defined 6508 // page cache.)^ 6509 // 6510 // [[the xShutdown() page cache method]] 6511 // ^The xShutdown() method is called by [sqlite3_shutdown()]. 6512 // It can be used to clean up 6513 // any outstanding resources before process shutdown, if required. 6514 // ^The xShutdown() method may be NULL. 6515 // 6516 // ^SQLite automatically serializes calls to the xInit method, 6517 // so the xInit method need not be threadsafe. ^The 6518 // xShutdown method is only called from [sqlite3_shutdown()] so it does 6519 // not need to be threadsafe either. All other methods must be threadsafe 6520 // in multithreaded applications. 6521 // 6522 // ^SQLite will never invoke xInit() more than once without an intervening 6523 // call to xShutdown(). 6524 // 6525 // [[the xCreate() page cache methods]] 6526 // ^SQLite invokes the xCreate() method to construct a new cache instance. 6527 // SQLite will typically create one cache instance for each open database file, 6528 // though this is not guaranteed. ^The 6529 // first parameter, szPage, is the size in bytes of the pages that must 6530 // be allocated by the cache. ^szPage will always a power of two. ^The 6531 // second parameter szExtra is a number of bytes of extra storage 6532 // associated with each page cache entry. ^The szExtra parameter will 6533 // a number less than 250. SQLite will use the 6534 // extra szExtra bytes on each page to store metadata about the underlying 6535 // database page on disk. The value passed into szExtra depends 6536 // on the SQLite version, the target platform, and how SQLite was compiled. 6537 // ^The third argument to xCreate(), bPurgeable, is true if the cache being 6538 // created will be used to cache database pages of a file stored on disk, or 6539 // false if it is used for an in-memory database. The cache implementation 6540 // does not have to do anything special based with the value of bPurgeable; 6541 // it is purely advisory. ^On a cache where bPurgeable is false, SQLite will 6542 // never invoke xUnpin() except to deliberately delete a page. 6543 // ^In other words, calls to xUnpin() on a cache with bPurgeable set to 6544 // false will always have the "discard" flag set to true. 6545 // ^Hence, a cache created with bPurgeable false will 6546 // never contain any unpinned pages. 6547 // 6548 // [[the xCachesize() page cache method]] 6549 // ^(The xCachesize() method may be called at any time by SQLite to set the 6550 // suggested maximum cache-size (number of pages stored by) the cache 6551 // instance passed as the first argument. This is the value configured using 6552 // the SQLite "[PRAGMA cache_size]" command.)^ As with the bPurgeable 6553 // parameter, the implementation is not required to do anything with this 6554 // value; it is advisory only. 6555 // 6556 // [[the xPagecount() page cache methods]] 6557 // The xPagecount() method must return the number of pages currently 6558 // stored in the cache, both pinned and unpinned. 6559 // 6560 // [[the xFetch() page cache methods]] 6561 // The xFetch() method locates a page in the cache and returns a pointer to 6562 // an sqlite3_pcache_page object associated with that page, or a NULL pointer. 6563 // The pBuf element of the returned sqlite3_pcache_page object will be a 6564 // pointer to a buffer of szPage bytes used to store the content of a 6565 // single database page. The pExtra element of sqlite3_pcache_page will be 6566 // a pointer to the szExtra bytes of extra storage that SQLite has requested 6567 // for each entry in the page cache. 6568 // 6569 // The page to be fetched is determined by the key. ^The minimum key value 6570 // is 1. After it has been retrieved using xFetch, the page is considered 6571 // to be "pinned". 6572 // 6573 // If the requested page is already in the page cache, then the page cache 6574 // implementation must return a pointer to the page buffer with its content 6575 // intact. If the requested page is not already in the cache, then the 6576 // cache implementation should use the value of the createFlag 6577 // parameter to help it determined what action to take: 6578 // 6579 // <table border=1 width=85% align=center> 6580 // <tr><th> createFlag <th> Behavior when page is not already in cache 6581 // <tr><td> 0 <td> Do not allocate a new page. Return NULL. 6582 // <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so. 6583 // Otherwise return NULL. 6584 // <tr><td> 2 <td> Make every effort to allocate a new page. Only return 6585 // NULL if allocating a new page is effectively impossible. 6586 // </table> 6587 // 6588 // ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite 6589 // will only use a createFlag of 2 after a prior call with a createFlag of 1 6590 // failed.)^ In between the xFetch() calls, SQLite may 6591 // attempt to unpin one or more cache pages by spilling the content of 6592 // pinned pages to disk and synching the operating system disk cache. 6593 // 6594 // [[the xUnpin() page cache method]] 6595 // ^xUnpin() is called by SQLite with a pointer to a currently pinned page 6596 // as its second argument. If the third parameter, discard, is non-zero, 6597 // then the page must be evicted from the cache. 6598 // ^If the discard parameter is 6599 // zero, then the page may be discarded or retained at the discretion of 6600 // page cache implementation. ^The page cache implementation 6601 // may choose to evict unpinned pages at any time. 6602 // 6603 // The cache must not perform any reference counting. A single 6604 // call to xUnpin() unpins the page regardless of the number of prior calls 6605 // to xFetch(). 6606 // 6607 // [[the xRekey() page cache methods]] 6608 // The xRekey() method is used to change the key value associated with the 6609 // page passed as the second argument. If the cache 6610 // previously contains an entry associated with newKey, it must be 6611 // discarded. ^Any prior cache entry associated with newKey is guaranteed not 6612 // to be pinned. 6613 // 6614 // When SQLite calls the xTruncate() method, the cache must discard all 6615 // existing cache entries with page numbers (keys) greater than or equal 6616 // to the value of the iLimit parameter passed to xTruncate(). If any 6617 // of these pages are pinned, they are implicitly unpinned, meaning that 6618 // they can be safely discarded. 6619 // 6620 // [[the xDestroy() page cache method]] 6621 // ^The xDestroy() method is used to delete a cache allocated by xCreate(). 6622 // All resources associated with the specified cache should be freed. ^After 6623 // calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] 6624 // handle invalid, and will not use it with any other sqlite3_pcache_methods2 6625 // functions. 6626 // 6627 // [[the xShrink() page cache method]] 6628 // ^SQLite invokes the xShrink() method when it wants the page cache to 6629 // free up as much of heap memory as possible. The page cache implementation 6630 // is not obligated to free any memory, but well-behaved implementations should 6631 // do their best. 6632 type sqlite3_pcache_methods21 = struct { 6633 FiVersion int32 6634 _ [4]byte 6635 FpArg uintptr 6636 FxInit uintptr 6637 FxShutdown uintptr 6638 FxCreate uintptr 6639 FxCachesize uintptr 6640 FxPagecount uintptr 6641 FxFetch uintptr 6642 FxUnpin uintptr 6643 FxRekey uintptr 6644 FxTruncate uintptr 6645 FxDestroy uintptr 6646 FxShrink uintptr 6647 } /* sqlite3.h:8509:9 */ 6648 6649 // CAPI3REF: Application Defined Page Cache. 6650 // KEYWORDS: {page cache} 6651 // 6652 // ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE2], ...) interface can 6653 // register an alternative page cache implementation by passing in an 6654 // instance of the sqlite3_pcache_methods2 structure.)^ 6655 // In many applications, most of the heap memory allocated by 6656 // SQLite is used for the page cache. 6657 // By implementing a 6658 // custom page cache using this API, an application can better control 6659 // the amount of memory consumed by SQLite, the way in which 6660 // that memory is allocated and released, and the policies used to 6661 // determine exactly which parts of a database file are cached and for 6662 // how long. 6663 // 6664 // The alternative page cache mechanism is an 6665 // extreme measure that is only needed by the most demanding applications. 6666 // The built-in page cache is recommended for most uses. 6667 // 6668 // ^(The contents of the sqlite3_pcache_methods2 structure are copied to an 6669 // internal buffer by SQLite within the call to [sqlite3_config]. Hence 6670 // the application may discard the parameter after the call to 6671 // [sqlite3_config()] returns.)^ 6672 // 6673 // [[the xInit() page cache method]] 6674 // ^(The xInit() method is called once for each effective 6675 // call to [sqlite3_initialize()])^ 6676 // (usually only once during the lifetime of the process). ^(The xInit() 6677 // method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^ 6678 // The intent of the xInit() method is to set up global data structures 6679 // required by the custom page cache implementation. 6680 // ^(If the xInit() method is NULL, then the 6681 // built-in default page cache is used instead of the application defined 6682 // page cache.)^ 6683 // 6684 // [[the xShutdown() page cache method]] 6685 // ^The xShutdown() method is called by [sqlite3_shutdown()]. 6686 // It can be used to clean up 6687 // any outstanding resources before process shutdown, if required. 6688 // ^The xShutdown() method may be NULL. 6689 // 6690 // ^SQLite automatically serializes calls to the xInit method, 6691 // so the xInit method need not be threadsafe. ^The 6692 // xShutdown method is only called from [sqlite3_shutdown()] so it does 6693 // not need to be threadsafe either. All other methods must be threadsafe 6694 // in multithreaded applications. 6695 // 6696 // ^SQLite will never invoke xInit() more than once without an intervening 6697 // call to xShutdown(). 6698 // 6699 // [[the xCreate() page cache methods]] 6700 // ^SQLite invokes the xCreate() method to construct a new cache instance. 6701 // SQLite will typically create one cache instance for each open database file, 6702 // though this is not guaranteed. ^The 6703 // first parameter, szPage, is the size in bytes of the pages that must 6704 // be allocated by the cache. ^szPage will always a power of two. ^The 6705 // second parameter szExtra is a number of bytes of extra storage 6706 // associated with each page cache entry. ^The szExtra parameter will 6707 // a number less than 250. SQLite will use the 6708 // extra szExtra bytes on each page to store metadata about the underlying 6709 // database page on disk. The value passed into szExtra depends 6710 // on the SQLite version, the target platform, and how SQLite was compiled. 6711 // ^The third argument to xCreate(), bPurgeable, is true if the cache being 6712 // created will be used to cache database pages of a file stored on disk, or 6713 // false if it is used for an in-memory database. The cache implementation 6714 // does not have to do anything special based with the value of bPurgeable; 6715 // it is purely advisory. ^On a cache where bPurgeable is false, SQLite will 6716 // never invoke xUnpin() except to deliberately delete a page. 6717 // ^In other words, calls to xUnpin() on a cache with bPurgeable set to 6718 // false will always have the "discard" flag set to true. 6719 // ^Hence, a cache created with bPurgeable false will 6720 // never contain any unpinned pages. 6721 // 6722 // [[the xCachesize() page cache method]] 6723 // ^(The xCachesize() method may be called at any time by SQLite to set the 6724 // suggested maximum cache-size (number of pages stored by) the cache 6725 // instance passed as the first argument. This is the value configured using 6726 // the SQLite "[PRAGMA cache_size]" command.)^ As with the bPurgeable 6727 // parameter, the implementation is not required to do anything with this 6728 // value; it is advisory only. 6729 // 6730 // [[the xPagecount() page cache methods]] 6731 // The xPagecount() method must return the number of pages currently 6732 // stored in the cache, both pinned and unpinned. 6733 // 6734 // [[the xFetch() page cache methods]] 6735 // The xFetch() method locates a page in the cache and returns a pointer to 6736 // an sqlite3_pcache_page object associated with that page, or a NULL pointer. 6737 // The pBuf element of the returned sqlite3_pcache_page object will be a 6738 // pointer to a buffer of szPage bytes used to store the content of a 6739 // single database page. The pExtra element of sqlite3_pcache_page will be 6740 // a pointer to the szExtra bytes of extra storage that SQLite has requested 6741 // for each entry in the page cache. 6742 // 6743 // The page to be fetched is determined by the key. ^The minimum key value 6744 // is 1. After it has been retrieved using xFetch, the page is considered 6745 // to be "pinned". 6746 // 6747 // If the requested page is already in the page cache, then the page cache 6748 // implementation must return a pointer to the page buffer with its content 6749 // intact. If the requested page is not already in the cache, then the 6750 // cache implementation should use the value of the createFlag 6751 // parameter to help it determined what action to take: 6752 // 6753 // <table border=1 width=85% align=center> 6754 // <tr><th> createFlag <th> Behavior when page is not already in cache 6755 // <tr><td> 0 <td> Do not allocate a new page. Return NULL. 6756 // <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so. 6757 // Otherwise return NULL. 6758 // <tr><td> 2 <td> Make every effort to allocate a new page. Only return 6759 // NULL if allocating a new page is effectively impossible. 6760 // </table> 6761 // 6762 // ^(SQLite will normally invoke xFetch() with a createFlag of 0 or 1. SQLite 6763 // will only use a createFlag of 2 after a prior call with a createFlag of 1 6764 // failed.)^ In between the xFetch() calls, SQLite may 6765 // attempt to unpin one or more cache pages by spilling the content of 6766 // pinned pages to disk and synching the operating system disk cache. 6767 // 6768 // [[the xUnpin() page cache method]] 6769 // ^xUnpin() is called by SQLite with a pointer to a currently pinned page 6770 // as its second argument. If the third parameter, discard, is non-zero, 6771 // then the page must be evicted from the cache. 6772 // ^If the discard parameter is 6773 // zero, then the page may be discarded or retained at the discretion of 6774 // page cache implementation. ^The page cache implementation 6775 // may choose to evict unpinned pages at any time. 6776 // 6777 // The cache must not perform any reference counting. A single 6778 // call to xUnpin() unpins the page regardless of the number of prior calls 6779 // to xFetch(). 6780 // 6781 // [[the xRekey() page cache methods]] 6782 // The xRekey() method is used to change the key value associated with the 6783 // page passed as the second argument. If the cache 6784 // previously contains an entry associated with newKey, it must be 6785 // discarded. ^Any prior cache entry associated with newKey is guaranteed not 6786 // to be pinned. 6787 // 6788 // When SQLite calls the xTruncate() method, the cache must discard all 6789 // existing cache entries with page numbers (keys) greater than or equal 6790 // to the value of the iLimit parameter passed to xTruncate(). If any 6791 // of these pages are pinned, they are implicitly unpinned, meaning that 6792 // they can be safely discarded. 6793 // 6794 // [[the xDestroy() page cache method]] 6795 // ^The xDestroy() method is used to delete a cache allocated by xCreate(). 6796 // All resources associated with the specified cache should be freed. ^After 6797 // calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] 6798 // handle invalid, and will not use it with any other sqlite3_pcache_methods2 6799 // functions. 6800 // 6801 // [[the xShrink() page cache method]] 6802 // ^SQLite invokes the xShrink() method when it wants the page cache to 6803 // free up as much of heap memory as possible. The page cache implementation 6804 // is not obligated to free any memory, but well-behaved implementations should 6805 // do their best. 6806 type sqlite3_pcache_methods2 = sqlite3_pcache_methods21 /* sqlite3.h:8509:40 */ 6807 6808 // This is the obsolete pcache_methods object that has now been replaced 6809 // by sqlite3_pcache_methods2. This object is not used by SQLite. It is 6810 // retained in the header file for backwards compatibility only. 6811 type sqlite3_pcache_methods1 = struct { 6812 FpArg uintptr 6813 FxInit uintptr 6814 FxShutdown uintptr 6815 FxCreate uintptr 6816 FxCachesize uintptr 6817 FxPagecount uintptr 6818 FxFetch uintptr 6819 FxUnpin uintptr 6820 FxRekey uintptr 6821 FxTruncate uintptr 6822 FxDestroy uintptr 6823 } /* sqlite3.h:8532:9 */ 6824 6825 // This is the obsolete pcache_methods object that has now been replaced 6826 // by sqlite3_pcache_methods2. This object is not used by SQLite. It is 6827 // retained in the header file for backwards compatibility only. 6828 type sqlite3_pcache_methods = sqlite3_pcache_methods1 /* sqlite3.h:8532:39 */ 6829 6830 // CAPI3REF: Database Snapshot 6831 // KEYWORDS: {snapshot} {sqlite3_snapshot} 6832 // 6833 // An instance of the snapshot object records the state of a [WAL mode] 6834 // database for some specific point in history. 6835 // 6836 // In [WAL mode], multiple [database connections] that are open on the 6837 // same database file can each be reading a different historical version 6838 // of the database file. When a [database connection] begins a read 6839 // transaction, that connection sees an unchanging copy of the database 6840 // as it existed for the point in time when the transaction first started. 6841 // Subsequent changes to the database from other connections are not seen 6842 // by the reader until a new read transaction is started. 6843 // 6844 // The sqlite3_snapshot object records state information about an historical 6845 // version of the database file so that it is possible to later open a new read 6846 // transaction that sees that historical version of the database rather than 6847 // the most recent version. 6848 type sqlite3_snapshot1 = struct{ Fhidden [48]uint8 } /* sqlite3.h:9589:9 */ 6849 6850 // CAPI3REF: Database Snapshot 6851 // KEYWORDS: {snapshot} {sqlite3_snapshot} 6852 // 6853 // An instance of the snapshot object records the state of a [WAL mode] 6854 // database for some specific point in history. 6855 // 6856 // In [WAL mode], multiple [database connections] that are open on the 6857 // same database file can each be reading a different historical version 6858 // of the database file. When a [database connection] begins a read 6859 // transaction, that connection sees an unchanging copy of the database 6860 // as it existed for the point in time when the transaction first started. 6861 // Subsequent changes to the database from other connections are not seen 6862 // by the reader until a new read transaction is started. 6863 // 6864 // The sqlite3_snapshot object records state information about an historical 6865 // version of the database file so that it is possible to later open a new read 6866 // transaction that sees that historical version of the database rather than 6867 // the most recent version. 6868 type sqlite3_snapshot = sqlite3_snapshot1 /* sqlite3.h:9591:3 */ 6869 6870 // CAPI3REF: Flags for sqlite3_deserialize() 6871 // 6872 // The following are allowed values for 6th argument (the F argument) to 6873 // the [sqlite3_deserialize(D,S,P,N,M,F)] interface. 6874 // 6875 // The SQLITE_DESERIALIZE_FREEONCLOSE means that the database serialization 6876 // in the P argument is held in memory obtained from [sqlite3_malloc64()] 6877 // and that SQLite should take ownership of this memory and automatically 6878 // free it when it has finished using it. Without this flag, the caller 6879 // is responsible for freeing any dynamically allocated memory. 6880 // 6881 // The SQLITE_DESERIALIZE_RESIZEABLE flag means that SQLite is allowed to 6882 // grow the size of the database using calls to [sqlite3_realloc64()]. This 6883 // flag should only be used if SQLITE_DESERIALIZE_FREEONCLOSE is also used. 6884 // Without this flag, the deserialized database cannot increase in size beyond 6885 // the number of bytes specified by the M parameter. 6886 // 6887 // The SQLITE_DESERIALIZE_READONLY flag means that the deserialized database 6888 // should be treated as read-only. 6889 6890 // Undo the hack that converts floating point types to integer for 6891 // builds on processors without floating point support. 6892 6893 //******* Begin file sqlite3rtree.h ******** 6894 // 2010 August 30 6895 // 6896 // The author disclaims copyright to this source code. In place of 6897 // a legal notice, here is a blessing: 6898 // 6899 // May you do good and not evil. 6900 // May you find forgiveness for yourself and forgive others. 6901 // May you share freely, never taking more than you give. 6902 // 6903 // 6904 6905 type sqlite3_rtree_geometry1 = struct { 6906 FpContext uintptr 6907 FnParam int32 6908 _ [4]byte 6909 FaParam uintptr 6910 FpUser uintptr 6911 FxDelUser uintptr 6912 } /* sqlite3.h:9916:9 */ 6913 6914 // CAPI3REF: Flags for sqlite3_deserialize() 6915 // 6916 // The following are allowed values for 6th argument (the F argument) to 6917 // the [sqlite3_deserialize(D,S,P,N,M,F)] interface. 6918 // 6919 // The SQLITE_DESERIALIZE_FREEONCLOSE means that the database serialization 6920 // in the P argument is held in memory obtained from [sqlite3_malloc64()] 6921 // and that SQLite should take ownership of this memory and automatically 6922 // free it when it has finished using it. Without this flag, the caller 6923 // is responsible for freeing any dynamically allocated memory. 6924 // 6925 // The SQLITE_DESERIALIZE_RESIZEABLE flag means that SQLite is allowed to 6926 // grow the size of the database using calls to [sqlite3_realloc64()]. This 6927 // flag should only be used if SQLITE_DESERIALIZE_FREEONCLOSE is also used. 6928 // Without this flag, the deserialized database cannot increase in size beyond 6929 // the number of bytes specified by the M parameter. 6930 // 6931 // The SQLITE_DESERIALIZE_READONLY flag means that the deserialized database 6932 // should be treated as read-only. 6933 6934 // Undo the hack that converts floating point types to integer for 6935 // builds on processors without floating point support. 6936 6937 //******* Begin file sqlite3rtree.h ******** 6938 // 2010 August 30 6939 // 6940 // The author disclaims copyright to this source code. In place of 6941 // a legal notice, here is a blessing: 6942 // 6943 // May you do good and not evil. 6944 // May you find forgiveness for yourself and forgive others. 6945 // May you share freely, never taking more than you give. 6946 // 6947 // 6948 6949 type sqlite3_rtree_geometry = sqlite3_rtree_geometry1 /* sqlite3.h:9916:39 */ 6950 type sqlite3_rtree_query_info1 = struct { 6951 FpContext uintptr 6952 FnParam int32 6953 _ [4]byte 6954 FaParam uintptr 6955 FpUser uintptr 6956 FxDelUser uintptr 6957 FaCoord uintptr 6958 FanQueue uintptr 6959 FnCoord int32 6960 FiLevel int32 6961 FmxLevel int32 6962 _ [4]byte 6963 FiRowid sqlite3_int64 6964 FrParentScore sqlite3_rtree_dbl 6965 FeParentWithin int32 6966 FeWithin int32 6967 FrScore sqlite3_rtree_dbl 6968 FapSqlParam uintptr 6969 } /* sqlite3.h:9917:9 */ 6970 6971 type sqlite3_rtree_query_info = sqlite3_rtree_query_info1 /* sqlite3.h:9917:41 */ 6972 6973 // The double-precision datatype used by RTree depends on the 6974 // SQLITE_RTREE_INT_ONLY compile-time option. 6975 type sqlite3_rtree_dbl = float64 /* sqlite3.h:9925:18 */ 6976 6977 // Allowed values for sqlite3_rtree_query.eWithin and .eParentWithin. 6978 6979 //******* End of sqlite3rtree.h ******** 6980 //******* Begin file sqlite3session.h ******** 6981 6982 //******* End of sqlite3session.h ******** 6983 //******* Begin file fts5.h ******** 6984 // 2014 May 31 6985 // 6986 // The author disclaims copyright to this source code. In place of 6987 // a legal notice, here is a blessing: 6988 // 6989 // May you do good and not evil. 6990 // May you find forgiveness for yourself and forgive others. 6991 // May you share freely, never taking more than you give. 6992 // 6993 // 6994 // 6995 // Interfaces to extend FTS5. Using the interfaces defined in this file, 6996 // FTS5 may be extended with: 6997 // 6998 // * custom tokenizers, and 6999 // * custom auxiliary functions. 7000 7001 // ************************************************************************ 7002 // 7003 // CUSTOM AUXILIARY FUNCTIONS 7004 // 7005 // Virtual table implementations may overload SQL functions by implementing 7006 // the sqlite3_module.xFindFunction() method. 7007 7008 type Fts5ExtensionApi1 = struct { 7009 FiVersion int32 7010 _ [4]byte 7011 FxUserData uintptr 7012 FxColumnCount uintptr 7013 FxRowCount uintptr 7014 FxColumnTotalSize uintptr 7015 FxTokenize uintptr 7016 FxPhraseCount uintptr 7017 FxPhraseSize uintptr 7018 FxInstCount uintptr 7019 FxInst uintptr 7020 FxRowid uintptr 7021 FxColumnText uintptr 7022 FxColumnSize uintptr 7023 FxQueryPhrase uintptr 7024 FxSetAuxdata uintptr 7025 FxGetAuxdata uintptr 7026 FxPhraseFirst uintptr 7027 FxPhraseNext uintptr 7028 FxPhraseFirstColumn uintptr 7029 FxPhraseNextColumn uintptr 7030 } /* sqlite3.h:11724:9 */ 7031 7032 // Allowed values for sqlite3_rtree_query.eWithin and .eParentWithin. 7033 7034 //******* End of sqlite3rtree.h ******** 7035 //******* Begin file sqlite3session.h ******** 7036 7037 //******* End of sqlite3session.h ******** 7038 //******* Begin file fts5.h ******** 7039 // 2014 May 31 7040 // 7041 // The author disclaims copyright to this source code. In place of 7042 // a legal notice, here is a blessing: 7043 // 7044 // May you do good and not evil. 7045 // May you find forgiveness for yourself and forgive others. 7046 // May you share freely, never taking more than you give. 7047 // 7048 // 7049 // 7050 // Interfaces to extend FTS5. Using the interfaces defined in this file, 7051 // FTS5 may be extended with: 7052 // 7053 // * custom tokenizers, and 7054 // * custom auxiliary functions. 7055 7056 // ************************************************************************ 7057 // 7058 // CUSTOM AUXILIARY FUNCTIONS 7059 // 7060 // Virtual table implementations may overload SQL functions by implementing 7061 // the sqlite3_module.xFindFunction() method. 7062 7063 type Fts5ExtensionApi = Fts5ExtensionApi1 /* sqlite3.h:11724:33 */ 7064 type Fts5PhraseIter1 = struct { 7065 Fa uintptr 7066 Fb uintptr 7067 } /* sqlite3.h:11726:9 */ 7068 7069 type Fts5PhraseIter = Fts5PhraseIter1 /* sqlite3.h:11726:31 */ 7070 7071 type fts5_extension_function = uintptr /* sqlite3.h:11728:14 */ 7072 type fts5_tokenizer1 = struct { 7073 FxCreate uintptr 7074 FxDelete uintptr 7075 FxTokenize uintptr 7076 } /* sqlite3.h:12187:9 */ 7077 7078 type fts5_tokenizer = fts5_tokenizer1 /* sqlite3.h:12187:31 */ 7079 7080 // Flags that may be passed as the third argument to xTokenize() 7081 7082 // Flags that may be passed by the tokenizer implementation back to FTS5 7083 // as the third argument to the supplied xToken callback. 7084 7085 // 7086 // END OF CUSTOM TOKENIZERS 7087 // 7088 7089 // ************************************************************************ 7090 // 7091 // FTS5 EXTENSION REGISTRATION API 7092 type fts5_api1 = struct { 7093 FiVersion int32 7094 _ [4]byte 7095 FxCreateTokenizer uintptr 7096 FxFindTokenizer uintptr 7097 FxCreateFunction uintptr 7098 } /* sqlite3.h:12223:9 */ 7099 7100 // Flags that may be passed as the third argument to xTokenize() 7101 7102 // Flags that may be passed by the tokenizer implementation back to FTS5 7103 // as the third argument to the supplied xToken callback. 7104 7105 // 7106 // END OF CUSTOM TOKENIZERS 7107 // 7108 7109 // ************************************************************************ 7110 // 7111 // FTS5 EXTENSION REGISTRATION API 7112 type fts5_api = fts5_api1 /* sqlite3.h:12223:25 */ 7113 7114 // 7115 // END OF REGISTRATION API 7116 // 7117 7118 //******* End of fts5.h ******** 7119 7120 type sqlite3expert1 = struct { 7121 FiSample int32 7122 _ [4]byte 7123 Fdb uintptr 7124 Fdbm uintptr 7125 Fdbv uintptr 7126 FpTable uintptr 7127 FpScan uintptr 7128 FpWrite uintptr 7129 FpStatement uintptr 7130 FbRun int32 7131 _ [4]byte 7132 FpzErrmsg uintptr 7133 Frc int32 7134 _ [4]byte 7135 FhIdx IdxHash 7136 FzCandidates uintptr 7137 } /* sqlite3expert.h:17:9 */ 7138 7139 // 7140 // END OF REGISTRATION API 7141 // 7142 7143 //******* End of fts5.h ******** 7144 7145 type sqlite3expert = sqlite3expert1 /* sqlite3expert.h:17:30 */ 7146 7147 // POSIX.1-2008 extended locale interface (see locale.h). 7148 // Definition of locale_t. 7149 // Copyright (C) 2017-2018 Free Software Foundation, Inc. 7150 // This file is part of the GNU C Library. 7151 // 7152 // The GNU C Library is free software; you can redistribute it and/or 7153 // modify it under the terms of the GNU Lesser General Public 7154 // License as published by the Free Software Foundation; either 7155 // version 2.1 of the License, or (at your option) any later version. 7156 // 7157 // The GNU C Library is distributed in the hope that it will be useful, 7158 // but WITHOUT ANY WARRANTY; without even the implied warranty of 7159 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 7160 // Lesser General Public License for more details. 7161 // 7162 // You should have received a copy of the GNU Lesser General Public 7163 // License along with the GNU C Library; if not, see 7164 // <http://www.gnu.org/licenses/>. 7165 7166 // Definition of struct __locale_struct and __locale_t. 7167 // Copyright (C) 1997-2018 Free Software Foundation, Inc. 7168 // This file is part of the GNU C Library. 7169 // Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. 7170 // 7171 // The GNU C Library is free software; you can redistribute it and/or 7172 // modify it under the terms of the GNU Lesser General Public 7173 // License as published by the Free Software Foundation; either 7174 // version 2.1 of the License, or (at your option) any later version. 7175 // 7176 // The GNU C Library is distributed in the hope that it will be useful, 7177 // but WITHOUT ANY WARRANTY; without even the implied warranty of 7178 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 7179 // Lesser General Public License for more details. 7180 // 7181 // You should have received a copy of the GNU Lesser General Public 7182 // License along with the GNU C Library; if not, see 7183 // <http://www.gnu.org/licenses/>. 7184 7185 // POSIX.1-2008: the locale_t type, representing a locale context 7186 // (implementation-namespace version). This type should be treated 7187 // as opaque by applications; some details are exposed for the sake of 7188 // efficiency in e.g. ctype functions. 7189 7190 type __locale_struct = struct { 7191 F__locales [13]uintptr 7192 F__ctype_b uintptr 7193 F__ctype_tolower uintptr 7194 F__ctype_toupper uintptr 7195 F__names [13]uintptr 7196 } /* __locale_t.h:28:1 */ 7197 7198 type locale_t = uintptr /* locale_t.h:24:20 */ 7199 7200 // The tag name of this struct is _G_fpos_t to preserve historic 7201 // C++ mangled names for functions taking fpos_t arguments. 7202 // That name should not be used in new code. 7203 type _G_fpos_t = struct { 7204 F__pos int64 7205 F__state struct { 7206 F__count int32 7207 F__value struct{ F__wch uint32 } 7208 } 7209 } /* __fpos_t.h:10:9 */ 7210 7211 // bits/types.h -- definitions of __*_t types underlying *_t types. 7212 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 7213 // This file is part of the GNU C Library. 7214 // 7215 // The GNU C Library is free software; you can redistribute it and/or 7216 // modify it under the terms of the GNU Lesser General Public 7217 // License as published by the Free Software Foundation; either 7218 // version 2.1 of the License, or (at your option) any later version. 7219 // 7220 // The GNU C Library is distributed in the hope that it will be useful, 7221 // but WITHOUT ANY WARRANTY; without even the implied warranty of 7222 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 7223 // Lesser General Public License for more details. 7224 // 7225 // You should have received a copy of the GNU Lesser General Public 7226 // License along with the GNU C Library; if not, see 7227 // <http://www.gnu.org/licenses/>. 7228 7229 // Never include this file directly; use <sys/types.h> instead. 7230 7231 // The tag name of this struct is _G_fpos64_t to preserve historic 7232 // C++ mangled names for functions taking fpos_t and/or fpos64_t 7233 // arguments. That name should not be used in new code. 7234 type _G_fpos64_t = struct { 7235 F__pos int64 7236 F__state struct { 7237 F__count int32 7238 F__value struct{ F__wch uint32 } 7239 } 7240 } /* __fpos64_t.h:10:9 */ 7241 7242 type _IO_FILE = struct { 7243 F_flags int32 7244 _ [4]byte 7245 F_IO_read_ptr uintptr 7246 F_IO_read_end uintptr 7247 F_IO_read_base uintptr 7248 F_IO_write_base uintptr 7249 F_IO_write_ptr uintptr 7250 F_IO_write_end uintptr 7251 F_IO_buf_base uintptr 7252 F_IO_buf_end uintptr 7253 F_IO_save_base uintptr 7254 F_IO_backup_base uintptr 7255 F_IO_save_end uintptr 7256 F_markers uintptr 7257 F_chain uintptr 7258 F_fileno int32 7259 F_flags2 int32 7260 F_old_offset int64 7261 F_cur_column uint16 7262 F_vtable_offset int8 7263 F_shortbuf [1]int8 7264 _ [4]byte 7265 F_lock uintptr 7266 F_offset int64 7267 F_codecvt uintptr 7268 F_wide_data uintptr 7269 F_freeres_list uintptr 7270 F_freeres_buf uintptr 7271 F__pad5 size_t 7272 F_mode int32 7273 F_unused2 [20]int8 7274 } /* __FILE.h:4:1 */ 7275 7276 // The opaque type of streams. This is the definition used elsewhere. 7277 type FILE = _IO_FILE /* FILE.h:7:25 */ 7278 7279 // These macros are used by bits/stdio.h and internal headers. 7280 7281 // Many more flag bits are defined internally. 7282 7283 type off_t = int64 /* stdio.h:65:19 */ 7284 7285 type ssize_t = int64 /* stdio.h:77:19 */ 7286 7287 // The type of the second argument to `fgetpos' and `fsetpos'. 7288 type fpos_t = _G_fpos64_t /* stdio.h:86:20 */ 7289 7290 // If we are compiling with optimizing read this file. It contains 7291 // several optimizing inline functions and macros. 7292 7293 type i64 = sqlite3_int64 /* sqlite3expert.c:20:23 */ 7294 type u64 = sqlite3_uint64 /* sqlite3expert.c:21:24 */ 7295 7296 type IdxColumn1 = struct { 7297 FzName uintptr 7298 FzColl uintptr 7299 FiPk int32 7300 _ [4]byte 7301 } /* sqlite3expert.h:17:9 */ 7302 7303 type IdxColumn = IdxColumn1 /* sqlite3expert.c:23:26 */ 7304 type IdxConstraint1 = struct { 7305 FzColl uintptr 7306 FbRange int32 7307 FiCol int32 7308 FbFlag int32 7309 FbDesc int32 7310 FpNext uintptr 7311 FpLink uintptr 7312 } /* sqlite3expert.h:17:9 */ 7313 7314 type IdxConstraint = IdxConstraint1 /* sqlite3expert.c:24:30 */ 7315 type IdxScan1 = struct { 7316 FpTab uintptr 7317 FiDb int32 7318 _ [4]byte 7319 Fcovering i64 7320 FpOrder uintptr 7321 FpEq uintptr 7322 FpRange uintptr 7323 FpNextScan uintptr 7324 } /* sqlite3expert.h:17:9 */ 7325 7326 type IdxScan = IdxScan1 /* sqlite3expert.c:25:24 */ 7327 type IdxStatement1 = struct { 7328 FiId int32 7329 _ [4]byte 7330 FzSql uintptr 7331 FzIdx uintptr 7332 FzEQP uintptr 7333 FpNext uintptr 7334 } /* sqlite3expert.h:17:9 */ 7335 7336 type IdxStatement = IdxStatement1 /* sqlite3expert.c:26:29 */ 7337 type IdxTable1 = struct { 7338 FnCol int32 7339 _ [4]byte 7340 FzName uintptr 7341 FaCol uintptr 7342 FpNext uintptr 7343 } /* sqlite3expert.h:17:9 */ 7344 7345 type IdxTable = IdxTable1 /* sqlite3expert.c:27:25 */ 7346 type IdxWrite1 = struct { 7347 FpTab uintptr 7348 FeOp int32 7349 _ [4]byte 7350 FpNext uintptr 7351 } /* sqlite3expert.h:17:9 */ 7352 7353 type IdxWrite = IdxWrite1 /* sqlite3expert.c:28:25 */ 7354 7355 // A hash table for storing strings. With space for a payload string 7356 // with each entry. Methods are: 7357 // 7358 // idxHashInit() 7359 // idxHashClear() 7360 // idxHashAdd() 7361 // idxHashSearch() 7362 type IdxHashEntry1 = struct { 7363 FzKey uintptr 7364 FzVal uintptr 7365 FzVal2 uintptr 7366 FpHashNext uintptr 7367 FpNext uintptr 7368 } /* sqlite3expert.h:17:9 */ 7369 7370 // A hash table for storing strings. With space for a payload string 7371 // with each entry. Methods are: 7372 // 7373 // idxHashInit() 7374 // idxHashClear() 7375 // idxHashAdd() 7376 // idxHashSearch() 7377 type IdxHashEntry = IdxHashEntry1 /* sqlite3expert.c:120:29 */ 7378 type IdxHash1 = struct { 7379 FpFirst uintptr 7380 FaHash [1023]uintptr 7381 } /* sqlite3expert.h:17:9 */ 7382 7383 type IdxHash = IdxHash1 /* sqlite3expert.c:121:24 */ 7384 7385 // Allocate and return nByte bytes of zeroed memory using sqlite3_malloc(). 7386 // If the allocation fails, set *pRc to SQLITE_NOMEM and return NULL. 7387 func idxMalloc(tls *libc.TLS, pRc uintptr, nByte int32) uintptr { /* sqlite3expert.c:158:13: */ 7388 var pRet uintptr 7389 7390 pRet = sqlite3.Xsqlite3_malloc(tls, nByte) 7391 if pRet != 0 { 7392 libc.Xmemset(tls, pRet, 0, uint64(nByte)) 7393 } else { 7394 *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM 7395 } 7396 return pRet 7397 } 7398 7399 // Initialize an IdxHash hash table. 7400 func idxHashInit(tls *libc.TLS, pHash uintptr) { /* sqlite3expert.c:174:13: */ 7401 libc.Xmemset(tls, pHash, 0, uint64(unsafe.Sizeof(IdxHash{}))) 7402 } 7403 7404 // Reset an IdxHash hash table. 7405 func idxHashClear(tls *libc.TLS, pHash uintptr) { /* sqlite3expert.c:181:13: */ 7406 var i int32 7407 for i = 0; i < IDX_HASH_SIZE; i++ { 7408 var pEntry uintptr 7409 var pNext uintptr 7410 for pEntry = *(*uintptr)(unsafe.Pointer((pHash + 8 /* &.aHash */) + uintptr(i)*8)); pEntry != 0; pEntry = pNext { 7411 pNext = (*IdxHashEntry)(unsafe.Pointer(pEntry)).FpHashNext 7412 sqlite3.Xsqlite3_free(tls, (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzVal2) 7413 sqlite3.Xsqlite3_free(tls, pEntry) 7414 } 7415 } 7416 libc.Xmemset(tls, pHash, 0, uint64(unsafe.Sizeof(IdxHash{}))) 7417 } 7418 7419 // Return the index of the hash bucket that the string specified by the 7420 // arguments to this function belongs. 7421 func idxHashString(tls *libc.TLS, z uintptr, n int32) int32 { /* sqlite3expert.c:199:12: */ 7422 var ret uint32 = uint32(0) 7423 var i int32 7424 for i = 0; i < n; i++ { 7425 ret = ret + ((ret << 3) + uint32((uint8(*(*int8)(unsafe.Pointer(z + uintptr(i))))))) 7426 } 7427 return (int32(ret % uint32(IDX_HASH_SIZE))) 7428 } 7429 7430 // If zKey is already present in the hash table, return non-zero and do 7431 // nothing. Otherwise, add an entry with key zKey and payload string zVal to 7432 // the hash table passed as the second argument. 7433 func idxHashAdd(tls *libc.TLS, pRc uintptr, pHash uintptr, zKey uintptr, zVal uintptr) int32 { /* sqlite3expert.c:213:12: */ 7434 var nKey int32 = int32(libc.Xstrlen(tls, zKey)) 7435 var iHash int32 = idxHashString(tls, zKey, nKey) 7436 var nVal int32 = func() int32 { 7437 if zVal != 0 { 7438 return int32(libc.Xstrlen(tls, zVal)) 7439 } 7440 return 0 7441 }() 7442 var pEntry uintptr 7443 7444 for pEntry = *(*uintptr)(unsafe.Pointer((pHash + 8 /* &.aHash */) + uintptr(iHash)*8)); pEntry != 0; pEntry = (*IdxHashEntry)(unsafe.Pointer(pEntry)).FpHashNext { 7445 if (int32(libc.Xstrlen(tls, (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzKey)) == nKey) && (0 == libc.Xmemcmp(tls, (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzKey, zKey, uint64(nKey))) { 7446 return 1 7447 } 7448 } 7449 pEntry = idxMalloc(tls, pRc, (int32((((uint64(unsafe.Sizeof(IdxHashEntry{})) + uint64(nKey)) + uint64(1)) + uint64(nVal)) + uint64(1)))) 7450 if pEntry != 0 { 7451 (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzKey = (pEntry + 1*40) 7452 libc.Xmemcpy(tls, (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzKey, zKey, uint64(nKey)) 7453 if zVal != 0 { 7454 (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzVal = ((*IdxHashEntry)(unsafe.Pointer(pEntry)).FzKey + uintptr((nKey + 1))) 7455 libc.Xmemcpy(tls, (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzVal, zVal, uint64(nVal)) 7456 } 7457 (*IdxHashEntry)(unsafe.Pointer(pEntry)).FpHashNext = *(*uintptr)(unsafe.Pointer((pHash + 8 /* &.aHash */) + uintptr(iHash)*8)) 7458 *(*uintptr)(unsafe.Pointer((pHash + 8 /* &.aHash */) + uintptr(iHash)*8)) = pEntry 7459 7460 (*IdxHashEntry)(unsafe.Pointer(pEntry)).FpNext = (*IdxHash)(unsafe.Pointer(pHash)).FpFirst 7461 (*IdxHash)(unsafe.Pointer(pHash)).FpFirst = pEntry 7462 } 7463 return 0 7464 } 7465 7466 // If zKey/nKey is present in the hash table, return a pointer to the 7467 // hash-entry object. 7468 func idxHashFind(tls *libc.TLS, pHash uintptr, zKey uintptr, nKey int32) uintptr { /* sqlite3expert.c:250:21: */ 7469 var iHash int32 7470 var pEntry uintptr 7471 if nKey < 0 { 7472 nKey = int32(libc.Xstrlen(tls, zKey)) 7473 } 7474 iHash = idxHashString(tls, zKey, nKey) 7475 7476 for pEntry = *(*uintptr)(unsafe.Pointer((pHash + 8 /* &.aHash */) + uintptr(iHash)*8)); pEntry != 0; pEntry = (*IdxHashEntry)(unsafe.Pointer(pEntry)).FpHashNext { 7477 if (int32(libc.Xstrlen(tls, (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzKey)) == nKey) && (0 == libc.Xmemcmp(tls, (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzKey, zKey, uint64(nKey))) { 7478 return pEntry 7479 } 7480 } 7481 return uintptr(0) 7482 } 7483 7484 // If the hash table contains an entry with a key equal to the string 7485 // passed as the final two arguments to this function, return a pointer 7486 // to the payload string. Otherwise, if zKey/nKey is not present in the 7487 // hash table, return NULL. 7488 func idxHashSearch(tls *libc.TLS, pHash uintptr, zKey uintptr, nKey int32) uintptr { /* sqlite3expert.c:270:19: */ 7489 var pEntry uintptr = idxHashFind(tls, pHash, zKey, nKey) 7490 if pEntry != 0 { 7491 return (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzVal 7492 } 7493 return uintptr(0) 7494 } 7495 7496 // Allocate and return a new IdxConstraint object. Set the IdxConstraint.zColl 7497 // variable to point to a copy of nul-terminated string zColl. 7498 func idxNewConstraint(tls *libc.TLS, pRc uintptr, zColl uintptr) uintptr { /* sqlite3expert.c:280:22: */ 7499 var pNew uintptr 7500 var nColl int32 = int32(libc.Xstrlen(tls, zColl)) 7501 7502 pNew = idxMalloc(tls, pRc, (int32((uint64(unsafe.Sizeof(IdxConstraint{})) * uint64(nColl)) + uint64(1)))) 7503 if pNew != 0 { 7504 (*IdxConstraint)(unsafe.Pointer(pNew)).FzColl = (pNew + 1*40) 7505 libc.Xmemcpy(tls, (*IdxConstraint)(unsafe.Pointer(pNew)).FzColl, zColl, (uint64(nColl + 1))) 7506 } 7507 return pNew 7508 } 7509 7510 // An error associated with database handle db has just occurred. Pass 7511 // the error message to callback function xOut. 7512 func idxDatabaseError(tls *libc.TLS, db uintptr, pzErrmsg uintptr) { /* sqlite3expert.c:297:13: */ 7513 bp := tls.Alloc(8) 7514 defer tls.Free(8) 7515 7516 *(*uintptr)(unsafe.Pointer(pzErrmsg)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, db))) 7517 } 7518 7519 // Prepare an SQL statement. 7520 func idxPrepareStmt(tls *libc.TLS, db uintptr, ppStmt uintptr, pzErrmsg uintptr, zSql uintptr) int32 { /* sqlite3expert.c:307:12: */ 7521 var rc int32 = sqlite3.Xsqlite3_prepare_v2(tls, db, zSql, -1, ppStmt, uintptr(0)) 7522 if rc != SQLITE_OK { 7523 *(*uintptr)(unsafe.Pointer(ppStmt)) = uintptr(0) 7524 idxDatabaseError(tls, db, pzErrmsg) 7525 } 7526 return rc 7527 } 7528 7529 // Prepare an SQL statement using the results of a printf() formatting. 7530 func idxPrintfPrepareStmt(tls *libc.TLS, db uintptr, ppStmt uintptr, pzErrmsg uintptr, zFmt uintptr, va uintptr) int32 { /* sqlite3expert.c:324:12: */ 7531 var ap va_list 7532 _ = ap 7533 var rc int32 7534 var zSql uintptr 7535 ap = va 7536 zSql = sqlite3.Xsqlite3_vmprintf(tls, zFmt, ap) 7537 if zSql == uintptr(0) { 7538 rc = SQLITE_NOMEM 7539 } else { 7540 rc = idxPrepareStmt(tls, db, ppStmt, pzErrmsg, zSql) 7541 sqlite3.Xsqlite3_free(tls, zSql) 7542 } 7543 _ = ap 7544 return rc 7545 } 7546 7547 // ************************************************************************ 7548 // 7549 // Beginning of virtual table implementation. 7550 type ExpertVtab1 = struct { 7551 Fbase sqlite3_vtab 7552 FpTab uintptr 7553 FpExpert uintptr 7554 } /* sqlite3expert.c:350:9 */ 7555 7556 // ************************************************************************ 7557 // 7558 // Beginning of virtual table implementation. 7559 type ExpertVtab = ExpertVtab1 /* sqlite3expert.c:350:27 */ 7560 7561 type ExpertCsr1 = struct { 7562 Fbase sqlite3_vtab_cursor 7563 FpData uintptr 7564 } /* sqlite3expert.c:357:9 */ 7565 7566 type ExpertCsr = ExpertCsr1 /* sqlite3expert.c:357:26 */ 7567 7568 func expertDequote(tls *libc.TLS, zIn uintptr) uintptr { /* sqlite3expert.c:363:13: */ 7569 var n int32 = int32(libc.Xstrlen(tls, zIn)) 7570 var zRet uintptr = sqlite3.Xsqlite3_malloc(tls, n) 7571 7572 if zRet != 0 { 7573 var iOut int32 = 0 7574 var iIn int32 = 0 7575 for iIn = 1; iIn < (n - 1); iIn++ { 7576 if int32(*(*int8)(unsafe.Pointer(zIn + uintptr(iIn)))) == '\'' { 7577 7578 iIn++ 7579 } 7580 *(*int8)(unsafe.Pointer(zRet + uintptr(libc.PostIncInt32(&iOut, 1)))) = *(*int8)(unsafe.Pointer(zIn + uintptr(iIn))) 7581 } 7582 *(*int8)(unsafe.Pointer(zRet + uintptr(iOut))) = int8(0) 7583 } 7584 7585 return zRet 7586 } 7587 7588 // This function is the implementation of both the xConnect and xCreate 7589 // methods of the r-tree virtual table. 7590 // 7591 // argv[0] -> module name 7592 // argv[1] -> database name 7593 // argv[2] -> table name 7594 // argv[...] -> column names... 7595 func expertConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* sqlite3expert.c:395:12: */ 7596 bp := tls.Alloc(4) 7597 defer tls.Free(4) 7598 7599 var pExpert uintptr = pAux 7600 var p uintptr = uintptr(0) 7601 // var rc int32 at bp, 4 7602 7603 if argc != 4 { 7604 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3 /* "internal error!" */, 0) 7605 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_ERROR 7606 } else { 7607 var zCreateTable uintptr = expertDequote(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) 7608 if zCreateTable != 0 { 7609 *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3.Xsqlite3_declare_vtab(tls, db, zCreateTable) 7610 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 7611 p = idxMalloc(tls, bp /* &rc */, int32(unsafe.Sizeof(ExpertVtab{}))) 7612 } 7613 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 7614 (*ExpertVtab)(unsafe.Pointer(p)).FpExpert = pExpert 7615 (*ExpertVtab)(unsafe.Pointer(p)).FpTab = (*sqlite3expert)(unsafe.Pointer(pExpert)).FpTable 7616 7617 } 7618 sqlite3.Xsqlite3_free(tls, zCreateTable) 7619 } else { 7620 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_NOMEM 7621 } 7622 } 7623 7624 *(*uintptr)(unsafe.Pointer(ppVtab)) = p 7625 return *(*int32)(unsafe.Pointer(bp /* rc */)) 7626 } 7627 7628 func expertDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* sqlite3expert.c:431:12: */ 7629 var p uintptr = pVtab 7630 sqlite3.Xsqlite3_free(tls, p) 7631 return SQLITE_OK 7632 } 7633 7634 func expertBestIndex(tls *libc.TLS, pVtab uintptr, pIdxInfo uintptr) int32 { /* sqlite3expert.c:437:12: */ 7635 bp := tls.Alloc(4) 7636 defer tls.Free(4) 7637 7638 var p uintptr = pVtab 7639 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK 7640 var n int32 = 0 7641 var pScan uintptr 7642 var opmask int32 = ((((SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_GT) | SQLITE_INDEX_CONSTRAINT_LT) | SQLITE_INDEX_CONSTRAINT_GE) | SQLITE_INDEX_CONSTRAINT_LE) 7643 7644 pScan = idxMalloc(tls, bp /* &rc */, int32(unsafe.Sizeof(IdxScan{}))) 7645 if pScan != 0 { 7646 var i int32 7647 7648 // Link the new scan object into the list 7649 (*IdxScan)(unsafe.Pointer(pScan)).FpTab = (*ExpertVtab)(unsafe.Pointer(p)).FpTab 7650 (*IdxScan)(unsafe.Pointer(pScan)).FpNextScan = (*sqlite3expert)(unsafe.Pointer((*ExpertVtab)(unsafe.Pointer(p)).FpExpert)).FpScan 7651 (*sqlite3expert)(unsafe.Pointer((*ExpertVtab)(unsafe.Pointer(p)).FpExpert)).FpScan = pScan 7652 7653 // Add the constraints to the IdxScan object 7654 for i = 0; i < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; i++ { 7655 var pCons uintptr = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12) 7656 if ((((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fusable != 0) && 7657 ((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn >= 0)) && 7658 ((*IdxColumn)(unsafe.Pointer((*IdxTable)(unsafe.Pointer((*ExpertVtab)(unsafe.Pointer(p)).FpTab)).FaCol+uintptr((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn)*24)).FiPk == 0)) && 7659 ((int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) & opmask) != 0) { 7660 var pNew uintptr 7661 var zColl uintptr = sqlite3.Xsqlite3_vtab_collation(tls, pIdxInfo, i) 7662 pNew = idxNewConstraint(tls, bp /* &rc */, zColl) 7663 if pNew != 0 { 7664 (*IdxConstraint)(unsafe.Pointer(pNew)).FiCol = (*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn 7665 if int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ { 7666 (*IdxConstraint)(unsafe.Pointer(pNew)).FpNext = (*IdxScan)(unsafe.Pointer(pScan)).FpEq 7667 (*IdxScan)(unsafe.Pointer(pScan)).FpEq = pNew 7668 } else { 7669 (*IdxConstraint)(unsafe.Pointer(pNew)).FbRange = 1 7670 (*IdxConstraint)(unsafe.Pointer(pNew)).FpNext = (*IdxScan)(unsafe.Pointer(pScan)).FpRange 7671 (*IdxScan)(unsafe.Pointer(pScan)).FpRange = pNew 7672 } 7673 } 7674 n++ 7675 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = n 7676 } 7677 } 7678 7679 // Add the ORDER BY to the IdxScan object 7680 for i = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy - 1); i >= 0; i-- { 7681 var iCol int32 = (*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy + uintptr(i)*8)).FiColumn 7682 if iCol >= 0 { 7683 var pNew uintptr = idxNewConstraint(tls, bp /* &rc */, (*IdxColumn)(unsafe.Pointer((*IdxTable)(unsafe.Pointer((*ExpertVtab)(unsafe.Pointer(p)).FpTab)).FaCol+uintptr(iCol)*24)).FzColl) 7684 if pNew != 0 { 7685 (*IdxConstraint)(unsafe.Pointer(pNew)).FiCol = iCol 7686 (*IdxConstraint)(unsafe.Pointer(pNew)).FbDesc = int32((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy + uintptr(i)*8)).Fdesc) 7687 (*IdxConstraint)(unsafe.Pointer(pNew)).FpNext = (*IdxScan)(unsafe.Pointer(pScan)).FpOrder 7688 (*IdxConstraint)(unsafe.Pointer(pNew)).FpLink = (*IdxScan)(unsafe.Pointer(pScan)).FpOrder 7689 (*IdxScan)(unsafe.Pointer(pScan)).FpOrder = pNew 7690 n++ 7691 } 7692 } 7693 } 7694 } 7695 7696 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = (1000000.0 / (float64(n + 1))) 7697 return *(*int32)(unsafe.Pointer(bp /* rc */)) 7698 } 7699 7700 func expertUpdate(tls *libc.TLS, pVtab uintptr, nData int32, azData uintptr, pRowid uintptr) int32 { /* sqlite3expert.c:504:12: */ 7701 _ = pVtab 7702 _ = nData 7703 _ = azData 7704 _ = pRowid 7705 return SQLITE_OK 7706 } 7707 7708 // Virtual table module xOpen method. 7709 func expertOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* sqlite3expert.c:520:12: */ 7710 bp := tls.Alloc(4) 7711 defer tls.Free(4) 7712 7713 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK 7714 var pCsr uintptr 7715 _ = pVTab 7716 pCsr = idxMalloc(tls, bp /* &rc */, int32(unsafe.Sizeof(ExpertCsr{}))) 7717 *(*uintptr)(unsafe.Pointer(ppCursor)) = pCsr 7718 return *(*int32)(unsafe.Pointer(bp /* rc */)) 7719 } 7720 7721 // Virtual table module xClose method. 7722 func expertClose(tls *libc.TLS, cur uintptr) int32 { /* sqlite3expert.c:532:12: */ 7723 var pCsr uintptr = cur 7724 sqlite3.Xsqlite3_finalize(tls, (*ExpertCsr)(unsafe.Pointer(pCsr)).FpData) 7725 sqlite3.Xsqlite3_free(tls, pCsr) 7726 return SQLITE_OK 7727 } 7728 7729 // Virtual table module xEof method. 7730 // 7731 // Return non-zero if the cursor does not currently point to a valid 7732 // record (i.e if the scan has finished), or zero otherwise. 7733 func expertEof(tls *libc.TLS, cur uintptr) int32 { /* sqlite3expert.c:545:12: */ 7734 var pCsr uintptr = cur 7735 return (libc.Bool32((*ExpertCsr)(unsafe.Pointer(pCsr)).FpData == uintptr(0))) 7736 } 7737 7738 // Virtual table module xNext method. 7739 func expertNext(tls *libc.TLS, cur uintptr) int32 { /* sqlite3expert.c:553:12: */ 7740 var pCsr uintptr = cur 7741 var rc int32 = SQLITE_OK 7742 7743 rc = sqlite3.Xsqlite3_step(tls, (*ExpertCsr)(unsafe.Pointer(pCsr)).FpData) 7744 if rc != SQLITE_ROW { 7745 rc = sqlite3.Xsqlite3_finalize(tls, (*ExpertCsr)(unsafe.Pointer(pCsr)).FpData) 7746 (*ExpertCsr)(unsafe.Pointer(pCsr)).FpData = uintptr(0) 7747 } else { 7748 rc = SQLITE_OK 7749 } 7750 7751 return rc 7752 } 7753 7754 // Virtual table module xRowid method. 7755 func expertRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* sqlite3expert.c:572:12: */ 7756 _ = cur 7757 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = int64(0) 7758 return SQLITE_OK 7759 } 7760 7761 // Virtual table module xColumn method. 7762 func expertColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* sqlite3expert.c:581:12: */ 7763 var pCsr uintptr = cur 7764 var pVal uintptr 7765 pVal = sqlite3.Xsqlite3_column_value(tls, (*ExpertCsr)(unsafe.Pointer(pCsr)).FpData, i) 7766 if pVal != 0 { 7767 sqlite3.Xsqlite3_result_value(tls, ctx, pVal) 7768 } 7769 return SQLITE_OK 7770 } 7771 7772 // Virtual table module xFilter method. 7773 func expertFilter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* sqlite3expert.c:594:12: */ 7774 bp := tls.Alloc(8) 7775 defer tls.Free(8) 7776 7777 var pCsr uintptr = cur 7778 var pVtab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab 7779 var pExpert uintptr = (*ExpertVtab)(unsafe.Pointer(pVtab)).FpExpert 7780 var rc int32 7781 7782 _ = idxNum 7783 _ = idxStr 7784 _ = argc 7785 _ = argv 7786 rc = sqlite3.Xsqlite3_finalize(tls, (*ExpertCsr)(unsafe.Pointer(pCsr)).FpData) 7787 (*ExpertCsr)(unsafe.Pointer(pCsr)).FpData = uintptr(0) 7788 if rc == SQLITE_OK { 7789 rc = idxPrintfPrepareStmt(tls, (*sqlite3expert)(unsafe.Pointer(pExpert)).Fdb, (pCsr + 8 /* &.pData */), (pVtab /* &.base */ + 16 /* &.zErrMsg */), 7790 ts+19 /* "SELECT * FROM ma..." */, libc.VaList(bp, (*IdxTable)(unsafe.Pointer((*ExpertVtab)(unsafe.Pointer(pVtab)).FpTab)).FzName)) 7791 } 7792 7793 if rc == SQLITE_OK { 7794 rc = expertNext(tls, cur) 7795 } 7796 return rc 7797 } 7798 7799 func idxRegisterVtab(tls *libc.TLS, p uintptr) int32 { /* sqlite3expert.c:622:12: */ 7800 7801 return sqlite3.Xsqlite3_create_module(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, ts+56 /* "expert" */, uintptr(unsafe.Pointer(&expertModule)), p) 7802 } 7803 7804 var expertModule = sqlite3_module{ 7805 FiVersion: 2, // iVersion 7806 FxCreate: 0, // xCreate - create a table 7807 FxConnect: 0, // xConnect - connect to an existing table 7808 FxBestIndex: 0, // xBestIndex - Determine search strategy 7809 FxDisconnect: 0, // xDisconnect - Disconnect from a table 7810 FxDestroy: 0, // xDestroy - Drop a table 7811 FxOpen: 0, // xOpen - open a cursor 7812 FxClose: 0, // xClose - close a cursor 7813 FxFilter: 0, // xFilter - configure scan constraints 7814 FxNext: 0, // xNext - advance a cursor 7815 FxEof: 0, // xEof 7816 FxColumn: 0, // xColumn - read data 7817 FxRowid: 0, // xRowid - read data 7818 FxUpdate: 0, // xShadowName 7819 } /* sqlite3expert.c:623:25 */ 7820 7821 // 7822 // End of virtual table implementation. 7823 // 7824 // Finalize SQL statement pStmt. If (*pRc) is SQLITE_OK when this function 7825 // is called, set it to the return value of sqlite3_finalize() before 7826 // returning. Otherwise, discard the sqlite3_finalize() return value. 7827 func idxFinalize(tls *libc.TLS, pRc uintptr, pStmt uintptr) { /* sqlite3expert.c:660:13: */ 7828 var rc int32 = sqlite3.Xsqlite3_finalize(tls, pStmt) 7829 if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { 7830 *(*int32)(unsafe.Pointer(pRc)) = rc 7831 } 7832 } 7833 7834 // Attempt to allocate an IdxTable structure corresponding to table zTab 7835 // in the main database of connection db. If successful, set (*ppOut) to 7836 // point to the new object and return SQLITE_OK. Otherwise, return an 7837 // SQLite error code and set (*ppOut) to NULL. In this case *pzErrmsg may be 7838 // set to point to an error string. 7839 // 7840 // It is the responsibility of the caller to eventually free either the 7841 // IdxTable object or error message using sqlite3_free(). 7842 func idxGetTableInfo(tls *libc.TLS, db uintptr, zTab uintptr, ppOut uintptr, pzErrmsg uintptr) int32 { /* sqlite3expert.c:675:12: */ 7843 bp := tls.Alloc(40) 7844 defer tls.Free(40) 7845 7846 *(*uintptr)(unsafe.Pointer(bp + 8 /* p1 */)) = uintptr(0) 7847 var nCol int32 = 0 7848 var nTab int32 = int32(libc.Xstrlen(tls, zTab)) 7849 var nByte int32 = (int32((uint64(unsafe.Sizeof(IdxTable{})) + uint64(nTab)) + uint64(1))) 7850 var pNew uintptr = uintptr(0) 7851 // var rc int32 at bp+24, 4 7852 7853 var rc2 int32 7854 var pCsr uintptr = uintptr(0) 7855 var nPk int32 = 0 7856 7857 *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = idxPrintfPrepareStmt(tls, db, bp+8 /* &p1 */, pzErrmsg, ts+63 /* "PRAGMA table_xin..." */, libc.VaList(bp, zTab)) 7858 for (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* p1 */)))) { 7859 *(*uintptr)(unsafe.Pointer(bp + 16 /* zCol */)) = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* p1 */)), 1) 7860 nByte = nByte + (1 + int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* zCol */))))) 7861 *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = sqlite3.Xsqlite3_table_column_metadata(tls, 7862 db, ts+85 /* "main" */, zTab, *(*uintptr)(unsafe.Pointer(bp + 16 /* zCol */)), uintptr(0), bp+16 /* &zCol */, uintptr(0), uintptr(0), uintptr(0)) 7863 nByte = nByte + (1 + int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* zCol */))))) 7864 nCol++ 7865 nPk = nPk + (libc.Bool32(sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* p1 */)), 5) > 0)) 7866 } 7867 rc2 = sqlite3.Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* p1 */))) 7868 if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { 7869 *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = rc2 7870 } 7871 7872 nByte = int32(uint64(nByte) + (uint64(unsafe.Sizeof(IdxColumn{})) * uint64(nCol))) 7873 if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { 7874 pNew = idxMalloc(tls, bp+24 /* &rc */, nByte) 7875 } 7876 if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { 7877 (*IdxTable)(unsafe.Pointer(pNew)).FaCol = (pNew + 1*32) 7878 (*IdxTable)(unsafe.Pointer(pNew)).FnCol = nCol 7879 pCsr = ((*IdxTable)(unsafe.Pointer(pNew)).FaCol + uintptr(nCol)*24) 7880 } 7881 7882 nCol = 0 7883 for (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* p1 */)))) { 7884 *(*uintptr)(unsafe.Pointer(bp + 32 /* zCol */)) = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* p1 */)), 1) 7885 var nCopy int32 = (int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* zCol */)))) + 1) 7886 (*IdxColumn)(unsafe.Pointer((*IdxTable)(unsafe.Pointer(pNew)).FaCol + uintptr(nCol)*24)).FzName = pCsr 7887 (*IdxColumn)(unsafe.Pointer((*IdxTable)(unsafe.Pointer(pNew)).FaCol + uintptr(nCol)*24)).FiPk = (libc.Bool32((sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* p1 */)), 5) == 1) && (nPk == 1))) 7888 libc.Xmemcpy(tls, pCsr, *(*uintptr)(unsafe.Pointer(bp + 32 /* zCol */)), uint64(nCopy)) 7889 pCsr += uintptr(nCopy) 7890 7891 *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = sqlite3.Xsqlite3_table_column_metadata(tls, 7892 db, ts+85 /* "main" */, zTab, *(*uintptr)(unsafe.Pointer(bp + 32 /* zCol */)), uintptr(0), bp+32 /* &zCol */, uintptr(0), uintptr(0), uintptr(0)) 7893 if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { 7894 nCopy = (int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* zCol */)))) + 1) 7895 (*IdxColumn)(unsafe.Pointer((*IdxTable)(unsafe.Pointer(pNew)).FaCol + uintptr(nCol)*24)).FzColl = pCsr 7896 libc.Xmemcpy(tls, pCsr, *(*uintptr)(unsafe.Pointer(bp + 32 /* zCol */)), uint64(nCopy)) 7897 pCsr += uintptr(nCopy) 7898 } 7899 7900 nCol++ 7901 } 7902 idxFinalize(tls, bp+24 /* &rc */, *(*uintptr)(unsafe.Pointer(bp + 8 /* p1 */))) 7903 7904 if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) != SQLITE_OK { 7905 sqlite3.Xsqlite3_free(tls, pNew) 7906 pNew = uintptr(0) 7907 } else { 7908 (*IdxTable)(unsafe.Pointer(pNew)).FzName = pCsr 7909 libc.Xmemcpy(tls, (*IdxTable)(unsafe.Pointer(pNew)).FzName, zTab, (uint64(nTab + 1))) 7910 } 7911 7912 *(*uintptr)(unsafe.Pointer(ppOut)) = pNew 7913 return *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) 7914 } 7915 7916 // This function is a no-op if *pRc is set to anything other than 7917 // SQLITE_OK when it is called. 7918 // 7919 // If *pRc is initially set to SQLITE_OK, then the text specified by 7920 // the printf() style arguments is appended to zIn and the result returned 7921 // in a buffer allocated by sqlite3_malloc(). sqlite3_free() is called on 7922 // zIn before returning. 7923 func idxAppendText(tls *libc.TLS, pRc uintptr, zIn uintptr, zFmt uintptr, va uintptr) uintptr { /* sqlite3expert.c:758:13: */ 7924 var ap va_list 7925 _ = ap 7926 var zAppend uintptr = uintptr(0) 7927 var zRet uintptr = uintptr(0) 7928 var nIn int32 7929 if zIn != 0 { 7930 nIn = int32(libc.Xstrlen(tls, zIn)) 7931 } else { 7932 nIn = 0 7933 } 7934 var nAppend int32 = 0 7935 ap = va 7936 if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { 7937 zAppend = sqlite3.Xsqlite3_vmprintf(tls, zFmt, ap) 7938 if zAppend != 0 { 7939 nAppend = int32(libc.Xstrlen(tls, zAppend)) 7940 zRet = sqlite3.Xsqlite3_malloc(tls, ((nIn + nAppend) + 1)) 7941 } 7942 if (zAppend != 0) && (zRet != 0) { 7943 if nIn != 0 { 7944 libc.Xmemcpy(tls, zRet, zIn, uint64(nIn)) 7945 } 7946 libc.Xmemcpy(tls, (zRet + uintptr(nIn)), zAppend, (uint64(nAppend + 1))) 7947 } else { 7948 sqlite3.Xsqlite3_free(tls, zRet) 7949 zRet = uintptr(0) 7950 *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM 7951 } 7952 sqlite3.Xsqlite3_free(tls, zAppend) 7953 sqlite3.Xsqlite3_free(tls, zIn) 7954 } 7955 _ = ap 7956 return zRet 7957 } 7958 7959 // Return true if zId must be quoted in order to use it as an SQL 7960 // identifier, or false otherwise. 7961 func idxIdentifierRequiresQuotes(tls *libc.TLS, zId uintptr) int32 { /* sqlite3expert.c:790:12: */ 7962 var i int32 7963 for i = 0; *(*int8)(unsafe.Pointer(zId + uintptr(i))) != 0; i++ { 7964 if ((!(int32(*(*int8)(unsafe.Pointer(zId + uintptr(i)))) == '_') && 7965 !((int32(*(*int8)(unsafe.Pointer(zId + uintptr(i)))) >= '0') && (int32(*(*int8)(unsafe.Pointer(zId + uintptr(i)))) <= '9'))) && 7966 !((int32(*(*int8)(unsafe.Pointer(zId + uintptr(i)))) >= 'a') && (int32(*(*int8)(unsafe.Pointer(zId + uintptr(i)))) <= 'z'))) && 7967 !((int32(*(*int8)(unsafe.Pointer(zId + uintptr(i)))) >= 'A') && (int32(*(*int8)(unsafe.Pointer(zId + uintptr(i)))) <= 'Z')) { 7968 return 1 7969 } 7970 } 7971 return 0 7972 } 7973 7974 // This function appends an index column definition suitable for constraint 7975 // pCons to the string passed as zIn and returns the result. 7976 func idxAppendColDefn(tls *libc.TLS, pRc uintptr, zIn uintptr, pTab uintptr, pCons uintptr) uintptr { /* sqlite3expert.c:808:13: */ 7977 bp := tls.Alloc(32) 7978 defer tls.Free(32) 7979 7980 var zRet uintptr = zIn 7981 var p uintptr = ((*IdxTable)(unsafe.Pointer(pTab)).FaCol + uintptr((*IdxConstraint)(unsafe.Pointer(pCons)).FiCol)*24) 7982 if zRet != 0 { 7983 zRet = idxAppendText(tls, pRc, zRet, ts+90 /* ", " */, 0) 7984 } 7985 7986 if idxIdentifierRequiresQuotes(tls, (*IdxColumn)(unsafe.Pointer(p)).FzName) != 0 { 7987 zRet = idxAppendText(tls, pRc, zRet, ts+93 /* "%Q" */, libc.VaList(bp, (*IdxColumn)(unsafe.Pointer(p)).FzName)) 7988 } else { 7989 zRet = idxAppendText(tls, pRc, zRet, ts /* "%s" */, libc.VaList(bp+8, (*IdxColumn)(unsafe.Pointer(p)).FzName)) 7990 } 7991 7992 if sqlite3.Xsqlite3_stricmp(tls, (*IdxColumn)(unsafe.Pointer(p)).FzColl, (*IdxConstraint)(unsafe.Pointer(pCons)).FzColl) != 0 { 7993 if idxIdentifierRequiresQuotes(tls, (*IdxConstraint)(unsafe.Pointer(pCons)).FzColl) != 0 { 7994 zRet = idxAppendText(tls, pRc, zRet, ts+96 /* " COLLATE %Q" */, libc.VaList(bp+16, (*IdxConstraint)(unsafe.Pointer(pCons)).FzColl)) 7995 } else { 7996 zRet = idxAppendText(tls, pRc, zRet, ts+108 /* " COLLATE %s" */, libc.VaList(bp+24, (*IdxConstraint)(unsafe.Pointer(pCons)).FzColl)) 7997 } 7998 } 7999 8000 if (*IdxConstraint)(unsafe.Pointer(pCons)).FbDesc != 0 { 8001 zRet = idxAppendText(tls, pRc, zRet, ts+120 /* " DESC" */, 0) 8002 } 8003 return zRet 8004 } 8005 8006 // Search database dbm for an index compatible with the one idxCreateFromCons() 8007 // would create from arguments pScan, pEq and pTail. If no error occurs and 8008 // such an index is found, return non-zero. Or, if no such index is found, 8009 // return zero. 8010 // 8011 // If an error occurs, set *pRc to an SQLite error code and return zero. 8012 func idxFindCompatible(tls *libc.TLS, pRc uintptr, dbm uintptr, pScan uintptr, pEq uintptr, pTail uintptr) int32 { /* sqlite3expert.c:846:12: */ 8013 bp := tls.Alloc(36) 8014 defer tls.Free(36) 8015 8016 var zTbl uintptr = (*IdxTable)(unsafe.Pointer((*IdxScan)(unsafe.Pointer(pScan)).FpTab)).FzName 8017 *(*uintptr)(unsafe.Pointer(bp + 16 /* pIdxList */)) = uintptr(0) 8018 var pIter uintptr 8019 var nEq int32 = 0 // Number of elements in pEq 8020 // var rc int32 at bp+32, 4 8021 8022 // Count the elements in list pEq 8023 for pIter = pEq; pIter != 0; pIter = (*IdxConstraint)(unsafe.Pointer(pIter)).FpLink { 8024 nEq++ 8025 } 8026 8027 *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = idxPrintfPrepareStmt(tls, dbm, bp+16 /* &pIdxList */, uintptr(0), ts+126 /* "PRAGMA index_lis..." */, libc.VaList(bp, zTbl)) 8028 for (*(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK) && (sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pIdxList */))) == SQLITE_ROW) { 8029 var bMatch int32 = 1 8030 var pT uintptr = pTail 8031 *(*uintptr)(unsafe.Pointer(bp + 24 /* pInfo */)) = uintptr(0) 8032 var zIdx uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pIdxList */)), 1) 8033 8034 // Zero the IdxConstraint.bFlag values in the pEq list 8035 for pIter = pEq; pIter != 0; pIter = (*IdxConstraint)(unsafe.Pointer(pIter)).FpLink { 8036 (*IdxConstraint)(unsafe.Pointer(pIter)).FbFlag = 0 8037 } 8038 8039 *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = idxPrintfPrepareStmt(tls, dbm, bp+24 /* &pInfo */, uintptr(0), ts+147 /* "PRAGMA index_xIn..." */, libc.VaList(bp+8, zIdx)) 8040 for (*(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK) && (sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pInfo */))) == SQLITE_ROW) { 8041 var iIdx int32 = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pInfo */)), 0) 8042 var iCol int32 = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pInfo */)), 1) 8043 var zColl uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pInfo */)), 4) 8044 8045 if iIdx < nEq { 8046 for pIter = pEq; pIter != 0; pIter = (*IdxConstraint)(unsafe.Pointer(pIter)).FpLink { 8047 if (*IdxConstraint)(unsafe.Pointer(pIter)).FbFlag != 0 { 8048 continue 8049 } 8050 if (*IdxConstraint)(unsafe.Pointer(pIter)).FiCol != iCol { 8051 continue 8052 } 8053 if sqlite3.Xsqlite3_stricmp(tls, (*IdxConstraint)(unsafe.Pointer(pIter)).FzColl, zColl) != 0 { 8054 continue 8055 } 8056 (*IdxConstraint)(unsafe.Pointer(pIter)).FbFlag = 1 8057 break 8058 } 8059 if pIter == uintptr(0) { 8060 bMatch = 0 8061 break 8062 } 8063 } else { 8064 if pT != 0 { 8065 if ((*IdxConstraint)(unsafe.Pointer(pT)).FiCol != iCol) || (sqlite3.Xsqlite3_stricmp(tls, (*IdxConstraint)(unsafe.Pointer(pT)).FzColl, zColl) != 0) { 8066 bMatch = 0 8067 break 8068 } 8069 pT = (*IdxConstraint)(unsafe.Pointer(pT)).FpLink 8070 } 8071 } 8072 } 8073 idxFinalize(tls, bp+32 /* &rc */, *(*uintptr)(unsafe.Pointer(bp + 24 /* pInfo */))) 8074 8075 if (*(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK) && (bMatch != 0) { 8076 sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pIdxList */))) 8077 return 1 8078 } 8079 } 8080 idxFinalize(tls, bp+32 /* &rc */, *(*uintptr)(unsafe.Pointer(bp + 16 /* pIdxList */))) 8081 8082 *(*int32)(unsafe.Pointer(pRc)) = *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) 8083 return 0 8084 } 8085 8086 func idxCreateFromCons(tls *libc.TLS, p uintptr, pScan uintptr, pEq uintptr, pTail uintptr) int32 { /* sqlite3expert.c:913:12: */ 8087 bp := tls.Alloc(44) 8088 defer tls.Free(44) 8089 8090 var dbm uintptr = (*sqlite3expert)(unsafe.Pointer(p)).Fdbm 8091 *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_OK 8092 if ((pEq != 0) || (pTail != 0)) && (0 == idxFindCompatible(tls, bp+40 /* &rc */, dbm, pScan, pEq, pTail)) { 8093 var pTab uintptr = (*IdxScan)(unsafe.Pointer(pScan)).FpTab 8094 var zCols uintptr = uintptr(0) 8095 var zIdx uintptr = uintptr(0) 8096 var pCons uintptr 8097 var h uint32 = uint32(0) 8098 var zFmt uintptr 8099 8100 for pCons = pEq; pCons != 0; pCons = (*IdxConstraint)(unsafe.Pointer(pCons)).FpLink { 8101 zCols = idxAppendColDefn(tls, bp+40 /* &rc */, zCols, pTab, pCons) 8102 } 8103 for pCons = pTail; pCons != 0; pCons = (*IdxConstraint)(unsafe.Pointer(pCons)).FpLink { 8104 zCols = idxAppendColDefn(tls, bp+40 /* &rc */, zCols, pTab, pCons) 8105 } 8106 8107 if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { 8108 // Hash the list of columns to come up with a name for the index 8109 var zTable uintptr = (*IdxTable)(unsafe.Pointer((*IdxScan)(unsafe.Pointer(pScan)).FpTab)).FzName 8110 var zName uintptr // Index name 8111 var i int32 8112 for i = 0; *(*int8)(unsafe.Pointer(zCols + uintptr(i))) != 0; i++ { 8113 h = h + ((h << 3) + uint32(*(*int8)(unsafe.Pointer(zCols + uintptr(i))))) 8114 } 8115 zName = sqlite3.Xsqlite3_mprintf(tls, ts+169 /* "%s_idx_%08x" */, libc.VaList(bp, zTable, h)) 8116 if zName == uintptr(0) { 8117 *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_NOMEM 8118 } else { 8119 if idxIdentifierRequiresQuotes(tls, zTable) != 0 { 8120 zFmt = ts + 181 /* "CREATE INDEX '%q..." */ 8121 } else { 8122 zFmt = ts + 209 /* "CREATE INDEX %s ..." */ 8123 } 8124 zIdx = sqlite3.Xsqlite3_mprintf(tls, zFmt, libc.VaList(bp+16, zName, zTable, zCols)) 8125 if !(zIdx != 0) { 8126 *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_NOMEM 8127 } else { 8128 *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = sqlite3.Xsqlite3_exec(tls, dbm, zIdx, uintptr(0), uintptr(0), (*sqlite3expert)(unsafe.Pointer(p)).FpzErrmsg) 8129 idxHashAdd(tls, bp+40 /* &rc */, (p + 88 /* &.hIdx */), zName, zIdx) 8130 } 8131 sqlite3.Xsqlite3_free(tls, zName) 8132 sqlite3.Xsqlite3_free(tls, zIdx) 8133 } 8134 } 8135 8136 sqlite3.Xsqlite3_free(tls, zCols) 8137 } 8138 return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) 8139 } 8140 8141 // Return true if list pList (linked by IdxConstraint.pLink) contains 8142 // a constraint compatible with *p. Otherwise return false. 8143 func idxFindConstraint(tls *libc.TLS, pList uintptr, p uintptr) int32 { /* sqlite3expert.c:974:12: */ 8144 var pCmp uintptr 8145 for pCmp = pList; pCmp != 0; pCmp = (*IdxConstraint)(unsafe.Pointer(pCmp)).FpLink { 8146 if (*IdxConstraint)(unsafe.Pointer(p)).FiCol == (*IdxConstraint)(unsafe.Pointer(pCmp)).FiCol { 8147 return 1 8148 } 8149 } 8150 return 0 8151 } 8152 8153 func idxCreateFromWhere(tls *libc.TLS, p uintptr, pScan uintptr, pTail uintptr) int32 { /* sqlite3expert.c:982:12: */ 8154 var p1 uintptr = uintptr(0) 8155 var pCon uintptr 8156 var rc int32 8157 8158 // Gather up all the == constraints. 8159 for pCon = (*IdxScan)(unsafe.Pointer(pScan)).FpEq; pCon != 0; pCon = (*IdxConstraint)(unsafe.Pointer(pCon)).FpNext { 8160 if !(idxFindConstraint(tls, p1, pCon) != 0) && !(idxFindConstraint(tls, pTail, pCon) != 0) { 8161 (*IdxConstraint)(unsafe.Pointer(pCon)).FpLink = p1 8162 p1 = pCon 8163 } 8164 } 8165 8166 // Create an index using the == constraints collected above. And the 8167 // range constraint/ORDER BY terms passed in by the caller, if any. 8168 rc = idxCreateFromCons(tls, p, pScan, p1, pTail) 8169 8170 // If no range/ORDER BY passed by the caller, create a version of the 8171 // index for each range constraint. 8172 if pTail == uintptr(0) { 8173 for pCon = (*IdxScan)(unsafe.Pointer(pScan)).FpRange; (rc == SQLITE_OK) && (pCon != 0); pCon = (*IdxConstraint)(unsafe.Pointer(pCon)).FpNext { 8174 8175 if !(idxFindConstraint(tls, p1, pCon) != 0) && !(idxFindConstraint(tls, pTail, pCon) != 0) { 8176 rc = idxCreateFromCons(tls, p, pScan, p1, pCon) 8177 } 8178 } 8179 } 8180 8181 return rc 8182 } 8183 8184 // Create candidate indexes in database [dbm] based on the data in 8185 // linked-list pScan. 8186 func idxCreateCandidates(tls *libc.TLS, p uintptr) int32 { /* sqlite3expert.c:1021:12: */ 8187 var rc int32 = SQLITE_OK 8188 var pIter uintptr 8189 8190 for pIter = (*sqlite3expert)(unsafe.Pointer(p)).FpScan; (pIter != 0) && (rc == SQLITE_OK); pIter = (*IdxScan)(unsafe.Pointer(pIter)).FpNextScan { 8191 rc = idxCreateFromWhere(tls, p, pIter, uintptr(0)) 8192 if (rc == SQLITE_OK) && ((*IdxScan)(unsafe.Pointer(pIter)).FpOrder != 0) { 8193 rc = idxCreateFromWhere(tls, p, pIter, (*IdxScan)(unsafe.Pointer(pIter)).FpOrder) 8194 } 8195 } 8196 8197 return rc 8198 } 8199 8200 // Free all elements of the linked list starting at pConstraint. 8201 func idxConstraintFree(tls *libc.TLS, pConstraint uintptr) { /* sqlite3expert.c:1038:13: */ 8202 var pNext uintptr 8203 var p uintptr 8204 8205 for p = pConstraint; p != 0; p = pNext { 8206 pNext = (*IdxConstraint)(unsafe.Pointer(p)).FpNext 8207 sqlite3.Xsqlite3_free(tls, p) 8208 } 8209 } 8210 8211 // Free all elements of the linked list starting from pScan up until pLast 8212 // (pLast is not freed). 8213 func idxScanFree(tls *libc.TLS, pScan uintptr, pLast uintptr) { /* sqlite3expert.c:1052:13: */ 8214 var p uintptr 8215 var pNext uintptr 8216 for p = pScan; p != pLast; p = pNext { 8217 pNext = (*IdxScan)(unsafe.Pointer(p)).FpNextScan 8218 idxConstraintFree(tls, (*IdxScan)(unsafe.Pointer(p)).FpOrder) 8219 idxConstraintFree(tls, (*IdxScan)(unsafe.Pointer(p)).FpEq) 8220 idxConstraintFree(tls, (*IdxScan)(unsafe.Pointer(p)).FpRange) 8221 sqlite3.Xsqlite3_free(tls, p) 8222 } 8223 } 8224 8225 // Free all elements of the linked list starting from pStatement up 8226 // until pLast (pLast is not freed). 8227 func idxStatementFree(tls *libc.TLS, pStatement uintptr, pLast uintptr) { /* sqlite3expert.c:1068:13: */ 8228 var p uintptr 8229 var pNext uintptr 8230 for p = pStatement; p != pLast; p = pNext { 8231 pNext = (*IdxStatement)(unsafe.Pointer(p)).FpNext 8232 sqlite3.Xsqlite3_free(tls, (*IdxStatement)(unsafe.Pointer(p)).FzEQP) 8233 sqlite3.Xsqlite3_free(tls, (*IdxStatement)(unsafe.Pointer(p)).FzIdx) 8234 sqlite3.Xsqlite3_free(tls, p) 8235 } 8236 } 8237 8238 // Free the linked list of IdxTable objects starting at pTab. 8239 func idxTableFree(tls *libc.TLS, pTab uintptr) { /* sqlite3expert.c:1082:13: */ 8240 var pIter uintptr 8241 var pNext uintptr 8242 for pIter = pTab; pIter != 0; pIter = pNext { 8243 pNext = (*IdxTable)(unsafe.Pointer(pIter)).FpNext 8244 sqlite3.Xsqlite3_free(tls, pIter) 8245 } 8246 } 8247 8248 // Free the linked list of IdxWrite objects starting at pTab. 8249 func idxWriteFree(tls *libc.TLS, pTab uintptr) { /* sqlite3expert.c:1094:13: */ 8250 var pIter uintptr 8251 var pNext uintptr 8252 for pIter = pTab; pIter != 0; pIter = pNext { 8253 pNext = (*IdxWrite)(unsafe.Pointer(pIter)).FpNext 8254 sqlite3.Xsqlite3_free(tls, pIter) 8255 } 8256 } 8257 8258 // This function is called after candidate indexes have been created. It 8259 // runs all the queries to see which indexes they prefer, and populates 8260 // IdxStatement.zIdx and IdxStatement.zEQP with the results. 8261 func idxFindIndexes(tls *libc.TLS, p uintptr, pzErr uintptr) int32 { /* sqlite3expert.c:1110:5: */ 8262 bp := tls.Alloc(8228) 8263 defer tls.Free(8228) 8264 8265 var pStmt uintptr 8266 var dbm uintptr 8267 // var rc int32 at bp+8224, 4 8268 8269 // var hIdx IdxHash at bp+24, 8192 8270 8271 var zSql uintptr 8272 var nIdx int32 8273 var zIdx uintptr 8274 // int iId = sqlite3_column_int(pExplain, 0); 8275 // int iParent = sqlite3_column_int(pExplain, 1); 8276 // int iNotUsed = sqlite3_column_int(pExplain, 2); 8277 var zDetail uintptr 8278 var nDetail int32 8279 var i int32 8280 var pEntry uintptr 8281 // var pExplain uintptr at bp+8216, 8 8282 dbm = (*sqlite3expert)(unsafe.Pointer(p)).Fdbm 8283 *(*int32)(unsafe.Pointer(bp + 8224 /* rc */)) = SQLITE_OK 8284 idxHashInit(tls, bp+24 /* &hIdx */) 8285 8286 pStmt = (*sqlite3expert)(unsafe.Pointer(p)).FpStatement 8287 __1: 8288 if !((*(*int32)(unsafe.Pointer(bp + 8224 /* rc */)) == SQLITE_OK) && (pStmt != 0)) { 8289 goto __3 8290 } 8291 *(*uintptr)(unsafe.Pointer(bp + 8216 /* pExplain */)) = uintptr(0) 8292 idxHashClear(tls, bp+24 /* &hIdx */) 8293 *(*int32)(unsafe.Pointer(bp + 8224 /* rc */)) = idxPrintfPrepareStmt(tls, dbm, bp+8216 /* &pExplain */, pzErr, 8294 ts+235 /* "EXPLAIN QUERY PL..." */, libc.VaList(bp, (*IdxStatement)(unsafe.Pointer(pStmt)).FzSql)) 8295 __4: 8296 if !((*(*int32)(unsafe.Pointer(bp + 8224 /* rc */)) == SQLITE_OK) && (sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8216 /* pExplain */))) == SQLITE_ROW)) { 8297 goto __5 8298 } 8299 // int iId = sqlite3_column_int(pExplain, 0); 8300 // int iParent = sqlite3_column_int(pExplain, 1); 8301 // int iNotUsed = sqlite3_column_int(pExplain, 2); 8302 zDetail = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 8216 /* pExplain */)), 3) 8303 8304 if !(!(zDetail != 0)) { 8305 goto __6 8306 } 8307 goto __4 8308 __6: 8309 ; 8310 nDetail = int32(libc.Xstrlen(tls, zDetail)) 8311 8312 i = 0 8313 __7: 8314 if !(i < nDetail) { 8315 goto __9 8316 } 8317 zIdx = uintptr(0) 8318 if !(((i + 13) < nDetail) && (libc.Xmemcmp(tls, (zDetail+uintptr(i)), ts+257 /* " USING INDEX " */, uint64(13)) == 0)) { 8319 goto __10 8320 } 8321 zIdx = (zDetail + uintptr((i + 13))) 8322 goto __11 8323 __10: 8324 if !(((i + 22) < nDetail) && 8325 (libc.Xmemcmp(tls, (zDetail+uintptr(i)), ts+271 /* " USING COVERING ..." */, uint64(22)) == 0)) { 8326 goto __12 8327 } 8328 zIdx = (zDetail + uintptr((i + 22))) 8329 __12: 8330 ; 8331 __11: 8332 ; 8333 if !(zIdx != 0) { 8334 goto __13 8335 } 8336 nIdx = 0 8337 __14: 8338 if !((int32(*(*int8)(unsafe.Pointer(zIdx + uintptr(nIdx)))) != 0) && ((int32(*(*int8)(unsafe.Pointer(zIdx + uintptr(nIdx)))) != ' ') || (int32(*(*int8)(unsafe.Pointer(zIdx + uintptr((nIdx + 1))))) != '('))) { 8339 goto __15 8340 } 8341 nIdx++ 8342 goto __14 8343 __15: 8344 ; 8345 zSql = idxHashSearch(tls, (p + 88 /* &.hIdx */), zIdx, nIdx) 8346 if !(zSql != 0) { 8347 goto __16 8348 } 8349 idxHashAdd(tls, bp+8224 /* &rc */, bp+24 /* &hIdx */, zSql, uintptr(0)) 8350 if !(*(*int32)(unsafe.Pointer(bp + 8224 /* rc */)) != 0) { 8351 goto __17 8352 } 8353 goto find_indexes_out 8354 __17: 8355 ; 8356 __16: 8357 ; 8358 goto __9 8359 __13: 8360 ; 8361 goto __8 8362 __8: 8363 i++ 8364 goto __7 8365 goto __9 8366 __9: 8367 ; 8368 8369 if !(int32(*(*int8)(unsafe.Pointer(zDetail))) != '-') { 8370 goto __18 8371 } 8372 (*IdxStatement)(unsafe.Pointer(pStmt)).FzEQP = idxAppendText(tls, bp+8224 /* &rc */, (*IdxStatement)(unsafe.Pointer(pStmt)).FzEQP, ts+294 /* "%s\n" */, libc.VaList(bp+8, zDetail)) 8373 __18: 8374 ; 8375 goto __4 8376 __5: 8377 ; 8378 8379 pEntry = (*IdxHash)(unsafe.Pointer(bp + 24 /* &hIdx */)).FpFirst 8380 __19: 8381 if !(pEntry != 0) { 8382 goto __21 8383 } 8384 (*IdxStatement)(unsafe.Pointer(pStmt)).FzIdx = idxAppendText(tls, bp+8224 /* &rc */, (*IdxStatement)(unsafe.Pointer(pStmt)).FzIdx, ts+298 /* "%s;\n" */, libc.VaList(bp+16, (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzKey)) 8385 goto __20 8386 __20: 8387 pEntry = (*IdxHashEntry)(unsafe.Pointer(pEntry)).FpNext 8388 goto __19 8389 goto __21 8390 __21: 8391 ; 8392 8393 idxFinalize(tls, bp+8224 /* &rc */, *(*uintptr)(unsafe.Pointer(bp + 8216 /* pExplain */))) 8394 goto __2 8395 __2: 8396 pStmt = (*IdxStatement)(unsafe.Pointer(pStmt)).FpNext 8397 goto __1 8398 goto __3 8399 __3: 8400 ; 8401 8402 find_indexes_out: 8403 idxHashClear(tls, bp+24 /* &hIdx */) 8404 return *(*int32)(unsafe.Pointer(bp + 8224 /* rc */)) 8405 } 8406 8407 func idxAuthCallback(tls *libc.TLS, pCtx uintptr, eOp int32, z3 uintptr, z4 uintptr, zDb uintptr, zTrigger uintptr) int32 { /* sqlite3expert.c:1180:12: */ 8408 bp := tls.Alloc(4) 8409 defer tls.Free(4) 8410 8411 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK 8412 _ = z4 8413 _ = zTrigger 8414 if ((eOp == SQLITE_INSERT) || (eOp == SQLITE_UPDATE)) || (eOp == SQLITE_DELETE) { 8415 if sqlite3.Xsqlite3_stricmp(tls, zDb, ts+85 /* "main" */) == 0 { 8416 var p uintptr = pCtx 8417 var pTab uintptr 8418 for pTab = (*sqlite3expert)(unsafe.Pointer(p)).FpTable; pTab != 0; pTab = (*IdxTable)(unsafe.Pointer(pTab)).FpNext { 8419 if 0 == sqlite3.Xsqlite3_stricmp(tls, z3, (*IdxTable)(unsafe.Pointer(pTab)).FzName) { 8420 break 8421 } 8422 } 8423 if pTab != 0 { 8424 var pWrite uintptr 8425 for pWrite = (*sqlite3expert)(unsafe.Pointer(p)).FpWrite; pWrite != 0; pWrite = (*IdxWrite)(unsafe.Pointer(pWrite)).FpNext { 8426 if ((*IdxWrite)(unsafe.Pointer(pWrite)).FpTab == pTab) && ((*IdxWrite)(unsafe.Pointer(pWrite)).FeOp == eOp) { 8427 break 8428 } 8429 } 8430 if pWrite == uintptr(0) { 8431 pWrite = idxMalloc(tls, bp /* &rc */, int32(unsafe.Sizeof(IdxWrite{}))) 8432 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 8433 (*IdxWrite)(unsafe.Pointer(pWrite)).FpTab = pTab 8434 (*IdxWrite)(unsafe.Pointer(pWrite)).FeOp = eOp 8435 (*IdxWrite)(unsafe.Pointer(pWrite)).FpNext = (*sqlite3expert)(unsafe.Pointer(p)).FpWrite 8436 (*sqlite3expert)(unsafe.Pointer(p)).FpWrite = pWrite 8437 } 8438 } 8439 } 8440 } 8441 } 8442 return *(*int32)(unsafe.Pointer(bp /* rc */)) 8443 } 8444 8445 func idxProcessOneTrigger(tls *libc.TLS, p uintptr, pWrite uintptr, pzErr uintptr) int32 { /* sqlite3expert.c:1218:12: */ 8446 bp := tls.Alloc(104) 8447 defer tls.Free(104) 8448 8449 var pTab uintptr = (*IdxWrite)(unsafe.Pointer(pWrite)).FpTab 8450 var zTab uintptr = (*IdxTable)(unsafe.Pointer(pTab)).FzName 8451 var zSql uintptr = ts + 303 /* "SELECT 'CREATE T..." */ 8452 *(*uintptr)(unsafe.Pointer(bp + 80 /* pSelect */)) = uintptr(0) 8453 *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = SQLITE_OK 8454 var zWrite uintptr = uintptr(0) 8455 8456 // Create the table and its triggers in the temp schema 8457 *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = idxPrintfPrepareStmt(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdb, bp+80 /* &pSelect */, pzErr, zSql, libc.VaList(bp, zTab, zTab)) 8458 for (*(*int32)(unsafe.Pointer(bp + 88 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pSelect */)))) { 8459 var zCreate uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pSelect */)), 0) 8460 *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, zCreate, uintptr(0), uintptr(0), pzErr) 8461 } 8462 idxFinalize(tls, bp+88 /* &rc */, *(*uintptr)(unsafe.Pointer(bp + 80 /* pSelect */))) 8463 8464 // Rename the table in the temp schema to zInt 8465 if *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) == SQLITE_OK { 8466 var z uintptr = sqlite3.Xsqlite3_mprintf(tls, ts+429 /* "ALTER TABLE temp..." */, libc.VaList(bp+16, zTab, zInt)) 8467 if z == uintptr(0) { 8468 *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = SQLITE_NOMEM 8469 } else { 8470 *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, z, uintptr(0), uintptr(0), pzErr) 8471 sqlite3.Xsqlite3_free(tls, z) 8472 } 8473 } 8474 8475 switch (*IdxWrite)(unsafe.Pointer(pWrite)).FeOp { 8476 case SQLITE_INSERT: 8477 { 8478 var i int32 8479 zWrite = idxAppendText(tls, bp+88 /* &rc */, zWrite, ts+462 /* "INSERT INTO %Q V..." */, libc.VaList(bp+32, zInt)) 8480 for i = 0; i < (*IdxTable)(unsafe.Pointer(pTab)).FnCol; i++ { 8481 zWrite = idxAppendText(tls, bp+88 /* &rc */, zWrite, ts+485 /* "%s?" */, libc.VaList(bp+40, func() uintptr { 8482 if i == 0 { 8483 return ts + 489 /* "" */ 8484 } 8485 return ts + 90 /* ", " */ 8486 }())) 8487 } 8488 zWrite = idxAppendText(tls, bp+88 /* &rc */, zWrite, ts+490 /* ")" */, 0) 8489 break 8490 8491 } 8492 case SQLITE_UPDATE: 8493 { 8494 var i int32 8495 zWrite = idxAppendText(tls, bp+88 /* &rc */, zWrite, ts+492 /* "UPDATE %Q SET " */, libc.VaList(bp+48, zInt)) 8496 for i = 0; i < (*IdxTable)(unsafe.Pointer(pTab)).FnCol; i++ { 8497 zWrite = idxAppendText(tls, bp+88 /* &rc */, zWrite, ts+507 /* "%s%Q=?" */, libc.VaList(bp+56, func() uintptr { 8498 if i == 0 { 8499 return ts + 489 /* "" */ 8500 } 8501 return ts + 90 /* ", " */ 8502 }(), 8503 (*IdxColumn)(unsafe.Pointer((*IdxTable)(unsafe.Pointer(pTab)).FaCol+uintptr(i)*24)).FzName)) 8504 } 8505 break 8506 8507 } 8508 default: 8509 { 8510 8511 if *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) == SQLITE_OK { 8512 zWrite = sqlite3.Xsqlite3_mprintf(tls, ts+514 /* "DELETE FROM %Q" */, libc.VaList(bp+72, zInt)) 8513 if zWrite == uintptr(0) { 8514 *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = SQLITE_NOMEM 8515 } 8516 } 8517 8518 } 8519 } 8520 8521 if *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) == SQLITE_OK { 8522 *(*uintptr)(unsafe.Pointer(bp + 96 /* pX */)) = uintptr(0) 8523 *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = sqlite3.Xsqlite3_prepare_v2(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, zWrite, -1, bp+96 /* &pX */, uintptr(0)) 8524 idxFinalize(tls, bp+88 /* &rc */, *(*uintptr)(unsafe.Pointer(bp + 96 /* pX */))) 8525 if *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) != SQLITE_OK { 8526 idxDatabaseError(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, pzErr) 8527 } 8528 } 8529 sqlite3.Xsqlite3_free(tls, zWrite) 8530 8531 if *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) == SQLITE_OK { 8532 *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, zDrop, uintptr(0), uintptr(0), pzErr) 8533 } 8534 8535 return *(*int32)(unsafe.Pointer(bp + 88 /* rc */)) 8536 } 8537 8538 var zInt uintptr = ts + 529 /* "t592690916721053..." */ /* sqlite3expert.c:1223:21 */ 8539 var zDrop uintptr = ts + 567 /* "DROP TABLE t5926..." */ /* sqlite3expert.c:1224:21 */ 8540 8541 func idxProcessTriggers(tls *libc.TLS, p uintptr, pzErr uintptr) int32 { /* sqlite3expert.c:1300:12: */ 8542 var rc int32 = SQLITE_OK 8543 var pEnd uintptr = uintptr(0) 8544 var pFirst uintptr = (*sqlite3expert)(unsafe.Pointer(p)).FpWrite 8545 8546 for (rc == SQLITE_OK) && (pFirst != pEnd) { 8547 var pIter uintptr 8548 for pIter = pFirst; (rc == SQLITE_OK) && (pIter != pEnd); pIter = (*IdxWrite)(unsafe.Pointer(pIter)).FpNext { 8549 rc = idxProcessOneTrigger(tls, p, pIter, pzErr) 8550 } 8551 pEnd = pFirst 8552 pFirst = (*sqlite3expert)(unsafe.Pointer(p)).FpWrite 8553 } 8554 8555 return rc 8556 } 8557 8558 func idxCreateVtabSchema(tls *libc.TLS, p uintptr, pzErrmsg uintptr) int32 { /* sqlite3expert.c:1318:12: */ 8559 bp := tls.Alloc(60) 8560 defer tls.Free(60) 8561 8562 *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = idxRegisterVtab(tls, p) 8563 *(*uintptr)(unsafe.Pointer(bp + 40 /* pSchema */)) = uintptr(0) 8564 8565 // For each table in the main db schema: 8566 // 8567 // 1) Add an entry to the p->pTable list, and 8568 // 2) Create the equivalent virtual table in dbv. 8569 *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = idxPrepareStmt(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdb, bp+40 /* &pSchema */, pzErrmsg, 8570 8571 ts+616 /* "SELECT type, nam..." */) 8572 for (*(*int32)(unsafe.Pointer(bp + 56 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pSchema */)))) { 8573 var zType uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pSchema */)), 0) 8574 var zName uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pSchema */)), 1) 8575 var zSql uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pSchema */)), 2) 8576 8577 if (int32(*(*int8)(unsafe.Pointer(zType))) == 'v') || (int32(*(*int8)(unsafe.Pointer(zType + 1))) == 'r') { 8578 *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, zSql, uintptr(0), uintptr(0), pzErrmsg) 8579 } else { 8580 // var pTab uintptr at bp+48, 8 8581 8582 *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = idxGetTableInfo(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdb, zName, bp+48 /* &pTab */, pzErrmsg) 8583 if *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) == SQLITE_OK { 8584 var i int32 8585 var zInner uintptr = uintptr(0) 8586 var zOuter uintptr = uintptr(0) 8587 (*IdxTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 48 /* pTab */)))).FpNext = (*sqlite3expert)(unsafe.Pointer(p)).FpTable 8588 (*sqlite3expert)(unsafe.Pointer(p)).FpTable = *(*uintptr)(unsafe.Pointer(bp + 48 /* pTab */)) 8589 8590 // The statement the vtab will pass to sqlite3_declare_vtab() 8591 zInner = idxAppendText(tls, bp+56 /* &rc */, uintptr(0), ts+884 /* "CREATE TABLE x(" */, 0) 8592 for i = 0; i < (*IdxTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 48 /* pTab */)))).FnCol; i++ { 8593 zInner = idxAppendText(tls, bp+56 /* &rc */, zInner, ts+900, /* "%s%Q COLLATE %s" */ 8594 libc.VaList(bp, func() uintptr { 8595 if i == 0 { 8596 return ts + 489 /* "" */ 8597 } 8598 return ts + 90 /* ", " */ 8599 }(), (*IdxColumn)(unsafe.Pointer((*IdxTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 48 /* pTab */)))).FaCol+uintptr(i)*24)).FzName, (*IdxColumn)(unsafe.Pointer((*IdxTable)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 48 /* pTab */)))).FaCol+uintptr(i)*24)).FzColl)) 8600 } 8601 zInner = idxAppendText(tls, bp+56 /* &rc */, zInner, ts+490 /* ")" */, 0) 8602 8603 // The CVT statement to create the vtab 8604 zOuter = idxAppendText(tls, bp+56 /* &rc */, uintptr(0), 8605 ts+916 /* "CREATE VIRTUAL T..." */, libc.VaList(bp+24, zName, zInner)) 8606 if *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) == SQLITE_OK { 8607 *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, zOuter, uintptr(0), uintptr(0), pzErrmsg) 8608 } 8609 sqlite3.Xsqlite3_free(tls, zInner) 8610 sqlite3.Xsqlite3_free(tls, zOuter) 8611 } 8612 } 8613 } 8614 idxFinalize(tls, bp+56 /* &rc */, *(*uintptr)(unsafe.Pointer(bp + 40 /* pSchema */))) 8615 return *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) 8616 } 8617 8618 type IdxSampleCtx = struct { 8619 FiTarget int32 8620 _ [4]byte 8621 Ftarget float64 8622 FnRow float64 8623 FnRet float64 8624 } /* sqlite3expert.c:1378:1 */ 8625 8626 func idxSampleFunc(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) { /* sqlite3expert.c:1385:13: */ 8627 bp := tls.Alloc(2) 8628 defer tls.Free(2) 8629 8630 var p uintptr = sqlite3.Xsqlite3_user_data(tls, pCtx) 8631 var bRet int32 8632 8633 _ = argv 8634 8635 if (*IdxSampleCtx)(unsafe.Pointer(p)).FnRow == 0.0 { 8636 bRet = 1 8637 } else { 8638 bRet = (libc.Bool32(((*IdxSampleCtx)(unsafe.Pointer(p)).FnRet / (*IdxSampleCtx)(unsafe.Pointer(p)).FnRow) <= (*IdxSampleCtx)(unsafe.Pointer(p)).Ftarget)) 8639 if bRet == 0 { 8640 // var rnd uint16 at bp, 2 8641 8642 sqlite3.Xsqlite3_randomness(tls, 2, bp /* &rnd */) 8643 bRet = (libc.Bool32((int32(*(*uint16)(unsafe.Pointer(bp /* rnd */))) % 100) <= (*IdxSampleCtx)(unsafe.Pointer(p)).FiTarget)) 8644 } 8645 } 8646 8647 sqlite3.Xsqlite3_result_int(tls, pCtx, bRet) 8648 *(*float64)(unsafe.Pointer(p + 16 /* &.nRow */)) += (1.0) 8649 *(*float64)(unsafe.Pointer(p + 24 /* &.nRet */)) += (float64(bRet)) 8650 } 8651 8652 type IdxRemCtx = struct { 8653 FnSlot int32 8654 _ [4]byte 8655 FaSlot [1]struct { 8656 FeType int32 8657 _ [4]byte 8658 FiVal i64 8659 FrVal float64 8660 FnByte int32 8661 Fn int32 8662 Fz uintptr 8663 } 8664 } /* sqlite3expert.c:1411:1 */ 8665 8666 type IdxRemSlot = struct { 8667 FeType int32 8668 _ [4]byte 8669 FiVal i64 8670 FrVal float64 8671 FnByte int32 8672 Fn int32 8673 Fz uintptr 8674 } /* sqlite3expert.c:1411:1 */ 8675 8676 // Implementation of scalar function rem(). 8677 func idxRemFunc(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) { /* sqlite3expert.c:1426:13: */ 8678 var p uintptr = sqlite3.Xsqlite3_user_data(tls, pCtx) 8679 var pSlot uintptr 8680 var iSlot int32 8681 8682 iSlot = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))) 8683 8684 pSlot = ((p + 8 /* &.aSlot */) + uintptr(iSlot)*40) 8685 8686 switch (*IdxRemSlot)(unsafe.Pointer(pSlot)).FeType { 8687 case SQLITE_NULL: 8688 // no-op 8689 break 8690 8691 case SQLITE_INTEGER: 8692 sqlite3.Xsqlite3_result_int64(tls, pCtx, (*IdxRemSlot)(unsafe.Pointer(pSlot)).FiVal) 8693 break 8694 8695 case SQLITE_FLOAT: 8696 sqlite3.Xsqlite3_result_double(tls, pCtx, (*IdxRemSlot)(unsafe.Pointer(pSlot)).FrVal) 8697 break 8698 8699 case SQLITE_BLOB: 8700 sqlite3.Xsqlite3_result_blob(tls, pCtx, (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fz, (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fn, libc.UintptrFromInt32(-1)) 8701 break 8702 8703 case SQLITE_TEXT: 8704 sqlite3.Xsqlite3_result_text(tls, pCtx, (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fz, (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fn, libc.UintptrFromInt32(-1)) 8705 break 8706 } 8707 8708 (*IdxRemSlot)(unsafe.Pointer(pSlot)).FeType = sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 8709 switch (*IdxRemSlot)(unsafe.Pointer(pSlot)).FeType { 8710 case SQLITE_NULL: 8711 // no-op 8712 break 8713 8714 case SQLITE_INTEGER: 8715 (*IdxRemSlot)(unsafe.Pointer(pSlot)).FiVal = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 8716 break 8717 8718 case SQLITE_FLOAT: 8719 (*IdxRemSlot)(unsafe.Pointer(pSlot)).FrVal = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 8720 break 8721 8722 case SQLITE_BLOB: 8723 fallthrough 8724 case SQLITE_TEXT: 8725 { 8726 var nByte int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 8727 if nByte > (*IdxRemSlot)(unsafe.Pointer(pSlot)).FnByte { 8728 var zNew uintptr = sqlite3.Xsqlite3_realloc(tls, (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fz, (nByte * 2)) 8729 if zNew == uintptr(0) { 8730 sqlite3.Xsqlite3_result_error_nomem(tls, pCtx) 8731 return 8732 } 8733 (*IdxRemSlot)(unsafe.Pointer(pSlot)).FnByte = (nByte * 2) 8734 (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fz = zNew 8735 } 8736 (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fn = nByte 8737 if (*IdxRemSlot)(unsafe.Pointer(pSlot)).FeType == SQLITE_BLOB { 8738 libc.Xmemcpy(tls, (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fz, sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))), uint64(nByte)) 8739 } else { 8740 libc.Xmemcpy(tls, (*IdxRemSlot)(unsafe.Pointer(pSlot)).Fz, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))), uint64(nByte)) 8741 } 8742 break 8743 8744 } 8745 } 8746 } 8747 8748 func idxLargestIndex(tls *libc.TLS, db uintptr, pnMax uintptr, pzErr uintptr) int32 { /* sqlite3expert.c:1499:12: */ 8749 bp := tls.Alloc(12) 8750 defer tls.Free(12) 8751 8752 *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK 8753 var zMax uintptr = ts + 957 /* "SELECT max(i.seq..." */ 8754 *(*uintptr)(unsafe.Pointer(bp /* pMax */)) = uintptr(0) 8755 8756 *(*int32)(unsafe.Pointer(pnMax)) = 0 8757 *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = idxPrepareStmt(tls, db, bp /* &pMax */, pzErr, zMax) 8758 if (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pMax */)))) { 8759 *(*int32)(unsafe.Pointer(pnMax)) = (sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp /* pMax */)), 0) + 1) 8760 } 8761 idxFinalize(tls, bp+8 /* &rc */, *(*uintptr)(unsafe.Pointer(bp /* pMax */))) 8762 8763 return *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) 8764 } 8765 8766 func idxPopulateOneStat1(tls *libc.TLS, p uintptr, pIndexXInfo uintptr, pWriteStat uintptr, zTab uintptr, zIdx uintptr, pzErr uintptr) int32 { /* sqlite3expert.c:1519:12: */ 8767 bp := tls.Alloc(128) 8768 defer tls.Free(128) 8769 8770 var zCols uintptr = uintptr(0) 8771 var zOrder uintptr = uintptr(0) 8772 var zQuery uintptr = uintptr(0) 8773 var nCol int32 = 0 8774 var i int32 8775 *(*uintptr)(unsafe.Pointer(bp + 120 /* pQuery */)) = uintptr(0) 8776 var aStat uintptr = uintptr(0) 8777 *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = SQLITE_OK 8778 8779 // Formulate the query text 8780 sqlite3.Xsqlite3_bind_text(tls, pIndexXInfo, 1, zIdx, -1, uintptr(0)) 8781 for (SQLITE_OK == *(*int32)(unsafe.Pointer(bp + 112 /* rc */))) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, pIndexXInfo)) { 8782 var zComma uintptr 8783 if zCols == uintptr(0) { 8784 zComma = ts + 489 /* "" */ 8785 } else { 8786 zComma = ts + 90 /* ", " */ 8787 } 8788 var zName uintptr = sqlite3.Xsqlite3_column_text(tls, pIndexXInfo, 0) 8789 var zColl uintptr = sqlite3.Xsqlite3_column_text(tls, pIndexXInfo, 1) 8790 zCols = idxAppendText(tls, bp+112 /* &rc */, zCols, 8791 ts+1094 /* "%sx.%Q IS rem(%d..." */, libc.VaList(bp, zComma, zName, nCol, zName, zColl)) 8792 zOrder = idxAppendText(tls, bp+112 /* &rc */, zOrder, ts+1129 /* "%s%d" */, libc.VaList(bp+40, zComma, libc.PreIncInt32(&nCol, 1))) 8793 } 8794 sqlite3.Xsqlite3_reset(tls, pIndexXInfo) 8795 if *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == SQLITE_OK { 8796 if (*sqlite3expert)(unsafe.Pointer(p)).FiSample == 100 { 8797 zQuery = sqlite3.Xsqlite3_mprintf(tls, 8798 ts+1134 /* "SELECT %s FROM %..." */, libc.VaList(bp+56, zCols, zTab, zOrder)) 8799 } else { 8800 zQuery = sqlite3.Xsqlite3_mprintf(tls, 8801 ts+1166 /* "SELECT %s FROM t..." */, libc.VaList(bp+80, zCols, zOrder)) 8802 } 8803 } 8804 sqlite3.Xsqlite3_free(tls, zCols) 8805 sqlite3.Xsqlite3_free(tls, zOrder) 8806 8807 // Formulate the query text 8808 if *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == SQLITE_OK { 8809 var dbrem uintptr = func() uintptr { 8810 if (*sqlite3expert)(unsafe.Pointer(p)).FiSample == 100 { 8811 return (*sqlite3expert)(unsafe.Pointer(p)).Fdb 8812 } 8813 return (*sqlite3expert)(unsafe.Pointer(p)).Fdbv 8814 }() 8815 *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = idxPrepareStmt(tls, dbrem, bp+120 /* &pQuery */, pzErr, zQuery) 8816 } 8817 sqlite3.Xsqlite3_free(tls, zQuery) 8818 8819 if *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == SQLITE_OK { 8820 aStat = idxMalloc(tls, bp+112 /* &rc */, (int32(uint64(unsafe.Sizeof(int32(0))) * (uint64(nCol + 1))))) 8821 } 8822 if (*(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 120 /* pQuery */)))) { 8823 var pEntry uintptr 8824 var zStat uintptr = uintptr(0) 8825 for i = 0; i <= nCol; i++ { 8826 *(*int32)(unsafe.Pointer(aStat + uintptr(i)*4)) = 1 8827 } 8828 for (*(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 120 /* pQuery */)))) { 8829 *(*int32)(unsafe.Pointer(aStat))++ 8830 for i = 0; i < nCol; i++ { 8831 if sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 120 /* pQuery */)), i) == 0 { 8832 break 8833 } 8834 } 8835 for ; i < nCol; i++ { 8836 *(*int32)(unsafe.Pointer(aStat + uintptr((i+1))*4))++ 8837 } 8838 } 8839 8840 if *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == SQLITE_OK { 8841 var s0 int32 = *(*int32)(unsafe.Pointer(aStat)) 8842 zStat = sqlite3.Xsqlite3_mprintf(tls, ts+1238 /* "%d" */, libc.VaList(bp+96, s0)) 8843 if zStat == uintptr(0) { 8844 *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = SQLITE_NOMEM 8845 } 8846 for i = 1; (*(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == SQLITE_OK) && (i <= nCol); i++ { 8847 zStat = idxAppendText(tls, bp+112 /* &rc */, zStat, ts+1241 /* " %d" */, libc.VaList(bp+104, ((s0+(*(*int32)(unsafe.Pointer(aStat + uintptr(i)*4))/2)) / *(*int32)(unsafe.Pointer(aStat + uintptr(i)*4))))) 8848 } 8849 } 8850 8851 if *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) == SQLITE_OK { 8852 sqlite3.Xsqlite3_bind_text(tls, pWriteStat, 1, zTab, -1, uintptr(0)) 8853 sqlite3.Xsqlite3_bind_text(tls, pWriteStat, 2, zIdx, -1, uintptr(0)) 8854 sqlite3.Xsqlite3_bind_text(tls, pWriteStat, 3, zStat, -1, uintptr(0)) 8855 sqlite3.Xsqlite3_step(tls, pWriteStat) 8856 *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) = sqlite3.Xsqlite3_reset(tls, pWriteStat) 8857 } 8858 8859 pEntry = idxHashFind(tls, (p + 88 /* &.hIdx */), zIdx, int32(libc.Xstrlen(tls, zIdx))) 8860 if pEntry != 0 { 8861 8862 (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzVal2 = zStat 8863 } else { 8864 sqlite3.Xsqlite3_free(tls, zStat) 8865 } 8866 } 8867 sqlite3.Xsqlite3_free(tls, aStat) 8868 idxFinalize(tls, bp+112 /* &rc */, *(*uintptr)(unsafe.Pointer(bp + 120 /* pQuery */))) 8869 8870 return *(*int32)(unsafe.Pointer(bp + 112 /* rc */)) 8871 } 8872 8873 func idxBuildSampleTable(tls *libc.TLS, p uintptr, zTab uintptr) int32 { /* sqlite3expert.c:1619:12: */ 8874 bp := tls.Alloc(8) 8875 defer tls.Free(8) 8876 8877 var rc int32 8878 var zSql uintptr 8879 8880 rc = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, ts+1245 /* "DROP TABLE IF EX..." */, uintptr(0), uintptr(0), uintptr(0)) 8881 if rc != SQLITE_OK { 8882 return rc 8883 } 8884 8885 zSql = sqlite3.Xsqlite3_mprintf(tls, 8886 ts+1309 /* "CREATE TABLE tem..." */, libc.VaList(bp, zTab)) 8887 if zSql == uintptr(0) { 8888 return SQLITE_NOMEM 8889 } 8890 rc = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, zSql, uintptr(0), uintptr(0), uintptr(0)) 8891 sqlite3.Xsqlite3_free(tls, zSql) 8892 8893 return rc 8894 } 8895 8896 // This function is called as part of sqlite3_expert_analyze(). Candidate 8897 // indexes have already been created in database sqlite3expert.dbm, this 8898 // function populates sqlite_stat1 table in the same database. 8899 // 8900 // The stat1 data is generated by querying the 8901 func idxPopulateStat1(tls *libc.TLS, p uintptr, pzErr uintptr) int32 { /* sqlite3expert.c:1643:12: */ 8902 bp := tls.Alloc(64) 8903 defer tls.Free(64) 8904 8905 *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = SQLITE_OK 8906 *(*int32)(unsafe.Pointer(bp /* nMax */)) = 0 8907 var pCtx uintptr = uintptr(0) 8908 // var samplectx IdxSampleCtx at bp+8, 32 8909 8910 var i int32 8911 var iPrev i64 = int64(-100000) 8912 *(*uintptr)(unsafe.Pointer(bp + 40 /* pAllIndex */)) = uintptr(0) 8913 *(*uintptr)(unsafe.Pointer(bp + 48 /* pIndexXInfo */)) = uintptr(0) 8914 *(*uintptr)(unsafe.Pointer(bp + 56 /* pWrite */)) = uintptr(0) 8915 8916 var zAllIndex uintptr = ts + 1385 /* "SELECT s.rowid, ..." */ 8917 var zIndexXInfo uintptr = ts + 1499 /* "SELECT name, col..." */ 8918 var zWrite uintptr = ts + 1554 /* "INSERT INTO sqli..." */ 8919 8920 // If iSample==0, no sqlite_stat1 data is required. 8921 if (*sqlite3expert)(unsafe.Pointer(p)).FiSample == 0 { 8922 return SQLITE_OK 8923 } 8924 8925 *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = idxLargestIndex(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbm, bp /* &nMax */, pzErr) 8926 if (*(*int32)(unsafe.Pointer(bp /* nMax */)) <= 0) || (*(*int32)(unsafe.Pointer(bp + 4 /* rc */)) != SQLITE_OK) { 8927 return *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) 8928 } 8929 8930 *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbm, ts+1595 /* "ANALYZE; PRAGMA ..." */, uintptr(0), uintptr(0), uintptr(0)) 8931 8932 if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { 8933 var nByte int32 = (int32(uint64(unsafe.Sizeof(IdxRemCtx{})) + (uint64(unsafe.Sizeof(IdxRemSlot{})) * uint64(*(*int32)(unsafe.Pointer(bp /* nMax */)))))) 8934 pCtx = idxMalloc(tls, bp+4 /* &rc */, nByte) 8935 } 8936 8937 if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { 8938 var dbrem uintptr = func() uintptr { 8939 if (*sqlite3expert)(unsafe.Pointer(p)).FiSample == 100 { 8940 return (*sqlite3expert)(unsafe.Pointer(p)).Fdb 8941 } 8942 return (*sqlite3expert)(unsafe.Pointer(p)).Fdbv 8943 }() 8944 *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = sqlite3.Xsqlite3_create_function(tls, 8945 dbrem, ts+1629 /* "rem" */, 2, SQLITE_UTF8, pCtx, *(*uintptr)(unsafe.Pointer(&struct { 8946 f func(*libc.TLS, uintptr, int32, uintptr) 8947 }{idxRemFunc})), uintptr(0), uintptr(0)) 8948 } 8949 if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { 8950 *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = sqlite3.Xsqlite3_create_function(tls, 8951 (*sqlite3expert)(unsafe.Pointer(p)).Fdb, ts+1633 /* "sample" */, 0, SQLITE_UTF8, bp+8 /* &samplectx */, *(*uintptr)(unsafe.Pointer(&struct { 8952 f func(*libc.TLS, uintptr, int32, uintptr) 8953 }{idxSampleFunc})), uintptr(0), uintptr(0)) 8954 } 8955 8956 if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { 8957 (*IdxRemCtx)(unsafe.Pointer(pCtx)).FnSlot = (*(*int32)(unsafe.Pointer(bp /* nMax */)) + 1) 8958 *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = idxPrepareStmt(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbm, bp+40 /* &pAllIndex */, pzErr, zAllIndex) 8959 } 8960 if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { 8961 *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = idxPrepareStmt(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbm, bp+48 /* &pIndexXInfo */, pzErr, zIndexXInfo) 8962 } 8963 if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { 8964 *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = idxPrepareStmt(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbm, bp+56 /* &pWrite */, pzErr, zWrite) 8965 } 8966 8967 for (*(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pAllIndex */)))) { 8968 var iRowid i64 = sqlite3.Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pAllIndex */)), 0) 8969 var zTab uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pAllIndex */)), 1) 8970 var zIdx uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pAllIndex */)), 2) 8971 if ((*sqlite3expert)(unsafe.Pointer(p)).FiSample < 100) && (iPrev != iRowid) { 8972 (*IdxSampleCtx)(unsafe.Pointer(bp + 8 /* &samplectx */)).Ftarget = (float64((*sqlite3expert)(unsafe.Pointer(p)).FiSample) / 100.0) 8973 (*IdxSampleCtx)(unsafe.Pointer(bp + 8 /* &samplectx */)).FiTarget = (*sqlite3expert)(unsafe.Pointer(p)).FiSample 8974 (*IdxSampleCtx)(unsafe.Pointer(bp + 8 /* &samplectx */)).FnRow = 0.0 8975 (*IdxSampleCtx)(unsafe.Pointer(bp + 8 /* &samplectx */)).FnRet = 0.0 8976 *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = idxBuildSampleTable(tls, p, zTab) 8977 if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) != SQLITE_OK { 8978 break 8979 } 8980 } 8981 *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = idxPopulateOneStat1(tls, p, *(*uintptr)(unsafe.Pointer(bp + 48 /* pIndexXInfo */)), *(*uintptr)(unsafe.Pointer(bp + 56 /* pWrite */)), zTab, zIdx, pzErr) 8982 iPrev = iRowid 8983 } 8984 if (*(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK) && ((*sqlite3expert)(unsafe.Pointer(p)).FiSample < 100) { 8985 *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, 8986 ts+1245 /* "DROP TABLE IF EX..." */, uintptr(0), uintptr(0), uintptr(0)) 8987 } 8988 8989 idxFinalize(tls, bp+4 /* &rc */, *(*uintptr)(unsafe.Pointer(bp + 40 /* pAllIndex */))) 8990 idxFinalize(tls, bp+4 /* &rc */, *(*uintptr)(unsafe.Pointer(bp + 48 /* pIndexXInfo */))) 8991 idxFinalize(tls, bp+4 /* &rc */, *(*uintptr)(unsafe.Pointer(bp + 56 /* pWrite */))) 8992 8993 if pCtx != 0 { 8994 for i = 0; i < (*IdxRemCtx)(unsafe.Pointer(pCtx)).FnSlot; i++ { 8995 sqlite3.Xsqlite3_free(tls, (*IdxRemSlot)(unsafe.Pointer((pCtx+8 /* &.aSlot */)+uintptr(i)*40)).Fz) 8996 } 8997 sqlite3.Xsqlite3_free(tls, pCtx) 8998 } 8999 9000 if *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) == SQLITE_OK { 9001 *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbm, ts+1640 /* "ANALYZE sqlite_s..." */, uintptr(0), uintptr(0), uintptr(0)) 9002 } 9003 9004 sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdb, ts+1245 /* "DROP TABLE IF EX..." */, uintptr(0), uintptr(0), uintptr(0)) 9005 return *(*int32)(unsafe.Pointer(bp + 4 /* rc */)) 9006 } 9007 9008 // Allocate a new sqlite3expert object. 9009 func sqlite3_expert_new(tls *libc.TLS, db uintptr, pzErrmsg uintptr) uintptr { /* sqlite3expert.c:1742:15: */ 9010 bp := tls.Alloc(32) 9011 defer tls.Free(32) 9012 9013 *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_OK 9014 var pNew uintptr 9015 9016 pNew = idxMalloc(tls, bp+16 /* &rc */, int32(unsafe.Sizeof(sqlite3expert{}))) 9017 9018 // Open two in-memory databases to work with. The "vtab database" (dbv) 9019 // will contain a virtual table corresponding to each real table in 9020 // the user database schema, and a copy of each view. It is used to 9021 // collect information regarding the WHERE, ORDER BY and other clauses 9022 // of the user's query. 9023 if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { 9024 (*sqlite3expert)(unsafe.Pointer(pNew)).Fdb = db 9025 (*sqlite3expert)(unsafe.Pointer(pNew)).FiSample = 100 9026 *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3.Xsqlite3_open(tls, ts+1662 /* ":memory:" */, (pNew + 24 /* &.dbv */)) 9027 } 9028 if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { 9029 *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3.Xsqlite3_open(tls, ts+1662 /* ":memory:" */, (pNew + 16 /* &.dbm */)) 9030 if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { 9031 sqlite3.Xsqlite3_db_config(tls, (*sqlite3expert)(unsafe.Pointer(pNew)).Fdbm, SQLITE_DBCONFIG_TRIGGER_EQP, libc.VaList(bp, 1, uintptr(0))) 9032 } 9033 } 9034 9035 // Copy the entire schema of database [db] into [dbm]. 9036 if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { 9037 // var pSql uintptr at bp+24, 8 9038 9039 *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = idxPrintfPrepareStmt(tls, (*sqlite3expert)(unsafe.Pointer(pNew)).Fdb, bp+24 /* &pSql */, pzErrmsg, 9040 9041 ts+1671 /* "SELECT sql FROM ..." */, 0) 9042 for (*(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pSql */)))) { 9043 var zSql uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pSql */)), 0) 9044 *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3.Xsqlite3_exec(tls, (*sqlite3expert)(unsafe.Pointer(pNew)).Fdbm, zSql, uintptr(0), uintptr(0), pzErrmsg) 9045 } 9046 idxFinalize(tls, bp+16 /* &rc */, *(*uintptr)(unsafe.Pointer(bp + 24 /* pSql */))) 9047 } 9048 9049 // Create the vtab schema 9050 if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { 9051 *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = idxCreateVtabSchema(tls, pNew, pzErrmsg) 9052 } 9053 9054 // Register the auth callback with dbv 9055 if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { 9056 sqlite3.Xsqlite3_set_authorizer(tls, (*sqlite3expert)(unsafe.Pointer(pNew)).Fdbv, *(*uintptr)(unsafe.Pointer(&struct { 9057 f func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr, uintptr) int32 9058 }{idxAuthCallback})), pNew) 9059 } 9060 9061 // If an error has occurred, free the new object and reutrn NULL. Otherwise, 9062 // return the new sqlite3expert handle. 9063 if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) != SQLITE_OK { 9064 sqlite3_expert_destroy(tls, pNew) 9065 pNew = uintptr(0) 9066 } 9067 return pNew 9068 } 9069 9070 // Configure an sqlite3expert object. 9071 func sqlite3_expert_config(tls *libc.TLS, p uintptr, op int32, va uintptr) int32 { /* sqlite3expert.c:1803:5: */ 9072 var rc int32 = SQLITE_OK 9073 var ap va_list 9074 _ = ap 9075 ap = va 9076 switch op { 9077 case EXPERT_CONFIG_SAMPLE: 9078 { 9079 var iVal int32 = int32(libc.VaInt32(&ap)) 9080 if iVal < 0 { 9081 iVal = 0 9082 } 9083 if iVal > 100 { 9084 iVal = 100 9085 } 9086 (*sqlite3expert)(unsafe.Pointer(p)).FiSample = iVal 9087 break 9088 9089 } 9090 default: 9091 rc = SQLITE_NOTFOUND 9092 break 9093 } 9094 9095 _ = ap 9096 return rc 9097 } 9098 9099 // Add an SQL statement to the analysis. 9100 func sqlite3_expert_sql(tls *libc.TLS, p uintptr, zSql uintptr, pzErr uintptr) int32 { /* sqlite3expert.c:1827:5: */ 9101 bp := tls.Alloc(20) 9102 defer tls.Free(20) 9103 9104 var pScanOrig uintptr = (*sqlite3expert)(unsafe.Pointer(p)).FpScan 9105 var pStmtOrig uintptr = (*sqlite3expert)(unsafe.Pointer(p)).FpStatement 9106 *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_OK 9107 *(*uintptr)(unsafe.Pointer(bp + 8 /* zStmt */)) = zSql 9108 9109 if (*sqlite3expert)(unsafe.Pointer(p)).FbRun != 0 { 9110 return SQLITE_MISUSE 9111 } 9112 9113 for ((*(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK) && (*(*uintptr)(unsafe.Pointer(bp + 8 /* zStmt */)) != 0)) && (*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* zStmt */)))) != 0) { 9114 *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) 9115 *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = sqlite3.Xsqlite3_prepare_v2(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, *(*uintptr)(unsafe.Pointer(bp + 8 /* zStmt */)), -1, bp /* &pStmt */, bp+8 /* &zStmt */) 9116 if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { 9117 if *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) != 0 { 9118 var pNew uintptr 9119 var z uintptr = sqlite3.Xsqlite3_sql(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) 9120 var n int32 = int32(libc.Xstrlen(tls, z)) 9121 pNew = idxMalloc(tls, bp+16 /* &rc */, (int32((uint64(unsafe.Sizeof(IdxStatement{})) + uint64(n)) + uint64(1)))) 9122 if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { 9123 (*IdxStatement)(unsafe.Pointer(pNew)).FzSql = (pNew + 1*40) 9124 libc.Xmemcpy(tls, (*IdxStatement)(unsafe.Pointer(pNew)).FzSql, z, (uint64(n + 1))) 9125 (*IdxStatement)(unsafe.Pointer(pNew)).FpNext = (*sqlite3expert)(unsafe.Pointer(p)).FpStatement 9126 if (*sqlite3expert)(unsafe.Pointer(p)).FpStatement != 0 { 9127 (*IdxStatement)(unsafe.Pointer(pNew)).FiId = ((*IdxStatement)(unsafe.Pointer((*sqlite3expert)(unsafe.Pointer(p)).FpStatement)).FiId + 1) 9128 } 9129 (*sqlite3expert)(unsafe.Pointer(p)).FpStatement = pNew 9130 } 9131 sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) 9132 } 9133 } else { 9134 idxDatabaseError(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv, pzErr) 9135 } 9136 } 9137 9138 if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) != SQLITE_OK { 9139 idxScanFree(tls, (*sqlite3expert)(unsafe.Pointer(p)).FpScan, pScanOrig) 9140 idxStatementFree(tls, (*sqlite3expert)(unsafe.Pointer(p)).FpStatement, pStmtOrig) 9141 (*sqlite3expert)(unsafe.Pointer(p)).FpScan = pScanOrig 9142 (*sqlite3expert)(unsafe.Pointer(p)).FpStatement = pStmtOrig 9143 } 9144 9145 return *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) 9146 } 9147 9148 func sqlite3_expert_analyze(tls *libc.TLS, p uintptr, pzErr uintptr) int32 { /* sqlite3expert.c:1872:5: */ 9149 bp := tls.Alloc(28) 9150 defer tls.Free(28) 9151 9152 // var rc int32 at bp+24, 4 9153 9154 var pEntry uintptr 9155 9156 // Do trigger processing to collect any extra IdxScan structures 9157 *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = idxProcessTriggers(tls, p, pzErr) 9158 9159 // Create candidate indexes within the in-memory database file 9160 if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { 9161 *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = idxCreateCandidates(tls, p) 9162 } 9163 9164 // Generate the stat1 data 9165 if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { 9166 *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = idxPopulateStat1(tls, p, pzErr) 9167 } 9168 9169 // Formulate the EXPERT_REPORT_CANDIDATES text 9170 for pEntry = (*sqlite3expert)(unsafe.Pointer(p)).FhIdx.FpFirst; pEntry != 0; pEntry = (*IdxHashEntry)(unsafe.Pointer(pEntry)).FpNext { 9171 (*sqlite3expert)(unsafe.Pointer(p)).FzCandidates = idxAppendText(tls, bp+24 /* &rc */, (*sqlite3expert)(unsafe.Pointer(p)).FzCandidates, 9172 ts+1770 /* "%s;%s%s\n" */, libc.VaList(bp, (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzVal, 9173 func() uintptr { 9174 if (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzVal2 != 0 { 9175 return ts + 1779 /* " -- stat1: " */ 9176 } 9177 return ts + 489 /* "" */ 9178 }(), (*IdxHashEntry)(unsafe.Pointer(pEntry)).FzVal2)) 9179 } 9180 9181 // Figure out which of the candidate indexes are preferred by the query 9182 // planner and report the results to the user. 9183 if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { 9184 *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = idxFindIndexes(tls, p, pzErr) 9185 } 9186 9187 if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { 9188 (*sqlite3expert)(unsafe.Pointer(p)).FbRun = 1 9189 } 9190 return *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) 9191 } 9192 9193 // Return the total number of statements that have been added to this 9194 // sqlite3expert using sqlite3_expert_sql(). 9195 func sqlite3_expert_count(tls *libc.TLS, p uintptr) int32 { /* sqlite3expert.c:1913:5: */ 9196 var nRet int32 = 0 9197 if (*sqlite3expert)(unsafe.Pointer(p)).FpStatement != 0 { 9198 nRet = ((*IdxStatement)(unsafe.Pointer((*sqlite3expert)(unsafe.Pointer(p)).FpStatement)).FiId + 1) 9199 } 9200 return nRet 9201 } 9202 9203 // Return a component of the report. 9204 func sqlite3_expert_report(tls *libc.TLS, p uintptr, iStmt int32, eReport int32) uintptr { /* sqlite3expert.c:1922:12: */ 9205 var zRet uintptr = uintptr(0) 9206 var pStmt uintptr 9207 9208 if (*sqlite3expert)(unsafe.Pointer(p)).FbRun == 0 { 9209 return uintptr(0) 9210 } 9211 for pStmt = (*sqlite3expert)(unsafe.Pointer(p)).FpStatement; (pStmt != 0) && ((*IdxStatement)(unsafe.Pointer(pStmt)).FiId != iStmt); pStmt = (*IdxStatement)(unsafe.Pointer(pStmt)).FpNext { 9212 } 9213 switch eReport { 9214 case EXPERT_REPORT_SQL: 9215 if pStmt != 0 { 9216 zRet = (*IdxStatement)(unsafe.Pointer(pStmt)).FzSql 9217 } 9218 break 9219 case EXPERT_REPORT_INDEXES: 9220 if pStmt != 0 { 9221 zRet = (*IdxStatement)(unsafe.Pointer(pStmt)).FzIdx 9222 } 9223 break 9224 case EXPERT_REPORT_PLAN: 9225 if pStmt != 0 { 9226 zRet = (*IdxStatement)(unsafe.Pointer(pStmt)).FzEQP 9227 } 9228 break 9229 case EXPERT_REPORT_CANDIDATES: 9230 zRet = (*sqlite3expert)(unsafe.Pointer(p)).FzCandidates 9231 break 9232 } 9233 return zRet 9234 } 9235 9236 // Free an sqlite3expert object. 9237 func sqlite3_expert_destroy(tls *libc.TLS, p uintptr) { /* sqlite3expert.c:1948:6: */ 9238 if p != 0 { 9239 sqlite3.Xsqlite3_close(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbm) 9240 sqlite3.Xsqlite3_close(tls, (*sqlite3expert)(unsafe.Pointer(p)).Fdbv) 9241 idxScanFree(tls, (*sqlite3expert)(unsafe.Pointer(p)).FpScan, uintptr(0)) 9242 idxStatementFree(tls, (*sqlite3expert)(unsafe.Pointer(p)).FpStatement, uintptr(0)) 9243 idxTableFree(tls, (*sqlite3expert)(unsafe.Pointer(p)).FpTable) 9244 idxWriteFree(tls, (*sqlite3expert)(unsafe.Pointer(p)).FpWrite) 9245 idxHashClear(tls, (p + 88 /* &.hIdx */)) 9246 sqlite3.Xsqlite3_free(tls, (*sqlite3expert)(unsafe.Pointer(p)).FzCandidates) 9247 sqlite3.Xsqlite3_free(tls, p) 9248 } 9249 } 9250 9251 // If we are compiling with optimizing read this file. It contains 9252 // several optimizing inline functions and macros. 9253 9254 //---------------------------------------------------------------------------- 9255 // Support for functions with a variable number of arguments. 9256 // 9257 // The following TCL_VARARGS* macros are to support old extensions 9258 // written for older versions of Tcl where the macros permitted 9259 // support for the varargs.h system as well as stdarg.h . 9260 // 9261 // New code should just directly be written to use stdarg.h conventions. 9262 9263 // Copyright (C) 1989-2018 Free Software Foundation, Inc. 9264 // 9265 // This file is part of GCC. 9266 // 9267 // GCC is free software; you can redistribute it and/or modify 9268 // it under the terms of the GNU General Public License as published by 9269 // the Free Software Foundation; either version 3, or (at your option) 9270 // any later version. 9271 // 9272 // GCC is distributed in the hope that it will be useful, 9273 // but WITHOUT ANY WARRANTY; without even the implied warranty of 9274 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9275 // GNU General Public License for more details. 9276 // 9277 // Under Section 7 of GPL version 3, you are granted additional 9278 // permissions described in the GCC Runtime Library Exception, version 9279 // 3.1, as published by the Free Software Foundation. 9280 // 9281 // You should have received a copy of the GNU General Public License and 9282 // a copy of the GCC Runtime Library Exception along with this program; 9283 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 9284 // <http://www.gnu.org/licenses/>. 9285 9286 // ISO C Standard: 7.15 Variable arguments <stdarg.h> 9287 9288 // Allow a part of Tcl's API to be explicitly marked as deprecated. 9289 // 9290 // Used to make TIP 330/336 generate moans even if people use the 9291 // compatibility macros. Change your code, guys! We won't support you forever. 9292 9293 //---------------------------------------------------------------------------- 9294 // Macros used to declare a function to be exported by a DLL. Used by Windows, 9295 // maps to no-op declarations on non-Windows systems. The default build on 9296 // windows is for a DLL, which causes the DLLIMPORT and DLLEXPORT macros to be 9297 // nonempty. To build a static library, the macro STATIC_BUILD should be 9298 // defined. 9299 // 9300 // Note: when building static but linking dynamically to MSVCRT we must still 9301 // correctly decorate the C library imported function. Use CRTIMPORT 9302 // for this purpose. _DLL is defined by the compiler when linking to 9303 // MSVCRT. 9304 9305 // These macros are used to control whether functions are being declared for 9306 // import or export. If a function is being declared while it is being built 9307 // to be included in a shared library, then it should have the DLLEXPORT 9308 // storage class. If is being declared for use by a module that is going to 9309 // link against the shared library, then it should have the DLLIMPORT storage 9310 // class. If the symbol is beind declared for a static build or for use from a 9311 // stub library, then the storage class should be empty. 9312 // 9313 // The convention is that a macro called BUILD_xxxx, where xxxx is the name of 9314 // a library we are building, is set on the compile line for sources that are 9315 // to be placed in the library. When this macro is set, the storage class will 9316 // be set to DLLEXPORT. At the end of the header file, the storage class will 9317 // be reset to DLLIMPORT. 9318 9319 // The following _ANSI_ARGS_ macro is to support old extensions 9320 // written for older versions of Tcl where it permitted support 9321 // for compilers written in the pre-prototype era of C. 9322 // 9323 // New code should use prototypes. 9324 9325 // Definitions that allow this header file to be used either with or without 9326 // ANSI C features. 9327 9328 // Make sure EXTERN isn't defined elsewhere. 9329 9330 //---------------------------------------------------------------------------- 9331 // The following code is copied from winnt.h. If we don't replicate it here, 9332 // then <windows.h> can't be included after tcl.h, since tcl.h also defines 9333 // VOID. This block is skipped under Cygwin and Mingw. 9334 9335 // Macro to use instead of "void" for arguments that must have type "void *" 9336 // in ANSI C; maps them to type "char *" in non-ANSI systems. 9337 9338 // Miscellaneous declarations. 9339 9340 type ClientData = uintptr /* tcl.h:340:15 */ 9341 9342 // Darwin specific configure overrides (to support fat compiles, where 9343 // configure runs only once for multiple architectures): 9344 9345 // Define Tcl_WideInt to be a type that is (at least) 64-bits wide, and define 9346 // Tcl_WideUInt to be the unsigned variant of that type (assuming that where 9347 // we have one, we can have the other.) 9348 // 9349 // Also defines the following macros: 9350 // TCL_WIDE_INT_IS_LONG - if wide ints are really longs (i.e. we're on a 9351 // LP64 system such as modern Solaris or Linux ... not including Win64) 9352 // Tcl_WideAsLong - forgetful converter from wideInt to long. 9353 // Tcl_LongAsWide - sign-extending converter from long to wideInt. 9354 // Tcl_WideAsDouble - converter from wideInt to double. 9355 // Tcl_DoubleAsWide - converter from double to wideInt. 9356 // 9357 // The following invariant should hold for any long value 'longVal': 9358 // longVal == Tcl_WideAsLong(Tcl_LongAsWide(longVal)) 9359 // 9360 // Note on converting between Tcl_WideInt and strings. This implementation (in 9361 // tclObj.c) depends on the function 9362 // sprintf(...,"%" TCL_LL_MODIFIER "d",...). 9363 9364 type Tcl_WideInt = int64 /* tcl.h:415:28 */ 9365 type Tcl_WideUInt = uint64 /* tcl.h:416:36 */ 9366 9367 // The next short section of defines are only done when not running on Windows 9368 // or some other strange platform. 9369 9370 type stat = struct { 9371 Fst_dev uint64 9372 Fst_ino uint64 9373 Fst_nlink uint64 9374 Fst_mode uint32 9375 Fst_uid uint32 9376 Fst_gid uint32 9377 F__glibc_reserved0 int32 9378 Fst_rdev uint64 9379 Fst_size int64 9380 Fst_atim struct { 9381 Ftv_sec int64 9382 Ftv_nsec int64 9383 } 9384 Fst_mtim struct { 9385 Ftv_sec int64 9386 Ftv_nsec int64 9387 } 9388 Fst_ctim struct { 9389 Ftv_sec int64 9390 Ftv_nsec int64 9391 } 9392 Fst_blksize int64 9393 Fst_blocks int64 9394 F__glibc_reserved [3]int64 9395 } /* stat.h:50:1 */ 9396 9397 //---------------------------------------------------------------------------- 9398 // Data structures defined opaquely in this module. The definitions below just 9399 // provide dummy types. A few fields are made visible in Tcl_Interp 9400 // structures, namely those used for returning a string result from commands. 9401 // Direct access to the result field is discouraged in Tcl 8.0. The 9402 // interpreter result is either an object or a string, and the two values are 9403 // kept consistent unless some C code sets interp->result directly. 9404 // Programmers should use either the function Tcl_GetObjResult() or 9405 // Tcl_GetStringResult() to read the interpreter's result. See the SetResult 9406 // man page for details. 9407 // 9408 // Note: any change to the Tcl_Interp definition below must be mirrored in the 9409 // "real" definition in tclInt.h. 9410 // 9411 // Note: Tcl_ObjCmdProc functions do not directly set result and freeProc. 9412 // Instead, they set a Tcl_Obj member in the "real" structure that can be 9413 // accessed with Tcl_GetObjResult() and Tcl_SetObjResult(). 9414 9415 type Tcl_Interp1 = struct { 9416 FresultDontUse uintptr 9417 FfreeProcDontUse uintptr 9418 FerrorLineDontUse int32 9419 _ [4]byte 9420 } /* tcl.h:493:9 */ 9421 9422 //---------------------------------------------------------------------------- 9423 // Data structures defined opaquely in this module. The definitions below just 9424 // provide dummy types. A few fields are made visible in Tcl_Interp 9425 // structures, namely those used for returning a string result from commands. 9426 // Direct access to the result field is discouraged in Tcl 8.0. The 9427 // interpreter result is either an object or a string, and the two values are 9428 // kept consistent unless some C code sets interp->result directly. 9429 // Programmers should use either the function Tcl_GetObjResult() or 9430 // Tcl_GetStringResult() to read the interpreter's result. See the SetResult 9431 // man page for details. 9432 // 9433 // Note: any change to the Tcl_Interp definition below must be mirrored in the 9434 // "real" definition in tclInt.h. 9435 // 9436 // Note: Tcl_ObjCmdProc functions do not directly set result and freeProc. 9437 // Instead, they set a Tcl_Obj member in the "real" structure that can be 9438 // accessed with Tcl_GetObjResult() and Tcl_SetObjResult(). 9439 9440 type Tcl_Interp = Tcl_Interp1 /* tcl.h:525:1 */ 9441 9442 type Tcl_AsyncHandler = uintptr /* tcl.h:527:34 */ 9443 type Tcl_Channel = uintptr /* tcl.h:528:29 */ 9444 type Tcl_ChannelTypeVersion = uintptr /* tcl.h:529:40 */ 9445 type Tcl_Command = uintptr /* tcl.h:530:29 */ 9446 type Tcl_Condition = uintptr /* tcl.h:531:31 */ 9447 type Tcl_Dict = uintptr /* tcl.h:532:26 */ 9448 type Tcl_EncodingState = uintptr /* tcl.h:533:35 */ 9449 type Tcl_Encoding = uintptr /* tcl.h:534:30 */ 9450 type Tcl_Event1 = struct { 9451 Fproc uintptr 9452 FnextPtr uintptr 9453 } /* tcl.h:535:9 */ 9454 9455 type Tcl_Event = Tcl_Event1 /* tcl.h:535:26 */ 9456 type Tcl_InterpState = uintptr /* tcl.h:536:33 */ 9457 type Tcl_LoadHandle = uintptr /* tcl.h:537:32 */ 9458 type Tcl_Mutex = uintptr /* tcl.h:538:27 */ 9459 type Tcl_Pid = uintptr /* tcl.h:539:25 */ 9460 type Tcl_RegExp = uintptr /* tcl.h:540:28 */ 9461 type Tcl_ThreadDataKey = uintptr /* tcl.h:541:35 */ 9462 type Tcl_ThreadId = uintptr /* tcl.h:542:30 */ 9463 type Tcl_TimerToken = uintptr /* tcl.h:543:32 */ 9464 type Tcl_Trace = uintptr /* tcl.h:544:27 */ 9465 type Tcl_Var = uintptr /* tcl.h:545:25 */ 9466 type Tcl_ZlibStream = uintptr /* tcl.h:546:32 */ 9467 9468 // Threading function return types used for abstracting away platform 9469 // differences when writing a Tcl_ThreadCreateProc. See the NewThread function 9470 // in generic/tclThreadTest.c for it's usage. 9471 9472 // Definition of values for default stacksize and the possible flags to be 9473 // given to Tcl_CreateThread. 9474 9475 // Flag values passed to Tcl_StringCaseMatch. 9476 9477 // Flag values passed to Tcl_GetRegExpFromObj. 9478 9479 // Flags values passed to Tcl_RegExpExecObj. 9480 9481 // Structures filled in by Tcl_RegExpInfo. Note that all offset values are 9482 // relative to the start of the match string, not the beginning of the entire 9483 // string. 9484 9485 type Tcl_RegExpIndices1 = struct { 9486 Fstart int64 9487 Fend int64 9488 } /* tcl.h:623:9 */ 9489 9490 // Threading function return types used for abstracting away platform 9491 // differences when writing a Tcl_ThreadCreateProc. See the NewThread function 9492 // in generic/tclThreadTest.c for it's usage. 9493 9494 // Definition of values for default stacksize and the possible flags to be 9495 // given to Tcl_CreateThread. 9496 9497 // Flag values passed to Tcl_StringCaseMatch. 9498 9499 // Flag values passed to Tcl_GetRegExpFromObj. 9500 9501 // Flags values passed to Tcl_RegExpExecObj. 9502 9503 // Structures filled in by Tcl_RegExpInfo. Note that all offset values are 9504 // relative to the start of the match string, not the beginning of the entire 9505 // string. 9506 9507 type Tcl_RegExpIndices = Tcl_RegExpIndices1 /* tcl.h:628:3 */ 9508 9509 type Tcl_RegExpInfo1 = struct { 9510 Fnsubs int32 9511 _ [4]byte 9512 Fmatches uintptr 9513 FextendStart int64 9514 Freserved int64 9515 } /* tcl.h:630:9 */ 9516 9517 type Tcl_RegExpInfo = Tcl_RegExpInfo1 /* tcl.h:637:3 */ 9518 9519 // Picky compilers complain if this typdef doesn't appear before the struct's 9520 // reference in tclDecls.h. 9521 9522 type Tcl_Stat_ = uintptr /* tcl.h:644:21 */ 9523 type Tcl_OldStat_ = uintptr /* tcl.h:645:21 */ 9524 9525 //---------------------------------------------------------------------------- 9526 // When a TCL command returns, the interpreter contains a result from the 9527 // command. Programmers are strongly encouraged to use one of the functions 9528 // Tcl_GetObjResult() or Tcl_GetStringResult() to read the interpreter's 9529 // result. See the SetResult man page for details. Besides this result, the 9530 // command function returns an integer code, which is one of the following: 9531 // 9532 // TCL_OK Command completed normally; the interpreter's result 9533 // contains the command's result. 9534 // TCL_ERROR The command couldn't be completed successfully; the 9535 // interpreter's result describes what went wrong. 9536 // TCL_RETURN The command requests that the current function return; 9537 // the interpreter's result contains the function's 9538 // return value. 9539 // TCL_BREAK The command requests that the innermost loop be 9540 // exited; the interpreter's result is meaningless. 9541 // TCL_CONTINUE Go on to the next iteration of the current loop; the 9542 // interpreter's result is meaningless. 9543 9544 //---------------------------------------------------------------------------- 9545 // Flags to control what substitutions are performed by Tcl_SubstObj(): 9546 9547 // Argument descriptors for math function callbacks in expressions: 9548 9549 type Tcl_ValueType = uint32 /* tcl.h:692:3 */ 9550 9551 type Tcl_Value1 = struct { 9552 Ftype Tcl_ValueType 9553 _ [4]byte 9554 FintValue int64 9555 FdoubleValue float64 9556 FwideValue Tcl_WideInt 9557 } /* tcl.h:694:9 */ 9558 9559 type Tcl_Value = Tcl_Value1 /* tcl.h:700:3 */ 9560 9561 // Forward declaration of Tcl_Obj to prevent an error when the forward 9562 // reference to Tcl_Obj is encountered in the function types declared below. 9563 9564 type Tcl_Obj1 = struct { 9565 FrefCount int32 9566 _ [4]byte 9567 Fbytes uintptr 9568 Flength int32 9569 _ [4]byte 9570 FtypePtr uintptr 9571 FinternalRep struct { 9572 FlongValue int64 9573 _ [8]byte 9574 } 9575 } /* tcl.h:707:1 */ 9576 9577 //---------------------------------------------------------------------------- 9578 // The following structure represents a type of object, which is a particular 9579 // internal representation for an object plus a set of functions that provide 9580 // standard operations on objects of that type. 9581 9582 type Tcl_ObjType1 = struct { 9583 Fname uintptr 9584 FfreeIntRepProc uintptr 9585 FdupIntRepProc uintptr 9586 FupdateStringProc uintptr 9587 FsetFromAnyProc uintptr 9588 } /* tcl.h:707:1 */ 9589 9590 //---------------------------------------------------------------------------- 9591 // The following structure represents a type of object, which is a particular 9592 // internal representation for an object plus a set of functions that provide 9593 // standard operations on objects of that type. 9594 9595 type Tcl_ObjType = Tcl_ObjType1 /* tcl.h:796:3 */ 9596 9597 // One of the following structures exists for each object in the Tcl system. 9598 // An object stores a value as either a string, some internal representation, 9599 // or both. 9600 9601 type Tcl_Obj = Tcl_Obj1 /* tcl.h:843:3 */ 9602 9603 //---------------------------------------------------------------------------- 9604 // The following structure contains the state needed by Tcl_SaveResult. No-one 9605 // outside of Tcl should access any of these fields. This structure is 9606 // typically allocated on the stack. 9607 9608 type Tcl_SavedResult1 = struct { 9609 Fresult uintptr 9610 FfreeProc uintptr 9611 FobjResultPtr uintptr 9612 FappendResult uintptr 9613 FappendAvl int32 9614 FappendUsed int32 9615 FresultSpace [201]int8 9616 _ [7]byte 9617 } /* tcl.h:864:9 */ 9618 9619 //---------------------------------------------------------------------------- 9620 // The following structure contains the state needed by Tcl_SaveResult. No-one 9621 // outside of Tcl should access any of these fields. This structure is 9622 // typically allocated on the stack. 9623 9624 type Tcl_SavedResult = Tcl_SavedResult1 /* tcl.h:872:3 */ 9625 9626 //---------------------------------------------------------------------------- 9627 // The following definitions support Tcl's namespace facility. Note: the first 9628 // five fields must match exactly the fields in a Namespace structure (see 9629 // tclInt.h). 9630 9631 type Tcl_Namespace1 = struct { 9632 Fname uintptr 9633 FfullName uintptr 9634 FclientData ClientData 9635 FdeleteProc uintptr 9636 FparentPtr uintptr 9637 } /* tcl.h:881:9 */ 9638 9639 //---------------------------------------------------------------------------- 9640 // The following definitions support Tcl's namespace facility. Note: the first 9641 // five fields must match exactly the fields in a Namespace structure (see 9642 // tclInt.h). 9643 9644 type Tcl_Namespace = Tcl_Namespace1 /* tcl.h:897:3 */ 9645 9646 //---------------------------------------------------------------------------- 9647 // The following structure represents a call frame, or activation record. A 9648 // call frame defines a naming context for a procedure call: its local scope 9649 // (for local variables) and its namespace scope (used for non-local 9650 // variables; often the global :: namespace). A call frame can also define the 9651 // naming context for a namespace eval or namespace inscope command: the 9652 // namespace in which the command's code should execute. The Tcl_CallFrame 9653 // structures exist only while procedures or namespace eval/inscope's are 9654 // being executed, and provide a Tcl call stack. 9655 // 9656 // A call frame is initialized and pushed using Tcl_PushCallFrame and popped 9657 // using Tcl_PopCallFrame. Storage for a Tcl_CallFrame must be provided by the 9658 // Tcl_PushCallFrame caller, and callers typically allocate them on the C call 9659 // stack for efficiency. For this reason, Tcl_CallFrame is defined as a 9660 // structure and not as an opaque token. However, most Tcl_CallFrame fields 9661 // are hidden since applications should not access them directly; others are 9662 // declared as "dummyX". 9663 // 9664 // WARNING!! The structure definition must be kept consistent with the 9665 // CallFrame structure in tclInt.h. If you change one, change the other. 9666 9667 type Tcl_CallFrame1 = struct { 9668 FnsPtr uintptr 9669 Fdummy1 int32 9670 Fdummy2 int32 9671 Fdummy3 uintptr 9672 Fdummy4 uintptr 9673 Fdummy5 uintptr 9674 Fdummy6 int32 9675 _ [4]byte 9676 Fdummy7 uintptr 9677 Fdummy8 uintptr 9678 Fdummy9 int32 9679 _ [4]byte 9680 Fdummy10 uintptr 9681 Fdummy11 uintptr 9682 Fdummy12 uintptr 9683 Fdummy13 uintptr 9684 } /* tcl.h:922:9 */ 9685 9686 //---------------------------------------------------------------------------- 9687 // The following structure represents a call frame, or activation record. A 9688 // call frame defines a naming context for a procedure call: its local scope 9689 // (for local variables) and its namespace scope (used for non-local 9690 // variables; often the global :: namespace). A call frame can also define the 9691 // naming context for a namespace eval or namespace inscope command: the 9692 // namespace in which the command's code should execute. The Tcl_CallFrame 9693 // structures exist only while procedures or namespace eval/inscope's are 9694 // being executed, and provide a Tcl call stack. 9695 // 9696 // A call frame is initialized and pushed using Tcl_PushCallFrame and popped 9697 // using Tcl_PopCallFrame. Storage for a Tcl_CallFrame must be provided by the 9698 // Tcl_PushCallFrame caller, and callers typically allocate them on the C call 9699 // stack for efficiency. For this reason, Tcl_CallFrame is defined as a 9700 // structure and not as an opaque token. However, most Tcl_CallFrame fields 9701 // are hidden since applications should not access them directly; others are 9702 // declared as "dummyX". 9703 // 9704 // WARNING!! The structure definition must be kept consistent with the 9705 // CallFrame structure in tclInt.h. If you change one, change the other. 9706 9707 type Tcl_CallFrame = Tcl_CallFrame1 /* tcl.h:937:3 */ 9708 9709 //---------------------------------------------------------------------------- 9710 // Information about commands that is returned by Tcl_GetCommandInfo and 9711 // passed to Tcl_SetCommandInfo. objProc is an objc/objv object-based command 9712 // function while proc is a traditional Tcl argc/argv string-based function. 9713 // Tcl_CreateObjCommand and Tcl_CreateCommand ensure that both objProc and 9714 // proc are non-NULL and can be called to execute the command. However, it may 9715 // be faster to call one instead of the other. The member isNativeObjectProc 9716 // is set to 1 if an object-based function was registered by 9717 // Tcl_CreateObjCommand, and to 0 if a string-based function was registered by 9718 // Tcl_CreateCommand. The other function is typically set to a compatibility 9719 // wrapper that does string-to-object or object-to-string argument conversions 9720 // then calls the other function. 9721 9722 type Tcl_CmdInfo1 = struct { 9723 FisNativeObjectProc int32 9724 _ [4]byte 9725 FobjProc uintptr 9726 FobjClientData ClientData 9727 Fproc uintptr 9728 FclientData ClientData 9729 FdeleteProc uintptr 9730 FdeleteData ClientData 9731 FnamespacePtr uintptr 9732 } /* tcl.h:954:9 */ 9733 9734 //---------------------------------------------------------------------------- 9735 // Information about commands that is returned by Tcl_GetCommandInfo and 9736 // passed to Tcl_SetCommandInfo. objProc is an objc/objv object-based command 9737 // function while proc is a traditional Tcl argc/argv string-based function. 9738 // Tcl_CreateObjCommand and Tcl_CreateCommand ensure that both objProc and 9739 // proc are non-NULL and can be called to execute the command. However, it may 9740 // be faster to call one instead of the other. The member isNativeObjectProc 9741 // is set to 1 if an object-based function was registered by 9742 // Tcl_CreateObjCommand, and to 0 if a string-based function was registered by 9743 // Tcl_CreateCommand. The other function is typically set to a compatibility 9744 // wrapper that does string-to-object or object-to-string argument conversions 9745 // then calls the other function. 9746 9747 type Tcl_CmdInfo = Tcl_CmdInfo1 /* tcl.h:973:3 */ 9748 9749 //---------------------------------------------------------------------------- 9750 // The structure defined below is used to hold dynamic strings. The only 9751 // fields that clients should use are string and length, accessible via the 9752 // macros Tcl_DStringValue and Tcl_DStringLength. 9753 9754 type Tcl_DString1 = struct { 9755 Fstring uintptr 9756 Flength int32 9757 FspaceAvl int32 9758 FstaticSpace [200]int8 9759 } /* tcl.h:983:9 */ 9760 9761 //---------------------------------------------------------------------------- 9762 // The structure defined below is used to hold dynamic strings. The only 9763 // fields that clients should use are string and length, accessible via the 9764 // macros Tcl_DStringValue and Tcl_DStringLength. 9765 9766 type Tcl_DString = Tcl_DString1 /* tcl.h:993:3 */ 9767 9768 // Definitions for the maximum number of digits of precision that may be 9769 // specified in the "tcl_precision" variable, and the number of bytes of 9770 // buffer space required by Tcl_PrintDouble. 9771 9772 // Definition for a number of bytes of buffer space sufficient to hold the 9773 // string representation of an integer in base 10 (assuming the existence of 9774 // 64-bit integers). 9775 9776 // Flag values passed to Tcl_ConvertElement. 9777 // TCL_DONT_USE_BRACES forces it not to enclose the element in braces, but to 9778 // use backslash quoting instead. 9779 // TCL_DONT_QUOTE_HASH disables the default quoting of the '#' character. It 9780 // is safe to leave the hash unquoted when the element is not the first 9781 // element of a list, and this flag can be used by the caller to indicate 9782 // that condition. 9783 9784 // Flag that may be passed to Tcl_GetIndexFromObj to force it to disallow 9785 // abbreviated strings. 9786 9787 //---------------------------------------------------------------------------- 9788 // Flag values passed to Tcl_RecordAndEval, Tcl_EvalObj, Tcl_EvalObjv. 9789 // WARNING: these bit choices must not conflict with the bit choices for 9790 // evalFlag bits in tclInt.h! 9791 // 9792 // Meanings: 9793 // TCL_NO_EVAL: Just record this command 9794 // TCL_EVAL_GLOBAL: Execute script in global namespace 9795 // TCL_EVAL_DIRECT: Do not compile this script 9796 // TCL_EVAL_INVOKE: Magical Tcl_EvalObjv mode for aliases/ensembles 9797 // o Run in iPtr->lookupNsPtr or global namespace 9798 // o Cut out of error traces 9799 // o Don't reset the flags controlling ensemble 9800 // error message rewriting. 9801 // TCL_CANCEL_UNWIND: Magical Tcl_CancelEval mode that causes the 9802 // stack for the script in progress to be 9803 // completely unwound. 9804 // TCL_EVAL_NOERR: Do no exception reporting at all, just return 9805 // as the caller will report. 9806 9807 // Special freeProc values that may be passed to Tcl_SetResult (see the man 9808 // page for details): 9809 9810 // Flag values passed to variable-related functions. 9811 // WARNING: these bit choices must not conflict with the bit choice for 9812 // TCL_CANCEL_UNWIND, above. 9813 9814 // Required to support old variable/vdelete/vinfo traces. 9815 // Indicate the semantics of the result of a trace. 9816 9817 // Flag values for ensemble commands. 9818 9819 // Flag values passed to command-related functions. 9820 9821 // The TCL_PARSE_PART1 flag is deprecated and has no effect. The part1 is now 9822 // always parsed whenever the part2 is NULL. (This is to avoid a common error 9823 // when converting code to use the new object based APIs and forgetting to 9824 // give the flag) 9825 9826 // Types for linked variables: 9827 9828 //---------------------------------------------------------------------------- 9829 // Forward declarations of Tcl_HashTable and related types. 9830 9831 type Tcl_HashKeyType1 = struct { 9832 Fversion int32 9833 Fflags int32 9834 FhashKeyProc uintptr 9835 FcompareKeysProc uintptr 9836 FallocEntryProc uintptr 9837 FfreeEntryProc uintptr 9838 } /* tcl.h:1152:9 */ 9839 9840 // Definitions for the maximum number of digits of precision that may be 9841 // specified in the "tcl_precision" variable, and the number of bytes of 9842 // buffer space required by Tcl_PrintDouble. 9843 9844 // Definition for a number of bytes of buffer space sufficient to hold the 9845 // string representation of an integer in base 10 (assuming the existence of 9846 // 64-bit integers). 9847 9848 // Flag values passed to Tcl_ConvertElement. 9849 // TCL_DONT_USE_BRACES forces it not to enclose the element in braces, but to 9850 // use backslash quoting instead. 9851 // TCL_DONT_QUOTE_HASH disables the default quoting of the '#' character. It 9852 // is safe to leave the hash unquoted when the element is not the first 9853 // element of a list, and this flag can be used by the caller to indicate 9854 // that condition. 9855 9856 // Flag that may be passed to Tcl_GetIndexFromObj to force it to disallow 9857 // abbreviated strings. 9858 9859 //---------------------------------------------------------------------------- 9860 // Flag values passed to Tcl_RecordAndEval, Tcl_EvalObj, Tcl_EvalObjv. 9861 // WARNING: these bit choices must not conflict with the bit choices for 9862 // evalFlag bits in tclInt.h! 9863 // 9864 // Meanings: 9865 // TCL_NO_EVAL: Just record this command 9866 // TCL_EVAL_GLOBAL: Execute script in global namespace 9867 // TCL_EVAL_DIRECT: Do not compile this script 9868 // TCL_EVAL_INVOKE: Magical Tcl_EvalObjv mode for aliases/ensembles 9869 // o Run in iPtr->lookupNsPtr or global namespace 9870 // o Cut out of error traces 9871 // o Don't reset the flags controlling ensemble 9872 // error message rewriting. 9873 // TCL_CANCEL_UNWIND: Magical Tcl_CancelEval mode that causes the 9874 // stack for the script in progress to be 9875 // completely unwound. 9876 // TCL_EVAL_NOERR: Do no exception reporting at all, just return 9877 // as the caller will report. 9878 9879 // Special freeProc values that may be passed to Tcl_SetResult (see the man 9880 // page for details): 9881 9882 // Flag values passed to variable-related functions. 9883 // WARNING: these bit choices must not conflict with the bit choice for 9884 // TCL_CANCEL_UNWIND, above. 9885 9886 // Required to support old variable/vdelete/vinfo traces. 9887 // Indicate the semantics of the result of a trace. 9888 9889 // Flag values for ensemble commands. 9890 9891 // Flag values passed to command-related functions. 9892 9893 // The TCL_PARSE_PART1 flag is deprecated and has no effect. The part1 is now 9894 // always parsed whenever the part2 is NULL. (This is to avoid a common error 9895 // when converting code to use the new object based APIs and forgetting to 9896 // give the flag) 9897 9898 // Types for linked variables: 9899 9900 //---------------------------------------------------------------------------- 9901 // Forward declarations of Tcl_HashTable and related types. 9902 9903 type Tcl_HashKeyType = Tcl_HashKeyType1 /* tcl.h:1152:32 */ 9904 type Tcl_HashTable1 = struct { 9905 Fbuckets uintptr 9906 FstaticBuckets [4]uintptr 9907 FnumBuckets int32 9908 FnumEntries int32 9909 FrebuildSize int32 9910 FdownShift int32 9911 Fmask int32 9912 FkeyType int32 9913 FfindProc uintptr 9914 FcreateProc uintptr 9915 FtypePtr uintptr 9916 } /* tcl.h:1153:9 */ 9917 9918 type Tcl_HashTable = Tcl_HashTable1 /* tcl.h:1153:30 */ 9919 type Tcl_HashEntry1 = struct { 9920 FnextPtr uintptr 9921 FtablePtr uintptr 9922 Fhash uintptr 9923 FclientData ClientData 9924 Fkey struct{ FoneWordValue uintptr } 9925 } /* tcl.h:1153:9 */ 9926 9927 type Tcl_HashEntry = Tcl_HashEntry1 /* tcl.h:1154:30 */ 9928 9929 // Structure definition for information used to keep track of searches through 9930 // hash tables: 9931 9932 type Tcl_HashSearch1 = struct { 9933 FtablePtr uintptr 9934 FnextIndex int32 9935 _ [4]byte 9936 FnextEntryPtr uintptr 9937 } /* tcl.h:1308:9 */ 9938 9939 // Structure definition for information used to keep track of searches through 9940 // hash tables: 9941 9942 type Tcl_HashSearch = Tcl_HashSearch1 /* tcl.h:1314:3 */ 9943 9944 // Acceptable key types for hash tables: 9945 // 9946 // TCL_STRING_KEYS: The keys are strings, they are copied into the 9947 // entry. 9948 // TCL_ONE_WORD_KEYS: The keys are pointers, the pointer is stored 9949 // in the entry. 9950 // TCL_CUSTOM_TYPE_KEYS: The keys are arbitrary types which are copied 9951 // into the entry. 9952 // TCL_CUSTOM_PTR_KEYS: The keys are pointers to arbitrary types, the 9953 // pointer is stored in the entry. 9954 // 9955 // While maintaining binary compatibility the above have to be distinct values 9956 // as they are used to differentiate between old versions of the hash table 9957 // which don't have a typePtr and new ones which do. Once binary compatibility 9958 // is discarded in favour of making more wide spread changes TCL_STRING_KEYS 9959 // can be the same as TCL_CUSTOM_TYPE_KEYS, and TCL_ONE_WORD_KEYS can be the 9960 // same as TCL_CUSTOM_PTR_KEYS because they simply determine how the key is 9961 // accessed from the entry and not the behaviour. 9962 9963 // Structure definition for information used to keep track of searches through 9964 // dictionaries. These fields should not be accessed by code outside 9965 // tclDictObj.c 9966 9967 type Tcl_DictSearch = struct { 9968 Fnext uintptr 9969 Fepoch int32 9970 _ [4]byte 9971 FdictionaryPtr Tcl_Dict 9972 } /* tcl.h:1354:3 */ 9973 9974 // Positions to pass to Tcl_QueueEvent: 9975 9976 type Tcl_QueuePosition = uint32 /* tcl.h:1389:3 */ 9977 9978 // Values to pass to Tcl_SetServiceMode to specify the behavior of notifier 9979 // event routines. 9980 9981 // The following structure keeps is used to hold a time value, either as an 9982 // absolute time (the number of seconds from the epoch) or as an elapsed time. 9983 // On Unix systems the epoch is Midnight Jan 1, 1970 GMT. 9984 9985 type Tcl_Time1 = struct { 9986 Fsec int64 9987 Fusec int64 9988 } /* tcl.h:1405:9 */ 9989 9990 // Values to pass to Tcl_SetServiceMode to specify the behavior of notifier 9991 // event routines. 9992 9993 // The following structure keeps is used to hold a time value, either as an 9994 // absolute time (the number of seconds from the epoch) or as an elapsed time. 9995 // On Unix systems the epoch is Midnight Jan 1, 1970 GMT. 9996 9997 type Tcl_Time = Tcl_Time1 /* tcl.h:1408:3 */ 9998 9999 // struct Tcl_ChannelType: 10000 // 10001 // One such structure exists for each type (kind) of channel. It collects 10002 // together in one place all the functions that are part of the specific 10003 // channel type. 10004 // 10005 // It is recommend that the Tcl_Channel* functions are used to access elements 10006 // of this structure, instead of direct accessing. 10007 10008 type Tcl_ChannelType1 = struct { 10009 FtypeName uintptr 10010 Fversion Tcl_ChannelTypeVersion 10011 FcloseProc uintptr 10012 FinputProc uintptr 10013 FoutputProc uintptr 10014 FseekProc uintptr 10015 FsetOptionProc uintptr 10016 FgetOptionProc uintptr 10017 FwatchProc uintptr 10018 FgetHandleProc uintptr 10019 Fclose2Proc uintptr 10020 FblockModeProc uintptr 10021 FflushProc uintptr 10022 FhandlerProc uintptr 10023 FwideSeekProc uintptr 10024 FthreadActionProc uintptr 10025 FtruncateProc uintptr 10026 } /* tcl.h:1524:9 */ 10027 10028 // struct Tcl_ChannelType: 10029 // 10030 // One such structure exists for each type (kind) of channel. It collects 10031 // together in one place all the functions that are part of the specific 10032 // channel type. 10033 // 10034 // It is recommend that the Tcl_Channel* functions are used to access elements 10035 // of this structure, instead of direct accessing. 10036 10037 type Tcl_ChannelType = Tcl_ChannelType1 /* tcl.h:1592:3 */ 10038 10039 // The following flags determine whether the blockModeProc above should set 10040 // the channel into blocking or nonblocking mode. They are passed as arguments 10041 // to the blockModeProc function in the above structure. 10042 10043 //---------------------------------------------------------------------------- 10044 // Enum for different types of file paths. 10045 10046 type Tcl_PathType = uint32 /* tcl.h:1613:3 */ 10047 10048 // The following structure is used to pass glob type data amongst the various 10049 // glob routines and Tcl_FSMatchInDirectory. 10050 10051 type Tcl_GlobTypeData1 = struct { 10052 Ftype int32 10053 Fperm int32 10054 FmacType uintptr 10055 FmacCreator uintptr 10056 } /* tcl.h:1620:9 */ 10057 10058 // The following structure is used to pass glob type data amongst the various 10059 // glob routines and Tcl_FSMatchInDirectory. 10060 10061 type Tcl_GlobTypeData = Tcl_GlobTypeData1 /* tcl.h:1625:3 */ 10062 // We have to declare the utime structure here. 10063 type utimbuf = struct { 10064 Factime int64 10065 Fmodtime int64 10066 } /* utime.h:36:1 */ 10067 10068 type Tcl_FSVersion = uintptr /* tcl.h:1700:31 */ 10069 10070 //---------------------------------------------------------------------------- 10071 // Data structures related to hooking into the filesystem 10072 10073 // Filesystem version tag. This was introduced in 8.4. 10074 10075 // struct Tcl_Filesystem: 10076 // 10077 // One such structure exists for each type (kind) of filesystem. It collects 10078 // together in one place all the functions that are part of the specific 10079 // filesystem. Tcl always accesses the filesystem through one of these 10080 // structures. 10081 // 10082 // Not all entries need be non-NULL; any which are NULL are simply ignored. 10083 // However, a complete filesystem should provide all of these functions. The 10084 // explanations in the structure show the importance of each function. 10085 10086 type Tcl_Filesystem1 = struct { 10087 FtypeName uintptr 10088 FstructureLength int32 10089 _ [4]byte 10090 Fversion Tcl_FSVersion 10091 FpathInFilesystemProc uintptr 10092 FdupInternalRepProc uintptr 10093 FfreeInternalRepProc uintptr 10094 FinternalToNormalizedProc uintptr 10095 FcreateInternalRepProc uintptr 10096 FnormalizePathProc uintptr 10097 FfilesystemPathTypeProc uintptr 10098 FfilesystemSeparatorProc uintptr 10099 FstatProc uintptr 10100 FaccessProc uintptr 10101 FopenFileChannelProc uintptr 10102 FmatchInDirectoryProc uintptr 10103 FutimeProc uintptr 10104 FlinkProc uintptr 10105 FlistVolumesProc uintptr 10106 FfileAttrStringsProc uintptr 10107 FfileAttrsGetProc uintptr 10108 FfileAttrsSetProc uintptr 10109 FcreateDirectoryProc uintptr 10110 FremoveDirectoryProc uintptr 10111 FdeleteFileProc uintptr 10112 FcopyFileProc uintptr 10113 FrenameFileProc uintptr 10114 FcopyDirectoryProc uintptr 10115 FlstatProc uintptr 10116 FloadFileProc uintptr 10117 FgetCwdProc uintptr 10118 FchdirProc uintptr 10119 } /* tcl.h:1726:9 */ 10120 10121 //---------------------------------------------------------------------------- 10122 // Data structures related to hooking into the filesystem 10123 10124 // Filesystem version tag. This was introduced in 8.4. 10125 10126 // struct Tcl_Filesystem: 10127 // 10128 // One such structure exists for each type (kind) of filesystem. It collects 10129 // together in one place all the functions that are part of the specific 10130 // filesystem. Tcl always accesses the filesystem through one of these 10131 // structures. 10132 // 10133 // Not all entries need be non-NULL; any which are NULL are simply ignored. 10134 // However, a complete filesystem should provide all of these functions. The 10135 // explanations in the structure show the importance of each function. 10136 10137 type Tcl_Filesystem = Tcl_Filesystem1 /* tcl.h:1873:3 */ 10138 10139 // The following definitions are used as values for the 'linkAction' flag to 10140 // Tcl_FSLink, or the linkProc of any filesystem. Any combination of flags can 10141 // be given. For link creation, the linkProc should create a link which 10142 // matches any of the types given. 10143 // 10144 // TCL_CREATE_SYMBOLIC_LINK - Create a symbolic or soft link. 10145 // TCL_CREATE_HARD_LINK - Create a hard link. 10146 10147 //---------------------------------------------------------------------------- 10148 // The following structure represents the Notifier functions that you can 10149 // override with the Tcl_SetNotifier call. 10150 10151 type Tcl_NotifierProcs1 = struct { 10152 FsetTimerProc uintptr 10153 FwaitForEventProc uintptr 10154 FcreateFileHandlerProc uintptr 10155 FdeleteFileHandlerProc uintptr 10156 FinitNotifierProc uintptr 10157 FfinalizeNotifierProc uintptr 10158 FalertNotifierProc uintptr 10159 FserviceModeHookProc uintptr 10160 } /* tcl.h:1894:9 */ 10161 10162 // The following definitions are used as values for the 'linkAction' flag to 10163 // Tcl_FSLink, or the linkProc of any filesystem. Any combination of flags can 10164 // be given. For link creation, the linkProc should create a link which 10165 // matches any of the types given. 10166 // 10167 // TCL_CREATE_SYMBOLIC_LINK - Create a symbolic or soft link. 10168 // TCL_CREATE_HARD_LINK - Create a hard link. 10169 10170 //---------------------------------------------------------------------------- 10171 // The following structure represents the Notifier functions that you can 10172 // override with the Tcl_SetNotifier call. 10173 10174 type Tcl_NotifierProcs = Tcl_NotifierProcs1 /* tcl.h:1903:3 */ 10175 10176 //---------------------------------------------------------------------------- 10177 // The following data structures and declarations are for the new Tcl parser. 10178 // 10179 // For each word of a command, and for each piece of a word such as a variable 10180 // reference, one of the following structures is created to describe the 10181 // token. 10182 10183 type Tcl_Token1 = struct { 10184 Ftype int32 10185 _ [4]byte 10186 Fstart uintptr 10187 Fsize int32 10188 FnumComponents int32 10189 } /* tcl.h:1914:9 */ 10190 10191 //---------------------------------------------------------------------------- 10192 // The following data structures and declarations are for the new Tcl parser. 10193 // 10194 // For each word of a command, and for each piece of a word such as a variable 10195 // reference, one of the following structures is created to describe the 10196 // token. 10197 10198 type Tcl_Token = Tcl_Token1 /* tcl.h:1924:3 */ 10199 10200 // Type values defined for Tcl_Token structures. These values are defined as 10201 // mask bits so that it's easy to check for collections of types. 10202 // 10203 // TCL_TOKEN_WORD - The token describes one word of a command, 10204 // from the first non-blank character of the word 10205 // (which may be " or {) up to but not including 10206 // the space, semicolon, or bracket that 10207 // terminates the word. NumComponents counts the 10208 // total number of sub-tokens that make up the 10209 // word. This includes, for example, sub-tokens 10210 // of TCL_TOKEN_VARIABLE tokens. 10211 // TCL_TOKEN_SIMPLE_WORD - This token is just like TCL_TOKEN_WORD except 10212 // that the word is guaranteed to consist of a 10213 // single TCL_TOKEN_TEXT sub-token. 10214 // TCL_TOKEN_TEXT - The token describes a range of literal text 10215 // that is part of a word. NumComponents is 10216 // always 0. 10217 // TCL_TOKEN_BS - The token describes a backslash sequence that 10218 // must be collapsed. NumComponents is always 0. 10219 // TCL_TOKEN_COMMAND - The token describes a command whose result 10220 // must be substituted into the word. The token 10221 // includes the enclosing brackets. NumComponents 10222 // is always 0. 10223 // TCL_TOKEN_VARIABLE - The token describes a variable substitution, 10224 // including the dollar sign, variable name, and 10225 // array index (if there is one) up through the 10226 // right parentheses. NumComponents tells how 10227 // many additional tokens follow to represent the 10228 // variable name. The first token will be a 10229 // TCL_TOKEN_TEXT token that describes the 10230 // variable name. If the variable is an array 10231 // reference then there will be one or more 10232 // additional tokens, of type TCL_TOKEN_TEXT, 10233 // TCL_TOKEN_BS, TCL_TOKEN_COMMAND, and 10234 // TCL_TOKEN_VARIABLE, that describe the array 10235 // index; numComponents counts the total number 10236 // of nested tokens that make up the variable 10237 // reference, including sub-tokens of 10238 // TCL_TOKEN_VARIABLE tokens. 10239 // TCL_TOKEN_SUB_EXPR - The token describes one subexpression of an 10240 // expression, from the first non-blank character 10241 // of the subexpression up to but not including 10242 // the space, brace, or bracket that terminates 10243 // the subexpression. NumComponents counts the 10244 // total number of following subtokens that make 10245 // up the subexpression; this includes all 10246 // subtokens for any nested TCL_TOKEN_SUB_EXPR 10247 // tokens. For example, a numeric value used as a 10248 // primitive operand is described by a 10249 // TCL_TOKEN_SUB_EXPR token followed by a 10250 // TCL_TOKEN_TEXT token. A binary subexpression 10251 // is described by a TCL_TOKEN_SUB_EXPR token 10252 // followed by the TCL_TOKEN_OPERATOR token for 10253 // the operator, then TCL_TOKEN_SUB_EXPR tokens 10254 // for the left then the right operands. 10255 // TCL_TOKEN_OPERATOR - The token describes one expression operator. 10256 // An operator might be the name of a math 10257 // function such as "abs". A TCL_TOKEN_OPERATOR 10258 // token is always preceded by one 10259 // TCL_TOKEN_SUB_EXPR token for the operator's 10260 // subexpression, and is followed by zero or more 10261 // TCL_TOKEN_SUB_EXPR tokens for the operator's 10262 // operands. NumComponents is always 0. 10263 // TCL_TOKEN_EXPAND_WORD - This token is just like TCL_TOKEN_WORD except 10264 // that it marks a word that began with the 10265 // literal character prefix "{*}". This word is 10266 // marked to be expanded - that is, broken into 10267 // words after substitution is complete. 10268 10269 // Parsing error types. On any parsing error, one of these values will be 10270 // stored in the error field of the Tcl_Parse structure defined below. 10271 10272 // A structure of the following type is filled in by Tcl_ParseCommand. It 10273 // describes a single command parsed from an input string. 10274 10275 type Tcl_Parse1 = struct { 10276 FcommentStart uintptr 10277 FcommentSize int32 10278 _ [4]byte 10279 FcommandStart uintptr 10280 FcommandSize int32 10281 FnumWords int32 10282 FtokenPtr uintptr 10283 FnumTokens int32 10284 FtokensAvailable int32 10285 FerrorType int32 10286 _ [4]byte 10287 Fstring uintptr 10288 Fend uintptr 10289 Finterp uintptr 10290 Fterm uintptr 10291 Fincomplete int32 10292 _ [4]byte 10293 FstaticTokens [20]Tcl_Token 10294 } /* tcl.h:2030:9 */ 10295 10296 // Type values defined for Tcl_Token structures. These values are defined as 10297 // mask bits so that it's easy to check for collections of types. 10298 // 10299 // TCL_TOKEN_WORD - The token describes one word of a command, 10300 // from the first non-blank character of the word 10301 // (which may be " or {) up to but not including 10302 // the space, semicolon, or bracket that 10303 // terminates the word. NumComponents counts the 10304 // total number of sub-tokens that make up the 10305 // word. This includes, for example, sub-tokens 10306 // of TCL_TOKEN_VARIABLE tokens. 10307 // TCL_TOKEN_SIMPLE_WORD - This token is just like TCL_TOKEN_WORD except 10308 // that the word is guaranteed to consist of a 10309 // single TCL_TOKEN_TEXT sub-token. 10310 // TCL_TOKEN_TEXT - The token describes a range of literal text 10311 // that is part of a word. NumComponents is 10312 // always 0. 10313 // TCL_TOKEN_BS - The token describes a backslash sequence that 10314 // must be collapsed. NumComponents is always 0. 10315 // TCL_TOKEN_COMMAND - The token describes a command whose result 10316 // must be substituted into the word. The token 10317 // includes the enclosing brackets. NumComponents 10318 // is always 0. 10319 // TCL_TOKEN_VARIABLE - The token describes a variable substitution, 10320 // including the dollar sign, variable name, and 10321 // array index (if there is one) up through the 10322 // right parentheses. NumComponents tells how 10323 // many additional tokens follow to represent the 10324 // variable name. The first token will be a 10325 // TCL_TOKEN_TEXT token that describes the 10326 // variable name. If the variable is an array 10327 // reference then there will be one or more 10328 // additional tokens, of type TCL_TOKEN_TEXT, 10329 // TCL_TOKEN_BS, TCL_TOKEN_COMMAND, and 10330 // TCL_TOKEN_VARIABLE, that describe the array 10331 // index; numComponents counts the total number 10332 // of nested tokens that make up the variable 10333 // reference, including sub-tokens of 10334 // TCL_TOKEN_VARIABLE tokens. 10335 // TCL_TOKEN_SUB_EXPR - The token describes one subexpression of an 10336 // expression, from the first non-blank character 10337 // of the subexpression up to but not including 10338 // the space, brace, or bracket that terminates 10339 // the subexpression. NumComponents counts the 10340 // total number of following subtokens that make 10341 // up the subexpression; this includes all 10342 // subtokens for any nested TCL_TOKEN_SUB_EXPR 10343 // tokens. For example, a numeric value used as a 10344 // primitive operand is described by a 10345 // TCL_TOKEN_SUB_EXPR token followed by a 10346 // TCL_TOKEN_TEXT token. A binary subexpression 10347 // is described by a TCL_TOKEN_SUB_EXPR token 10348 // followed by the TCL_TOKEN_OPERATOR token for 10349 // the operator, then TCL_TOKEN_SUB_EXPR tokens 10350 // for the left then the right operands. 10351 // TCL_TOKEN_OPERATOR - The token describes one expression operator. 10352 // An operator might be the name of a math 10353 // function such as "abs". A TCL_TOKEN_OPERATOR 10354 // token is always preceded by one 10355 // TCL_TOKEN_SUB_EXPR token for the operator's 10356 // subexpression, and is followed by zero or more 10357 // TCL_TOKEN_SUB_EXPR tokens for the operator's 10358 // operands. NumComponents is always 0. 10359 // TCL_TOKEN_EXPAND_WORD - This token is just like TCL_TOKEN_WORD except 10360 // that it marks a word that began with the 10361 // literal character prefix "{*}". This word is 10362 // marked to be expanded - that is, broken into 10363 // words after substitution is complete. 10364 10365 // Parsing error types. On any parsing error, one of these values will be 10366 // stored in the error field of the Tcl_Parse structure defined below. 10367 10368 // A structure of the following type is filled in by Tcl_ParseCommand. It 10369 // describes a single command parsed from an input string. 10370 10371 type Tcl_Parse = Tcl_Parse1 /* tcl.h:2083:3 */ 10372 10373 //---------------------------------------------------------------------------- 10374 // The following structure represents a user-defined encoding. It collects 10375 // together all the functions that are used by the specific encoding. 10376 10377 type Tcl_EncodingType1 = struct { 10378 FencodingName uintptr 10379 FtoUtfProc uintptr 10380 FfromUtfProc uintptr 10381 FfreeProc uintptr 10382 FclientData ClientData 10383 FnullSize int32 10384 _ [4]byte 10385 } /* tcl.h:2091:9 */ 10386 10387 //---------------------------------------------------------------------------- 10388 // The following structure represents a user-defined encoding. It collects 10389 // together all the functions that are used by the specific encoding. 10390 10391 type Tcl_EncodingType = Tcl_EncodingType1 /* tcl.h:2111:3 */ 10392 10393 // The following definitions are used as values for the conversion control 10394 // flags argument when converting text from one character set to another: 10395 // 10396 // TCL_ENCODING_START - Signifies that the source buffer is the first 10397 // block in a (potentially multi-block) input 10398 // stream. Tells the conversion function to reset 10399 // to an initial state and perform any 10400 // initialization that needs to occur before the 10401 // first byte is converted. If the source buffer 10402 // contains the entire input stream to be 10403 // converted, this flag should be set. 10404 // TCL_ENCODING_END - Signifies that the source buffer is the last 10405 // block in a (potentially multi-block) input 10406 // stream. Tells the conversion routine to 10407 // perform any finalization that needs to occur 10408 // after the last byte is converted and then to 10409 // reset to an initial state. If the source 10410 // buffer contains the entire input stream to be 10411 // converted, this flag should be set. 10412 // TCL_ENCODING_STOPONERROR - If set, then the converter will return 10413 // immediately upon encountering an invalid byte 10414 // sequence or a source character that has no 10415 // mapping in the target encoding. If clear, then 10416 // the converter will skip the problem, 10417 // substituting one or more "close" characters in 10418 // the destination buffer and then continue to 10419 // convert the source. 10420 // TCL_ENCODING_NO_TERMINATE - If set, Tcl_ExternalToUtf will not append a 10421 // terminating NUL byte. Knowing that it will 10422 // not need space to do so, it will fill all 10423 // dstLen bytes with encoded UTF-8 content, as 10424 // other circumstances permit. If clear, the 10425 // default behavior is to reserve a byte in 10426 // the dst space for NUL termination, and to 10427 // append the NUL byte. 10428 // TCL_ENCODING_CHAR_LIMIT - If set and dstCharsPtr is not NULL, then 10429 // Tcl_ExternalToUtf takes the initial value 10430 // of *dstCharsPtr is taken as a limit of the 10431 // maximum number of chars to produce in the 10432 // encoded UTF-8 content. Otherwise, the 10433 // number of chars produced is controlled only 10434 // by other limiting factors. 10435 10436 // The following definitions are the error codes returned by the conversion 10437 // routines: 10438 // 10439 // TCL_OK - All characters were converted. 10440 // TCL_CONVERT_NOSPACE - The output buffer would not have been large 10441 // enough for all of the converted data; as many 10442 // characters as could fit were converted though. 10443 // TCL_CONVERT_MULTIBYTE - The last few bytes in the source string were 10444 // the beginning of a multibyte sequence, but 10445 // more bytes were needed to complete this 10446 // sequence. A subsequent call to the conversion 10447 // routine should pass the beginning of this 10448 // unconverted sequence plus additional bytes 10449 // from the source stream to properly convert the 10450 // formerly split-up multibyte sequence. 10451 // TCL_CONVERT_SYNTAX - The source stream contained an invalid 10452 // character sequence. This may occur if the 10453 // input stream has been damaged or if the input 10454 // encoding method was misidentified. This error 10455 // is reported only if TCL_ENCODING_STOPONERROR 10456 // was specified. 10457 // TCL_CONVERT_UNKNOWN - The source string contained a character that 10458 // could not be represented in the target 10459 // encoding. This error is reported only if 10460 // TCL_ENCODING_STOPONERROR was specified. 10461 10462 // The maximum number of bytes that are necessary to represent a single 10463 // Unicode character in UTF-8. The valid values should be 3, 4 or 6 10464 // (or perhaps 1 if we want to support a non-unicode enabled core). If 3 or 10465 // 4, then Tcl_UniChar must be 2-bytes in size (UCS-2) (the default). If 6, 10466 // then Tcl_UniChar must be 4-bytes in size (UCS-4). At this time UCS-2 mode 10467 // is the default and recommended mode. UCS-4 is experimental and not 10468 // recommended. It works for the core, but most extensions expect UCS-2. 10469 10470 // This represents a Unicode character. Any changes to this should also be 10471 // reflected in regcustom.h. 10472 10473 type Tcl_UniChar = uint16 /* tcl.h:2228:24 */ 10474 10475 //---------------------------------------------------------------------------- 10476 // TIP #59: The following structure is used in calls 'Tcl_RegisterConfig' to 10477 // provide the system with the embedded configuration data. 10478 10479 type Tcl_Config1 = struct { 10480 Fkey uintptr 10481 Fvalue uintptr 10482 } /* tcl.h:2237:9 */ 10483 10484 //---------------------------------------------------------------------------- 10485 // TIP #59: The following structure is used in calls 'Tcl_RegisterConfig' to 10486 // provide the system with the embedded configuration data. 10487 10488 type Tcl_Config = Tcl_Config1 /* tcl.h:2242:3 */ 10489 type mp_digit = uint32 /* tcl.h:2268:22 */ 10490 10491 //---------------------------------------------------------------------------- 10492 // Definitions needed for Tcl_ParseArgvObj routines. 10493 // Based on tkArgv.c. 10494 // Modifications from the original are copyright (c) Sam Bromley 2006 10495 10496 type Tcl_ArgvInfo = struct { 10497 Ftype int32 10498 _ [4]byte 10499 FkeyStr uintptr 10500 FsrcPtr uintptr 10501 FdstPtr uintptr 10502 FhelpStr uintptr 10503 FclientData ClientData 10504 } /* tcl.h:2289:3 */ 10505 10506 type TclPlatStubs1 = struct { 10507 Fmagic int32 10508 _ [4]byte 10509 Fhooks uintptr 10510 } /* tclDecls.h:1821:11 */ 10511 10512 type TclStubHooks = struct { 10513 FtclPlatStubs uintptr 10514 FtclIntStubs uintptr 10515 FtclIntPlatStubs uintptr 10516 } /* tclDecls.h:1824:3 */ 10517 10518 type TclStubs1 = struct { 10519 Fmagic int32 10520 _ [4]byte 10521 Fhooks uintptr 10522 Ftcl_PkgProvideEx uintptr 10523 Ftcl_PkgRequireEx uintptr 10524 Ftcl_Panic uintptr 10525 Ftcl_Alloc uintptr 10526 Ftcl_Free uintptr 10527 Ftcl_Realloc uintptr 10528 Ftcl_DbCkalloc uintptr 10529 Ftcl_DbCkfree uintptr 10530 Ftcl_DbCkrealloc uintptr 10531 Ftcl_CreateFileHandler uintptr 10532 Ftcl_DeleteFileHandler uintptr 10533 Ftcl_SetTimer uintptr 10534 Ftcl_Sleep uintptr 10535 Ftcl_WaitForEvent uintptr 10536 Ftcl_AppendAllObjTypes uintptr 10537 Ftcl_AppendStringsToObj uintptr 10538 Ftcl_AppendToObj uintptr 10539 Ftcl_ConcatObj uintptr 10540 Ftcl_ConvertToType uintptr 10541 Ftcl_DbDecrRefCount uintptr 10542 Ftcl_DbIncrRefCount uintptr 10543 Ftcl_DbIsShared uintptr 10544 Ftcl_DbNewBooleanObj uintptr 10545 Ftcl_DbNewByteArrayObj uintptr 10546 Ftcl_DbNewDoubleObj uintptr 10547 Ftcl_DbNewListObj uintptr 10548 Ftcl_DbNewLongObj uintptr 10549 Ftcl_DbNewObj uintptr 10550 Ftcl_DbNewStringObj uintptr 10551 Ftcl_DuplicateObj uintptr 10552 FtclFreeObj uintptr 10553 Ftcl_GetBoolean uintptr 10554 Ftcl_GetBooleanFromObj uintptr 10555 Ftcl_GetByteArrayFromObj uintptr 10556 Ftcl_GetDouble uintptr 10557 Ftcl_GetDoubleFromObj uintptr 10558 Ftcl_GetIndexFromObj uintptr 10559 Ftcl_GetInt uintptr 10560 Ftcl_GetIntFromObj uintptr 10561 Ftcl_GetLongFromObj uintptr 10562 Ftcl_GetObjType uintptr 10563 Ftcl_GetStringFromObj uintptr 10564 Ftcl_InvalidateStringRep uintptr 10565 Ftcl_ListObjAppendList uintptr 10566 Ftcl_ListObjAppendElement uintptr 10567 Ftcl_ListObjGetElements uintptr 10568 Ftcl_ListObjIndex uintptr 10569 Ftcl_ListObjLength uintptr 10570 Ftcl_ListObjReplace uintptr 10571 Ftcl_NewBooleanObj uintptr 10572 Ftcl_NewByteArrayObj uintptr 10573 Ftcl_NewDoubleObj uintptr 10574 Ftcl_NewIntObj uintptr 10575 Ftcl_NewListObj uintptr 10576 Ftcl_NewLongObj uintptr 10577 Ftcl_NewObj uintptr 10578 Ftcl_NewStringObj uintptr 10579 Ftcl_SetBooleanObj uintptr 10580 Ftcl_SetByteArrayLength uintptr 10581 Ftcl_SetByteArrayObj uintptr 10582 Ftcl_SetDoubleObj uintptr 10583 Ftcl_SetIntObj uintptr 10584 Ftcl_SetListObj uintptr 10585 Ftcl_SetLongObj uintptr 10586 Ftcl_SetObjLength uintptr 10587 Ftcl_SetStringObj uintptr 10588 Ftcl_AddErrorInfo uintptr 10589 Ftcl_AddObjErrorInfo uintptr 10590 Ftcl_AllowExceptions uintptr 10591 Ftcl_AppendElement uintptr 10592 Ftcl_AppendResult uintptr 10593 Ftcl_AsyncCreate uintptr 10594 Ftcl_AsyncDelete uintptr 10595 Ftcl_AsyncInvoke uintptr 10596 Ftcl_AsyncMark uintptr 10597 Ftcl_AsyncReady uintptr 10598 Ftcl_BackgroundError uintptr 10599 Ftcl_Backslash uintptr 10600 Ftcl_BadChannelOption uintptr 10601 Ftcl_CallWhenDeleted uintptr 10602 Ftcl_CancelIdleCall uintptr 10603 Ftcl_Close uintptr 10604 Ftcl_CommandComplete uintptr 10605 Ftcl_Concat uintptr 10606 Ftcl_ConvertElement uintptr 10607 Ftcl_ConvertCountedElement uintptr 10608 Ftcl_CreateAlias uintptr 10609 Ftcl_CreateAliasObj uintptr 10610 Ftcl_CreateChannel uintptr 10611 Ftcl_CreateChannelHandler uintptr 10612 Ftcl_CreateCloseHandler uintptr 10613 Ftcl_CreateCommand uintptr 10614 Ftcl_CreateEventSource uintptr 10615 Ftcl_CreateExitHandler uintptr 10616 Ftcl_CreateInterp uintptr 10617 Ftcl_CreateMathFunc uintptr 10618 Ftcl_CreateObjCommand uintptr 10619 Ftcl_CreateSlave uintptr 10620 Ftcl_CreateTimerHandler uintptr 10621 Ftcl_CreateTrace uintptr 10622 Ftcl_DeleteAssocData uintptr 10623 Ftcl_DeleteChannelHandler uintptr 10624 Ftcl_DeleteCloseHandler uintptr 10625 Ftcl_DeleteCommand uintptr 10626 Ftcl_DeleteCommandFromToken uintptr 10627 Ftcl_DeleteEvents uintptr 10628 Ftcl_DeleteEventSource uintptr 10629 Ftcl_DeleteExitHandler uintptr 10630 Ftcl_DeleteHashEntry uintptr 10631 Ftcl_DeleteHashTable uintptr 10632 Ftcl_DeleteInterp uintptr 10633 Ftcl_DetachPids uintptr 10634 Ftcl_DeleteTimerHandler uintptr 10635 Ftcl_DeleteTrace uintptr 10636 Ftcl_DontCallWhenDeleted uintptr 10637 Ftcl_DoOneEvent uintptr 10638 Ftcl_DoWhenIdle uintptr 10639 Ftcl_DStringAppend uintptr 10640 Ftcl_DStringAppendElement uintptr 10641 Ftcl_DStringEndSublist uintptr 10642 Ftcl_DStringFree uintptr 10643 Ftcl_DStringGetResult uintptr 10644 Ftcl_DStringInit uintptr 10645 Ftcl_DStringResult uintptr 10646 Ftcl_DStringSetLength uintptr 10647 Ftcl_DStringStartSublist uintptr 10648 Ftcl_Eof uintptr 10649 Ftcl_ErrnoId uintptr 10650 Ftcl_ErrnoMsg uintptr 10651 Ftcl_Eval uintptr 10652 Ftcl_EvalFile uintptr 10653 Ftcl_EvalObj uintptr 10654 Ftcl_EventuallyFree uintptr 10655 Ftcl_Exit uintptr 10656 Ftcl_ExposeCommand uintptr 10657 Ftcl_ExprBoolean uintptr 10658 Ftcl_ExprBooleanObj uintptr 10659 Ftcl_ExprDouble uintptr 10660 Ftcl_ExprDoubleObj uintptr 10661 Ftcl_ExprLong uintptr 10662 Ftcl_ExprLongObj uintptr 10663 Ftcl_ExprObj uintptr 10664 Ftcl_ExprString uintptr 10665 Ftcl_Finalize uintptr 10666 Ftcl_FindExecutable uintptr 10667 Ftcl_FirstHashEntry uintptr 10668 Ftcl_Flush uintptr 10669 Ftcl_FreeResult uintptr 10670 Ftcl_GetAlias uintptr 10671 Ftcl_GetAliasObj uintptr 10672 Ftcl_GetAssocData uintptr 10673 Ftcl_GetChannel uintptr 10674 Ftcl_GetChannelBufferSize uintptr 10675 Ftcl_GetChannelHandle uintptr 10676 Ftcl_GetChannelInstanceData uintptr 10677 Ftcl_GetChannelMode uintptr 10678 Ftcl_GetChannelName uintptr 10679 Ftcl_GetChannelOption uintptr 10680 Ftcl_GetChannelType uintptr 10681 Ftcl_GetCommandInfo uintptr 10682 Ftcl_GetCommandName uintptr 10683 Ftcl_GetErrno uintptr 10684 Ftcl_GetHostName uintptr 10685 Ftcl_GetInterpPath uintptr 10686 Ftcl_GetMaster uintptr 10687 Ftcl_GetNameOfExecutable uintptr 10688 Ftcl_GetObjResult uintptr 10689 Ftcl_GetOpenFile uintptr 10690 Ftcl_GetPathType uintptr 10691 Ftcl_Gets uintptr 10692 Ftcl_GetsObj uintptr 10693 Ftcl_GetServiceMode uintptr 10694 Ftcl_GetSlave uintptr 10695 Ftcl_GetStdChannel uintptr 10696 Ftcl_GetStringResult uintptr 10697 Ftcl_GetVar uintptr 10698 Ftcl_GetVar2 uintptr 10699 Ftcl_GlobalEval uintptr 10700 Ftcl_GlobalEvalObj uintptr 10701 Ftcl_HideCommand uintptr 10702 Ftcl_Init uintptr 10703 Ftcl_InitHashTable uintptr 10704 Ftcl_InputBlocked uintptr 10705 Ftcl_InputBuffered uintptr 10706 Ftcl_InterpDeleted uintptr 10707 Ftcl_IsSafe uintptr 10708 Ftcl_JoinPath uintptr 10709 Ftcl_LinkVar uintptr 10710 Freserved188 uintptr 10711 Ftcl_MakeFileChannel uintptr 10712 Ftcl_MakeSafe uintptr 10713 Ftcl_MakeTcpClientChannel uintptr 10714 Ftcl_Merge uintptr 10715 Ftcl_NextHashEntry uintptr 10716 Ftcl_NotifyChannel uintptr 10717 Ftcl_ObjGetVar2 uintptr 10718 Ftcl_ObjSetVar2 uintptr 10719 Ftcl_OpenCommandChannel uintptr 10720 Ftcl_OpenFileChannel uintptr 10721 Ftcl_OpenTcpClient uintptr 10722 Ftcl_OpenTcpServer uintptr 10723 Ftcl_Preserve uintptr 10724 Ftcl_PrintDouble uintptr 10725 Ftcl_PutEnv uintptr 10726 Ftcl_PosixError uintptr 10727 Ftcl_QueueEvent uintptr 10728 Ftcl_Read uintptr 10729 Ftcl_ReapDetachedProcs uintptr 10730 Ftcl_RecordAndEval uintptr 10731 Ftcl_RecordAndEvalObj uintptr 10732 Ftcl_RegisterChannel uintptr 10733 Ftcl_RegisterObjType uintptr 10734 Ftcl_RegExpCompile uintptr 10735 Ftcl_RegExpExec uintptr 10736 Ftcl_RegExpMatch uintptr 10737 Ftcl_RegExpRange uintptr 10738 Ftcl_Release uintptr 10739 Ftcl_ResetResult uintptr 10740 Ftcl_ScanElement uintptr 10741 Ftcl_ScanCountedElement uintptr 10742 Ftcl_SeekOld uintptr 10743 Ftcl_ServiceAll uintptr 10744 Ftcl_ServiceEvent uintptr 10745 Ftcl_SetAssocData uintptr 10746 Ftcl_SetChannelBufferSize uintptr 10747 Ftcl_SetChannelOption uintptr 10748 Ftcl_SetCommandInfo uintptr 10749 Ftcl_SetErrno uintptr 10750 Ftcl_SetErrorCode uintptr 10751 Ftcl_SetMaxBlockTime uintptr 10752 Ftcl_SetPanicProc uintptr 10753 Ftcl_SetRecursionLimit uintptr 10754 Ftcl_SetResult uintptr 10755 Ftcl_SetServiceMode uintptr 10756 Ftcl_SetObjErrorCode uintptr 10757 Ftcl_SetObjResult uintptr 10758 Ftcl_SetStdChannel uintptr 10759 Ftcl_SetVar uintptr 10760 Ftcl_SetVar2 uintptr 10761 Ftcl_SignalId uintptr 10762 Ftcl_SignalMsg uintptr 10763 Ftcl_SourceRCFile uintptr 10764 Ftcl_SplitList uintptr 10765 Ftcl_SplitPath uintptr 10766 Ftcl_StaticPackage uintptr 10767 Ftcl_StringMatch uintptr 10768 Ftcl_TellOld uintptr 10769 Ftcl_TraceVar uintptr 10770 Ftcl_TraceVar2 uintptr 10771 Ftcl_TranslateFileName uintptr 10772 Ftcl_Ungets uintptr 10773 Ftcl_UnlinkVar uintptr 10774 Ftcl_UnregisterChannel uintptr 10775 Ftcl_UnsetVar uintptr 10776 Ftcl_UnsetVar2 uintptr 10777 Ftcl_UntraceVar uintptr 10778 Ftcl_UntraceVar2 uintptr 10779 Ftcl_UpdateLinkedVar uintptr 10780 Ftcl_UpVar uintptr 10781 Ftcl_UpVar2 uintptr 10782 Ftcl_VarEval uintptr 10783 Ftcl_VarTraceInfo uintptr 10784 Ftcl_VarTraceInfo2 uintptr 10785 Ftcl_Write uintptr 10786 Ftcl_WrongNumArgs uintptr 10787 Ftcl_DumpActiveMemory uintptr 10788 Ftcl_ValidateAllMemory uintptr 10789 Ftcl_AppendResultVA uintptr 10790 Ftcl_AppendStringsToObjVA uintptr 10791 Ftcl_HashStats uintptr 10792 Ftcl_ParseVar uintptr 10793 Ftcl_PkgPresent uintptr 10794 Ftcl_PkgPresentEx uintptr 10795 Ftcl_PkgProvide uintptr 10796 Ftcl_PkgRequire uintptr 10797 Ftcl_SetErrorCodeVA uintptr 10798 Ftcl_VarEvalVA uintptr 10799 Ftcl_WaitPid uintptr 10800 Ftcl_PanicVA uintptr 10801 Ftcl_GetVersion uintptr 10802 Ftcl_InitMemory uintptr 10803 Ftcl_StackChannel uintptr 10804 Ftcl_UnstackChannel uintptr 10805 Ftcl_GetStackedChannel uintptr 10806 Ftcl_SetMainLoop uintptr 10807 Freserved285 uintptr 10808 Ftcl_AppendObjToObj uintptr 10809 Ftcl_CreateEncoding uintptr 10810 Ftcl_CreateThreadExitHandler uintptr 10811 Ftcl_DeleteThreadExitHandler uintptr 10812 Ftcl_DiscardResult uintptr 10813 Ftcl_EvalEx uintptr 10814 Ftcl_EvalObjv uintptr 10815 Ftcl_EvalObjEx uintptr 10816 Ftcl_ExitThread uintptr 10817 Ftcl_ExternalToUtf uintptr 10818 Ftcl_ExternalToUtfDString uintptr 10819 Ftcl_FinalizeThread uintptr 10820 Ftcl_FinalizeNotifier uintptr 10821 Ftcl_FreeEncoding uintptr 10822 Ftcl_GetCurrentThread uintptr 10823 Ftcl_GetEncoding uintptr 10824 Ftcl_GetEncodingName uintptr 10825 Ftcl_GetEncodingNames uintptr 10826 Ftcl_GetIndexFromObjStruct uintptr 10827 Ftcl_GetThreadData uintptr 10828 Ftcl_GetVar2Ex uintptr 10829 Ftcl_InitNotifier uintptr 10830 Ftcl_MutexLock uintptr 10831 Ftcl_MutexUnlock uintptr 10832 Ftcl_ConditionNotify uintptr 10833 Ftcl_ConditionWait uintptr 10834 Ftcl_NumUtfChars uintptr 10835 Ftcl_ReadChars uintptr 10836 Ftcl_RestoreResult uintptr 10837 Ftcl_SaveResult uintptr 10838 Ftcl_SetSystemEncoding uintptr 10839 Ftcl_SetVar2Ex uintptr 10840 Ftcl_ThreadAlert uintptr 10841 Ftcl_ThreadQueueEvent uintptr 10842 Ftcl_UniCharAtIndex uintptr 10843 Ftcl_UniCharToLower uintptr 10844 Ftcl_UniCharToTitle uintptr 10845 Ftcl_UniCharToUpper uintptr 10846 Ftcl_UniCharToUtf uintptr 10847 Ftcl_UtfAtIndex uintptr 10848 Ftcl_UtfCharComplete uintptr 10849 Ftcl_UtfBackslash uintptr 10850 Ftcl_UtfFindFirst uintptr 10851 Ftcl_UtfFindLast uintptr 10852 Ftcl_UtfNext uintptr 10853 Ftcl_UtfPrev uintptr 10854 Ftcl_UtfToExternal uintptr 10855 Ftcl_UtfToExternalDString uintptr 10856 Ftcl_UtfToLower uintptr 10857 Ftcl_UtfToTitle uintptr 10858 Ftcl_UtfToUniChar uintptr 10859 Ftcl_UtfToUpper uintptr 10860 Ftcl_WriteChars uintptr 10861 Ftcl_WriteObj uintptr 10862 Ftcl_GetString uintptr 10863 Ftcl_GetDefaultEncodingDir uintptr 10864 Ftcl_SetDefaultEncodingDir uintptr 10865 Ftcl_AlertNotifier uintptr 10866 Ftcl_ServiceModeHook uintptr 10867 Ftcl_UniCharIsAlnum uintptr 10868 Ftcl_UniCharIsAlpha uintptr 10869 Ftcl_UniCharIsDigit uintptr 10870 Ftcl_UniCharIsLower uintptr 10871 Ftcl_UniCharIsSpace uintptr 10872 Ftcl_UniCharIsUpper uintptr 10873 Ftcl_UniCharIsWordChar uintptr 10874 Ftcl_UniCharLen uintptr 10875 Ftcl_UniCharNcmp uintptr 10876 Ftcl_UniCharToUtfDString uintptr 10877 Ftcl_UtfToUniCharDString uintptr 10878 Ftcl_GetRegExpFromObj uintptr 10879 Ftcl_EvalTokens uintptr 10880 Ftcl_FreeParse uintptr 10881 Ftcl_LogCommandInfo uintptr 10882 Ftcl_ParseBraces uintptr 10883 Ftcl_ParseCommand uintptr 10884 Ftcl_ParseExpr uintptr 10885 Ftcl_ParseQuotedString uintptr 10886 Ftcl_ParseVarName uintptr 10887 Ftcl_GetCwd uintptr 10888 Ftcl_Chdir uintptr 10889 Ftcl_Access uintptr 10890 Ftcl_Stat uintptr 10891 Ftcl_UtfNcmp uintptr 10892 Ftcl_UtfNcasecmp uintptr 10893 Ftcl_StringCaseMatch uintptr 10894 Ftcl_UniCharIsControl uintptr 10895 Ftcl_UniCharIsGraph uintptr 10896 Ftcl_UniCharIsPrint uintptr 10897 Ftcl_UniCharIsPunct uintptr 10898 Ftcl_RegExpExecObj uintptr 10899 Ftcl_RegExpGetInfo uintptr 10900 Ftcl_NewUnicodeObj uintptr 10901 Ftcl_SetUnicodeObj uintptr 10902 Ftcl_GetCharLength uintptr 10903 Ftcl_GetUniChar uintptr 10904 Ftcl_GetUnicode uintptr 10905 Ftcl_GetRange uintptr 10906 Ftcl_AppendUnicodeToObj uintptr 10907 Ftcl_RegExpMatchObj uintptr 10908 Ftcl_SetNotifier uintptr 10909 Ftcl_GetAllocMutex uintptr 10910 Ftcl_GetChannelNames uintptr 10911 Ftcl_GetChannelNamesEx uintptr 10912 Ftcl_ProcObjCmd uintptr 10913 Ftcl_ConditionFinalize uintptr 10914 Ftcl_MutexFinalize uintptr 10915 Ftcl_CreateThread uintptr 10916 Ftcl_ReadRaw uintptr 10917 Ftcl_WriteRaw uintptr 10918 Ftcl_GetTopChannel uintptr 10919 Ftcl_ChannelBuffered uintptr 10920 Ftcl_ChannelName uintptr 10921 Ftcl_ChannelVersion uintptr 10922 Ftcl_ChannelBlockModeProc uintptr 10923 Ftcl_ChannelCloseProc uintptr 10924 Ftcl_ChannelClose2Proc uintptr 10925 Ftcl_ChannelInputProc uintptr 10926 Ftcl_ChannelOutputProc uintptr 10927 Ftcl_ChannelSeekProc uintptr 10928 Ftcl_ChannelSetOptionProc uintptr 10929 Ftcl_ChannelGetOptionProc uintptr 10930 Ftcl_ChannelWatchProc uintptr 10931 Ftcl_ChannelGetHandleProc uintptr 10932 Ftcl_ChannelFlushProc uintptr 10933 Ftcl_ChannelHandlerProc uintptr 10934 Ftcl_JoinThread uintptr 10935 Ftcl_IsChannelShared uintptr 10936 Ftcl_IsChannelRegistered uintptr 10937 Ftcl_CutChannel uintptr 10938 Ftcl_SpliceChannel uintptr 10939 Ftcl_ClearChannelHandlers uintptr 10940 Ftcl_IsChannelExisting uintptr 10941 Ftcl_UniCharNcasecmp uintptr 10942 Ftcl_UniCharCaseMatch uintptr 10943 Ftcl_FindHashEntry uintptr 10944 Ftcl_CreateHashEntry uintptr 10945 Ftcl_InitCustomHashTable uintptr 10946 Ftcl_InitObjHashTable uintptr 10947 Ftcl_CommandTraceInfo uintptr 10948 Ftcl_TraceCommand uintptr 10949 Ftcl_UntraceCommand uintptr 10950 Ftcl_AttemptAlloc uintptr 10951 Ftcl_AttemptDbCkalloc uintptr 10952 Ftcl_AttemptRealloc uintptr 10953 Ftcl_AttemptDbCkrealloc uintptr 10954 Ftcl_AttemptSetObjLength uintptr 10955 Ftcl_GetChannelThread uintptr 10956 Ftcl_GetUnicodeFromObj uintptr 10957 Ftcl_GetMathFuncInfo uintptr 10958 Ftcl_ListMathFuncs uintptr 10959 Ftcl_SubstObj uintptr 10960 Ftcl_DetachChannel uintptr 10961 Ftcl_IsStandardChannel uintptr 10962 Ftcl_FSCopyFile uintptr 10963 Ftcl_FSCopyDirectory uintptr 10964 Ftcl_FSCreateDirectory uintptr 10965 Ftcl_FSDeleteFile uintptr 10966 Ftcl_FSLoadFile uintptr 10967 Ftcl_FSMatchInDirectory uintptr 10968 Ftcl_FSLink uintptr 10969 Ftcl_FSRemoveDirectory uintptr 10970 Ftcl_FSRenameFile uintptr 10971 Ftcl_FSLstat uintptr 10972 Ftcl_FSUtime uintptr 10973 Ftcl_FSFileAttrsGet uintptr 10974 Ftcl_FSFileAttrsSet uintptr 10975 Ftcl_FSFileAttrStrings uintptr 10976 Ftcl_FSStat uintptr 10977 Ftcl_FSAccess uintptr 10978 Ftcl_FSOpenFileChannel uintptr 10979 Ftcl_FSGetCwd uintptr 10980 Ftcl_FSChdir uintptr 10981 Ftcl_FSConvertToPathType uintptr 10982 Ftcl_FSJoinPath uintptr 10983 Ftcl_FSSplitPath uintptr 10984 Ftcl_FSEqualPaths uintptr 10985 Ftcl_FSGetNormalizedPath uintptr 10986 Ftcl_FSJoinToPath uintptr 10987 Ftcl_FSGetInternalRep uintptr 10988 Ftcl_FSGetTranslatedPath uintptr 10989 Ftcl_FSEvalFile uintptr 10990 Ftcl_FSNewNativePath uintptr 10991 Ftcl_FSGetNativePath uintptr 10992 Ftcl_FSFileSystemInfo uintptr 10993 Ftcl_FSPathSeparator uintptr 10994 Ftcl_FSListVolumes uintptr 10995 Ftcl_FSRegister uintptr 10996 Ftcl_FSUnregister uintptr 10997 Ftcl_FSData uintptr 10998 Ftcl_FSGetTranslatedStringPath uintptr 10999 Ftcl_FSGetFileSystemForPath uintptr 11000 Ftcl_FSGetPathType uintptr 11001 Ftcl_OutputBuffered uintptr 11002 Ftcl_FSMountsChanged uintptr 11003 Ftcl_EvalTokensStandard uintptr 11004 Ftcl_GetTime uintptr 11005 Ftcl_CreateObjTrace uintptr 11006 Ftcl_GetCommandInfoFromToken uintptr 11007 Ftcl_SetCommandInfoFromToken uintptr 11008 Ftcl_DbNewWideIntObj uintptr 11009 Ftcl_GetWideIntFromObj uintptr 11010 Ftcl_NewWideIntObj uintptr 11011 Ftcl_SetWideIntObj uintptr 11012 Ftcl_AllocStatBuf uintptr 11013 Ftcl_Seek uintptr 11014 Ftcl_Tell uintptr 11015 Ftcl_ChannelWideSeekProc uintptr 11016 Ftcl_DictObjPut uintptr 11017 Ftcl_DictObjGet uintptr 11018 Ftcl_DictObjRemove uintptr 11019 Ftcl_DictObjSize uintptr 11020 Ftcl_DictObjFirst uintptr 11021 Ftcl_DictObjNext uintptr 11022 Ftcl_DictObjDone uintptr 11023 Ftcl_DictObjPutKeyList uintptr 11024 Ftcl_DictObjRemoveKeyList uintptr 11025 Ftcl_NewDictObj uintptr 11026 Ftcl_DbNewDictObj uintptr 11027 Ftcl_RegisterConfig uintptr 11028 Ftcl_CreateNamespace uintptr 11029 Ftcl_DeleteNamespace uintptr 11030 Ftcl_AppendExportList uintptr 11031 Ftcl_Export uintptr 11032 Ftcl_Import uintptr 11033 Ftcl_ForgetImport uintptr 11034 Ftcl_GetCurrentNamespace uintptr 11035 Ftcl_GetGlobalNamespace uintptr 11036 Ftcl_FindNamespace uintptr 11037 Ftcl_FindCommand uintptr 11038 Ftcl_GetCommandFromObj uintptr 11039 Ftcl_GetCommandFullName uintptr 11040 Ftcl_FSEvalFileEx uintptr 11041 Ftcl_SetExitProc uintptr 11042 Ftcl_LimitAddHandler uintptr 11043 Ftcl_LimitRemoveHandler uintptr 11044 Ftcl_LimitReady uintptr 11045 Ftcl_LimitCheck uintptr 11046 Ftcl_LimitExceeded uintptr 11047 Ftcl_LimitSetCommands uintptr 11048 Ftcl_LimitSetTime uintptr 11049 Ftcl_LimitSetGranularity uintptr 11050 Ftcl_LimitTypeEnabled uintptr 11051 Ftcl_LimitTypeExceeded uintptr 11052 Ftcl_LimitTypeSet uintptr 11053 Ftcl_LimitTypeReset uintptr 11054 Ftcl_LimitGetCommands uintptr 11055 Ftcl_LimitGetTime uintptr 11056 Ftcl_LimitGetGranularity uintptr 11057 Ftcl_SaveInterpState uintptr 11058 Ftcl_RestoreInterpState uintptr 11059 Ftcl_DiscardInterpState uintptr 11060 Ftcl_SetReturnOptions uintptr 11061 Ftcl_GetReturnOptions uintptr 11062 Ftcl_IsEnsemble uintptr 11063 Ftcl_CreateEnsemble uintptr 11064 Ftcl_FindEnsemble uintptr 11065 Ftcl_SetEnsembleSubcommandList uintptr 11066 Ftcl_SetEnsembleMappingDict uintptr 11067 Ftcl_SetEnsembleUnknownHandler uintptr 11068 Ftcl_SetEnsembleFlags uintptr 11069 Ftcl_GetEnsembleSubcommandList uintptr 11070 Ftcl_GetEnsembleMappingDict uintptr 11071 Ftcl_GetEnsembleUnknownHandler uintptr 11072 Ftcl_GetEnsembleFlags uintptr 11073 Ftcl_GetEnsembleNamespace uintptr 11074 Ftcl_SetTimeProc uintptr 11075 Ftcl_QueryTimeProc uintptr 11076 Ftcl_ChannelThreadActionProc uintptr 11077 Ftcl_NewBignumObj uintptr 11078 Ftcl_DbNewBignumObj uintptr 11079 Ftcl_SetBignumObj uintptr 11080 Ftcl_GetBignumFromObj uintptr 11081 Ftcl_TakeBignumFromObj uintptr 11082 Ftcl_TruncateChannel uintptr 11083 Ftcl_ChannelTruncateProc uintptr 11084 Ftcl_SetChannelErrorInterp uintptr 11085 Ftcl_GetChannelErrorInterp uintptr 11086 Ftcl_SetChannelError uintptr 11087 Ftcl_GetChannelError uintptr 11088 Ftcl_InitBignumFromDouble uintptr 11089 Ftcl_GetNamespaceUnknownHandler uintptr 11090 Ftcl_SetNamespaceUnknownHandler uintptr 11091 Ftcl_GetEncodingFromObj uintptr 11092 Ftcl_GetEncodingSearchPath uintptr 11093 Ftcl_SetEncodingSearchPath uintptr 11094 Ftcl_GetEncodingNameFromEnvironment uintptr 11095 Ftcl_PkgRequireProc uintptr 11096 Ftcl_AppendObjToErrorInfo uintptr 11097 Ftcl_AppendLimitedToObj uintptr 11098 Ftcl_Format uintptr 11099 Ftcl_AppendFormatToObj uintptr 11100 Ftcl_ObjPrintf uintptr 11101 Ftcl_AppendPrintfToObj uintptr 11102 Ftcl_CancelEval uintptr 11103 Ftcl_Canceled uintptr 11104 Ftcl_CreatePipe uintptr 11105 Ftcl_NRCreateCommand uintptr 11106 Ftcl_NREvalObj uintptr 11107 Ftcl_NREvalObjv uintptr 11108 Ftcl_NRCmdSwap uintptr 11109 Ftcl_NRAddCallback uintptr 11110 Ftcl_NRCallObjProc uintptr 11111 Ftcl_GetFSDeviceFromStat uintptr 11112 Ftcl_GetFSInodeFromStat uintptr 11113 Ftcl_GetModeFromStat uintptr 11114 Ftcl_GetLinkCountFromStat uintptr 11115 Ftcl_GetUserIdFromStat uintptr 11116 Ftcl_GetGroupIdFromStat uintptr 11117 Ftcl_GetDeviceTypeFromStat uintptr 11118 Ftcl_GetAccessTimeFromStat uintptr 11119 Ftcl_GetModificationTimeFromStat uintptr 11120 Ftcl_GetChangeTimeFromStat uintptr 11121 Ftcl_GetSizeFromStat uintptr 11122 Ftcl_GetBlocksFromStat uintptr 11123 Ftcl_GetBlockSizeFromStat uintptr 11124 Ftcl_SetEnsembleParameterList uintptr 11125 Ftcl_GetEnsembleParameterList uintptr 11126 Ftcl_ParseArgsObjv uintptr 11127 Ftcl_GetErrorLine uintptr 11128 Ftcl_SetErrorLine uintptr 11129 Ftcl_TransferResult uintptr 11130 Ftcl_InterpActive uintptr 11131 Ftcl_BackgroundException uintptr 11132 Ftcl_ZlibDeflate uintptr 11133 Ftcl_ZlibInflate uintptr 11134 Ftcl_ZlibCRC32 uintptr 11135 Ftcl_ZlibAdler32 uintptr 11136 Ftcl_ZlibStreamInit uintptr 11137 Ftcl_ZlibStreamGetCommandName uintptr 11138 Ftcl_ZlibStreamEof uintptr 11139 Ftcl_ZlibStreamChecksum uintptr 11140 Ftcl_ZlibStreamPut uintptr 11141 Ftcl_ZlibStreamGet uintptr 11142 Ftcl_ZlibStreamClose uintptr 11143 Ftcl_ZlibStreamReset uintptr 11144 Ftcl_SetStartupScript uintptr 11145 Ftcl_GetStartupScript uintptr 11146 Ftcl_CloseEx uintptr 11147 Ftcl_NRExprObj uintptr 11148 Ftcl_NRSubstObj uintptr 11149 Ftcl_LoadFile uintptr 11150 Ftcl_FindSymbol uintptr 11151 Ftcl_FSUnloadFile uintptr 11152 Ftcl_ZlibStreamSetCompressionDictionary uintptr 11153 } /* tclDecls.h:1826:9 */ 11154 11155 type TclStubs = TclStubs1 /* tclDecls.h:2485:3 */ 11156 11157 // !END!: Do not edit above this line. 11158 11159 // Deprecated Tcl procedures: 11160 11161 // Include platform specific public function declarations that are accessible 11162 // via the stubs table. Make all TclOO symbols MODULE_SCOPE (which only 11163 // has effect on building it as a shared library). See ticket [3010352]. 11164 11165 // tclPlatDecls.h -- 11166 // 11167 // Declarations of platform specific Tcl APIs. 11168 // 11169 // Copyright (c) 1998-1999 by Scriptics Corporation. 11170 // All rights reserved. 11171 11172 // WARNING: This file is automatically generated by the tools/genStubs.tcl 11173 // script. Any modifications to the function declarations below should be made 11174 // in the generic/tcl.decls script. 11175 11176 // TCHAR is needed here for win32, so if it is not defined yet do it here. 11177 // This way, we don't need to include <tchar.h> just for one define. 11178 11179 // !BEGIN!: Do not edit below this line. 11180 11181 // Exported function declarations: 11182 11183 type TclPlatStubs = TclPlatStubs1 /* tclPlatDecls.h:86:3 */ 11184 11185 // end block for C++ 11186 11187 // Local Variables: 11188 // mode: c 11189 // c-basic-offset: 4 11190 // fill-column: 78 11191 // End: 11192 11193 // Extract an sqlite3* db handle from the object passed as the second 11194 // argument. If successful, set *pDb to point to the db handle and return 11195 // TCL_OK. Otherwise, return TCL_ERROR. 11196 func dbHandleFromObj(tls *libc.TLS, interp uintptr, pObj uintptr, pDb uintptr) int32 { /* test_expert.c:36:12: */ 11197 bp := tls.Alloc(88) 11198 defer tls.Free(88) 11199 11200 // var info Tcl_CmdInfo at bp+24, 64 11201 11202 if 0 == tcl.XTcl_GetCommandInfo(tls, interp, tcl.XTcl_GetString(tls, pObj), bp+24 /* &info */) { 11203 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+1791 /* "no such handle: " */, tcl.XTcl_GetString(tls, pObj), 0)) 11204 return TCL_ERROR 11205 } 11206 11207 *(*uintptr)(unsafe.Pointer(pDb)) = *(*uintptr)(unsafe.Pointer((*Tcl_CmdInfo)(unsafe.Pointer(bp + 24 /* &info */)).FobjClientData)) 11208 return TCL_OK 11209 } 11210 11211 // Tclcmd: $expert sql SQL 11212 // $expert analyze 11213 // $expert count 11214 // $expert report STMT EREPORT 11215 // $expert destroy 11216 func testExpertCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_expert.c:55:26: */ 11217 bp := tls.Alloc(212) 11218 defer tls.Free(212) 11219 11220 var pExpert uintptr = clientData 11221 *(*[6]Subcmd)(unsafe.Pointer(bp /* aSub */)) = [6]Subcmd{ 11222 {FzSub: ts + 1808 /* "sql" */, FnArg: 1, FzMsg: ts + 1812 /* "TABLE" */}, // 0 11223 {FzSub: ts + 1818 /* "analyze" */, FzMsg: ts + 489 /* "" */}, // 1 11224 {FzSub: ts + 1826 /* "count" */, FzMsg: ts + 489 /* "" */}, // 2 11225 {FzSub: ts + 1832 /* "report" */, FnArg: 2, FzMsg: ts + 1839 /* "STMT EREPORT" */}, // 3 11226 {FzSub: ts + 1852 /* "destroy" */, FzMsg: ts + 489 /* "" */}, // 4 11227 {}, 11228 } 11229 // var iSub int32 at bp+144, 4 11230 11231 var rc int32 = TCL_OK 11232 *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */)) = uintptr(0) 11233 11234 if objc < 2 { 11235 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1860 /* "SUBCOMMAND ..." */) 11236 return TCL_ERROR 11237 } 11238 rc = tcl.XTcl_GetIndexFromObjStruct(tls, interp, 11239 *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &aSub[0] */, int32(unsafe.Sizeof(Subcmd{})), ts+1875 /* "sub-command" */, 0, bp+144 /* &iSub */) 11240 if rc != TCL_OK { 11241 return rc 11242 } 11243 if objc != (2 + (*Subcmd)(unsafe.Pointer(bp /* &aSub */ +uintptr(*(*int32)(unsafe.Pointer(bp + 144 /* iSub */)))*24)).FnArg) { 11244 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, (*Subcmd)(unsafe.Pointer(bp /* &aSub */ +uintptr(*(*int32)(unsafe.Pointer(bp + 144 /* iSub */)))*24)).FzMsg) 11245 return TCL_ERROR 11246 } 11247 11248 switch *(*int32)(unsafe.Pointer(bp + 144 /* iSub */)) { 11249 case 0: 11250 { // sql 11251 var zArg uintptr = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 11252 rc = sqlite3_expert_sql(tls, pExpert, zArg, bp+152 /* &zErr */) 11253 break 11254 11255 } 11256 11257 case 1: 11258 { // analyze 11259 rc = sqlite3_expert_analyze(tls, pExpert, bp+152 /* &zErr */) 11260 break 11261 11262 } 11263 11264 case 2: 11265 { // count 11266 var n int32 = sqlite3_expert_count(tls, pExpert) 11267 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, n)) 11268 break 11269 11270 } 11271 11272 case 3: 11273 { // report 11274 *(*[5]uintptr)(unsafe.Pointer(bp + 168 /* aEnum */)) = [5]uintptr{ 11275 ts + 1808 /* "sql" */, ts + 1887 /* "indexes" */, ts + 1895 /* "plan" */, ts + 1900 /* "candidates" */, uintptr(0), 11276 } 11277 // var iEnum int32 at bp+208, 4 11278 11279 // var iStmt int32 at bp+160, 4 11280 11281 var zReport uintptr 11282 11283 if (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+160 /* &iStmt */) != 0) || 11284 (tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+168 /* &aEnum[0] */, int32(unsafe.Sizeof(uintptr(0))), ts+1832 /* "report" */, 0, bp+208 /* &iEnum */) != 0) { 11285 return TCL_ERROR 11286 } 11287 11288 zReport = sqlite3_expert_report(tls, pExpert, *(*int32)(unsafe.Pointer(bp + 160 /* iStmt */)), (1 + *(*int32)(unsafe.Pointer(bp + 208 /* iEnum */)))) 11289 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, zReport, -1)) 11290 break 11291 11292 } 11293 11294 default: // destroy 11295 11296 tcl.XTcl_DeleteCommand(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv)))) 11297 break 11298 } 11299 11300 if rc != TCL_OK { 11301 if *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */)) != 0 { 11302 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */)), -1)) 11303 } else { 11304 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 11305 } 11306 } 11307 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */))) 11308 return rc 11309 } 11310 11311 type Subcmd = struct { 11312 FzSub uintptr 11313 FnArg int32 11314 _ [4]byte 11315 FzMsg uintptr 11316 } /* test_expert.c:62:3 */ 11317 11318 func testExpertDel(tls *libc.TLS, clientData uintptr) { /* test_expert.c:150:27: */ 11319 var pExpert uintptr = clientData 11320 sqlite3_expert_destroy(tls, pExpert) 11321 } 11322 11323 // sqlite3_expert_new DB 11324 func test_sqlite3_expert_new(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_expert.c:158:26: */ 11325 bp := tls.Alloc(56) 11326 defer tls.Free(56) 11327 11328 // var db uintptr at bp+40, 8 11329 11330 var zCmd uintptr = uintptr(0) 11331 *(*uintptr)(unsafe.Pointer(bp + 48 /* zErr */)) = uintptr(0) 11332 var pExpert uintptr 11333 var rc int32 = TCL_OK 11334 11335 if objc != 2 { 11336 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 11337 return TCL_ERROR 11338 } 11339 if dbHandleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+40 /* &db */) != 0 { 11340 return TCL_ERROR 11341 } 11342 11343 zCmd = sqlite3.Xsqlite3_mprintf(tls, ts+1914 /* "sqlite3expert%d" */, libc.VaList(bp, libc.PreIncInt32(&iCmd, 1))) 11344 if zCmd == uintptr(0) { 11345 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+8, ts+1930 /* "out of memory" */, uintptr(0))) 11346 return TCL_ERROR 11347 } 11348 11349 pExpert = sqlite3_expert_new(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* db */)), bp+48 /* &zErr */) 11350 if pExpert == uintptr(0) { 11351 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, *(*uintptr)(unsafe.Pointer(bp + 48 /* zErr */)), uintptr(0))) 11352 rc = TCL_ERROR 11353 } else { 11354 var p uintptr = pExpert 11355 tcl.XTcl_CreateObjCommand(tls, interp, zCmd, *(*uintptr)(unsafe.Pointer(&struct { 11356 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 11357 }{testExpertCmd})), p, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testExpertDel}))) 11358 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, zCmd, -1)) 11359 } 11360 11361 sqlite3.Xsqlite3_free(tls, zCmd) 11362 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* zErr */))) 11363 return rc 11364 } 11365 11366 var iCmd int32 = 0 /* test_expert.c:164:14 */ 11367 11368 func TestExpert_Init(tls *libc.TLS, interp uintptr) int32 { /* test_expert.c:202:5: */ 11369 bp := tls.Alloc(16) 11370 defer tls.Free(16) 11371 11372 *(*[1]struct { 11373 FzCmd uintptr 11374 FxProc uintptr 11375 })(unsafe.Pointer(bp /* aCmd */)) = [1]struct { 11376 FzCmd uintptr 11377 FxProc uintptr 11378 }{ 11379 {FzCmd: ts + 1944 /* "sqlite3_expert_n..." */, FxProc: *(*uintptr)(unsafe.Pointer(&struct { 11380 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 11381 }{test_sqlite3_expert_new}))}, 11382 } 11383 var i int32 11384 11385 for i = 0; uint64(i) < (uint64(unsafe.Sizeof([1]struct { 11386 FzCmd uintptr 11387 FxProc uintptr 11388 }{})) / uint64(unsafe.Sizeof(struct { 11389 FzCmd uintptr 11390 FxProc uintptr 11391 }{}))); i++ { 11392 var p uintptr = (bp /* &aCmd */ + uintptr(i)*16) 11393 tcl.XTcl_CreateObjCommand(tls, interp, (*struct { 11394 FzCmd uintptr 11395 FxProc uintptr 11396 })(unsafe.Pointer(p)).FzCmd, (*struct { 11397 FzCmd uintptr 11398 FxProc uintptr 11399 })(unsafe.Pointer(p)).FxProc, uintptr(0), uintptr(0)) 11400 } 11401 return TCL_OK 11402 } 11403 11404 // 2011 Jan 27 11405 // 11406 // The author disclaims copyright to this source code. In place of 11407 // a legal notice, here is a blessing: 11408 // 11409 // May you do good and not evil. 11410 // May you find forgiveness for yourself and forgive others. 11411 // May you share freely, never taking more than you give. 11412 // 11413 // 11414 // 11415 // This file is not part of the production FTS code. It is only used for 11416 // testing. It contains a virtual table implementation that provides direct 11417 // access to the full-text index of an FTS table. 11418 11419 // 2009 Nov 12 11420 // 11421 // The author disclaims copyright to this source code. In place of 11422 // a legal notice, here is a blessing: 11423 // 11424 // May you do good and not evil. 11425 // May you find forgiveness for yourself and forgive others. 11426 // May you share freely, never taking more than you give. 11427 // 11428 // 11429 // 11430 11431 // FTS3/FTS4 require virtual tables 11432 11433 // FTS4 is really an extension for FTS3. It is enabled using the 11434 // SQLITE_ENABLE_FTS3 macro. But to avoid confusion we also all 11435 // the SQLITE_ENABLE_FTS4 macro to serve as an alisse for SQLITE_ENABLE_FTS3. 11436 11437 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 11438 // This file is part of the GNU C Library. 11439 // 11440 // The GNU C Library is free software; you can redistribute it and/or 11441 // modify it under the terms of the GNU Lesser General Public 11442 // License as published by the Free Software Foundation; either 11443 // version 2.1 of the License, or (at your option) any later version. 11444 // 11445 // The GNU C Library is distributed in the hope that it will be useful, 11446 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11447 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11448 // Lesser General Public License for more details. 11449 // 11450 // You should have received a copy of the GNU Lesser General Public 11451 // License along with the GNU C Library; if not, see 11452 // <http://www.gnu.org/licenses/>. 11453 11454 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 11455 11456 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 11457 // This file is part of the GNU C Library. 11458 // 11459 // The GNU C Library is free software; you can redistribute it and/or 11460 // modify it under the terms of the GNU Lesser General Public 11461 // License as published by the Free Software Foundation; either 11462 // version 2.1 of the License, or (at your option) any later version. 11463 // 11464 // The GNU C Library is distributed in the hope that it will be useful, 11465 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11466 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11467 // Lesser General Public License for more details. 11468 // 11469 // You should have received a copy of the GNU Lesser General Public 11470 // License along with the GNU C Library; if not, see 11471 // <http://www.gnu.org/licenses/>. 11472 11473 // void assert (int expression); 11474 // 11475 // If NDEBUG is defined, do nothing. 11476 // If not, and EXPRESSION is zero, print an error message and abort. 11477 11478 // void assert_perror (int errnum); 11479 // 11480 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 11481 // error message with the error text for ERRNUM and abort. 11482 // (This is a GNU extension.) 11483 11484 // Decode a pointer to an sqlite3 object. 11485 func f5tDbPointer(tls *libc.TLS, interp uintptr, pObj uintptr, ppDb uintptr) int32 { /* fts5_tcl.c:52:12: */ 11486 bp := tls.Alloc(64) 11487 defer tls.Free(64) 11488 11489 var p uintptr 11490 // var cmdInfo Tcl_CmdInfo at bp, 64 11491 11492 var z uintptr = tcl.XTcl_GetString(tls, pObj) 11493 if tcl.XTcl_GetCommandInfo(tls, interp, z, bp /* &cmdInfo */) != 0 { 11494 p = (*Tcl_CmdInfo)(unsafe.Pointer(bp /* &cmdInfo */)).FobjClientData 11495 *(*uintptr)(unsafe.Pointer(ppDb)) = (*struct{ Fdb uintptr })(unsafe.Pointer(p)).Fdb 11496 return TCL_OK 11497 } 11498 return TCL_ERROR 11499 } 11500 11501 // End of code that accesses the SqliteDb struct. 11502 // 11503 11504 func f5tResultToErrorCode(tls *libc.TLS, zRes uintptr) int32 { /* fts5_tcl.c:67:12: */ 11505 bp := tls.Alloc(64) 11506 defer tls.Free(64) 11507 11508 *(*[4]ErrorCode)(unsafe.Pointer(bp /* aErr */)) = [4]ErrorCode{ 11509 {Frc: SQLITE_DONE, FzError: ts + 1963 /* "SQLITE_DONE" */}, 11510 {Frc: SQLITE_ERROR, FzError: ts + 1975 /* "SQLITE_ERROR" */}, 11511 {FzError: ts + 1988 /* "SQLITE_OK" */}, 11512 {FzError: ts + 489 /* "" */}, 11513 } 11514 var i int32 11515 11516 for i = 0; uint64(i) < (uint64(unsafe.Sizeof([4]ErrorCode{})) / uint64(unsafe.Sizeof(ErrorCode{}))); i++ { 11517 if 0 == sqlite3.Xsqlite3_stricmp(tls, zRes, (*ErrorCode)(unsafe.Pointer(bp /* &aErr */ +uintptr(i)*16)).FzError) { 11518 return (*ErrorCode)(unsafe.Pointer(bp /* &aErr */ + uintptr(i)*16)).Frc 11519 } 11520 } 11521 11522 return SQLITE_ERROR 11523 } 11524 11525 type ErrorCode = struct { 11526 Frc int32 11527 _ [4]byte 11528 FzError uintptr 11529 } /* fts5_tcl.c:68:3 */ 11530 11531 func f5tDbAndApi(tls *libc.TLS, interp uintptr, pObj uintptr, ppDb uintptr, ppApi uintptr) int32 { /* fts5_tcl.c:88:26: */ 11532 bp := tls.Alloc(72) 11533 defer tls.Free(72) 11534 11535 *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)) = uintptr(0) 11536 var rc int32 = f5tDbPointer(tls, interp, pObj, bp+48 /* &db */) 11537 if rc != TCL_OK { 11538 return TCL_ERROR 11539 } else { 11540 *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)) = uintptr(0) 11541 *(*uintptr)(unsafe.Pointer(bp + 64 /* pApi */)) = uintptr(0) 11542 11543 rc = sqlite3.Xsqlite3_prepare_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), ts+1998 /* "SELECT fts5(?1)" */, -1, bp+56 /* &pStmt */, uintptr(0)) 11544 if rc != SQLITE_OK { 11545 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+2014 /* "error: " */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */))), 0)) 11546 return TCL_ERROR 11547 } 11548 sqlite3.Xsqlite3_bind_pointer(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)), 1, bp+64 /* &pApi */, ts+2022 /* "fts5_api_ptr" */, uintptr(0)) 11549 sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) 11550 11551 if sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) != SQLITE_OK { 11552 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, ts+2014 /* "error: " */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */))), 0)) 11553 return TCL_ERROR 11554 } 11555 11556 *(*uintptr)(unsafe.Pointer(ppDb)) = *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)) 11557 *(*uintptr)(unsafe.Pointer(ppApi)) = *(*uintptr)(unsafe.Pointer(bp + 64 /* pApi */)) 11558 } 11559 11560 return TCL_OK 11561 } 11562 11563 type F5tFunction1 = struct { 11564 Finterp uintptr 11565 FpScript uintptr 11566 } /* fts5_tcl.c:122:9 */ 11567 11568 type F5tFunction = F5tFunction1 /* fts5_tcl.c:122:28 */ 11569 11570 type F5tApi1 = struct { 11571 FpApi uintptr 11572 FpFts uintptr 11573 } /* fts5_tcl.c:128:9 */ 11574 11575 type F5tApi = F5tApi1 /* fts5_tcl.c:128:23 */ 11576 11577 // An object of this type is used with the xSetAuxdata() and xGetAuxdata() 11578 // API test wrappers. The tcl interface allows a single tcl value to be 11579 // saved using xSetAuxdata(). Instead of simply storing a pointer to the 11580 // tcl object, the code in this file wraps it in an sqlite3_malloc'd 11581 // instance of the following struct so that if the destructor is not 11582 // correctly invoked it will be reported as an SQLite memory leak. 11583 type F5tAuxData1 = struct{ FpObj uintptr } /* fts5_tcl.c:142:9 */ 11584 11585 // An object of this type is used with the xSetAuxdata() and xGetAuxdata() 11586 // API test wrappers. The tcl interface allows a single tcl value to be 11587 // saved using xSetAuxdata(). Instead of simply storing a pointer to the 11588 // tcl object, the code in this file wraps it in an sqlite3_malloc'd 11589 // instance of the following struct so that if the destructor is not 11590 // correctly invoked it will be reported as an SQLite memory leak. 11591 type F5tAuxData = F5tAuxData1 /* fts5_tcl.c:142:27 */ 11592 11593 func xTokenizeCb(tls *libc.TLS, pCtx uintptr, tflags int32, zToken uintptr, nToken int32, iStart int32, iEnd int32) int32 { /* fts5_tcl.c:147:12: */ 11594 var p uintptr = pCtx 11595 var pEval uintptr = tcl.XTcl_DuplicateObj(tls, (*F5tFunction)(unsafe.Pointer(p)).FpScript) 11596 var rc int32 11597 11598 (*Tcl_Obj)(unsafe.Pointer(pEval)).FrefCount++ 11599 tcl.XTcl_ListObjAppendElement(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp, pEval, tcl.XTcl_NewStringObj(tls, zToken, nToken)) 11600 tcl.XTcl_ListObjAppendElement(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp, pEval, tcl.XTcl_NewIntObj(tls, iStart)) 11601 tcl.XTcl_ListObjAppendElement(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp, pEval, tcl.XTcl_NewIntObj(tls, iEnd)) 11602 11603 rc = tcl.XTcl_EvalObjEx(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp, pEval, 0) 11604 for ok := true; ok; ok = 0 != 0 { 11605 var _objPtr uintptr = pEval 11606 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 11607 tcl.XTclFreeObj(tls, _objPtr) 11608 } 11609 } 11610 if rc == TCL_OK { 11611 rc = f5tResultToErrorCode(tls, tcl.XTcl_GetStringResult(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp)) 11612 } 11613 11614 return rc 11615 } 11616 11617 func xQueryPhraseCb(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr) int32 { /* fts5_tcl.c:173:12: */ 11618 bp := tls.Alloc(88) 11619 defer tls.Free(88) 11620 11621 var p uintptr = pCtx 11622 var pEval uintptr 11623 var rc int32 11624 // var zCmd [64]int8 at bp+8, 64 11625 11626 // var sApi F5tApi at bp+72, 16 11627 11628 (*F5tApi)(unsafe.Pointer(bp + 72 /* &sApi */)).FpApi = pApi 11629 (*F5tApi)(unsafe.Pointer(bp + 72 /* &sApi */)).FpFts = pFts 11630 libc.Xsprintf(tls, bp+8 /* &zCmd[0] */, ts+2035 /* "f5t_2_%lld" */, libc.VaList(bp, libc.PostIncInt64(&iCmd1, 1))) 11631 tcl.XTcl_CreateObjCommand(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp, bp+8 /* &zCmd[0] */, *(*uintptr)(unsafe.Pointer(&struct { 11632 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 11633 }{xF5tApi})), bp+72 /* &sApi */, uintptr(0)) 11634 11635 pEval = tcl.XTcl_DuplicateObj(tls, (*F5tFunction)(unsafe.Pointer(p)).FpScript) 11636 (*Tcl_Obj)(unsafe.Pointer(pEval)).FrefCount++ 11637 tcl.XTcl_ListObjAppendElement(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp, pEval, tcl.XTcl_NewStringObj(tls, bp+8 /* &zCmd[0] */, -1)) 11638 rc = tcl.XTcl_EvalObjEx(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp, pEval, 0) 11639 for ok := true; ok; ok = 0 != 0 { 11640 var _objPtr uintptr = pEval 11641 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 11642 tcl.XTclFreeObj(tls, _objPtr) 11643 } 11644 } 11645 tcl.XTcl_DeleteCommand(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp, bp+8 /* &zCmd[0] */) 11646 11647 if rc == TCL_OK { 11648 rc = f5tResultToErrorCode(tls, tcl.XTcl_GetStringResult(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp)) 11649 } 11650 11651 return rc 11652 } 11653 11654 var iCmd1 sqlite3_int64 = int64(0) /* fts5_tcl.c:179:24 */ 11655 11656 func xSetAuxdataDestructor(tls *libc.TLS, p uintptr) { /* fts5_tcl.c:205:13: */ 11657 var pData uintptr = p 11658 for ok := true; ok; ok = 0 != 0 { 11659 var _objPtr uintptr = (*F5tAuxData)(unsafe.Pointer(pData)).FpObj 11660 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 11661 tcl.XTclFreeObj(tls, _objPtr) 11662 } 11663 } 11664 sqlite3.Xsqlite3_free(tls, pData) 11665 } 11666 11667 // api sub-command... 11668 // 11669 // Description... 11670 func xF5tApi(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* fts5_tcl.c:216:26: */ 11671 bp := tls.Alloc(684) 11672 defer tls.Free(684) 11673 11674 *(*[19]Sub)(unsafe.Pointer(bp + 32 /* aSub */)) = [19]Sub{ 11675 {FzName: ts + 2046 /* "xColumnCount" */, FzMsg: ts + 489 /* "" */}, // 0 11676 {FzName: ts + 2059 /* "xRowCount" */, FzMsg: ts + 489 /* "" */}, // 1 11677 {FzName: ts + 2069 /* "xColumnTotalSize" */, FnArg: 1, FzMsg: ts + 2086 /* "COL" */}, // 2 11678 {FzName: ts + 2090 /* "xTokenize" */, FnArg: 2, FzMsg: ts + 2100 /* "TEXT SCRIPT" */}, // 3 11679 {FzName: ts + 2112 /* "xPhraseCount" */, FzMsg: ts + 489 /* "" */}, // 4 11680 {FzName: ts + 2125 /* "xPhraseSize" */, FnArg: 1, FzMsg: ts + 2137 /* "PHRASE" */}, // 5 11681 {FzName: ts + 2144 /* "xInstCount" */, FzMsg: ts + 489 /* "" */}, // 6 11682 {FzName: ts + 2155 /* "xInst" */, FnArg: 1, FzMsg: ts + 2161 /* "IDX" */}, // 7 11683 {FzName: ts + 2165 /* "xRowid" */, FzMsg: ts + 489 /* "" */}, // 8 11684 {FzName: ts + 2172 /* "xColumnText" */, FnArg: 1, FzMsg: ts + 2086 /* "COL" */}, // 9 11685 {FzName: ts + 2184 /* "xColumnSize" */, FnArg: 1, FzMsg: ts + 2086 /* "COL" */}, // 10 11686 {FzName: ts + 2196 /* "xQueryPhrase" */, FnArg: 2, FzMsg: ts + 2209 /* "PHRASE SCRIPT" */}, // 11 11687 {FzName: ts + 2223 /* "xSetAuxdata" */, FnArg: 1, FzMsg: ts + 2235 /* "VALUE" */}, // 12 11688 {FzName: ts + 2241 /* "xGetAuxdata" */, FnArg: 1, FzMsg: ts + 2253 /* "CLEAR" */}, // 13 11689 {FzName: ts + 2259 /* "xSetAuxdataInt" */, FnArg: 1, FzMsg: ts + 2274 /* "INTEGER" */}, // 14 11690 {FzName: ts + 2282 /* "xGetAuxdataInt" */, FnArg: 1, FzMsg: ts + 2253 /* "CLEAR" */}, // 15 11691 {FzName: ts + 2297 /* "xPhraseForeach" */, FnArg: 4, FzMsg: ts + 2312 /* "IPHRASE COLVAR O..." */}, // 16 11692 {FzName: ts + 2341 /* "xPhraseColumnFor..." */, FnArg: 3, FzMsg: ts + 2362 /* "IPHRASE COLVAR S..." */}, // 17 11693 {}, 11694 } 11695 var rc int32 11696 *(*int32)(unsafe.Pointer(bp + 488 /* iSub */)) = 0 11697 var p uintptr = clientData 11698 11699 if objc < 2 { 11700 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2384 /* "SUB-COMMAND" */) 11701 return TCL_ERROR 11702 } 11703 11704 rc = tcl.XTcl_GetIndexFromObjStruct(tls, 11705 interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+32 /* &aSub[0] */, int32(unsafe.Sizeof(Sub{})), ts+2384 /* "SUB-COMMAND" */, 0, bp+488 /* &iSub */) 11706 if rc != TCL_OK { 11707 return rc 11708 } 11709 if (*Sub)(unsafe.Pointer(bp+32 /* &aSub */ +uintptr(*(*int32)(unsafe.Pointer(bp + 488 /* iSub */)))*24)).FnArg != (objc - 2) { 11710 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, (*Sub)(unsafe.Pointer(bp+32 /* &aSub */ +uintptr(*(*int32)(unsafe.Pointer(bp + 488 /* iSub */)))*24)).FzMsg) 11711 return TCL_ERROR 11712 } 11713 11714 switch *(*int32)(unsafe.Pointer(bp + 488 /* iSub */)) { 11715 case 0: 11716 { 11717 var nCol int32 11718 nCol = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 16 /* &.xColumnCount */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts) 11719 if rc == SQLITE_OK { 11720 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, nCol)) 11721 } 11722 break 11723 11724 } 11725 case 1: 11726 { 11727 // var nRow sqlite3_int64 at bp+496, 8 11728 11729 rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 24 /* &.xRowCount */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts, bp+496 /* &nRow */) 11730 if rc == SQLITE_OK { 11731 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, *(*sqlite3_int64)(unsafe.Pointer(bp + 496 /* nRow */)))) 11732 } 11733 break 11734 11735 } 11736 case 2: 11737 { 11738 // var iCol int32 at bp+504, 4 11739 11740 // var nSize sqlite3_int64 at bp+512, 8 11741 11742 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+504 /* &iCol */) != 0 { 11743 return TCL_ERROR 11744 } 11745 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 32 /* &.xColumnTotalSize */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts, *(*int32)(unsafe.Pointer(bp + 504 /* iCol */)), bp+512 /* &nSize */) 11746 if rc == SQLITE_OK { 11747 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, *(*sqlite3_int64)(unsafe.Pointer(bp + 512 /* nSize */)))) 11748 } 11749 break 11750 11751 } 11752 case 3: 11753 { 11754 // var nText int32 at bp+520, 4 11755 11756 var zText uintptr = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+520 /* &nText */) 11757 // var ctx F5tFunction at bp+528, 16 11758 11759 (*F5tFunction)(unsafe.Pointer(bp + 528 /* &ctx */)).Finterp = interp 11760 (*F5tFunction)(unsafe.Pointer(bp + 528 /* &ctx */)).FpScript = *(*uintptr)(unsafe.Pointer(objv + 3*8)) 11761 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 40 /* &.xTokenize */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts, zText, *(*int32)(unsafe.Pointer(bp + 520 /* nText */)), bp+528 /* &ctx */, *(*uintptr)(unsafe.Pointer(&struct { 11762 f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 11763 }{xTokenizeCb}))) 11764 if rc == SQLITE_OK { 11765 tcl.XTcl_ResetResult(tls, interp) 11766 } 11767 return rc 11768 11769 } 11770 case 4: 11771 { 11772 var nPhrase int32 11773 nPhrase = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 48 /* &.xPhraseCount */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts) 11774 if rc == SQLITE_OK { 11775 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, nPhrase)) 11776 } 11777 break 11778 11779 } 11780 case 5: 11781 { 11782 // var iPhrase int32 at bp+544, 4 11783 11784 var sz int32 11785 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+544 /* &iPhrase */) != 0 { 11786 return TCL_ERROR 11787 } 11788 sz = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 56 /* &.xPhraseSize */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts, *(*int32)(unsafe.Pointer(bp + 544 /* iPhrase */))) 11789 if rc == SQLITE_OK { 11790 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sz)) 11791 } 11792 break 11793 11794 } 11795 case 6: 11796 { 11797 // var nInst int32 at bp+548, 4 11798 11799 rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 64 /* &.xInstCount */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts, bp+548 /* &nInst */) 11800 if rc == SQLITE_OK { 11801 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 548 /* nInst */)))) 11802 } 11803 break 11804 11805 } 11806 case 7: 11807 { 11808 // var iIdx int32 at bp+552, 4 11809 11810 // var ip int32 at bp+556, 4 11811 11812 // var ic int32 at bp+560, 4 11813 11814 // var io int32 at bp+564, 4 11815 11816 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+552 /* &iIdx */) != 0 { 11817 return TCL_ERROR 11818 } 11819 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 72 /* &.xInst */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts, *(*int32)(unsafe.Pointer(bp + 552 /* iIdx */)), bp+556 /* &ip */, bp+560 /* &ic */, bp+564 /* &io */) 11820 if rc == SQLITE_OK { 11821 var pList uintptr = tcl.XTcl_NewObj(tls) 11822 tcl.XTcl_ListObjAppendElement(tls, interp, pList, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 556 /* ip */)))) 11823 tcl.XTcl_ListObjAppendElement(tls, interp, pList, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 560 /* ic */)))) 11824 tcl.XTcl_ListObjAppendElement(tls, interp, pList, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 564 /* io */)))) 11825 tcl.XTcl_SetObjResult(tls, interp, pList) 11826 } 11827 break 11828 11829 } 11830 case 8: 11831 { 11832 var iRowid sqlite3_int64 = (*(*func(*libc.TLS, uintptr) sqlite3_int64)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 80 /* &.xRowid */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts) 11833 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, iRowid)) 11834 break 11835 11836 } 11837 case 9: 11838 { 11839 *(*uintptr)(unsafe.Pointer(bp + 576 /* z */)) = uintptr(0) 11840 *(*int32)(unsafe.Pointer(bp + 584 /* n */)) = 0 11841 // var iCol int32 at bp+568, 4 11842 11843 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+568 /* &iCol */) != 0 { 11844 return TCL_ERROR 11845 } 11846 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 88 /* &.xColumnText */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts, *(*int32)(unsafe.Pointer(bp + 568 /* iCol */)), bp+576 /* &z */, bp+584 /* &n */) 11847 if rc == SQLITE_OK { 11848 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, *(*uintptr)(unsafe.Pointer(bp + 576 /* z */)), *(*int32)(unsafe.Pointer(bp + 584 /* n */)))) 11849 } 11850 break 11851 11852 } 11853 case 10: 11854 { 11855 *(*int32)(unsafe.Pointer(bp + 592 /* n */)) = 0 11856 // var iCol int32 at bp+588, 4 11857 11858 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+588 /* &iCol */) != 0 { 11859 return TCL_ERROR 11860 } 11861 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 96 /* &.xColumnSize */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts, *(*int32)(unsafe.Pointer(bp + 588 /* iCol */)), bp+592 /* &n */) 11862 if rc == SQLITE_OK { 11863 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 592 /* n */)))) 11864 } 11865 break 11866 11867 } 11868 case 11: 11869 { 11870 // var iPhrase int32 at bp+596, 4 11871 11872 // var ctx F5tFunction at bp+600, 16 11873 11874 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+596 /* &iPhrase */) != 0 { 11875 return TCL_ERROR 11876 } 11877 (*F5tFunction)(unsafe.Pointer(bp + 600 /* &ctx */)).Finterp = interp 11878 (*F5tFunction)(unsafe.Pointer(bp + 600 /* &ctx */)).FpScript = *(*uintptr)(unsafe.Pointer(objv + 3*8)) 11879 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 104 /* &.xQueryPhrase */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts, *(*int32)(unsafe.Pointer(bp + 596 /* iPhrase */)), bp+600 /* &ctx */, *(*uintptr)(unsafe.Pointer(&struct { 11880 f func(*libc.TLS, uintptr, uintptr, uintptr) int32 11881 }{xQueryPhraseCb}))) 11882 if rc == SQLITE_OK { 11883 tcl.XTcl_ResetResult(tls, interp) 11884 } 11885 break 11886 11887 } 11888 case 12: 11889 { 11890 var pData uintptr = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(F5tAuxData{}))) 11891 if pData == uintptr(0) { 11892 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+1930 /* "out of memory" */, 0)) 11893 return TCL_ERROR 11894 } 11895 (*F5tAuxData)(unsafe.Pointer(pData)).FpObj = *(*uintptr)(unsafe.Pointer(objv + 2*8)) 11896 (*Tcl_Obj)(unsafe.Pointer((*F5tAuxData)(unsafe.Pointer(pData)).FpObj)).FrefCount++ 11897 rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 112 /* &.xSetAuxdata */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts, pData, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{xSetAuxdataDestructor}))) 11898 break 11899 11900 } 11901 case 13: 11902 { 11903 var pData uintptr 11904 // var bClear int32 at bp+616, 4 11905 11906 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+616 /* &bClear */) != 0 { 11907 return TCL_ERROR 11908 } 11909 pData = (*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 120 /* &.xGetAuxdata */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts, *(*int32)(unsafe.Pointer(bp + 616 /* bClear */))) 11910 if pData == uintptr(0) { 11911 tcl.XTcl_ResetResult(tls, interp) 11912 } else { 11913 tcl.XTcl_SetObjResult(tls, interp, (*F5tAuxData)(unsafe.Pointer(pData)).FpObj) 11914 if *(*int32)(unsafe.Pointer(bp + 616 /* bClear */)) != 0 { 11915 xSetAuxdataDestructor(tls, pData) 11916 } 11917 } 11918 break 11919 11920 } 11921 11922 // These two - xSetAuxdataInt and xGetAuxdataInt - are similar to the 11923 // xSetAuxdata and xGetAuxdata methods implemented above. The difference 11924 // is that they may only save an integer value as auxiliary data, and 11925 // do not specify a destructor function. 11926 case 14: 11927 { 11928 // var iVal int32 at bp+620, 4 11929 11930 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+620 /* &iVal */) != 0 { 11931 return TCL_ERROR 11932 } 11933 rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 112 /* &.xSetAuxdata */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts, (uintptr(0) + uintptr(*(*int32)(unsafe.Pointer(bp + 620 /* iVal */)))), uintptr(0)) 11934 break 11935 11936 } 11937 case 15: 11938 { 11939 var iVal int32 11940 // var bClear int32 at bp+624, 4 11941 11942 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+624 /* &bClear */) != 0 { 11943 return TCL_ERROR 11944 } 11945 iVal = (int32((int64((*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 120 /* &.xGetAuxdata */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts, *(*int32)(unsafe.Pointer(bp + 624 /* bClear */)))) - int64(uintptr(0))) / 1)) 11946 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, iVal)) 11947 break 11948 11949 } 11950 11951 case 16: 11952 { 11953 // var iPhrase int32 at bp+628, 4 11954 11955 // var iCol int32 at bp+648, 4 11956 11957 // var iOff int32 at bp+652, 4 11958 11959 var zColvar uintptr 11960 var zOffvar uintptr 11961 var pScript uintptr = *(*uintptr)(unsafe.Pointer(objv + 5*8)) 11962 // var iter Fts5PhraseIter at bp+632, 16 11963 11964 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+628 /* &iPhrase */) != 0 { 11965 return TCL_ERROR 11966 } 11967 zColvar = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 11968 zOffvar = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8))) 11969 11970 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 128 /* &.xPhraseFirst */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts, *(*int32)(unsafe.Pointer(bp + 628 /* iPhrase */)), bp+632 /* &iter */, bp+648 /* &iCol */, bp+652 /* &iOff */) 11971 if rc != SQLITE_OK { 11972 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 11973 return TCL_ERROR 11974 } 11975 for ; *(*int32)(unsafe.Pointer(bp + 648 /* iCol */)) >= 0; (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr))(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 136 /* &.xPhraseNext */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts, bp+632 /* &iter */, bp+648 /* &iCol */, bp+652 /* &iOff */) { 11976 tcl.XTcl_SetVar2Ex(tls, interp, zColvar, uintptr(0), tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 648 /* iCol */))), 0) 11977 tcl.XTcl_SetVar2Ex(tls, interp, zOffvar, uintptr(0), tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 652 /* iOff */))), 0) 11978 rc = tcl.XTcl_EvalObjEx(tls, interp, pScript, 0) 11979 if rc == TCL_CONTINUE { 11980 rc = TCL_OK 11981 } 11982 if rc != TCL_OK { 11983 if rc == TCL_BREAK { 11984 rc = TCL_OK 11985 } 11986 break 11987 } 11988 } 11989 11990 break 11991 11992 } 11993 11994 case 17: 11995 { 11996 // var iPhrase int32 at bp+656, 4 11997 11998 // var iCol int32 at bp+680, 4 11999 12000 var zColvar uintptr 12001 var pScript uintptr = *(*uintptr)(unsafe.Pointer(objv + 4*8)) 12002 // var iter Fts5PhraseIter at bp+664, 16 12003 12004 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+656 /* &iPhrase */) != 0 { 12005 return TCL_ERROR 12006 } 12007 zColvar = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 12008 12009 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 144 /* &.xPhraseFirstColumn */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts, *(*int32)(unsafe.Pointer(bp + 656 /* iPhrase */)), bp+664 /* &iter */, bp+680 /* &iCol */) 12010 if rc != SQLITE_OK { 12011 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 12012 return TCL_ERROR 12013 } 12014 for ; *(*int32)(unsafe.Pointer(bp + 680 /* iCol */)) >= 0; (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer(((*F5tApi)(unsafe.Pointer(p)).FpApi + 152 /* &.xPhraseNextColumn */))))(tls, (*F5tApi)(unsafe.Pointer(p)).FpFts, bp+664 /* &iter */, bp+680 /* &iCol */) { 12015 tcl.XTcl_SetVar2Ex(tls, interp, zColvar, uintptr(0), tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 680 /* iCol */))), 0) 12016 rc = tcl.XTcl_EvalObjEx(tls, interp, pScript, 0) 12017 if rc == TCL_CONTINUE { 12018 rc = TCL_OK 12019 } 12020 if rc != TCL_OK { 12021 if rc == TCL_BREAK { 12022 rc = TCL_OK 12023 } 12024 break 12025 } 12026 } 12027 12028 break 12029 12030 } 12031 12032 default: 12033 12034 break 12035 } 12036 12037 if rc != SQLITE_OK { 12038 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 12039 return TCL_ERROR 12040 } 12041 12042 return TCL_OK 12043 } 12044 12045 type Sub = struct { 12046 FzName uintptr 12047 FnArg int32 12048 _ [4]byte 12049 FzMsg uintptr 12050 } /* fts5_tcl.c:222:3 */ 12051 12052 func xF5tFunction(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, nVal int32, apVal uintptr) { /* fts5_tcl.c:515:13: */ 12053 bp := tls.Alloc(112) 12054 defer tls.Free(112) 12055 12056 var p uintptr = (*(*func(*libc.TLS, uintptr) uintptr)(unsafe.Pointer((pApi + 8 /* &.xUserData */))))(tls, pFts) 12057 var pEval uintptr // Script to evaluate 12058 var i int32 12059 var rc int32 12060 // var zCmd [64]int8 at bp+8, 64 12061 12062 // var sApi F5tApi at bp+72, 16 12063 12064 (*F5tApi)(unsafe.Pointer(bp + 72 /* &sApi */)).FpApi = pApi 12065 (*F5tApi)(unsafe.Pointer(bp + 72 /* &sApi */)).FpFts = pFts 12066 12067 libc.Xsprintf(tls, bp+8 /* &zCmd[0] */, ts+2396 /* "f5t_%lld" */, libc.VaList(bp, libc.PostIncInt64(&iCmd2, 1))) 12068 tcl.XTcl_CreateObjCommand(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp, bp+8 /* &zCmd[0] */, *(*uintptr)(unsafe.Pointer(&struct { 12069 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 12070 }{xF5tApi})), bp+72 /* &sApi */, uintptr(0)) 12071 pEval = tcl.XTcl_DuplicateObj(tls, (*F5tFunction)(unsafe.Pointer(p)).FpScript) 12072 (*Tcl_Obj)(unsafe.Pointer(pEval)).FrefCount++ 12073 tcl.XTcl_ListObjAppendElement(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp, pEval, tcl.XTcl_NewStringObj(tls, bp+8 /* &zCmd[0] */, -1)) 12074 12075 for i = 0; i < nVal; i++ { 12076 var pObj uintptr = uintptr(0) 12077 switch sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8))) { 12078 case SQLITE_TEXT: 12079 pObj = tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8))), -1) 12080 break 12081 case SQLITE_BLOB: 12082 pObj = tcl.XTcl_NewByteArrayObj(tls, 12083 sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8))), sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8)))) 12084 break 12085 case SQLITE_INTEGER: 12086 pObj = tcl.XTcl_NewWideIntObj(tls, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8)))) 12087 break 12088 case SQLITE_FLOAT: 12089 pObj = tcl.XTcl_NewDoubleObj(tls, sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8)))) 12090 break 12091 default: 12092 pObj = tcl.XTcl_NewObj(tls) 12093 break 12094 } 12095 tcl.XTcl_ListObjAppendElement(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp, pEval, pObj) 12096 } 12097 12098 rc = tcl.XTcl_EvalObjEx(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp, pEval, TCL_GLOBAL_ONLY) 12099 for ok := true; ok; ok = 0 != 0 { 12100 var _objPtr uintptr = pEval 12101 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 12102 tcl.XTclFreeObj(tls, _objPtr) 12103 } 12104 } 12105 tcl.XTcl_DeleteCommand(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp, bp+8 /* &zCmd[0] */) 12106 12107 if rc != TCL_OK { 12108 sqlite3.Xsqlite3_result_error(tls, pCtx, tcl.XTcl_GetStringResult(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp), -1) 12109 } else { 12110 var pVar uintptr = tcl.XTcl_GetObjResult(tls, (*F5tFunction)(unsafe.Pointer(p)).Finterp) 12111 // var n int32 at bp+88, 4 12112 12113 var zType uintptr = func() uintptr { 12114 if (*Tcl_Obj)(unsafe.Pointer(pVar)).FtypePtr != 0 { 12115 return (*Tcl_ObjType)(unsafe.Pointer((*Tcl_Obj)(unsafe.Pointer(pVar)).FtypePtr)).Fname 12116 } 12117 return ts + 489 /* "" */ 12118 }() 12119 var c int8 = *(*int8)(unsafe.Pointer(zType)) 12120 if ((int32(c) == 'b') && (libc.Xstrcmp(tls, zType, ts+2405 /* "bytearray" */) == 0)) && ((*Tcl_Obj)(unsafe.Pointer(pVar)).Fbytes == uintptr(0)) { 12121 // Only return a BLOB type if the Tcl variable is a bytearray and 12122 // has no string representation. 12123 var data uintptr = tcl.XTcl_GetByteArrayFromObj(tls, pVar, bp+88 /* &n */) 12124 sqlite3.Xsqlite3_result_blob(tls, pCtx, data, *(*int32)(unsafe.Pointer(bp + 88 /* n */)), libc.UintptrFromInt32(-1)) 12125 } else if (int32(c) == 'b') && (libc.Xstrcmp(tls, zType, ts+2415 /* "boolean" */) == 0) { 12126 tcl.XTcl_GetIntFromObj(tls, uintptr(0), pVar, bp+88 /* &n */) 12127 sqlite3.Xsqlite3_result_int(tls, pCtx, *(*int32)(unsafe.Pointer(bp + 88 /* n */))) 12128 } else if (int32(c) == 'd') && (libc.Xstrcmp(tls, zType, ts+2423 /* "double" */) == 0) { 12129 // var r float64 at bp+96, 8 12130 12131 tcl.XTcl_GetDoubleFromObj(tls, uintptr(0), pVar, bp+96 /* &r */) 12132 sqlite3.Xsqlite3_result_double(tls, pCtx, *(*float64)(unsafe.Pointer(bp + 96 /* r */))) 12133 } else if ((int32(c) == 'w') && (libc.Xstrcmp(tls, zType, ts+2430 /* "wideInt" */) == 0)) || ((int32(c) == 'i') && (libc.Xstrcmp(tls, zType, ts+2438 /* "int" */) == 0)) { 12134 // var v Tcl_WideInt at bp+104, 8 12135 12136 tcl.XTcl_GetWideIntFromObj(tls, uintptr(0), pVar, bp+104 /* &v */) 12137 sqlite3.Xsqlite3_result_int64(tls, pCtx, *(*Tcl_WideInt)(unsafe.Pointer(bp + 104 /* v */))) 12138 } else { 12139 var data uintptr = tcl.XTcl_GetStringFromObj(tls, pVar, bp+88 /* &n */) 12140 sqlite3.Xsqlite3_result_text(tls, pCtx, data, *(*int32)(unsafe.Pointer(bp + 88 /* n */)), libc.UintptrFromInt32(-1)) 12141 } 12142 } 12143 } 12144 12145 var iCmd2 sqlite3_int64 = int64(0) /* fts5_tcl.c:527:24 */ 12146 12147 func xF5tDestroy(tls *libc.TLS, pCtx uintptr) { /* fts5_tcl.c:598:13: */ 12148 var p uintptr = pCtx 12149 for ok := true; ok; ok = 0 != 0 { 12150 var _objPtr uintptr = (*F5tFunction)(unsafe.Pointer(p)).FpScript 12151 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 12152 tcl.XTclFreeObj(tls, _objPtr) 12153 } 12154 } 12155 tcl.XTcl_Free(tls, p) 12156 } 12157 12158 // sqlite3_fts5_create_function DB NAME SCRIPT 12159 // 12160 // Description... 12161 func f5tCreateFunction(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* fts5_tcl.c:609:26: */ 12162 bp := tls.Alloc(40) 12163 defer tls.Free(40) 12164 12165 var zName uintptr 12166 var pScript uintptr 12167 *(*uintptr)(unsafe.Pointer(bp + 24 /* db */)) = uintptr(0) 12168 *(*uintptr)(unsafe.Pointer(bp + 32 /* pApi */)) = uintptr(0) 12169 var pCtx uintptr = uintptr(0) 12170 var rc int32 12171 12172 if objc != 4 { 12173 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2442 /* "DB NAME SCRIPT" */) 12174 return TCL_ERROR 12175 } 12176 if f5tDbAndApi(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+24 /* &db */, bp+32 /* &pApi */) != 0 { 12177 return TCL_ERROR 12178 } 12179 12180 zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 12181 pScript = *(*uintptr)(unsafe.Pointer(objv + 3*8)) 12182 pCtx = tcl.XTcl_Alloc(tls, uint32(unsafe.Sizeof(F5tFunction{}))) 12183 (*F5tFunction)(unsafe.Pointer(pCtx)).Finterp = interp 12184 (*F5tFunction)(unsafe.Pointer(pCtx)).FpScript = pScript 12185 (*Tcl_Obj)(unsafe.Pointer(pScript)).FrefCount++ 12186 12187 rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, fts5_extension_function, uintptr) int32)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 32 /* pApi */)) + 24 /* &.xCreateFunction */))))(tls, 12188 *(*uintptr)(unsafe.Pointer(bp + 32 /* pApi */)), zName, pCtx, *(*uintptr)(unsafe.Pointer(&struct { 12189 f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) 12190 }{xF5tFunction})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{xF5tDestroy}))) 12191 if rc != SQLITE_OK { 12192 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+2014 /* "error: " */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */))), 0)) 12193 return TCL_ERROR 12194 } 12195 12196 return TCL_OK 12197 } 12198 12199 type F5tTokenizeCtx1 = struct { 12200 FpRet uintptr 12201 FbSubst int32 12202 _ [4]byte 12203 FzInput uintptr 12204 } /* fts5_tcl.c:646:9 */ 12205 12206 type F5tTokenizeCtx = F5tTokenizeCtx1 /* fts5_tcl.c:646:31 */ 12207 12208 func xTokenizeCb2(tls *libc.TLS, pCtx uintptr, tflags int32, zToken uintptr, nToken int32, iStart int32, iEnd int32) int32 { /* fts5_tcl.c:653:12: */ 12209 var p uintptr = pCtx 12210 if (*F5tTokenizeCtx)(unsafe.Pointer(p)).FbSubst != 0 { 12211 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), (*F5tTokenizeCtx)(unsafe.Pointer(p)).FpRet, tcl.XTcl_NewStringObj(tls, zToken, nToken)) 12212 tcl.XTcl_ListObjAppendElement(tls, 12213 uintptr(0), (*F5tTokenizeCtx)(unsafe.Pointer(p)).FpRet, tcl.XTcl_NewStringObj(tls, ((*F5tTokenizeCtx)(unsafe.Pointer(p)).FzInput+uintptr(iStart)), (iEnd-iStart))) 12214 } else { 12215 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), (*F5tTokenizeCtx)(unsafe.Pointer(p)).FpRet, tcl.XTcl_NewStringObj(tls, zToken, nToken)) 12216 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), (*F5tTokenizeCtx)(unsafe.Pointer(p)).FpRet, tcl.XTcl_NewIntObj(tls, iStart)) 12217 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), (*F5tTokenizeCtx)(unsafe.Pointer(p)).FpRet, tcl.XTcl_NewIntObj(tls, iEnd)) 12218 } 12219 return SQLITE_OK 12220 } 12221 12222 // sqlite3_fts5_tokenize DB TOKENIZER TEXT 12223 // 12224 // Description... 12225 func f5tTokenize(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* fts5_tcl.c:679:26: */ 12226 bp := tls.Alloc(200) 12227 defer tls.Free(200) 12228 12229 var zText uintptr 12230 // var nText int32 at bp+128, 4 12231 12232 *(*uintptr)(unsafe.Pointer(bp + 96 /* db */)) = uintptr(0) 12233 *(*uintptr)(unsafe.Pointer(bp + 104 /* pApi */)) = uintptr(0) 12234 *(*uintptr)(unsafe.Pointer(bp + 168 /* pTok */)) = uintptr(0) 12235 // var tokenizer fts5_tokenizer at bp+144, 24 12236 12237 var pRet uintptr = uintptr(0) 12238 // var pUserdata uintptr at bp+136, 8 12239 12240 var rc int32 12241 // var nArg int32 at bp+112, 4 12242 12243 // var azArg uintptr at bp+120, 8 12244 12245 // var ctx F5tTokenizeCtx at bp+176, 24 12246 12247 if (objc != 4) && (objc != 5) { 12248 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2457 /* "?-subst? DB NAME..." */) 12249 return TCL_ERROR 12250 } 12251 if objc == 5 { 12252 var zOpt uintptr = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 12253 if libc.Xstrcmp(tls, ts+2479 /* "-subst" */, zOpt) != 0 { 12254 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+2486 /* "unrecognized opt..." */, zOpt, 0)) 12255 return TCL_ERROR 12256 } 12257 } 12258 if f5tDbAndApi(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-3))*8)), bp+96 /* &db */, bp+104 /* &pApi */) != 0 { 12259 return TCL_ERROR 12260 } 12261 if tcl.XTcl_SplitList(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-2))*8))), bp+112 /* &nArg */, bp+120 /* &azArg */) != 0 { 12262 return TCL_ERROR 12263 } 12264 if *(*int32)(unsafe.Pointer(bp + 112 /* nArg */)) == 0 { 12265 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, ts+2508 /* "no such tokenize..." */, 0)) 12266 tcl.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(bp + 120 /* azArg */))) 12267 return TCL_ERROR 12268 } 12269 zText = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-1))*8)), bp+128 /* &nText */) 12270 12271 rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 104 /* pApi */)) + 16 /* &.xFindTokenizer */))))(tls, *(*uintptr)(unsafe.Pointer(bp + 104 /* pApi */)), *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 120 /* azArg */)))), bp+136 /* &pUserdata */, bp+144 /* &tokenizer */) 12272 if rc != SQLITE_OK { 12273 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, ts+2508 /* "no such tokenize..." */, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 120 /* azArg */)))), 0)) 12274 return TCL_ERROR 12275 } 12276 12277 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((bp + 144 /* &tokenizer */ /* &.xCreate */))))(tls, *(*uintptr)(unsafe.Pointer(bp + 136 /* pUserdata */)), (*(*uintptr)(unsafe.Pointer(bp + 120 /* azArg */)) + 1*8), (*(*int32)(unsafe.Pointer(bp + 112 /* nArg */)) - 1), bp+168 /* &pTok */) 12278 if rc != SQLITE_OK { 12279 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, ts+2528 /* "error in tokeniz..." */, 0)) 12280 return TCL_ERROR 12281 } 12282 12283 pRet = tcl.XTcl_NewObj(tls) 12284 (*Tcl_Obj)(unsafe.Pointer(pRet)).FrefCount++ 12285 (*F5tTokenizeCtx)(unsafe.Pointer(bp + 176 /* &ctx */)).FbSubst = (libc.Bool32(objc == 5)) 12286 (*F5tTokenizeCtx)(unsafe.Pointer(bp + 176 /* &ctx */)).FpRet = pRet 12287 (*F5tTokenizeCtx)(unsafe.Pointer(bp + 176 /* &ctx */)).FzInput = zText 12288 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer((bp + 144 /* &tokenizer */ + 16 /* &.xTokenize */))))(tls, 12289 *(*uintptr)(unsafe.Pointer(bp + 168 /* pTok */)), bp+176 /* &ctx */, FTS5_TOKENIZE_DOCUMENT, zText, *(*int32)(unsafe.Pointer(bp + 128 /* nText */)), *(*uintptr)(unsafe.Pointer(&struct { 12290 f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 12291 }{xTokenizeCb2}))) 12292 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((bp + 144 /* &tokenizer */ + 8 /* &.xDelete */))))(tls, *(*uintptr)(unsafe.Pointer(bp + 168 /* pTok */))) 12293 if rc != SQLITE_OK { 12294 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+80, ts+2557 /* "error in tokeniz..." */, 0)) 12295 for ok := true; ok; ok = 0 != 0 { 12296 var _objPtr uintptr = pRet 12297 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 12298 tcl.XTclFreeObj(tls, _objPtr) 12299 } 12300 } 12301 return TCL_ERROR 12302 } 12303 12304 tcl.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer(bp + 120 /* azArg */))) 12305 tcl.XTcl_SetObjResult(tls, interp, pRet) 12306 for ok1 := true; ok1; ok1 = 0 != 0 { 12307 var _objPtr uintptr = pRet 12308 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 12309 tcl.XTclFreeObj(tls, _objPtr) 12310 } 12311 } 12312 return TCL_OK 12313 } 12314 12315 // ************************************************************************ 12316 // 12317 // Start of tokenizer wrapper. 12318 12319 type F5tTokenizerContext1 = struct { 12320 FpCtx uintptr 12321 FxToken uintptr 12322 } /* fts5_tcl.c:759:9 */ 12323 12324 // ************************************************************************ 12325 // 12326 // Start of tokenizer wrapper. 12327 12328 type F5tTokenizerContext = F5tTokenizerContext1 /* fts5_tcl.c:759:36 */ 12329 type F5tTokenizerModule1 = struct { 12330 Finterp uintptr 12331 FpScript uintptr 12332 FpContext uintptr 12333 } /* fts5_tcl.c:761:9 */ 12334 12335 type F5tTokenizerModule = F5tTokenizerModule1 /* fts5_tcl.c:761:35 */ 12336 type F5tTokenizerInstance1 = struct { 12337 Finterp uintptr 12338 FpScript uintptr 12339 FpContext uintptr 12340 } /* fts5_tcl.c:762:9 */ 12341 12342 type F5tTokenizerInstance = F5tTokenizerInstance1 /* fts5_tcl.c:762:37 */ 12343 12344 func f5tTokenizerCreate(tls *libc.TLS, pCtx uintptr, azArg uintptr, nArg int32, ppOut uintptr) int32 { /* fts5_tcl.c:781:12: */ 12345 var pMod uintptr = pCtx 12346 var pEval uintptr 12347 var rc int32 = TCL_OK 12348 var i int32 12349 12350 pEval = tcl.XTcl_DuplicateObj(tls, (*F5tTokenizerModule)(unsafe.Pointer(pMod)).FpScript) 12351 (*Tcl_Obj)(unsafe.Pointer(pEval)).FrefCount++ 12352 for i = 0; (rc == TCL_OK) && (i < nArg); i++ { 12353 var pObj uintptr = tcl.XTcl_NewStringObj(tls, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)), -1) 12354 rc = tcl.XTcl_ListObjAppendElement(tls, (*F5tTokenizerModule)(unsafe.Pointer(pMod)).Finterp, pEval, pObj) 12355 } 12356 12357 if rc == TCL_OK { 12358 rc = tcl.XTcl_EvalObjEx(tls, (*F5tTokenizerModule)(unsafe.Pointer(pMod)).Finterp, pEval, TCL_GLOBAL_ONLY) 12359 } 12360 for ok := true; ok; ok = 0 != 0 { 12361 var _objPtr uintptr = pEval 12362 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 12363 tcl.XTclFreeObj(tls, _objPtr) 12364 } 12365 } 12366 12367 if rc == TCL_OK { 12368 var pInst uintptr 12369 pInst = tcl.XTcl_Alloc(tls, uint32(unsafe.Sizeof(F5tTokenizerInstance{}))) 12370 libc.Xmemset(tls, pInst, 0, uint64(unsafe.Sizeof(F5tTokenizerInstance{}))) 12371 (*F5tTokenizerInstance)(unsafe.Pointer(pInst)).Finterp = (*F5tTokenizerModule)(unsafe.Pointer(pMod)).Finterp 12372 (*F5tTokenizerInstance)(unsafe.Pointer(pInst)).FpScript = tcl.XTcl_GetObjResult(tls, (*F5tTokenizerModule)(unsafe.Pointer(pMod)).Finterp) 12373 (*F5tTokenizerInstance)(unsafe.Pointer(pInst)).FpContext = (*F5tTokenizerModule)(unsafe.Pointer(pMod)).FpContext 12374 (*Tcl_Obj)(unsafe.Pointer((*F5tTokenizerInstance)(unsafe.Pointer(pInst)).FpScript)).FrefCount++ 12375 *(*uintptr)(unsafe.Pointer(ppOut)) = pInst 12376 } 12377 12378 return rc 12379 } 12380 12381 func f5tTokenizerDelete(tls *libc.TLS, p uintptr) { /* fts5_tcl.c:819:13: */ 12382 var pInst uintptr = p 12383 for ok := true; ok; ok = 0 != 0 { 12384 var _objPtr uintptr = (*F5tTokenizerInstance)(unsafe.Pointer(pInst)).FpScript 12385 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 12386 tcl.XTclFreeObj(tls, _objPtr) 12387 } 12388 } 12389 tcl.XTcl_Free(tls, pInst) 12390 } 12391 12392 func f5tTokenizerTokenize(tls *libc.TLS, p uintptr, pCtx uintptr, flags int32, pText uintptr, nText int32, xToken uintptr) int32 { /* fts5_tcl.c:825:12: */ 12393 var pInst uintptr = p 12394 var pOldCtx uintptr 12395 var xOldToken uintptr 12396 var pEval uintptr 12397 var rc int32 12398 var zFlags uintptr 12399 12400 pOldCtx = (*F5tTokenizerContext)(unsafe.Pointer((*F5tTokenizerInstance)(unsafe.Pointer(pInst)).FpContext)).FpCtx 12401 xOldToken = (*F5tTokenizerContext)(unsafe.Pointer((*F5tTokenizerInstance)(unsafe.Pointer(pInst)).FpContext)).FxToken 12402 12403 (*F5tTokenizerContext)(unsafe.Pointer((*F5tTokenizerInstance)(unsafe.Pointer(pInst)).FpContext)).FpCtx = pCtx 12404 (*F5tTokenizerContext)(unsafe.Pointer((*F5tTokenizerInstance)(unsafe.Pointer(pInst)).FpContext)).FxToken = xToken 12405 12406 pEval = tcl.XTcl_DuplicateObj(tls, (*F5tTokenizerInstance)(unsafe.Pointer(pInst)).FpScript) 12407 (*Tcl_Obj)(unsafe.Pointer(pEval)).FrefCount++ 12408 switch flags { 12409 case FTS5_TOKENIZE_DOCUMENT: 12410 zFlags = ts + 2588 /* "document" */ 12411 break 12412 case FTS5_TOKENIZE_AUX: 12413 zFlags = ts + 2597 /* "aux" */ 12414 break 12415 case FTS5_TOKENIZE_QUERY: 12416 zFlags = ts + 2601 /* "query" */ 12417 break 12418 case (FTS5_TOKENIZE_PREFIX | FTS5_TOKENIZE_QUERY): 12419 zFlags = ts + 2607 /* "prefixquery" */ 12420 break 12421 default: 12422 12423 zFlags = ts + 2619 /* "invalid" */ 12424 break 12425 } 12426 12427 tcl.XTcl_ListObjAppendElement(tls, (*F5tTokenizerInstance)(unsafe.Pointer(pInst)).Finterp, pEval, tcl.XTcl_NewStringObj(tls, zFlags, -1)) 12428 tcl.XTcl_ListObjAppendElement(tls, (*F5tTokenizerInstance)(unsafe.Pointer(pInst)).Finterp, pEval, tcl.XTcl_NewStringObj(tls, pText, nText)) 12429 rc = tcl.XTcl_EvalObjEx(tls, (*F5tTokenizerInstance)(unsafe.Pointer(pInst)).Finterp, pEval, TCL_GLOBAL_ONLY) 12430 for ok := true; ok; ok = 0 != 0 { 12431 var _objPtr uintptr = pEval 12432 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 12433 tcl.XTclFreeObj(tls, _objPtr) 12434 } 12435 } 12436 12437 (*F5tTokenizerContext)(unsafe.Pointer((*F5tTokenizerInstance)(unsafe.Pointer(pInst)).FpContext)).FpCtx = pOldCtx 12438 (*F5tTokenizerContext)(unsafe.Pointer((*F5tTokenizerInstance)(unsafe.Pointer(pInst)).FpContext)).FxToken = xOldToken 12439 return rc 12440 } 12441 12442 // sqlite3_fts5_token ?-colocated? TEXT START END 12443 func f5tTokenizerReturn(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* fts5_tcl.c:885:26: */ 12444 bp := tls.Alloc(32) 12445 defer tls.Free(32) 12446 12447 var p uintptr 12448 // var iStart int32 at bp+24, 4 12449 12450 // var iEnd int32 at bp+28, 4 12451 12452 // var nToken int32 at bp+20, 4 12453 12454 var tflags int32 12455 var zToken uintptr 12456 var rc int32 12457 // var nArg int32 at bp+16, 4 12458 12459 var zArg uintptr 12460 p = clientData 12461 tflags = 0 12462 12463 if !(objc == 5) { 12464 goto __1 12465 } 12466 zArg = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+16 /* &nArg */) 12467 if !(((*(*int32)(unsafe.Pointer(bp + 16 /* nArg */)) <= 10) && (*(*int32)(unsafe.Pointer(bp + 16 /* nArg */)) >= 2)) && (libc.Xmemcmp(tls, ts+2627 /* "-colocated" */, zArg, uint64(*(*int32)(unsafe.Pointer(bp + 16 /* nArg */)))) == 0)) { 12468 goto __3 12469 } 12470 tflags = tflags | (FTS5_TOKEN_COLOCATED) 12471 goto __4 12472 __3: 12473 goto usage 12474 __4: 12475 ; 12476 goto __2 12477 __1: 12478 if !(objc != 4) { 12479 goto __5 12480 } 12481 goto usage 12482 __5: 12483 ; 12484 __2: 12485 ; 12486 12487 zToken = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-3))*8)), bp+20 /* &nToken */) 12488 if !((tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-2))*8)), bp+24 /* &iStart */) != 0) || 12489 (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-1))*8)), bp+28 /* &iEnd */) != 0)) { 12490 goto __6 12491 } 12492 return TCL_ERROR 12493 __6: 12494 ; 12495 12496 if !((*F5tTokenizerContext)(unsafe.Pointer(p)).FxToken == uintptr(0)) { 12497 goto __7 12498 } 12499 tcl.XTcl_AppendResult(tls, interp, 12500 libc.VaList(bp, ts+2638 /* "sqlite3_fts5_tok..." */, 0)) 12501 return TCL_ERROR 12502 __7: 12503 ; 12504 12505 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32)(unsafe.Pointer((p + 8 /* &.xToken */))))(tls, (*F5tTokenizerContext)(unsafe.Pointer(p)).FpCtx, tflags, zToken, *(*int32)(unsafe.Pointer(bp + 20 /* nToken */)), *(*int32)(unsafe.Pointer(bp + 24 /* iStart */)), *(*int32)(unsafe.Pointer(bp + 28 /* iEnd */))) 12506 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 12507 if rc == SQLITE_OK { 12508 return TCL_OK 12509 } 12510 return TCL_ERROR 12511 12512 usage: 12513 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2696 /* "?-colocated? TEX..." */) 12514 return TCL_ERROR 12515 } 12516 12517 func f5tDelTokenizer(tls *libc.TLS, pCtx uintptr) { /* fts5_tcl.c:934:13: */ 12518 var pMod uintptr = pCtx 12519 for ok := true; ok; ok = 0 != 0 { 12520 var _objPtr uintptr = (*F5tTokenizerModule)(unsafe.Pointer(pMod)).FpScript 12521 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 12522 tcl.XTclFreeObj(tls, _objPtr) 12523 } 12524 } 12525 tcl.XTcl_Free(tls, pMod) 12526 } 12527 12528 // sqlite3_fts5_create_tokenizer DB NAME SCRIPT 12529 // 12530 // Register a tokenizer named NAME implemented by script SCRIPT. When 12531 // a tokenizer instance is created (fts5_tokenizer.xCreate), any tokenizer 12532 // arguments are appended to SCRIPT and the result executed. 12533 // 12534 // The value returned by (SCRIPT + args) is itself a tcl script. This 12535 // script - call it SCRIPT2 - is executed to tokenize text using the 12536 // tokenizer instance "returned" by SCRIPT. Specifically, to tokenize 12537 // text SCRIPT2 is invoked with a single argument appended to it - the 12538 // text to tokenize. 12539 // 12540 // SCRIPT2 should invoke the [sqlite3_fts5_token] command once for each 12541 // token within the tokenized text. 12542 func f5tCreateTokenizer(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* fts5_tcl.c:956:26: */ 12543 bp := tls.Alloc(56) 12544 defer tls.Free(56) 12545 12546 var pContext uintptr = clientData 12547 // var db uintptr at bp+16, 8 12548 12549 // var pApi uintptr at bp+24, 8 12550 12551 var zName uintptr 12552 var pScript uintptr 12553 // var t fts5_tokenizer at bp+32, 24 12554 12555 var pMod uintptr 12556 var rc int32 12557 12558 if objc != 4 { 12559 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2442 /* "DB NAME SCRIPT" */) 12560 return TCL_ERROR 12561 } 12562 if f5tDbAndApi(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+16 /* &db */, bp+24 /* &pApi */) != 0 { 12563 return TCL_ERROR 12564 } 12565 zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 12566 pScript = *(*uintptr)(unsafe.Pointer(objv + 3*8)) 12567 12568 (*fts5_tokenizer)(unsafe.Pointer(bp + 32 /* &t */)).FxCreate = *(*uintptr)(unsafe.Pointer(&struct { 12569 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 12570 }{f5tTokenizerCreate})) 12571 (*fts5_tokenizer)(unsafe.Pointer(bp + 32 /* &t */)).FxTokenize = *(*uintptr)(unsafe.Pointer(&struct { 12572 f func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32 12573 }{f5tTokenizerTokenize})) 12574 (*fts5_tokenizer)(unsafe.Pointer(bp + 32 /* &t */)).FxDelete = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{f5tTokenizerDelete})) 12575 12576 pMod = tcl.XTcl_Alloc(tls, uint32(unsafe.Sizeof(F5tTokenizerModule{}))) 12577 (*F5tTokenizerModule)(unsafe.Pointer(pMod)).Finterp = interp 12578 (*F5tTokenizerModule)(unsafe.Pointer(pMod)).FpScript = pScript 12579 (*F5tTokenizerModule)(unsafe.Pointer(pMod)).FpContext = pContext 12580 (*Tcl_Obj)(unsafe.Pointer(pScript)).FrefCount++ 12581 rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp + 24 /* pApi */)) + 8 /* &.xCreateTokenizer */))))(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pApi */)), zName, pMod, bp+32 /* &t */, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{f5tDelTokenizer}))) 12582 if rc != SQLITE_OK { 12583 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+2724 /* "error in fts5_ap..." */, 0)) 12584 return TCL_ERROR 12585 } 12586 12587 return TCL_OK 12588 } 12589 12590 func xF5tFree(tls *libc.TLS, clientData ClientData) { /* fts5_tcl.c:999:27: */ 12591 tcl.XTcl_Free(tls, clientData) 12592 } 12593 12594 // sqlite3_fts5_may_be_corrupt BOOLEAN 12595 // 12596 // Set or clear the global "may-be-corrupt" flag. Return the old value. 12597 func f5tMayBeCorrupt(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* fts5_tcl.c:1008:26: */ 12598 bp := tls.Alloc(4) 12599 defer tls.Free(4) 12600 12601 var bOld int32 = sqlite3.Xsqlite3_fts5_may_be_corrupt 12602 12603 if (objc != 2) && (objc != 1) { 12604 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2761 /* "?BOOLEAN?" */) 12605 return TCL_ERROR 12606 } 12607 if objc == 2 { 12608 // var bNew int32 at bp, 4 12609 12610 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &bNew */) != 0 { 12611 return TCL_ERROR 12612 } 12613 sqlite3.Xsqlite3_fts5_may_be_corrupt = *(*int32)(unsafe.Pointer(bp /* bNew */)) 12614 } 12615 12616 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, bOld)) 12617 return TCL_OK 12618 } 12619 12620 func f5t_fts5HashKey(tls *libc.TLS, nSlot int32, p uintptr, n int32) uint32 { /* fts5_tcl.c:1031:21: */ 12621 var i int32 12622 var h uint32 = uint32(13) 12623 for i = (n - 1); i >= 0; i-- { 12624 h = (((h << 3) ^ h) ^ uint32(*(*int8)(unsafe.Pointer(p + uintptr(i))))) 12625 } 12626 return (h % uint32(nSlot)) 12627 } 12628 12629 func f5tTokenHash(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* fts5_tcl.c:1040:26: */ 12630 bp := tls.Alloc(8) 12631 defer tls.Free(8) 12632 12633 var z uintptr 12634 // var n int32 at bp+4, 4 12635 12636 var iVal uint32 12637 // var nSlot int32 at bp, 4 12638 12639 if objc != 3 { 12640 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2771 /* "NSLOT TOKEN" */) 12641 return TCL_ERROR 12642 } 12643 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &nSlot */) != 0 { 12644 return TCL_ERROR 12645 } 12646 z = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+4 /* &n */) 12647 12648 iVal = f5t_fts5HashKey(tls, *(*int32)(unsafe.Pointer(bp /* nSlot */)), z, *(*int32)(unsafe.Pointer(bp + 4 /* n */))) 12649 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, int32(iVal))) 12650 return TCL_OK 12651 } 12652 12653 func f5tRegisterMatchinfo(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* fts5_tcl.c:1065:26: */ 12654 bp := tls.Alloc(8) 12655 defer tls.Free(8) 12656 12657 var rc int32 12658 *(*uintptr)(unsafe.Pointer(bp /* db */)) = uintptr(0) 12659 12660 if objc != 2 { 12661 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 12662 return TCL_ERROR 12663 } 12664 if f5tDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &db */) != 0 { 12665 return TCL_ERROR 12666 } 12667 12668 rc = sqlite3Fts5TestRegisterMatchinfo(tls, *(*uintptr)(unsafe.Pointer(bp /* db */))) 12669 if rc != SQLITE_OK { 12670 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 12671 return TCL_ERROR 12672 } 12673 return TCL_OK 12674 } 12675 12676 func f5tRegisterTok(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* fts5_tcl.c:1090:26: */ 12677 bp := tls.Alloc(16) 12678 defer tls.Free(16) 12679 12680 var rc int32 12681 *(*uintptr)(unsafe.Pointer(bp /* db */)) = uintptr(0) 12682 *(*uintptr)(unsafe.Pointer(bp + 8 /* pApi */)) = uintptr(0) 12683 12684 if objc != 2 { 12685 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 12686 return TCL_ERROR 12687 } 12688 if f5tDbAndApi(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &db */, bp+8 /* &pApi */) != 0 { 12689 return TCL_ERROR 12690 } 12691 12692 rc = sqlite3Fts5TestRegisterTok(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), *(*uintptr)(unsafe.Pointer(bp + 8 /* pApi */))) 12693 if rc != SQLITE_OK { 12694 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 12695 return TCL_ERROR 12696 } 12697 return TCL_OK 12698 } 12699 12700 // Entry point. 12701 func Fts5tcl_Init(tls *libc.TLS, interp uintptr) int32 { /* fts5_tcl.c:1119:5: */ 12702 var i int32 12703 var pContext uintptr 12704 12705 pContext = tcl.XTcl_Alloc(tls, uint32(unsafe.Sizeof(F5tTokenizerContext{}))) 12706 libc.Xmemset(tls, pContext, 0, uint64(unsafe.Sizeof(F5tTokenizerContext{}))) 12707 12708 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aCmd)) / uint64(unsafe.Sizeof(struct { 12709 FzName uintptr 12710 FxProc uintptr 12711 FbTokenizeCtx int32 12712 _ [4]byte 12713 }{}))); i++ { 12714 var p uintptr = (uintptr(unsafe.Pointer(&aCmd)) + uintptr(i)*24) 12715 var pCtx uintptr = uintptr(0) 12716 if (*struct { 12717 FzName uintptr 12718 FxProc uintptr 12719 FbTokenizeCtx int32 12720 _ [4]byte 12721 })(unsafe.Pointer(p)).FbTokenizeCtx != 0 { 12722 pCtx = pContext 12723 } 12724 tcl.XTcl_CreateObjCommand(tls, interp, (*struct { 12725 FzName uintptr 12726 FxProc uintptr 12727 FbTokenizeCtx int32 12728 _ [4]byte 12729 })(unsafe.Pointer(p)).FzName, (*struct { 12730 FzName uintptr 12731 FxProc uintptr 12732 FbTokenizeCtx int32 12733 _ [4]byte 12734 })(unsafe.Pointer(p)).FxProc, pCtx, func() uintptr { 12735 if i != 0 { 12736 return uintptr(0) 12737 } 12738 return *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, ClientData) }{xF5tFree})) 12739 }()) 12740 } 12741 12742 return TCL_OK 12743 } 12744 12745 var aCmd = [8]struct { 12746 FzName uintptr 12747 FxProc uintptr 12748 FbTokenizeCtx int32 12749 _ [4]byte 12750 }{ 12751 {FzName: ts + 2783 /* "sqlite3_fts5_cre..." */, FxProc: 0, FbTokenizeCtx: 1}, 12752 {FzName: ts + 2813 /* "sqlite3_fts5_tok..." */, FxProc: 0, FbTokenizeCtx: 1}, 12753 {FzName: ts + 2832 /* "sqlite3_fts5_tok..." */, FxProc: 0}, 12754 {FzName: ts + 2854 /* "sqlite3_fts5_cre..." */, FxProc: 0}, 12755 {FzName: ts + 2883 /* "sqlite3_fts5_may..." */, FxProc: 0}, 12756 {FzName: ts + 2911 /* "sqlite3_fts5_tok..." */, FxProc: 0}, 12757 {FzName: ts + 2935 /* "sqlite3_fts5_reg..." */, FxProc: 0}, 12758 {FzName: ts + 2967 /* "sqlite3_fts5_reg..." */, FxProc: 0}, 12759 } /* fts5_tcl.c:1124:5 */ 12760 12761 type Fts5MatchinfoCtx1 = struct { 12762 FnCol int32 12763 FnPhrase int32 12764 FzArg uintptr 12765 FnRet int32 12766 _ [4]byte 12767 FaRet uintptr 12768 } /* fts5_test_mi.c:50:9 */ 12769 12770 type Fts5MatchinfoCtx = Fts5MatchinfoCtx1 /* fts5_test_mi.c:50:33 */ 12771 12772 type u32 = uint32 /* fts5_test_mi.c:53:22 */ 12773 12774 // Return a pointer to the fts5_api pointer for database connection db. 12775 // If an error occurs, return NULL and leave an error in the database 12776 // handle (accessible using sqlite3_errcode()/errmsg()). 12777 func fts5_api_from_db(tls *libc.TLS, db uintptr, ppApi uintptr) int32 { /* fts5_test_mi.c:71:12: */ 12778 bp := tls.Alloc(8) 12779 defer tls.Free(8) 12780 12781 *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) 12782 var rc int32 12783 12784 *(*uintptr)(unsafe.Pointer(ppApi)) = uintptr(0) 12785 rc = sqlite3.Xsqlite3_prepare(tls, db, ts+1998 /* "SELECT fts5(?1)" */, -1, bp /* &pStmt */, uintptr(0)) 12786 if rc == SQLITE_OK { 12787 sqlite3.Xsqlite3_bind_pointer(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), 1, ppApi, ts+2022 /* "fts5_api_ptr" */, uintptr(0)) 12788 sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) 12789 rc = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) 12790 } 12791 12792 return rc 12793 } 12794 12795 // Argument f should be a flag accepted by matchinfo() (a valid character 12796 // in the string passed as the second argument). If it is not, -1 is 12797 // returned. Otherwise, if f is a valid matchinfo flag, the value returned 12798 // is the number of 32-bit integers added to the output array if the 12799 // table has nCol columns and the query nPhrase phrases. 12800 func fts5MatchinfoFlagsize(tls *libc.TLS, nCol int32, nPhrase int32, f int8) int32 { /* fts5_test_mi.c:94:12: */ 12801 var ret int32 = -1 12802 switch int32(f) { 12803 case 'p': 12804 ret = 1 12805 break 12806 case 'c': 12807 ret = 1 12808 break 12809 case 'x': 12810 ret = ((3 * nCol) * nPhrase) 12811 break 12812 case 'y': 12813 ret = (nCol * nPhrase) 12814 break 12815 case 'b': 12816 ret = (((nCol + 31) / 32) * nPhrase) 12817 break 12818 case 'n': 12819 ret = 1 12820 break 12821 case 'a': 12822 ret = nCol 12823 break 12824 case 'l': 12825 ret = nCol 12826 break 12827 case 's': 12828 ret = nCol 12829 break 12830 } 12831 return ret 12832 } 12833 12834 func fts5MatchinfoIter(tls *libc.TLS, pApi uintptr, pFts uintptr, p uintptr, x uintptr) int32 { /* fts5_test_mi.c:110:12: */ 12835 var i int32 12836 var n int32 = 0 12837 var rc int32 = SQLITE_OK 12838 var f int8 12839 for i = 0; libc.AssignInt8(&f, *(*int8)(unsafe.Pointer((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FzArg + uintptr(i)))) != 0; i++ { 12840 rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int8, uintptr) int32)(unsafe.Pointer(&x)))(tls, pApi, pFts, p, f, ((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FaRet + uintptr(n)*4)) 12841 if rc != SQLITE_OK { 12842 break 12843 } 12844 n = n + (fts5MatchinfoFlagsize(tls, (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol, (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnPhrase, f)) 12845 } 12846 return rc 12847 } 12848 12849 func fts5MatchinfoXCb(tls *libc.TLS, pApi uintptr, pFts uintptr, pUserData uintptr) int32 { /* fts5_test_mi.c:128:12: */ 12850 bp := tls.Alloc(24) 12851 defer tls.Free(24) 12852 12853 // var iter Fts5PhraseIter at bp, 16 12854 12855 // var iCol int32 at bp+16, 4 12856 12857 // var iOff int32 at bp+20, 4 12858 12859 var aOut uintptr = pUserData 12860 var iPrev int32 = -1 12861 12862 for (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 128 /* &.xPhraseFirst */))))(tls, pFts, 0, bp /* &iter */, bp+16 /* &iCol */, bp+20 /* &iOff */); *(*int32)(unsafe.Pointer(bp + 16 /* iCol */)) >= 0; (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr))(unsafe.Pointer((pApi + 136 /* &.xPhraseNext */))))(tls, pFts, bp /* &iter */, bp+16 /* &iCol */, bp+20 /* &iOff */) { 12863 *(*u32)(unsafe.Pointer(aOut + uintptr(((*(*int32)(unsafe.Pointer(bp + 16 /* iCol */))*3)+1))*4))++ 12864 if *(*int32)(unsafe.Pointer(bp + 16 /* iCol */)) != iPrev { 12865 *(*u32)(unsafe.Pointer(aOut + uintptr(((*(*int32)(unsafe.Pointer(bp + 16 /* iCol */))*3)+2))*4))++ 12866 } 12867 iPrev = *(*int32)(unsafe.Pointer(bp + 16 /* iCol */)) 12868 } 12869 12870 return SQLITE_OK 12871 } 12872 12873 func fts5MatchinfoGlobalCb(tls *libc.TLS, pApi uintptr, pFts uintptr, p uintptr, f int8, aOut uintptr) int32 { /* fts5_test_mi.c:150:12: */ 12874 bp := tls.Alloc(24) 12875 defer tls.Free(24) 12876 12877 var rc int32 = SQLITE_OK 12878 switch int32(f) { 12879 case 'p': 12880 *(*u32)(unsafe.Pointer(aOut)) = u32((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnPhrase) 12881 break 12882 12883 case 'c': 12884 *(*u32)(unsafe.Pointer(aOut)) = u32((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol) 12885 break 12886 12887 case 'x': 12888 { 12889 var i int32 12890 for i = 0; (i < (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnPhrase) && (rc == SQLITE_OK); i++ { 12891 var pPtr uintptr = (aOut + uintptr(((i*(*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol)*3))*4) 12892 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 104 /* &.xQueryPhrase */))))(tls, pFts, i, pPtr, *(*uintptr)(unsafe.Pointer(&struct { 12893 f func(*libc.TLS, uintptr, uintptr, uintptr) int32 12894 }{fts5MatchinfoXCb}))) 12895 } 12896 break 12897 12898 } 12899 12900 case 'n': 12901 { 12902 // var nRow sqlite3_int64 at bp, 8 12903 12904 rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 24 /* &.xRowCount */))))(tls, pFts, bp /* &nRow */) 12905 *(*u32)(unsafe.Pointer(aOut)) = u32(*(*sqlite3_int64)(unsafe.Pointer(bp /* nRow */))) 12906 break 12907 12908 } 12909 12910 case 'a': 12911 { 12912 *(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* nRow */)) = int64(0) 12913 rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 24 /* &.xRowCount */))))(tls, pFts, bp+8 /* &nRow */) 12914 if *(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* nRow */)) == int64(0) { 12915 libc.Xmemset(tls, aOut, 0, (uint64(unsafe.Sizeof(u32(0))) * uint64((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol))) 12916 } else { 12917 var i int32 12918 for i = 0; (rc == SQLITE_OK) && (i < (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol); i++ { 12919 // var nToken sqlite3_int64 at bp+16, 8 12920 12921 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((pApi + 32 /* &.xColumnTotalSize */))))(tls, pFts, i, bp+16 /* &nToken */) 12922 if rc == SQLITE_OK { 12923 *(*u32)(unsafe.Pointer(aOut + uintptr(i)*4)) = (u32(((int64(2) * *(*sqlite3_int64)(unsafe.Pointer(bp + 16 /* nToken */))) + *(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* nRow */))) / (int64(2) * *(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* nRow */))))) 12924 } 12925 } 12926 } 12927 break 12928 12929 } 12930 12931 } 12932 return rc 12933 } 12934 12935 func fts5MatchinfoLocalCb(tls *libc.TLS, pApi uintptr, pFts uintptr, p uintptr, f int8, aOut uintptr) int32 { /* fts5_test_mi.c:205:12: */ 12936 bp := tls.Alloc(80) 12937 defer tls.Free(80) 12938 12939 var i int32 12940 var rc int32 = SQLITE_OK 12941 12942 switch int32(f) { 12943 case 'b': 12944 { 12945 var iPhrase int32 12946 var nInt int32 = ((((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol + 31) / 32) * (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnPhrase) 12947 for i = 0; i < nInt; i++ { 12948 *(*u32)(unsafe.Pointer(aOut + uintptr(i)*4)) = u32(0) 12949 } 12950 12951 for iPhrase = 0; iPhrase < (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnPhrase; iPhrase++ { 12952 // var iter Fts5PhraseIter at bp, 16 12953 12954 // var iCol int32 at bp+16, 4 12955 12956 for (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 144 /* &.xPhraseFirstColumn */))))(tls, pFts, iPhrase, bp /* &iter */, bp+16 /* &iCol */); *(*int32)(unsafe.Pointer(bp + 16 /* iCol */)) >= 0; (*(*func(*libc.TLS, uintptr, uintptr, uintptr))(unsafe.Pointer((pApi + 152 /* &.xPhraseNextColumn */))))(tls, pFts, bp /* &iter */, bp+16 /* &iCol */) { 12957 *(*u32)(unsafe.Pointer(aOut + uintptr(((iPhrase*(((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol+31)/32))+(*(*int32)(unsafe.Pointer(bp + 16 /* iCol */))/32)))*4)) |= (u32(u32(1)) << (*(*int32)(unsafe.Pointer(bp + 16 /* iCol */)) % 32)) 12958 } 12959 } 12960 12961 break 12962 12963 } 12964 12965 case 'x': 12966 fallthrough 12967 case 'y': 12968 { 12969 var nMul int32 = func() int32 { 12970 if int32(f) == 'x' { 12971 return 3 12972 } 12973 return 1 12974 }() 12975 var iPhrase int32 12976 12977 for i = 0; i < ((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol * (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnPhrase); i++ { 12978 *(*u32)(unsafe.Pointer(aOut + uintptr((i*nMul))*4)) = u32(0) 12979 } 12980 12981 for iPhrase = 0; iPhrase < (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnPhrase; iPhrase++ { 12982 // var iter Fts5PhraseIter at bp+24, 16 12983 12984 // var iOff int32 at bp+44, 4 12985 12986 // var iCol int32 at bp+40, 4 12987 12988 for (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 128 /* &.xPhraseFirst */))))(tls, pFts, iPhrase, bp+24 /* &iter */, bp+40 /* &iCol */, bp+44 /* &iOff */); *(*int32)(unsafe.Pointer(bp + 44 /* iOff */)) >= 0; (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr))(unsafe.Pointer((pApi + 136 /* &.xPhraseNext */))))(tls, pFts, bp+24 /* &iter */, bp+40 /* &iCol */, bp+44 /* &iOff */) { 12989 *(*u32)(unsafe.Pointer(aOut + uintptr((nMul*(*(*int32)(unsafe.Pointer(bp + 40 /* iCol */))+(iPhrase*(*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol))))*4))++ 12990 } 12991 } 12992 12993 break 12994 12995 } 12996 12997 case 'l': 12998 { 12999 for i = 0; (rc == SQLITE_OK) && (i < (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol); i++ { 13000 // var nToken int32 at bp+48, 4 13001 13002 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((pApi + 96 /* &.xColumnSize */))))(tls, pFts, i, bp+48 /* &nToken */) 13003 *(*u32)(unsafe.Pointer(aOut + uintptr(i)*4)) = u32(*(*int32)(unsafe.Pointer(bp + 48 /* nToken */))) 13004 } 13005 break 13006 13007 } 13008 13009 case 's': 13010 { 13011 // var nInst int32 at bp+52, 4 13012 13013 libc.Xmemset(tls, aOut, 0, (uint64(unsafe.Sizeof(u32(0))) * uint64((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol))) 13014 13015 rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 64 /* &.xInstCount */))))(tls, pFts, bp+52 /* &nInst */) 13016 for i = 0; (rc == SQLITE_OK) && (i < *(*int32)(unsafe.Pointer(bp + 52 /* nInst */))); i++ { 13017 // var iPhrase int32 at bp+56, 4 13018 13019 // var iOff int32 at bp+64, 4 13020 13021 *(*int32)(unsafe.Pointer(bp + 60 /* iCol */)) = 0 13022 var iNextPhrase int32 13023 var iNextOff int32 13024 var nSeq u32 = u32(1) 13025 var j int32 13026 13027 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 72 /* &.xInst */))))(tls, pFts, i, bp+56 /* &iPhrase */, bp+60 /* &iCol */, bp+64 /* &iOff */) 13028 iNextPhrase = (*(*int32)(unsafe.Pointer(bp + 56 /* iPhrase */)) + 1) 13029 iNextOff = (*(*int32)(unsafe.Pointer(bp + 64 /* iOff */)) + (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((pApi + 56 /* &.xPhraseSize */))))(tls, pFts, 0)) 13030 for j = (i + 1); (rc == SQLITE_OK) && (j < *(*int32)(unsafe.Pointer(bp + 52 /* nInst */))); j++ { 13031 // var ip int32 at bp+68, 4 13032 13033 // var ic int32 at bp+72, 4 13034 13035 // var io int32 at bp+76, 4 13036 13037 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 72 /* &.xInst */))))(tls, pFts, j, bp+68 /* &ip */, bp+72 /* &ic */, bp+76 /* &io */) 13038 if (*(*int32)(unsafe.Pointer(bp + 72 /* ic */)) != *(*int32)(unsafe.Pointer(bp + 60 /* iCol */))) || (*(*int32)(unsafe.Pointer(bp + 76 /* io */)) > iNextOff) { 13039 break 13040 } 13041 if (*(*int32)(unsafe.Pointer(bp + 68 /* ip */)) == iNextPhrase) && (*(*int32)(unsafe.Pointer(bp + 76 /* io */)) == iNextOff) { 13042 nSeq++ 13043 iNextPhrase = (*(*int32)(unsafe.Pointer(bp + 68 /* ip */)) + 1) 13044 iNextOff = (*(*int32)(unsafe.Pointer(bp + 76 /* io */)) + (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((pApi + 56 /* &.xPhraseSize */))))(tls, pFts, *(*int32)(unsafe.Pointer(bp + 68 /* ip */)))) 13045 } 13046 } 13047 13048 if nSeq > *(*u32)(unsafe.Pointer(aOut + uintptr(*(*int32)(unsafe.Pointer(bp + 60 /* iCol */)))*4)) { 13049 *(*u32)(unsafe.Pointer(aOut + uintptr(*(*int32)(unsafe.Pointer(bp + 60 /* iCol */)))*4)) = nSeq 13050 } 13051 } 13052 13053 break 13054 13055 } 13056 } 13057 return rc 13058 } 13059 13060 func fts5MatchinfoNew(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, zArg uintptr) uintptr { /* fts5_test_mi.c:301:25: */ 13061 bp := tls.Alloc(8) 13062 defer tls.Free(8) 13063 13064 var p uintptr 13065 var nCol int32 13066 var nPhrase int32 13067 var i int32 13068 var nInt int32 13069 var nByte sqlite3_int64 13070 var rc int32 13071 13072 nCol = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((pApi + 16 /* &.xColumnCount */))))(tls, pFts) 13073 nPhrase = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((pApi + 48 /* &.xPhraseCount */))))(tls, pFts) 13074 13075 nInt = 0 13076 for i = 0; *(*int8)(unsafe.Pointer(zArg + uintptr(i))) != 0; i++ { 13077 var n int32 = fts5MatchinfoFlagsize(tls, nCol, nPhrase, *(*int8)(unsafe.Pointer(zArg + uintptr(i)))) 13078 if n < 0 { 13079 var zErr uintptr = sqlite3.Xsqlite3_mprintf(tls, ts+3002 /* "unrecognized mat..." */, libc.VaList(bp, int32(*(*int8)(unsafe.Pointer(zArg + uintptr(i)))))) 13080 sqlite3.Xsqlite3_result_error(tls, pCtx, zErr, -1) 13081 sqlite3.Xsqlite3_free(tls, zErr) 13082 return uintptr(0) 13083 } 13084 nInt = nInt + (n) 13085 } 13086 13087 nByte = (sqlite3_int64((uint64(unsafe.Sizeof(Fts5MatchinfoCtx{})) + // The struct itself 13088 (uint64(unsafe.Sizeof(u32(0))) * uint64(nInt))) + // The p->aRet[] array 13089 (uint64(i + 1)))) // The p->zArg string 13090 p = sqlite3.Xsqlite3_malloc64(tls, uint64(nByte)) 13091 if p == uintptr(0) { 13092 sqlite3.Xsqlite3_result_error_nomem(tls, pCtx) 13093 return uintptr(0) 13094 } 13095 libc.Xmemset(tls, p, 0, uint64(nByte)) 13096 13097 (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnCol = nCol 13098 (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnPhrase = nPhrase 13099 (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FaRet = (p + 1*32) 13100 (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnRet = nInt 13101 (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FzArg = ((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FaRet + uintptr(nInt)*4) 13102 libc.Xmemcpy(tls, (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FzArg, zArg, uint64(i)) 13103 13104 rc = fts5MatchinfoIter(tls, pApi, pFts, p, *(*uintptr)(unsafe.Pointer(&struct { 13105 f func(*libc.TLS, uintptr, uintptr, uintptr, int8, uintptr) int32 13106 }{fts5MatchinfoGlobalCb}))) 13107 if rc != SQLITE_OK { 13108 sqlite3.Xsqlite3_result_error_code(tls, pCtx, rc) 13109 sqlite3.Xsqlite3_free(tls, p) 13110 p = uintptr(0) 13111 } 13112 13113 return p 13114 } 13115 13116 func fts5MatchinfoFunc(tls *libc.TLS, pApi uintptr, pFts uintptr, pCtx uintptr, nVal int32, apVal uintptr) { /* fts5_test_mi.c:357:13: */ 13117 var zArg uintptr 13118 var p uintptr 13119 var rc int32 = SQLITE_OK 13120 13121 if nVal > 0 { 13122 zArg = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal))) 13123 } else { 13124 zArg = ts + 3034 /* "pcx" */ 13125 } 13126 13127 p = (*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer((pApi + 120 /* &.xGetAuxdata */))))(tls, pFts, 0) 13128 if (p == uintptr(0)) || (sqlite3.Xsqlite3_stricmp(tls, zArg, (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FzArg) != 0) { 13129 p = fts5MatchinfoNew(tls, pApi, pFts, pCtx, zArg) 13130 if p == uintptr(0) { 13131 rc = SQLITE_NOMEM 13132 } else { 13133 rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 112 /* &.xSetAuxdata */))))(tls, pFts, p, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) 13134 } 13135 } 13136 13137 if rc == SQLITE_OK { 13138 rc = fts5MatchinfoIter(tls, pApi, pFts, p, *(*uintptr)(unsafe.Pointer(&struct { 13139 f func(*libc.TLS, uintptr, uintptr, uintptr, int8, uintptr) int32 13140 }{fts5MatchinfoLocalCb}))) 13141 } 13142 if rc != SQLITE_OK { 13143 sqlite3.Xsqlite3_result_error_code(tls, pCtx, rc) 13144 } else { 13145 // No errors has occured, so return a copy of the array of integers. 13146 var nByte int32 = (int32(uint64((*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FnRet) * uint64(unsafe.Sizeof(u32(0))))) 13147 sqlite3.Xsqlite3_result_blob(tls, pCtx, (*Fts5MatchinfoCtx)(unsafe.Pointer(p)).FaRet, nByte, libc.UintptrFromInt32(-1)) 13148 } 13149 } 13150 13151 func sqlite3Fts5TestRegisterMatchinfo(tls *libc.TLS, db uintptr) int32 { /* fts5_test_mi.c:396:5: */ 13152 bp := tls.Alloc(8) 13153 defer tls.Free(8) 13154 13155 var rc int32 // Return code 13156 // var pApi uintptr at bp, 8 13157 // FTS5 API functions 13158 13159 // Extract the FTS5 API pointer from the database handle. The 13160 // fts5_api_from_db() function above is copied verbatim from the 13161 // FTS5 documentation. Refer there for details. 13162 rc = fts5_api_from_db(tls, db, bp /* &pApi */) 13163 if rc != SQLITE_OK { 13164 return rc 13165 } 13166 13167 /* If fts5_api_from_db() returns NULL, then either FTS5 is not registered 13168 ** with this database handle, or an error (OOM perhaps?) has occurred. 13169 ** 13170 ** Also check that the fts5_api object is version 2 or newer. 13171 */ 13172 if (*(*uintptr)(unsafe.Pointer(bp /* pApi */)) == uintptr(0)) || ((*fts5_api)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* pApi */)))).FiVersion < 2) { 13173 return SQLITE_ERROR 13174 } 13175 13176 // Register the implementation of matchinfo() 13177 rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, fts5_extension_function, uintptr) int32)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(bp /* pApi */)) + 24 /* &.xCreateFunction */))))(tls, *(*uintptr)(unsafe.Pointer(bp /* pApi */)), ts+3038 /* "matchinfo" */, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 13178 f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) 13179 }{fts5MatchinfoFunc})), uintptr(0)) 13180 13181 return rc 13182 } 13183 13184 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 13185 // This file is part of the GNU C Library. 13186 // 13187 // The GNU C Library is free software; you can redistribute it and/or 13188 // modify it under the terms of the GNU Lesser General Public 13189 // License as published by the Free Software Foundation; either 13190 // version 2.1 of the License, or (at your option) any later version. 13191 // 13192 // The GNU C Library is distributed in the hope that it will be useful, 13193 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13194 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13195 // Lesser General Public License for more details. 13196 // 13197 // You should have received a copy of the GNU Lesser General Public 13198 // License along with the GNU C Library; if not, see 13199 // <http://www.gnu.org/licenses/>. 13200 13201 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 13202 13203 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 13204 // This file is part of the GNU C Library. 13205 // 13206 // The GNU C Library is free software; you can redistribute it and/or 13207 // modify it under the terms of the GNU Lesser General Public 13208 // License as published by the Free Software Foundation; either 13209 // version 2.1 of the License, or (at your option) any later version. 13210 // 13211 // The GNU C Library is distributed in the hope that it will be useful, 13212 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13213 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13214 // Lesser General Public License for more details. 13215 // 13216 // You should have received a copy of the GNU Lesser General Public 13217 // License along with the GNU C Library; if not, see 13218 // <http://www.gnu.org/licenses/>. 13219 13220 // void assert (int expression); 13221 // 13222 // If NDEBUG is defined, do nothing. 13223 // If not, and EXPRESSION is zero, print an error message and abort. 13224 13225 // void assert_perror (int errnum); 13226 // 13227 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 13228 // error message with the error text for ERRNUM and abort. 13229 // (This is a GNU extension.) 13230 13231 type Fts5tokTable1 = struct { 13232 Fbase sqlite3_vtab 13233 Ftok fts5_tokenizer 13234 FpTok uintptr 13235 } /* fts5_test_tok.c:47:9 */ 13236 13237 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 13238 // This file is part of the GNU C Library. 13239 // 13240 // The GNU C Library is free software; you can redistribute it and/or 13241 // modify it under the terms of the GNU Lesser General Public 13242 // License as published by the Free Software Foundation; either 13243 // version 2.1 of the License, or (at your option) any later version. 13244 // 13245 // The GNU C Library is distributed in the hope that it will be useful, 13246 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13247 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13248 // Lesser General Public License for more details. 13249 // 13250 // You should have received a copy of the GNU Lesser General Public 13251 // License along with the GNU C Library; if not, see 13252 // <http://www.gnu.org/licenses/>. 13253 13254 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 13255 13256 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 13257 // This file is part of the GNU C Library. 13258 // 13259 // The GNU C Library is free software; you can redistribute it and/or 13260 // modify it under the terms of the GNU Lesser General Public 13261 // License as published by the Free Software Foundation; either 13262 // version 2.1 of the License, or (at your option) any later version. 13263 // 13264 // The GNU C Library is distributed in the hope that it will be useful, 13265 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13266 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13267 // Lesser General Public License for more details. 13268 // 13269 // You should have received a copy of the GNU Lesser General Public 13270 // License along with the GNU C Library; if not, see 13271 // <http://www.gnu.org/licenses/>. 13272 13273 // void assert (int expression); 13274 // 13275 // If NDEBUG is defined, do nothing. 13276 // If not, and EXPRESSION is zero, print an error message and abort. 13277 13278 // void assert_perror (int errnum); 13279 // 13280 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 13281 // error message with the error text for ERRNUM and abort. 13282 // (This is a GNU extension.) 13283 13284 type Fts5tokTable = Fts5tokTable1 /* fts5_test_tok.c:47:29 */ 13285 type Fts5tokCursor1 = struct { 13286 Fbase sqlite3_vtab_cursor 13287 FiRowid int32 13288 _ [4]byte 13289 FzInput uintptr 13290 FnRow int32 13291 _ [4]byte 13292 FaRow uintptr 13293 } /* fts5_test_tok.c:48:9 */ 13294 13295 type Fts5tokCursor = Fts5tokCursor1 /* fts5_test_tok.c:48:30 */ 13296 type Fts5tokRow1 = struct { 13297 FzToken uintptr 13298 FiStart int32 13299 FiEnd int32 13300 FiPos int32 13301 _ [4]byte 13302 } /* fts5_test_tok.c:48:9 */ 13303 13304 type Fts5tokRow = Fts5tokRow1 /* fts5_test_tok.c:49:27 */ 13305 13306 func fts5tokDequote(tls *libc.TLS, z uintptr) { /* fts5_test_tok.c:81:13: */ 13307 var q int8 = *(*int8)(unsafe.Pointer(z)) 13308 13309 if (((int32(q) == '[') || (int32(q) == '\'')) || (int32(q) == '"')) || (int32(q) == '`') { 13310 var iIn int32 = 1 13311 var iOut int32 = 0 13312 if int32(q) == '[' { 13313 q = int8(']') 13314 } 13315 13316 for *(*int8)(unsafe.Pointer(z + uintptr(iIn))) != 0 { 13317 if int32(*(*int8)(unsafe.Pointer(z + uintptr(iIn)))) == int32(q) { 13318 if int32(*(*int8)(unsafe.Pointer(z + uintptr((iIn + 1))))) != int32(q) { 13319 // Character iIn was the close quote. 13320 iIn++ 13321 break 13322 } else { 13323 // Character iIn and iIn+1 form an escaped quote character. Skip 13324 // the input cursor past both and copy a single quote character 13325 // to the output buffer. 13326 iIn = iIn + (2) 13327 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&iOut, 1)))) = q 13328 } 13329 } else { 13330 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&iOut, 1)))) = *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&iIn, 1)))) 13331 } 13332 } 13333 13334 *(*int8)(unsafe.Pointer(z + uintptr(iOut))) = int8(0) 13335 } 13336 } 13337 13338 // The second argument, argv[], is an array of pointers to nul-terminated 13339 // strings. This function makes a copy of the array and strings into a 13340 // single block of memory. It then dequotes any of the strings that appear 13341 // to be quoted. 13342 // 13343 // If successful, output parameter *pazDequote is set to point at the 13344 // array of dequoted strings and SQLITE_OK is returned. The caller is 13345 // responsible for eventually calling sqlite3_free() to free the array 13346 // in this case. Or, if an error occurs, an SQLite error code is returned. 13347 // The final value of *pazDequote is undefined in this case. 13348 func fts5tokDequoteArray(tls *libc.TLS, argc int32, argv uintptr, pazDequote uintptr) int32 { /* fts5_test_tok.c:123:12: */ 13349 var rc int32 = SQLITE_OK // Return code 13350 if argc == 0 { 13351 *(*uintptr)(unsafe.Pointer(pazDequote)) = uintptr(0) 13352 } else { 13353 var i int32 13354 var nByte int32 = 0 13355 var azDequote uintptr 13356 13357 for i = 0; i < argc; i++ { 13358 nByte = nByte + (int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) + uint64(1))) 13359 } 13360 13361 *(*uintptr)(unsafe.Pointer(pazDequote)) = libc.AssignUintptr(&azDequote, sqlite3.Xsqlite3_malloc64(tls, (uint64((uint64(unsafe.Sizeof(uintptr(0)))*uint64(argc))+uint64(nByte))))) 13362 if azDequote == uintptr(0) { 13363 rc = SQLITE_NOMEM 13364 } else { 13365 var pSpace uintptr = (azDequote + uintptr(argc)*8) 13366 for i = 0; i < argc; i++ { 13367 var n int32 = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)))) 13368 *(*uintptr)(unsafe.Pointer(azDequote + uintptr(i)*8)) = pSpace 13369 libc.Xmemcpy(tls, pSpace, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), (uint64(n + 1))) 13370 fts5tokDequote(tls, pSpace) 13371 pSpace += (uintptr(n + 1)) 13372 } 13373 } 13374 } 13375 13376 return rc 13377 } 13378 13379 // Schema of the tokenizer table. 13380 13381 // This function does all the work for both the xConnect and xCreate methods. 13382 // These tables have no persistent representation of their own, so xConnect 13383 // and xCreate are identical operations. 13384 // 13385 // argv[0]: module name 13386 // argv[1]: database name 13387 // argv[2]: table name 13388 // argv[3]: first argument (tokenizer name) 13389 func fts5tokConnectMethod(tls *libc.TLS, db uintptr, pCtx uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* fts5_test_tok.c:173:12: */ 13390 bp := tls.Alloc(16) 13391 defer tls.Free(16) 13392 13393 var pApi uintptr = pCtx 13394 var pTab uintptr = uintptr(0) 13395 var rc int32 13396 *(*uintptr)(unsafe.Pointer(bp /* azDequote */)) = uintptr(0) 13397 var nDequote int32 = 0 13398 13399 rc = sqlite3.Xsqlite3_declare_vtab(tls, db, 13400 ts+3048 /* "CREATE TABLE x(i..." */) 13401 13402 if rc == SQLITE_OK { 13403 nDequote = (argc - 3) 13404 rc = fts5tokDequoteArray(tls, nDequote, (argv + 3*8), bp /* &azDequote */) 13405 } 13406 13407 if rc == SQLITE_OK { 13408 pTab = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Fts5tokTable{}))) 13409 if pTab == uintptr(0) { 13410 rc = SQLITE_NOMEM 13411 } else { 13412 libc.Xmemset(tls, pTab, 0, uint64(unsafe.Sizeof(Fts5tokTable{}))) 13413 } 13414 } 13415 13416 if rc == SQLITE_OK { 13417 *(*uintptr)(unsafe.Pointer(bp + 8 /* pTokCtx */)) = uintptr(0) 13418 var zModule uintptr = uintptr(0) 13419 if nDequote > 0 { 13420 zModule = *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* azDequote */)))) 13421 } 13422 13423 rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((pApi + 16 /* &.xFindTokenizer */))))(tls, pApi, zModule, bp+8 /* &pTokCtx */, (pTab + 24 /* &.tok */)) 13424 if rc == SQLITE_OK { 13425 var azArg uintptr = func() uintptr { 13426 if nDequote > 1 { 13427 return (*(*uintptr)(unsafe.Pointer(bp /* azDequote */)) + 1*8) 13428 } 13429 return uintptr(0) 13430 }() 13431 var nArg int32 13432 if nDequote > 0 { 13433 nArg = (nDequote - 1) 13434 } else { 13435 nArg = 0 13436 } 13437 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pTab + 24 /* &.tok */ /* &.xCreate */))))(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pTokCtx */)), azArg, nArg, (pTab + 48 /* &.pTok */)) 13438 } 13439 } 13440 13441 if rc != SQLITE_OK { 13442 sqlite3.Xsqlite3_free(tls, pTab) 13443 pTab = uintptr(0) 13444 } 13445 13446 *(*uintptr)(unsafe.Pointer(ppVtab)) = pTab 13447 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp /* azDequote */))) 13448 return rc 13449 } 13450 13451 // This function does the work for both the xDisconnect and xDestroy methods. 13452 // These tables have no persistent representation of their own, so xDisconnect 13453 // and xDestroy are identical operations. 13454 func fts5tokDisconnectMethod(tls *libc.TLS, pVtab uintptr) int32 { /* fts5_test_tok.c:235:12: */ 13455 var pTab uintptr = pVtab 13456 if (*Fts5tokTable)(unsafe.Pointer(pTab)).FpTok != 0 { 13457 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((pTab + 24 /* &.tok */ + 8 /* &.xDelete */))))(tls, (*Fts5tokTable)(unsafe.Pointer(pTab)).FpTok) 13458 } 13459 sqlite3.Xsqlite3_free(tls, pTab) 13460 return SQLITE_OK 13461 } 13462 13463 // xBestIndex - Analyze a WHERE and ORDER BY clause. 13464 func fts5tokBestIndexMethod(tls *libc.TLS, pVTab uintptr, pInfo uintptr) int32 { /* fts5_test_tok.c:247:12: */ 13465 var i int32 13466 13467 for i = 0; i < (*sqlite3_index_info)(unsafe.Pointer(pInfo)).FnConstraint; i++ { 13468 if (((*sqlite3_index_constraint)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint+uintptr(i)*12)).Fusable != 0) && 13469 ((*sqlite3_index_constraint)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint+uintptr(i)*12)).FiColumn == 0)) && 13470 (int32((*sqlite3_index_constraint)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraint+uintptr(i)*12)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { 13471 (*sqlite3_index_info)(unsafe.Pointer(pInfo)).FidxNum = 1 13472 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 1 13473 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) 13474 (*sqlite3_index_info)(unsafe.Pointer(pInfo)).FestimatedCost = float64(1) 13475 return SQLITE_OK 13476 } 13477 } 13478 13479 (*sqlite3_index_info)(unsafe.Pointer(pInfo)).FidxNum = 0 13480 13481 return SQLITE_OK 13482 } 13483 13484 // xOpen - Open a cursor. 13485 func fts5tokOpenMethod(tls *libc.TLS, pVTab uintptr, ppCsr uintptr) int32 { /* fts5_test_tok.c:275:12: */ 13486 var pCsr uintptr 13487 13488 pCsr = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Fts5tokCursor{}))) 13489 if pCsr == uintptr(0) { 13490 return SQLITE_NOMEM 13491 } 13492 libc.Xmemset(tls, pCsr, 0, uint64(unsafe.Sizeof(Fts5tokCursor{}))) 13493 13494 *(*uintptr)(unsafe.Pointer(ppCsr)) = pCsr 13495 return SQLITE_OK 13496 } 13497 13498 // Reset the tokenizer cursor passed as the only argument. As if it had 13499 // just been returned by fts5tokOpenMethod(). 13500 func fts5tokResetCursor(tls *libc.TLS, pCsr uintptr) { /* fts5_test_tok.c:292:13: */ 13501 var i int32 13502 for i = 0; i < (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FnRow; i++ { 13503 sqlite3.Xsqlite3_free(tls, (*Fts5tokRow)(unsafe.Pointer((*Fts5tokCursor)(unsafe.Pointer(pCsr)).FaRow+uintptr(i)*24)).FzToken) 13504 } 13505 sqlite3.Xsqlite3_free(tls, (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FzInput) 13506 sqlite3.Xsqlite3_free(tls, (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FaRow) 13507 (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FzInput = uintptr(0) 13508 (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FaRow = uintptr(0) 13509 (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FnRow = 0 13510 (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FiRowid = 0 13511 } 13512 13513 // xClose - Close a cursor. 13514 func fts5tokCloseMethod(tls *libc.TLS, pCursor uintptr) int32 { /* fts5_test_tok.c:308:12: */ 13515 var pCsr uintptr = pCursor 13516 fts5tokResetCursor(tls, pCsr) 13517 sqlite3.Xsqlite3_free(tls, pCsr) 13518 return SQLITE_OK 13519 } 13520 13521 // xNext - Advance the cursor to the next row, if any. 13522 func fts5tokNextMethod(tls *libc.TLS, pCursor uintptr) int32 { /* fts5_test_tok.c:318:12: */ 13523 var pCsr uintptr = pCursor 13524 (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FiRowid++ 13525 return SQLITE_OK 13526 } 13527 13528 func fts5tokCb(tls *libc.TLS, pCtx uintptr, tflags int32, pToken uintptr, nToken int32, iStart int32, iEnd int32) int32 { /* fts5_test_tok.c:324:12: */ 13529 var pCsr uintptr = pCtx 13530 var pRow uintptr 13531 13532 if ((*Fts5tokCursor)(unsafe.Pointer(pCsr)).FnRow & ((*Fts5tokCursor)(unsafe.Pointer(pCsr)).FnRow - 1)) == 0 { 13533 var nNew int32 13534 if (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FnRow != 0 { 13535 nNew = ((*Fts5tokCursor)(unsafe.Pointer(pCsr)).FnRow * 2) 13536 } else { 13537 nNew = 32 13538 } 13539 var aNew uintptr 13540 aNew = sqlite3.Xsqlite3_realloc64(tls, (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FaRow, (uint64(uint64(nNew) * uint64(unsafe.Sizeof(Fts5tokRow{}))))) 13541 if aNew == uintptr(0) { 13542 return SQLITE_NOMEM 13543 } 13544 libc.Xmemset(tls, (aNew + uintptr((*Fts5tokCursor)(unsafe.Pointer(pCsr)).FnRow)*24), 0, (uint64(unsafe.Sizeof(Fts5tokRow{})) * (uint64(nNew - (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FnRow)))) 13545 (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FaRow = aNew 13546 } 13547 13548 pRow = ((*Fts5tokCursor)(unsafe.Pointer(pCsr)).FaRow + uintptr((*Fts5tokCursor)(unsafe.Pointer(pCsr)).FnRow)*24) 13549 (*Fts5tokRow)(unsafe.Pointer(pRow)).FiStart = iStart 13550 (*Fts5tokRow)(unsafe.Pointer(pRow)).FiEnd = iEnd 13551 if (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FnRow != 0 { 13552 (*Fts5tokRow)(unsafe.Pointer(pRow)).FiPos = ((*Fts5tokRow)(unsafe.Pointer(pRow+libc.UintptrFromInt32(-1)*24)).FiPos + (func() int32 { 13553 if (tflags & FTS5_TOKEN_COLOCATED) != 0 { 13554 return 0 13555 } 13556 return 1 13557 }())) 13558 } 13559 (*Fts5tokRow)(unsafe.Pointer(pRow)).FzToken = sqlite3.Xsqlite3_malloc(tls, (nToken + 1)) 13560 if (*Fts5tokRow)(unsafe.Pointer(pRow)).FzToken == uintptr(0) { 13561 return SQLITE_NOMEM 13562 } 13563 libc.Xmemcpy(tls, (*Fts5tokRow)(unsafe.Pointer(pRow)).FzToken, pToken, uint64(nToken)) 13564 *(*int8)(unsafe.Pointer((*Fts5tokRow)(unsafe.Pointer(pRow)).FzToken + uintptr(nToken))) = int8(0) 13565 (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FnRow++ 13566 13567 return SQLITE_OK 13568 } 13569 13570 // xFilter - Initialize a cursor to point at the start of its data. 13571 func fts5tokFilterMethod(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr uintptr, nVal int32, apVal uintptr) int32 { /* fts5_test_tok.c:362:12: */ 13572 var rc int32 = SQLITE_ERROR 13573 var pCsr uintptr = pCursor 13574 var pTab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab 13575 13576 fts5tokResetCursor(tls, pCsr) 13577 if idxNum == 1 { 13578 var zByte uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal))) 13579 var nByte int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal))) 13580 (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FzInput = sqlite3.Xsqlite3_malloc(tls, (nByte + 1)) 13581 if (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FzInput == uintptr(0) { 13582 rc = SQLITE_NOMEM 13583 } else { 13584 if nByte > 0 { 13585 libc.Xmemcpy(tls, (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FzInput, zByte, uint64(nByte)) 13586 } 13587 *(*int8)(unsafe.Pointer((*Fts5tokCursor)(unsafe.Pointer(pCsr)).FzInput + uintptr(nByte))) = int8(0) 13588 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer((pTab + 24 /* &.tok */ + 16 /* &.xTokenize */))))(tls, 13589 (*Fts5tokTable)(unsafe.Pointer(pTab)).FpTok, pCsr, 0, zByte, nByte, *(*uintptr)(unsafe.Pointer(&struct { 13590 f func(*libc.TLS, uintptr, int32, uintptr, int32, int32, int32) int32 13591 }{fts5tokCb}))) 13592 } 13593 } 13594 13595 if rc != SQLITE_OK { 13596 return rc 13597 } 13598 return fts5tokNextMethod(tls, pCursor) 13599 } 13600 13601 // xEof - Return true if the cursor is at EOF, or false otherwise. 13602 func fts5tokEofMethod(tls *libc.TLS, pCursor uintptr) int32 { /* fts5_test_tok.c:396:12: */ 13603 var pCsr uintptr = pCursor 13604 return (libc.Bool32((*Fts5tokCursor)(unsafe.Pointer(pCsr)).FiRowid > (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FnRow)) 13605 } 13606 13607 // xColumn - Return a column value. 13608 func fts5tokColumnMethod(tls *libc.TLS, pCursor uintptr, pCtx uintptr, iCol int32) int32 { /* fts5_test_tok.c:404:12: */ 13609 var pCsr uintptr = pCursor 13610 var pRow uintptr = ((*Fts5tokCursor)(unsafe.Pointer(pCsr)).FaRow + uintptr(((*Fts5tokCursor)(unsafe.Pointer(pCsr)).FiRowid-1))*24) 13611 13612 // CREATE TABLE x(input, token, start, end, position) 13613 switch iCol { 13614 case 0: 13615 sqlite3.Xsqlite3_result_text(tls, pCtx, (*Fts5tokCursor)(unsafe.Pointer(pCsr)).FzInput, -1, libc.UintptrFromInt32(-1)) 13616 break 13617 case 1: 13618 sqlite3.Xsqlite3_result_text(tls, pCtx, (*Fts5tokRow)(unsafe.Pointer(pRow)).FzToken, -1, libc.UintptrFromInt32(-1)) 13619 break 13620 case 2: 13621 sqlite3.Xsqlite3_result_int(tls, pCtx, (*Fts5tokRow)(unsafe.Pointer(pRow)).FiStart) 13622 break 13623 case 3: 13624 sqlite3.Xsqlite3_result_int(tls, pCtx, (*Fts5tokRow)(unsafe.Pointer(pRow)).FiEnd) 13625 break 13626 default: 13627 13628 sqlite3.Xsqlite3_result_int(tls, pCtx, (*Fts5tokRow)(unsafe.Pointer(pRow)).FiPos) 13629 break 13630 } 13631 return SQLITE_OK 13632 } 13633 13634 // xRowid - Return the current rowid for the cursor. 13635 func fts5tokRowidMethod(tls *libc.TLS, pCursor uintptr, pRowid uintptr) int32 { /* fts5_test_tok.c:437:12: */ 13636 var pCsr uintptr = pCursor 13637 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite3_int64((*Fts5tokCursor)(unsafe.Pointer(pCsr)).FiRowid) 13638 return SQLITE_OK 13639 } 13640 13641 // Register the fts5tok module with database connection db. Return SQLITE_OK 13642 // if successful or an error code if sqlite3_create_module() fails. 13643 func sqlite3Fts5TestRegisterTok(tls *libc.TLS, db uintptr, pApi uintptr) int32 { /* fts5_test_tok.c:450:5: */ 13644 var rc int32 // Return code 13645 13646 rc = sqlite3.Xsqlite3_create_module(tls, db, ts+3106 /* "fts5tokenize" */, uintptr(unsafe.Pointer(&fts5tok_module)), pApi) 13647 return rc 13648 } 13649 13650 var fts5tok_module = sqlite3_module{ // iVersion 13651 FxCreate: 0, // xCreate 13652 FxConnect: 0, // xConnect 13653 FxBestIndex: 0, // xBestIndex 13654 FxDisconnect: 0, // xDisconnect 13655 FxDestroy: 0, // xDestroy 13656 FxOpen: 0, // xOpen 13657 FxClose: 0, // xClose 13658 FxFilter: 0, // xFilter 13659 FxNext: 0, // xNext 13660 FxEof: 0, // xEof 13661 FxColumn: 0, // xColumn 13662 FxRowid: 0, // xShadowName 13663 } /* fts5_test_tok.c:451:31 */ 13664 13665 // CAPI3REF: Loadable Extension Thunk 13666 // 13667 // A pointer to the opaque sqlite3_api_routines structure is passed as 13668 // the third parameter to entry points of [loadable extensions]. This 13669 // structure must be typedefed in order to work around compiler warnings 13670 // on some platforms. 13671 type sqlite3_api_routines = sqlite3_api_routines1 /* sqlite3.h:1197:37 */ 13672 13673 // This is the function signature used for all extension entry points. It 13674 // is also defined in the file "loadext.c". 13675 type sqlite3_loadext_entry = uintptr /* sqlite3ext.h:346:13 */ 13676 13677 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 13678 // This file is part of the GNU C Library. 13679 // 13680 // The GNU C Library is free software; you can redistribute it and/or 13681 // modify it under the terms of the GNU Lesser General Public 13682 // License as published by the Free Software Foundation; either 13683 // version 2.1 of the License, or (at your option) any later version. 13684 // 13685 // The GNU C Library is distributed in the hope that it will be useful, 13686 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13687 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13688 // Lesser General Public License for more details. 13689 // 13690 // You should have received a copy of the GNU Lesser General Public 13691 // License along with the GNU C Library; if not, see 13692 // <http://www.gnu.org/licenses/>. 13693 13694 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 13695 13696 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 13697 // This file is part of the GNU C Library. 13698 // 13699 // The GNU C Library is free software; you can redistribute it and/or 13700 // modify it under the terms of the GNU Lesser General Public 13701 // License as published by the Free Software Foundation; either 13702 // version 2.1 of the License, or (at your option) any later version. 13703 // 13704 // The GNU C Library is distributed in the hope that it will be useful, 13705 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13706 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13707 // Lesser General Public License for more details. 13708 // 13709 // You should have received a copy of the GNU Lesser General Public 13710 // License along with the GNU C Library; if not, see 13711 // <http://www.gnu.org/licenses/>. 13712 13713 // void assert (int expression); 13714 // 13715 // If NDEBUG is defined, do nothing. 13716 // If not, and EXPRESSION is zero, print an error message and abort. 13717 13718 // void assert_perror (int errnum); 13719 // 13720 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 13721 // error message with the error text for ERRNUM and abort. 13722 // (This is a GNU extension.) 13723 13724 // The append mark at the end of the database is: 13725 // 13726 // Start-Of-SQLite3-NNNNNNNN 13727 // 123456789 123456789 12345 13728 // 13729 // The NNNNNNNN represents a 64-bit big-endian unsigned integer which is 13730 // the offset to page 1, and also the length of the prefix content. 13731 13732 // Maximum size of the combined prefix + database + append-mark. This 13733 // must be less than 0x40000000 to avoid locking issues on Windows. 13734 13735 // Try to align the database to an even multiple of APND_ROUNDUP bytes. 13736 13737 // Forward declaration of objects used by this utility 13738 type ApndVfs = sqlite3_vfs1 /* appendvfs.c:85:28 */ 13739 type ApndFile1 = struct { 13740 Fbase sqlite3_file 13741 FiPgOne sqlite3_int64 13742 FiMark sqlite3_int64 13743 } /* appendvfs.c:86:9 */ 13744 13745 type ApndFile = ApndFile1 /* appendvfs.c:86:25 */ 13746 13747 var apnd_vfs = sqlite3_vfs{ 13748 FiVersion: 3, // szOsFile (set when registered) 13749 FmxPathname: 1024, // pNext 13750 FzName: ts + 3119, /* "apndvfs" */ /* pAppData (set when registered) */ 13751 FxOpen: 0, // xOpen 13752 FxDelete: 0, // xDelete 13753 FxAccess: 0, // xAccess 13754 FxFullPathname: 0, // xFullPathname 13755 FxDlOpen: 0, // xDlOpen 13756 FxDlError: 0, // xDlError 13757 FxDlSym: 0, // xDlSym 13758 FxDlClose: 0, // xDlClose 13759 FxRandomness: 0, // xRandomness 13760 FxSleep: 0, // xSleep 13761 FxCurrentTime: 0, // xCurrentTime 13762 FxGetLastError: 0, // xGetLastError 13763 FxCurrentTimeInt64: 0, // xCurrentTimeInt64 13764 FxSetSystemCall: 0, // xSetSystemCall 13765 FxGetSystemCall: 0, // xGetSystemCall 13766 FxNextSystemCall: 0, // xNextSystemCall 13767 } /* appendvfs.c:177:20 */ 13768 13769 var apnd_io_methods = sqlite3_io_methods{ 13770 FiVersion: 3, // iVersion 13771 FxClose: 0, // xClose 13772 FxRead: 0, // xRead 13773 FxWrite: 0, // xWrite 13774 FxTruncate: 0, // xTruncate 13775 FxSync: 0, // xSync 13776 FxFileSize: 0, // xFileSize 13777 FxLock: 0, // xLock 13778 FxUnlock: 0, // xUnlock 13779 FxCheckReservedLock: 0, // xCheckReservedLock 13780 FxFileControl: 0, // xFileControl 13781 FxSectorSize: 0, // xSectorSize 13782 FxDeviceCharacteristics: 0, // xDeviceCharacteristics 13783 FxShmMap: 0, // xShmMap 13784 FxShmLock: 0, // xShmLock 13785 FxShmBarrier: 0, // xShmBarrier 13786 FxShmUnmap: 0, // xShmUnmap 13787 FxFetch: 0, // xFetch 13788 FxUnfetch: 0, // xUnfetch 13789 } /* appendvfs.c:202:33 */ 13790 13791 // Close an apnd-file. 13792 func apndClose(tls *libc.TLS, pFile uintptr) int32 { /* appendvfs.c:227:12: */ 13793 pFile = ((pFile) + uintptr(1)*24) 13794 return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 8 /* &.xClose */))))(tls, pFile) 13795 } 13796 13797 // Read data from an apnd-file. 13798 func apndRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* appendvfs.c:235:12: */ 13799 var paf uintptr = pFile 13800 pFile = ((pFile) + uintptr(1)*24) 13801 return (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 16 /* &.xRead */))))(tls, pFile, zBuf, iAmt, ((*ApndFile)(unsafe.Pointer(paf)).FiPgOne + iOfst)) 13802 } 13803 13804 // Add the append-mark onto what should become the end of the file. 13805 // If and only if this succeeds, internal ApndFile.iMark is updated. 13806 // Parameter iWriteEnd is the appendvfs-relative offset of the new mark. 13807 func apndWriteMark(tls *libc.TLS, paf uintptr, pFile uintptr, iWriteEnd sqlite_int64) int32 { /* appendvfs.c:251:12: */ 13808 bp := tls.Alloc(25) 13809 defer tls.Free(25) 13810 13811 var iPgOne sqlite_int64 = (*ApndFile)(unsafe.Pointer(paf)).FiPgOne 13812 // var a [25]uint8 at bp, 25 13813 13814 var i int32 = APND_MARK_FOS_SZ 13815 var rc int32 13816 13817 libc.Xmemcpy(tls, bp /* &a[0] */, ts+3127 /* "Start-Of-SQLite3..." */, uint64(APND_MARK_PREFIX_SZ)) 13818 for libc.PreDecInt32(&i, 1) >= 0 { 13819 *(*uint8)(unsafe.Pointer(bp /* &a[0] */ + uintptr((APND_MARK_PREFIX_SZ + i)))) = (uint8(iPgOne & int64(0xff))) 13820 iPgOne >>= 8 13821 } 13822 iWriteEnd = iWriteEnd + ((*ApndFile)(unsafe.Pointer(paf)).FiPgOne) 13823 if SQLITE_OK == (libc.AssignInt32(&rc, (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 24 /* &.xWrite */))))(tls, pFile, bp /* &a[0] */, (APND_MARK_PREFIX_SZ+APND_MARK_FOS_SZ), iWriteEnd))) { 13824 (*ApndFile)(unsafe.Pointer(paf)).FiMark = iWriteEnd 13825 } 13826 return rc 13827 } 13828 13829 // Write data to an apnd-file. 13830 func apndWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* appendvfs.c:277:12: */ 13831 var paf uintptr = pFile 13832 var iWriteEnd sqlite_int64 = (iOfst + sqlite_int64(iAmt)) 13833 if iWriteEnd >= (int64(0x40000000)) { 13834 return SQLITE_FULL 13835 } 13836 pFile = ((pFile) + uintptr(1)*24) 13837 // If append-mark is absent or will be overwritten, write it. 13838 if ((*ApndFile)(unsafe.Pointer(paf)).FiMark < int64(0)) || (((*ApndFile)(unsafe.Pointer(paf)).FiPgOne + iWriteEnd) > (*ApndFile)(unsafe.Pointer(paf)).FiMark) { 13839 var rc int32 = apndWriteMark(tls, paf, pFile, iWriteEnd) 13840 if SQLITE_OK != rc { 13841 return rc 13842 } 13843 } 13844 return (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 24 /* &.xWrite */))))(tls, pFile, zBuf, iAmt, ((*ApndFile)(unsafe.Pointer(paf)).FiPgOne + iOfst)) 13845 } 13846 13847 // Truncate an apnd-file. 13848 func apndTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { /* appendvfs.c:298:12: */ 13849 var paf uintptr = pFile 13850 pFile = ((pFile) + uintptr(1)*24) 13851 // The append mark goes out first so truncate failure does not lose it. 13852 if SQLITE_OK != apndWriteMark(tls, paf, pFile, size) { 13853 return SQLITE_IOERR 13854 } 13855 // Truncate underlying file just past append mark 13856 return (*(*func(*libc.TLS, uintptr, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 32 /* &.xTruncate */))))(tls, pFile, ((*ApndFile)(unsafe.Pointer(paf)).FiMark + (int64(APND_MARK_PREFIX_SZ + APND_MARK_FOS_SZ)))) 13857 } 13858 13859 // Sync an apnd-file. 13860 func apndSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* appendvfs.c:310:12: */ 13861 pFile = ((pFile) + uintptr(1)*24) 13862 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 40 /* &.xSync */))))(tls, pFile, flags) 13863 } 13864 13865 // Return the current file-size of an apnd-file. 13866 // If the append mark is not yet there, the file-size is 0. 13867 func apndFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { /* appendvfs.c:319:12: */ 13868 var paf uintptr = pFile 13869 *(*sqlite_int64)(unsafe.Pointer(pSize)) = func() int64 { 13870 if (*ApndFile)(unsafe.Pointer(paf)).FiMark >= int64(0) { 13871 return ((*ApndFile)(unsafe.Pointer(paf)).FiMark - (*ApndFile)(unsafe.Pointer(paf)).FiPgOne) 13872 } 13873 return int64(0) 13874 }() 13875 return SQLITE_OK 13876 } 13877 13878 // Lock an apnd-file. 13879 func apndLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* appendvfs.c:328:12: */ 13880 pFile = ((pFile) + uintptr(1)*24) 13881 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 56 /* &.xLock */))))(tls, pFile, eLock) 13882 } 13883 13884 // Unlock an apnd-file. 13885 func apndUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* appendvfs.c:336:12: */ 13886 pFile = ((pFile) + uintptr(1)*24) 13887 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 64 /* &.xUnlock */))))(tls, pFile, eLock) 13888 } 13889 13890 // Check if another file-handle holds a RESERVED lock on an apnd-file. 13891 func apndCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int32 { /* appendvfs.c:344:12: */ 13892 pFile = ((pFile) + uintptr(1)*24) 13893 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 72 /* &.xCheckReservedLock */))))(tls, pFile, pResOut) 13894 } 13895 13896 // File control method. For custom operations on an apnd-file. 13897 func apndFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 { /* appendvfs.c:352:12: */ 13898 bp := tls.Alloc(16) 13899 defer tls.Free(16) 13900 13901 var paf uintptr = pFile 13902 var rc int32 13903 pFile = ((pFile) + uintptr(1)*24) 13904 if op == SQLITE_FCNTL_SIZE_HINT { 13905 *(*sqlite3_int64)(unsafe.Pointer(pArg)) += ((*ApndFile)(unsafe.Pointer(paf)).FiPgOne) 13906 } 13907 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 80 /* &.xFileControl */))))(tls, pFile, op, pArg) 13908 if (rc == SQLITE_OK) && (op == SQLITE_FCNTL_VFSNAME) { 13909 *(*uintptr)(unsafe.Pointer(pArg)) = sqlite3.Xsqlite3_mprintf(tls, ts+3145 /* "apnd(%lld)/%z" */, libc.VaList(bp, (*ApndFile)(unsafe.Pointer(paf)).FiPgOne, *(*uintptr)(unsafe.Pointer(pArg)))) 13910 } 13911 return rc 13912 } 13913 13914 // Return the sector-size in bytes for an apnd-file. 13915 func apndSectorSize(tls *libc.TLS, pFile uintptr) int32 { /* appendvfs.c:367:12: */ 13916 pFile = ((pFile) + uintptr(1)*24) 13917 return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 88 /* &.xSectorSize */))))(tls, pFile) 13918 } 13919 13920 // Return the device characteristic flags supported by an apnd-file. 13921 func apndDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { /* appendvfs.c:375:12: */ 13922 pFile = ((pFile) + uintptr(1)*24) 13923 return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 96 /* &.xDeviceCharacteristics */))))(tls, pFile) 13924 } 13925 13926 // Create a shared memory file mapping 13927 func apndShmMap(tls *libc.TLS, pFile uintptr, iPg int32, pgsz int32, bExtend int32, pp uintptr) int32 { /* appendvfs.c:381:12: */ 13928 pFile = ((pFile) + uintptr(1)*24) 13929 return (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 104 /* &.xShmMap */))))(tls, pFile, iPg, pgsz, bExtend, libc.AtomicLoadUintptr(&pp)) 13930 } 13931 13932 // Perform locking on a shared-memory segment 13933 func apndShmLock(tls *libc.TLS, pFile uintptr, offset int32, n int32, flags int32) int32 { /* appendvfs.c:393:12: */ 13934 pFile = ((pFile) + uintptr(1)*24) 13935 return (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 112 /* &.xShmLock */))))(tls, pFile, offset, n, flags) 13936 } 13937 13938 // Memory barrier operation on shared memory 13939 func apndShmBarrier(tls *libc.TLS, pFile uintptr) { /* appendvfs.c:399:13: */ 13940 pFile = ((pFile) + uintptr(1)*24) 13941 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 120 /* &.xShmBarrier */))))(tls, pFile) 13942 } 13943 13944 // Unmap a shared memory segment 13945 func apndShmUnmap(tls *libc.TLS, pFile uintptr, deleteFlag int32) int32 { /* appendvfs.c:405:12: */ 13946 pFile = ((pFile) + uintptr(1)*24) 13947 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 128 /* &.xShmUnmap */))))(tls, pFile, deleteFlag) 13948 } 13949 13950 // Fetch a page of a memory-mapped file 13951 func apndFetch(tls *libc.TLS, pFile uintptr, iOfst sqlite3_int64, iAmt int32, pp uintptr) int32 { /* appendvfs.c:411:12: */ 13952 var p uintptr = pFile 13953 if ((*ApndFile)(unsafe.Pointer(p)).FiMark < int64(0)) || ((iOfst + sqlite3_int64(iAmt)) > (*ApndFile)(unsafe.Pointer(p)).FiMark) { 13954 return SQLITE_IOERR // Cannot read what is not yet there. 13955 } 13956 pFile = ((pFile) + uintptr(1)*24) 13957 return (*(*func(*libc.TLS, uintptr, sqlite3_int64, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 136 /* &.xFetch */))))(tls, pFile, (iOfst + (*ApndFile)(unsafe.Pointer(p)).FiPgOne), iAmt, pp) 13958 } 13959 13960 // Release a memory-mapped page 13961 func apndUnfetch(tls *libc.TLS, pFile uintptr, iOfst sqlite3_int64, pPage uintptr) int32 { /* appendvfs.c:426:12: */ 13962 var p uintptr = pFile 13963 pFile = ((pFile) + uintptr(1)*24) 13964 return (*(*func(*libc.TLS, uintptr, sqlite3_int64, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 144 /* &.xUnfetch */))))(tls, pFile, (iOfst + (*ApndFile)(unsafe.Pointer(p)).FiPgOne), pPage) 13965 } 13966 13967 // Try to read the append-mark off the end of a file. Return the 13968 // start of the appended database if the append-mark is present. 13969 // If there is no valid append-mark, return -1; 13970 // 13971 // An append-mark is only valid if the NNNNNNNN start-of-database offset 13972 // indicates that the appended database contains at least one page. The 13973 // start-of-database value must be a multiple of 512. 13974 func apndReadMark(tls *libc.TLS, sz sqlite3_int64, pFile uintptr) sqlite3_int64 { /* appendvfs.c:441:22: */ 13975 bp := tls.Alloc(25) 13976 defer tls.Free(25) 13977 13978 var rc int32 13979 var i int32 13980 var iMark sqlite3_int64 13981 var msbs int32 = (8 * (APND_MARK_FOS_SZ - 1)) 13982 // var a [25]uint8 at bp, 25 13983 13984 if (int64(APND_MARK_PREFIX_SZ + APND_MARK_FOS_SZ)) != (sz & int64(0x1ff)) { 13985 return int64(-1) 13986 } 13987 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 16 /* &.xRead */))))(tls, pFile, bp /* &a[0] */, (APND_MARK_PREFIX_SZ + APND_MARK_FOS_SZ), (sz - (int64(APND_MARK_PREFIX_SZ + APND_MARK_FOS_SZ)))) 13988 if rc != 0 { 13989 return int64(-1) 13990 } 13991 if libc.Xmemcmp(tls, bp /* &a[0] */, ts+3127 /* "Start-Of-SQLite3..." */, uint64(APND_MARK_PREFIX_SZ)) != 0 { 13992 return int64(-1) 13993 } 13994 iMark = ((sqlite3_int64(int32(*(*uint8)(unsafe.Pointer(bp /* &a[0] */ + 17))) & 0x7f)) << msbs) 13995 for i = 1; i < 8; i++ { 13996 msbs = msbs - (8) 13997 iMark = iMark | (sqlite3_int64(*(*uint8)(unsafe.Pointer(bp /* &a[0] */ + uintptr((APND_MARK_PREFIX_SZ + i))))) << msbs) 13998 } 13999 if iMark > ((sz - (int64(APND_MARK_PREFIX_SZ + APND_MARK_FOS_SZ))) - int64(512)) { 14000 return int64(-1) 14001 } 14002 if (iMark & int64(0x1ff)) != 0 { 14003 return int64(-1) 14004 } 14005 return iMark 14006 } 14007 14008 var apvfsSqliteHdr = *(*[16]int8)(unsafe.Pointer(ts + 3159 /* "SQLite format 3" */)) /* appendvfs.c:461:19 */ 14009 14010 // Check to see if the file is an appendvfs SQLite database file. 14011 // Return true iff it is such. Parameter sz is the file's size. 14012 func apndIsAppendvfsDatabase(tls *libc.TLS, sz sqlite3_int64, pFile uintptr) int32 { /* appendvfs.c:466:12: */ 14013 bp := tls.Alloc(16) 14014 defer tls.Free(16) 14015 14016 var rc int32 14017 // var zHdr [16]int8 at bp, 16 14018 14019 var iMark sqlite3_int64 = apndReadMark(tls, sz, pFile) 14020 if iMark >= int64(0) { 14021 // If file has the correct end-marker, the expected odd size, and the 14022 // SQLite DB type marker where the end-marker puts it, then it 14023 // is an appendvfs database. 14024 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 16 /* &.xRead */))))(tls, pFile, bp /* &zHdr[0] */, int32(unsafe.Sizeof([16]int8{})), iMark) 14025 if (((SQLITE_OK == rc) && 14026 (libc.Xmemcmp(tls, bp /* &zHdr[0] */, uintptr(unsafe.Pointer(&apvfsSqliteHdr)), uint64(unsafe.Sizeof([16]int8{}))) == 0)) && 14027 ((sz & int64(0x1ff)) == (int64(APND_MARK_PREFIX_SZ + APND_MARK_FOS_SZ)))) && 14028 (sz >= (int64(512 + (APND_MARK_PREFIX_SZ + APND_MARK_FOS_SZ)))) { 14029 return 1 // It's an appendvfs database 14030 } 14031 } 14032 return 0 14033 } 14034 14035 // Check to see if the file is an ordinary SQLite database file. 14036 // Return true iff so. Parameter sz is the file's size. 14037 func apndIsOrdinaryDatabaseFile(tls *libc.TLS, sz sqlite3_int64, pFile uintptr) int32 { /* appendvfs.c:491:12: */ 14038 bp := tls.Alloc(16) 14039 defer tls.Free(16) 14040 14041 // var zHdr [16]int8 at bp, 16 14042 14043 if (((apndIsAppendvfsDatabase(tls, sz, pFile) != 0) || // rule 2 14044 ((sz & int64(0x1ff)) != int64(0))) || 14045 (SQLITE_OK != (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 16 /* &.xRead */))))(tls, pFile, bp /* &zHdr[0] */, int32(unsafe.Sizeof([16]int8{})), int64(0)))) || 14046 (libc.Xmemcmp(tls, bp /* &zHdr[0] */, uintptr(unsafe.Pointer(&apvfsSqliteHdr)), uint64(unsafe.Sizeof([16]int8{}))) != 0) { 14047 return 0 14048 } else { 14049 return 1 14050 } 14051 return int32(0) 14052 } 14053 14054 // Open an apnd file handle. 14055 func apndOpen(tls *libc.TLS, pApndVfs uintptr, zName uintptr, pFile uintptr, flags int32, pOutFlags uintptr) int32 { /* appendvfs.c:507:12: */ 14056 bp := tls.Alloc(8) 14057 defer tls.Free(8) 14058 14059 var pApndFile uintptr = pFile 14060 var pBaseFile uintptr = ((pFile) + uintptr(1)*24) 14061 var pBaseVfs uintptr = (*sqlite3_vfs)(unsafe.Pointer(pApndVfs)).FpAppData 14062 var rc int32 14063 *(*sqlite3_int64)(unsafe.Pointer(bp /* sz */)) = int64(0) 14064 if (flags & SQLITE_OPEN_MAIN_DB) == 0 { 14065 // The appendvfs is not to be used for transient or temporary databases. 14066 // Just use the base VFS open to initialize the given file object and 14067 // open the underlying file. (Appendvfs is then unused for this file.) 14068 return (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pBaseVfs + 40 /* &.xOpen */))))(tls, pBaseVfs, zName, pFile, flags, pOutFlags) 14069 } 14070 libc.Xmemset(tls, pApndFile, 0, uint64(unsafe.Sizeof(ApndFile{}))) 14071 (*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&apnd_io_methods)) 14072 (*ApndFile)(unsafe.Pointer(pApndFile)).FiMark = int64(-1) // Append mark not yet written 14073 14074 rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pBaseVfs + 40 /* &.xOpen */))))(tls, pBaseVfs, zName, pBaseFile, flags, pOutFlags) 14075 if rc == SQLITE_OK { 14076 rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pBaseFile)).FpMethods + 48 /* &.xFileSize */))))(tls, pBaseFile, bp /* &sz */) 14077 } 14078 if rc != 0 { 14079 (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pBaseFile)).FpMethods + 8 /* &.xClose */))))(tls, pBaseFile) 14080 (*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(0) 14081 return rc 14082 } 14083 if apndIsOrdinaryDatabaseFile(tls, *(*sqlite3_int64)(unsafe.Pointer(bp /* sz */)), pBaseFile) != 0 { 14084 // The file being opened appears to be just an ordinary DB. Copy 14085 // the base dispatch-table so this instance mimics the base VFS. 14086 libc.Xmemmove(tls, pApndFile, pBaseFile, uint64((*sqlite3_vfs)(unsafe.Pointer(pBaseVfs)).FszOsFile)) 14087 return SQLITE_OK 14088 } 14089 (*ApndFile)(unsafe.Pointer(pApndFile)).FiPgOne = apndReadMark(tls, *(*sqlite3_int64)(unsafe.Pointer(bp /* sz */)), pFile) 14090 if (*ApndFile)(unsafe.Pointer(pApndFile)).FiPgOne >= int64(0) { 14091 (*ApndFile)(unsafe.Pointer(pApndFile)).FiMark = (*(*sqlite3_int64)(unsafe.Pointer(bp /* sz */)) - (int64(APND_MARK_PREFIX_SZ + APND_MARK_FOS_SZ))) // Append mark found 14092 return SQLITE_OK 14093 } 14094 if (flags & SQLITE_OPEN_CREATE) == 0 { 14095 (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pBaseFile)).FpMethods + 8 /* &.xClose */))))(tls, pBaseFile) 14096 rc = SQLITE_CANTOPEN 14097 (*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(0) 14098 } else { 14099 // Round newly added appendvfs location to #define'd page boundary. 14100 // Note that nothing has yet been written to the underlying file. 14101 // The append mark will be written along with first content write. 14102 // Until then, paf->iMark value indicates it is not yet written. 14103 (*ApndFile)(unsafe.Pointer(pApndFile)).FiPgOne = (((*(*sqlite3_int64)(unsafe.Pointer(bp /* sz */))) + (int64(APND_ROUNDUP - 1))) & libc.CplInt64((int64(APND_ROUNDUP - 1)))) 14104 } 14105 return rc 14106 } 14107 14108 // Delete an apnd file. 14109 // For an appendvfs, this could mean delete the appendvfs portion, 14110 // leaving the appendee as it was before it gained an appendvfs. 14111 // For now, this code deletes the underlying file too. 14112 func apndDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) int32 { /* appendvfs.c:572:12: */ 14113 return (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 48 /* &.xDelete */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, zPath, dirSync) 14114 } 14115 14116 // All other VFS methods are pass-thrus. 14117 func apndAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut uintptr) int32 { /* appendvfs.c:579:12: */ 14118 return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 56 /* &.xAccess */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, zPath, flags, pResOut) 14119 } 14120 14121 func apndFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zOut uintptr) int32 { /* appendvfs.c:587:12: */ 14122 return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 64 /* &.xFullPathname */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, zPath, nOut, zOut) 14123 } 14124 14125 func apndDlOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr) uintptr { /* appendvfs.c:595:13: */ 14126 return (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 72 /* &.xDlOpen */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, zPath) 14127 } 14128 14129 func apndDlError(tls *libc.TLS, pVfs uintptr, nByte int32, zErrMsg uintptr) { /* appendvfs.c:598:13: */ 14130 (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 80 /* &.xDlError */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, nByte, zErrMsg) 14131 } 14132 14133 func apndDlSym(tls *libc.TLS, pVfs uintptr, p uintptr, zSym uintptr) uintptr { /* appendvfs.c:601:13: */ 14134 return (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 88 /* &.xDlSym */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, p, zSym) 14135 } 14136 14137 func apndDlClose(tls *libc.TLS, pVfs uintptr, pHandle uintptr) { /* appendvfs.c:604:13: */ 14138 (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 96 /* &.xDlClose */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, pHandle) 14139 } 14140 14141 func apndRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uintptr) int32 { /* appendvfs.c:607:12: */ 14142 return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 104 /* &.xRandomness */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, nByte, zBufOut) 14143 } 14144 14145 func apndSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) int32 { /* appendvfs.c:610:12: */ 14146 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 112 /* &.xSleep */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, nMicro) 14147 } 14148 14149 func apndCurrentTime(tls *libc.TLS, pVfs uintptr, pTimeOut uintptr) int32 { /* appendvfs.c:613:12: */ 14150 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 120 /* &.xCurrentTime */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, pTimeOut) 14151 } 14152 14153 func apndGetLastError(tls *libc.TLS, pVfs uintptr, a int32, b uintptr) int32 { /* appendvfs.c:616:12: */ 14154 return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 128 /* &.xGetLastError */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, a, b) 14155 } 14156 14157 func apndCurrentTimeInt64(tls *libc.TLS, pVfs uintptr, p uintptr) int32 { /* appendvfs.c:619:12: */ 14158 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 136 /* &.xCurrentTimeInt64 */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, p) 14159 } 14160 14161 func apndSetSystemCall(tls *libc.TLS, pVfs uintptr, zName uintptr, pCall sqlite3_syscall_ptr) int32 { /* appendvfs.c:622:12: */ 14162 return (*(*func(*libc.TLS, uintptr, uintptr, sqlite3_syscall_ptr) int32)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 144 /* &.xSetSystemCall */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, zName, pCall) 14163 } 14164 14165 func apndGetSystemCall(tls *libc.TLS, pVfs uintptr, zName uintptr) sqlite3_syscall_ptr { /* appendvfs.c:629:28: */ 14166 return (*(*func(*libc.TLS, uintptr, uintptr) sqlite3_syscall_ptr)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 152 /* &.xGetSystemCall */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, zName) 14167 } 14168 14169 func apndNextSystemCall(tls *libc.TLS, pVfs uintptr, zName uintptr) uintptr { /* appendvfs.c:635:19: */ 14170 return (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 160 /* &.xNextSystemCall */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, zName) 14171 } 14172 14173 // This routine is called when the extension is loaded. 14174 // Register the new VFS. 14175 func sqlite3_appendvfs_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* appendvfs.c:647:5: */ 14176 var rc int32 = SQLITE_OK 14177 var pOrig uintptr 14178 _ = pApi 14179 14180 _ = pzErrMsg 14181 _ = db 14182 pOrig = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 14183 apnd_vfs.FiVersion = (*sqlite3_vfs)(unsafe.Pointer(pOrig)).FiVersion 14184 apnd_vfs.FpAppData = pOrig 14185 apnd_vfs.FszOsFile = (int32(uint64((*sqlite3_vfs)(unsafe.Pointer(pOrig)).FszOsFile) + uint64(unsafe.Sizeof(ApndFile{})))) 14186 rc = sqlite3.Xsqlite3_vfs_register(tls, uintptr(unsafe.Pointer(&apnd_vfs)), 0) 14187 if rc == SQLITE_OK { 14188 rc = (SQLITE_OK | (int32(1) << 8)) 14189 } 14190 return rc 14191 } 14192 14193 // In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. 14194 // are already defined. 14195 // BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. 14196 // NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here. 14197 14198 // A null pointer constant. 14199 14200 // XPG requires a few symbols from <sys/wait.h> being defined. 14201 // Definitions of flag bits for `waitpid' et al. 14202 // Copyright (C) 1992-2018 Free Software Foundation, Inc. 14203 // This file is part of the GNU C Library. 14204 // 14205 // The GNU C Library is free software; you can redistribute it and/or 14206 // modify it under the terms of the GNU Lesser General Public 14207 // License as published by the Free Software Foundation; either 14208 // version 2.1 of the License, or (at your option) any later version. 14209 // 14210 // The GNU C Library is distributed in the hope that it will be useful, 14211 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14212 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14213 // Lesser General Public License for more details. 14214 // 14215 // You should have received a copy of the GNU Lesser General Public 14216 // License along with the GNU C Library; if not, see 14217 // <http://www.gnu.org/licenses/>. 14218 14219 // Bits in the third argument to `waitpid'. 14220 14221 // Bits in the fourth argument to `waitid'. 14222 14223 // The following values are used by the `waitid' function. 14224 14225 // The Linux kernel defines these bare, rather than an enum, 14226 // which causes a conflict if the include order is reversed. 14227 14228 type idtype_t = uint32 /* waitflags.h:57:3 */ 14229 // Definitions of status bits for `wait' et al. 14230 // Copyright (C) 1992-2018 Free Software Foundation, Inc. 14231 // This file is part of the GNU C Library. 14232 // 14233 // The GNU C Library is free software; you can redistribute it and/or 14234 // modify it under the terms of the GNU Lesser General Public 14235 // License as published by the Free Software Foundation; either 14236 // version 2.1 of the License, or (at your option) any later version. 14237 // 14238 // The GNU C Library is distributed in the hope that it will be useful, 14239 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14240 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14241 // Lesser General Public License for more details. 14242 // 14243 // You should have received a copy of the GNU Lesser General Public 14244 // License along with the GNU C Library; if not, see 14245 // <http://www.gnu.org/licenses/>. 14246 14247 // Everything extant so far uses these same bits. 14248 14249 // If WIFEXITED(STATUS), the low-order 8 bits of the status. 14250 14251 // If WIFSIGNALED(STATUS), the terminating signal. 14252 14253 // If WIFSTOPPED(STATUS), the signal that stopped the child. 14254 14255 // Nonzero if STATUS indicates normal termination. 14256 14257 // Nonzero if STATUS indicates termination by a signal. 14258 14259 // Nonzero if STATUS indicates the child is stopped. 14260 14261 // Nonzero if STATUS indicates the child continued after a stop. We only 14262 // define this if <bits/waitflags.h> provides the WCONTINUED flag bit. 14263 14264 // Nonzero if STATUS indicates the child dumped core. 14265 14266 // Macros for constructing status values. 14267 14268 // Define the macros <sys/wait.h> also would define this way. 14269 14270 // _FloatN API tests for enablement. 14271 // Macros to control TS 18661-3 glibc features on ldbl-128 platforms. 14272 // Copyright (C) 2017-2018 Free Software Foundation, Inc. 14273 // This file is part of the GNU C Library. 14274 // 14275 // The GNU C Library is free software; you can redistribute it and/or 14276 // modify it under the terms of the GNU Lesser General Public 14277 // License as published by the Free Software Foundation; either 14278 // version 2.1 of the License, or (at your option) any later version. 14279 // 14280 // The GNU C Library is distributed in the hope that it will be useful, 14281 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14282 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14283 // Lesser General Public License for more details. 14284 // 14285 // You should have received a copy of the GNU Lesser General Public 14286 // License along with the GNU C Library; if not, see 14287 // <http://www.gnu.org/licenses/>. 14288 14289 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 14290 // This file is part of the GNU C Library. 14291 // 14292 // The GNU C Library is free software; you can redistribute it and/or 14293 // modify it under the terms of the GNU Lesser General Public 14294 // License as published by the Free Software Foundation; either 14295 // version 2.1 of the License, or (at your option) any later version. 14296 // 14297 // The GNU C Library is distributed in the hope that it will be useful, 14298 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14299 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14300 // Lesser General Public License for more details. 14301 // 14302 // You should have received a copy of the GNU Lesser General Public 14303 // License along with the GNU C Library; if not, see 14304 // <http://www.gnu.org/licenses/>. 14305 14306 // Properties of long double type. ldbl-opt version. 14307 // Copyright (C) 2016-2018 Free Software Foundation, Inc. 14308 // This file is part of the GNU C Library. 14309 // 14310 // The GNU C Library is free software; you can redistribute it and/or 14311 // modify it under the terms of the GNU Lesser General Public 14312 // License published by the Free Software Foundation; either 14313 // version 2.1 of the License, or (at your option) any later version. 14314 // 14315 // The GNU C Library is distributed in the hope that it will be useful, 14316 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14317 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14318 // Lesser General Public License for more details. 14319 // 14320 // You should have received a copy of the GNU Lesser General Public 14321 // License along with the GNU C Library; if not, see 14322 // <http://www.gnu.org/licenses/>. 14323 14324 // Defined to 1 if the current compiler invocation provides a 14325 // floating-point type with the IEEE 754 binary128 format, and this 14326 // glibc includes corresponding *f128 interfaces for it. 14327 14328 // Defined to 1 if __HAVE_FLOAT128 is 1 and the type is ABI-distinct 14329 // from the default float, double and long double types in this glibc. 14330 14331 // Defined to 1 if the current compiler invocation provides a 14332 // floating-point type with the right format for _Float64x, and this 14333 // glibc includes corresponding *f64x interfaces for it. 14334 14335 // Defined to 1 if __HAVE_FLOAT64X is 1 and _Float64x has the format 14336 // of long double. Otherwise, if __HAVE_FLOAT64X is 1, _Float64x has 14337 // the format of _Float128, which must be different from that of long 14338 // double. 14339 14340 // Defined to concatenate the literal suffix to be used with _Float128 14341 // types, if __HAVE_FLOAT128 is 1. 14342 14343 // Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. 14344 14345 // The remaining of this file provides support for older compilers. 14346 14347 // The type _Float128 exists only since GCC 7.0. 14348 14349 // Various built-in functions do not exist before GCC 7.0. 14350 14351 // Macros to control TS 18661-3 glibc features where the same 14352 // definitions are appropriate for all platforms. 14353 // Copyright (C) 2017-2018 Free Software Foundation, Inc. 14354 // This file is part of the GNU C Library. 14355 // 14356 // The GNU C Library is free software; you can redistribute it and/or 14357 // modify it under the terms of the GNU Lesser General Public 14358 // License as published by the Free Software Foundation; either 14359 // version 2.1 of the License, or (at your option) any later version. 14360 // 14361 // The GNU C Library is distributed in the hope that it will be useful, 14362 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14363 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14364 // Lesser General Public License for more details. 14365 // 14366 // You should have received a copy of the GNU Lesser General Public 14367 // License along with the GNU C Library; if not, see 14368 // <http://www.gnu.org/licenses/>. 14369 14370 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 14371 // This file is part of the GNU C Library. 14372 // 14373 // The GNU C Library is free software; you can redistribute it and/or 14374 // modify it under the terms of the GNU Lesser General Public 14375 // License as published by the Free Software Foundation; either 14376 // version 2.1 of the License, or (at your option) any later version. 14377 // 14378 // The GNU C Library is distributed in the hope that it will be useful, 14379 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14380 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14381 // Lesser General Public License for more details. 14382 // 14383 // You should have received a copy of the GNU Lesser General Public 14384 // License along with the GNU C Library; if not, see 14385 // <http://www.gnu.org/licenses/>. 14386 14387 // Properties of long double type. ldbl-opt version. 14388 // Copyright (C) 2016-2018 Free Software Foundation, Inc. 14389 // This file is part of the GNU C Library. 14390 // 14391 // The GNU C Library is free software; you can redistribute it and/or 14392 // modify it under the terms of the GNU Lesser General Public 14393 // License published by the Free Software Foundation; either 14394 // version 2.1 of the License, or (at your option) any later version. 14395 // 14396 // The GNU C Library is distributed in the hope that it will be useful, 14397 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14398 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14399 // Lesser General Public License for more details. 14400 // 14401 // You should have received a copy of the GNU Lesser General Public 14402 // License along with the GNU C Library; if not, see 14403 // <http://www.gnu.org/licenses/>. 14404 14405 // This header should be included at the bottom of each bits/floatn.h. 14406 // It defines the following macros for each _FloatN and _FloatNx type, 14407 // where the same definitions, or definitions based only on the macros 14408 // in bits/floatn.h, are appropriate for all glibc configurations. 14409 14410 // Defined to 1 if the current compiler invocation provides a 14411 // floating-point type with the right format for this type, and this 14412 // glibc includes corresponding *fN or *fNx interfaces for it. 14413 14414 // Defined to 1 if the corresponding __HAVE_<type> macro is 1 and the 14415 // type is the first with its format in the sequence of (the default 14416 // choices for) float, double, long double, _Float16, _Float32, 14417 // _Float64, _Float128, _Float32x, _Float64x, _Float128x for this 14418 // glibc; that is, if functions present once per floating-point format 14419 // rather than once per type are present for this type. 14420 // 14421 // All configurations supported by glibc have _Float32 the same format 14422 // as float, _Float64 and _Float32x the same format as double, the 14423 // _Float64x the same format as either long double or _Float128. No 14424 // configurations support _Float128x or, as of GCC 7, have compiler 14425 // support for a type meeting the requirements for _Float128x. 14426 14427 // Defined to 1 if the corresponding _FloatN type is not binary compatible 14428 // with the corresponding ISO C type in the current compilation unit as 14429 // opposed to __HAVE_DISTINCT_FLOATN, which indicates the default types built 14430 // in glibc. 14431 14432 // Defined to 1 if any _FloatN or _FloatNx types that are not 14433 // ABI-distinct are however distinct types at the C language level (so 14434 // for the purposes of __builtin_types_compatible_p and _Generic). 14435 14436 // Defined to concatenate the literal suffix to be used with _FloatN 14437 // or _FloatNx types, if __HAVE_<type> is 1. The corresponding 14438 // literal suffixes exist since GCC 7, for C only. 14439 14440 // Defined to a complex type if __HAVE_<type> is 1. 14441 14442 // The remaining of this file provides support for older compilers. 14443 14444 // If double, long double and _Float64 all have the same set of 14445 // values, TS 18661-3 requires the usual arithmetic conversions on 14446 // long double and _Float64 to produce _Float64. For this to be the 14447 // case when building with a compiler without a distinct _Float64 14448 // type, _Float64 must be a typedef for long double, not for 14449 // double. 14450 14451 // Returned by `div'. 14452 type div_t = struct { 14453 Fquot int32 14454 Frem int32 14455 } /* stdlib.h:62:5 */ 14456 14457 // Returned by `ldiv'. 14458 type ldiv_t = struct { 14459 Fquot int64 14460 Frem int64 14461 } /* stdlib.h:70:5 */ 14462 14463 // Returned by `lldiv'. 14464 type lldiv_t = struct { 14465 Fquot int64 14466 Frem int64 14467 } /* stdlib.h:80:5 */ 14468 14469 type u_char = uint8 /* types.h:33:18 */ 14470 type u_short = uint16 /* types.h:34:19 */ 14471 type u_int = uint32 /* types.h:35:17 */ 14472 type u_long = uint64 /* types.h:36:18 */ 14473 type quad_t = int64 /* types.h:37:18 */ 14474 type u_quad_t = uint64 /* types.h:38:20 */ 14475 type fsid_t = struct{ F__val [2]int32 } /* types.h:39:18 */ 14476 type loff_t = int64 /* types.h:42:18 */ 14477 14478 type ino_t = uint64 /* types.h:49:19 */ 14479 14480 type dev_t = uint64 /* types.h:59:17 */ 14481 14482 type gid_t = uint32 /* types.h:64:17 */ 14483 14484 type mode_t = uint32 /* types.h:69:18 */ 14485 14486 type nlink_t = uint64 /* types.h:74:19 */ 14487 14488 type uid_t = uint32 /* types.h:79:17 */ 14489 14490 type pid_t = int32 /* types.h:97:17 */ 14491 14492 type id_t = uint32 /* types.h:103:16 */ 14493 14494 type daddr_t = int32 /* types.h:114:19 */ 14495 type caddr_t = uintptr /* types.h:115:19 */ 14496 14497 type key_t = int32 /* types.h:121:17 */ 14498 14499 // bits/types.h -- definitions of __*_t types underlying *_t types. 14500 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 14501 // This file is part of the GNU C Library. 14502 // 14503 // The GNU C Library is free software; you can redistribute it and/or 14504 // modify it under the terms of the GNU Lesser General Public 14505 // License as published by the Free Software Foundation; either 14506 // version 2.1 of the License, or (at your option) any later version. 14507 // 14508 // The GNU C Library is distributed in the hope that it will be useful, 14509 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14510 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14511 // Lesser General Public License for more details. 14512 // 14513 // You should have received a copy of the GNU Lesser General Public 14514 // License along with the GNU C Library; if not, see 14515 // <http://www.gnu.org/licenses/>. 14516 14517 // Never include this file directly; use <sys/types.h> instead. 14518 14519 // Returned by `clock'. 14520 type clock_t = int64 /* clock_t.h:7:19 */ 14521 14522 // bits/types.h -- definitions of __*_t types underlying *_t types. 14523 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 14524 // This file is part of the GNU C Library. 14525 // 14526 // The GNU C Library is free software; you can redistribute it and/or 14527 // modify it under the terms of the GNU Lesser General Public 14528 // License as published by the Free Software Foundation; either 14529 // version 2.1 of the License, or (at your option) any later version. 14530 // 14531 // The GNU C Library is distributed in the hope that it will be useful, 14532 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14533 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14534 // Lesser General Public License for more details. 14535 // 14536 // You should have received a copy of the GNU Lesser General Public 14537 // License along with the GNU C Library; if not, see 14538 // <http://www.gnu.org/licenses/>. 14539 14540 // Never include this file directly; use <sys/types.h> instead. 14541 14542 // Clock ID used in clock and timer functions. 14543 type clockid_t = int32 /* clockid_t.h:7:21 */ 14544 14545 // bits/types.h -- definitions of __*_t types underlying *_t types. 14546 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 14547 // This file is part of the GNU C Library. 14548 // 14549 // The GNU C Library is free software; you can redistribute it and/or 14550 // modify it under the terms of the GNU Lesser General Public 14551 // License as published by the Free Software Foundation; either 14552 // version 2.1 of the License, or (at your option) any later version. 14553 // 14554 // The GNU C Library is distributed in the hope that it will be useful, 14555 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14556 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14557 // Lesser General Public License for more details. 14558 // 14559 // You should have received a copy of the GNU Lesser General Public 14560 // License along with the GNU C Library; if not, see 14561 // <http://www.gnu.org/licenses/>. 14562 14563 // Never include this file directly; use <sys/types.h> instead. 14564 14565 // Returned by `time'. 14566 type time_t = int64 /* time_t.h:7:18 */ 14567 14568 // bits/types.h -- definitions of __*_t types underlying *_t types. 14569 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 14570 // This file is part of the GNU C Library. 14571 // 14572 // The GNU C Library is free software; you can redistribute it and/or 14573 // modify it under the terms of the GNU Lesser General Public 14574 // License as published by the Free Software Foundation; either 14575 // version 2.1 of the License, or (at your option) any later version. 14576 // 14577 // The GNU C Library is distributed in the hope that it will be useful, 14578 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14579 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14580 // Lesser General Public License for more details. 14581 // 14582 // You should have received a copy of the GNU Lesser General Public 14583 // License along with the GNU C Library; if not, see 14584 // <http://www.gnu.org/licenses/>. 14585 14586 // Never include this file directly; use <sys/types.h> instead. 14587 14588 // Timer ID returned by `timer_create'. 14589 type timer_t = uintptr /* timer_t.h:7:19 */ 14590 14591 // Copyright (C) 1989-2018 Free Software Foundation, Inc. 14592 // 14593 // This file is part of GCC. 14594 // 14595 // GCC is free software; you can redistribute it and/or modify 14596 // it under the terms of the GNU General Public License as published by 14597 // the Free Software Foundation; either version 3, or (at your option) 14598 // any later version. 14599 // 14600 // GCC is distributed in the hope that it will be useful, 14601 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14602 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14603 // GNU General Public License for more details. 14604 // 14605 // Under Section 7 of GPL version 3, you are granted additional 14606 // permissions described in the GCC Runtime Library Exception, version 14607 // 3.1, as published by the Free Software Foundation. 14608 // 14609 // You should have received a copy of the GNU General Public License and 14610 // a copy of the GCC Runtime Library Exception along with this program; 14611 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 14612 // <http://www.gnu.org/licenses/>. 14613 14614 // ISO C Standard: 7.17 Common definitions <stddef.h> 14615 14616 // Any one of these symbols __need_* means that GNU libc 14617 // wants us just to define one data type. So don't define 14618 // the symbols that indicate this file's entire job has been done. 14619 14620 // This avoids lossage on SunOS but only if stdtypes.h comes first. 14621 // There's no way to win with the other order! Sun lossage. 14622 14623 // On 4.3bsd-net2, make sure ansi.h is included, so we have 14624 // one less case to deal with in the following. 14625 // On FreeBSD 5, machine/ansi.h does not exist anymore... 14626 14627 // In 4.3bsd-net2, machine/ansi.h defines these symbols, which are 14628 // defined if the corresponding type is *not* defined. 14629 // FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_. 14630 // NetBSD defines _I386_ANSI_H_ and _X86_64_ANSI_H_ instead of _ANSI_H_ 14631 14632 // Sequent's header files use _PTRDIFF_T_ in some conflicting way. 14633 // Just ignore it. 14634 14635 // On VxWorks, <type/vxTypesBase.h> may have defined macros like 14636 // _TYPE_size_t which will typedef size_t. fixincludes patched the 14637 // vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is 14638 // not defined, and so that defining this macro defines _GCC_SIZE_T. 14639 // If we find that the macros are still defined at this point, we must 14640 // invoke them so that the type is defined as expected. 14641 14642 // In case nobody has defined these types, but we aren't running under 14643 // GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and 14644 // __WCHAR_TYPE__ have reasonable values. This can happen if the 14645 // parts of GCC is compiled by an older compiler, that actually 14646 // include gstddef.h, such as collect2. 14647 14648 // Signed type of difference of two pointers. 14649 14650 // Define this type if we are doing the whole job, 14651 // or if we want this type in particular. 14652 14653 // Unsigned type of `sizeof' something. 14654 14655 // Define this type if we are doing the whole job, 14656 // or if we want this type in particular. 14657 14658 // Wide character type. 14659 // Locale-writers should change this as necessary to 14660 // be big enough to hold unique values not between 0 and 127, 14661 // and not (wchar_t) -1, for each defined multibyte character. 14662 14663 // Define this type if we are doing the whole job, 14664 // or if we want this type in particular. 14665 14666 // In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. 14667 // are already defined. 14668 // BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. 14669 // NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here. 14670 14671 // A null pointer constant. 14672 14673 // Old compatibility names for C types. 14674 type ulong = uint64 /* types.h:148:27 */ 14675 type ushort = uint16 /* types.h:149:28 */ 14676 type uint = uint32 /* types.h:150:22 */ 14677 14678 // These size-specific names are used by some of the inet code. 14679 14680 // Define intN_t types. 14681 // Copyright (C) 2017-2018 Free Software Foundation, Inc. 14682 // This file is part of the GNU C Library. 14683 // 14684 // The GNU C Library is free software; you can redistribute it and/or 14685 // modify it under the terms of the GNU Lesser General Public 14686 // License as published by the Free Software Foundation; either 14687 // version 2.1 of the License, or (at your option) any later version. 14688 // 14689 // The GNU C Library is distributed in the hope that it will be useful, 14690 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14691 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14692 // Lesser General Public License for more details. 14693 // 14694 // You should have received a copy of the GNU Lesser General Public 14695 // License along with the GNU C Library; if not, see 14696 // <http://www.gnu.org/licenses/>. 14697 14698 // bits/types.h -- definitions of __*_t types underlying *_t types. 14699 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 14700 // This file is part of the GNU C Library. 14701 // 14702 // The GNU C Library is free software; you can redistribute it and/or 14703 // modify it under the terms of the GNU Lesser General Public 14704 // License as published by the Free Software Foundation; either 14705 // version 2.1 of the License, or (at your option) any later version. 14706 // 14707 // The GNU C Library is distributed in the hope that it will be useful, 14708 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14709 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14710 // Lesser General Public License for more details. 14711 // 14712 // You should have received a copy of the GNU Lesser General Public 14713 // License along with the GNU C Library; if not, see 14714 // <http://www.gnu.org/licenses/>. 14715 14716 // Never include this file directly; use <sys/types.h> instead. 14717 14718 type int8_t = int8 /* stdint-intn.h:24:18 */ 14719 type int16_t = int16 /* stdint-intn.h:25:19 */ 14720 type int32_t = int32 /* stdint-intn.h:26:19 */ 14721 type int64_t = int64 /* stdint-intn.h:27:19 */ 14722 14723 // For GCC 2.7 and later, we can use specific type-size attributes. 14724 14725 type u_int8_t = uint32 /* types.h:177:1 */ 14726 type u_int16_t = uint32 /* types.h:178:1 */ 14727 type u_int32_t = uint32 /* types.h:179:1 */ 14728 type u_int64_t = uint32 /* types.h:180:1 */ 14729 14730 type register_t = int32 /* types.h:182:13 */ 14731 14732 // A set of signals to be blocked, unblocked, or waited for. 14733 type sigset_t = struct{ F__val [16]uint64 } /* sigset_t.h:7:20 */ 14734 14735 // Get definition of timer specification structures. 14736 14737 // bits/types.h -- definitions of __*_t types underlying *_t types. 14738 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 14739 // This file is part of the GNU C Library. 14740 // 14741 // The GNU C Library is free software; you can redistribute it and/or 14742 // modify it under the terms of the GNU Lesser General Public 14743 // License as published by the Free Software Foundation; either 14744 // version 2.1 of the License, or (at your option) any later version. 14745 // 14746 // The GNU C Library is distributed in the hope that it will be useful, 14747 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14748 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14749 // Lesser General Public License for more details. 14750 // 14751 // You should have received a copy of the GNU Lesser General Public 14752 // License along with the GNU C Library; if not, see 14753 // <http://www.gnu.org/licenses/>. 14754 14755 // Never include this file directly; use <sys/types.h> instead. 14756 14757 // A time value that is accurate to the nearest 14758 // microsecond but also has a range of years. 14759 type timeval = struct { 14760 Ftv_sec int64 14761 Ftv_usec int64 14762 } /* struct_timeval.h:8:1 */ 14763 14764 // NB: Include guard matches what <linux/time.h> uses. 14765 14766 // bits/types.h -- definitions of __*_t types underlying *_t types. 14767 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 14768 // This file is part of the GNU C Library. 14769 // 14770 // The GNU C Library is free software; you can redistribute it and/or 14771 // modify it under the terms of the GNU Lesser General Public 14772 // License as published by the Free Software Foundation; either 14773 // version 2.1 of the License, or (at your option) any later version. 14774 // 14775 // The GNU C Library is distributed in the hope that it will be useful, 14776 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14777 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14778 // Lesser General Public License for more details. 14779 // 14780 // You should have received a copy of the GNU Lesser General Public 14781 // License along with the GNU C Library; if not, see 14782 // <http://www.gnu.org/licenses/>. 14783 14784 // Never include this file directly; use <sys/types.h> instead. 14785 14786 // POSIX.1b structure for a time value. This is like a `struct timeval' but 14787 // has nanoseconds instead of microseconds. 14788 type timespec = struct { 14789 Ftv_sec int64 14790 Ftv_nsec int64 14791 } /* struct_timespec.h:9:1 */ 14792 14793 type suseconds_t = int64 /* select.h:43:23 */ 14794 14795 // Some versions of <linux/posix_types.h> define this macros. 14796 // It's easier to assume 8-bit bytes than to get CHAR_BIT. 14797 14798 // fd_set for select and pselect. 14799 type fd_set = struct{ F__fds_bits [16]int64 } /* select.h:70:5 */ 14800 14801 // Maximum number of file descriptors in `fd_set'. 14802 14803 // Sometimes the fd_set member is assumed to have this type. 14804 type fd_mask = int64 /* select.h:77:19 */ 14805 14806 // Define some inlines helping to catch common problems. 14807 14808 type blksize_t = int64 /* types.h:202:21 */ 14809 14810 // Types from the Large File Support interface. 14811 type blkcnt_t = int64 /* types.h:222:22 */ // Type to count number of disk blocks. 14812 type fsblkcnt_t = uint64 /* types.h:226:24 */ // Type to count file system blocks. 14813 type fsfilcnt_t = uint64 /* types.h:230:24 */ // Type to count file system inodes. 14814 14815 // Now add the thread types. 14816 // Declaration of common pthread types for all architectures. 14817 // Copyright (C) 2017-2018 Free Software Foundation, Inc. 14818 // This file is part of the GNU C Library. 14819 // 14820 // The GNU C Library is free software; you can redistribute it and/or 14821 // modify it under the terms of the GNU Lesser General Public 14822 // License as published by the Free Software Foundation; either 14823 // version 2.1 of the License, or (at your option) any later version. 14824 // 14825 // The GNU C Library is distributed in the hope that it will be useful, 14826 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14827 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14828 // Lesser General Public License for more details. 14829 // 14830 // You should have received a copy of the GNU Lesser General Public 14831 // License along with the GNU C Library; if not, see 14832 // <http://www.gnu.org/licenses/>. 14833 14834 // For internal mutex and condition variable definitions. 14835 // Common threading primitives definitions for both POSIX and C11. 14836 // Copyright (C) 2017-2018 Free Software Foundation, Inc. 14837 // This file is part of the GNU C Library. 14838 // 14839 // The GNU C Library is free software; you can redistribute it and/or 14840 // modify it under the terms of the GNU Lesser General Public 14841 // License as published by the Free Software Foundation; either 14842 // version 2.1 of the License, or (at your option) any later version. 14843 // 14844 // The GNU C Library is distributed in the hope that it will be useful, 14845 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14846 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14847 // Lesser General Public License for more details. 14848 // 14849 // You should have received a copy of the GNU Lesser General Public 14850 // License along with the GNU C Library; if not, see 14851 // <http://www.gnu.org/licenses/>. 14852 14853 // Arch-specific definitions. Each architecture must define the following 14854 // macros to define the expected sizes of pthread data types: 14855 // 14856 // __SIZEOF_PTHREAD_ATTR_T - size of pthread_attr_t. 14857 // __SIZEOF_PTHREAD_MUTEX_T - size of pthread_mutex_t. 14858 // __SIZEOF_PTHREAD_MUTEXATTR_T - size of pthread_mutexattr_t. 14859 // __SIZEOF_PTHREAD_COND_T - size of pthread_cond_t. 14860 // __SIZEOF_PTHREAD_CONDATTR_T - size of pthread_condattr_t. 14861 // __SIZEOF_PTHREAD_RWLOCK_T - size of pthread_rwlock_t. 14862 // __SIZEOF_PTHREAD_RWLOCKATTR_T - size of pthread_rwlockattr_t. 14863 // __SIZEOF_PTHREAD_BARRIER_T - size of pthread_barrier_t. 14864 // __SIZEOF_PTHREAD_BARRIERATTR_T - size of pthread_barrierattr_t. 14865 // 14866 // Also, the following macros must be define for internal pthread_mutex_t 14867 // struct definitions (struct __pthread_mutex_s): 14868 // 14869 // __PTHREAD_COMPAT_PADDING_MID - any additional members after 'kind' 14870 // and before '__spin' (for 64 bits) or 14871 // '__nusers' (for 32 bits). 14872 // __PTHREAD_COMPAT_PADDING_END - any additional members at the end of 14873 // the internal structure. 14874 // __PTHREAD_MUTEX_LOCK_ELISION - 1 if the architecture supports lock 14875 // elision or 0 otherwise. 14876 // __PTHREAD_MUTEX_NUSERS_AFTER_KIND - control where to put __nusers. The 14877 // preferred value for new architectures 14878 // is 0. 14879 // __PTHREAD_MUTEX_USE_UNION - control whether internal __spins and 14880 // __list will be place inside a union for 14881 // linuxthreads compatibility. 14882 // The preferred value for new architectures 14883 // is 0. 14884 // 14885 // For a new port the preferred values for the required defines are: 14886 // 14887 // #define __PTHREAD_COMPAT_PADDING_MID 14888 // #define __PTHREAD_COMPAT_PADDING_END 14889 // #define __PTHREAD_MUTEX_LOCK_ELISION 0 14890 // #define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 0 14891 // #define __PTHREAD_MUTEX_USE_UNION 0 14892 // 14893 // __PTHREAD_MUTEX_LOCK_ELISION can be set to 1 if the hardware plans to 14894 // eventually support lock elision using transactional memory. 14895 // 14896 // The additional macro defines any constraint for the lock alignment 14897 // inside the thread structures: 14898 // 14899 // __LOCK_ALIGNMENT - for internal lock/futex usage. 14900 // 14901 // Same idea but for the once locking primitive: 14902 // 14903 // __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition. 14904 // 14905 // And finally the internal pthread_rwlock_t (struct __pthread_rwlock_arch_t) 14906 // must be defined. 14907 // 14908 // Copyright (C) 2003-2018 Free Software Foundation, Inc. 14909 // This file is part of the GNU C Library. 14910 // 14911 // The GNU C Library is free software; you can redistribute it and/or 14912 // modify it under the terms of the GNU Lesser General Public 14913 // License as published by the Free Software Foundation; either 14914 // version 2.1 of the License, or (at your option) any later version. 14915 // 14916 // The GNU C Library is distributed in the hope that it will be useful, 14917 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14918 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14919 // Lesser General Public License for more details. 14920 // 14921 // You should have received a copy of the GNU Lesser General Public 14922 // License along with the GNU C Library; if not, see 14923 // <http://www.gnu.org/licenses/>. 14924 14925 // Determine the wordsize from the preprocessor defines. 14926 14927 // Definitions for internal mutex struct. 14928 14929 type __pthread_rwlock_arch_t = struct { 14930 F__readers uint32 14931 F__writers uint32 14932 F__wrphase_futex uint32 14933 F__writers_futex uint32 14934 F__pad3 uint32 14935 F__pad4 uint32 14936 F__cur_writer int32 14937 F__shared int32 14938 F__pad1 uint64 14939 F__pad2 uint64 14940 F__flags uint32 14941 _ [4]byte 14942 } /* pthreadtypes-arch.h:50:1 */ 14943 14944 // Common definition of pthread_mutex_t. 14945 14946 type __pthread_internal_list = struct { 14947 F__prev uintptr 14948 F__next uintptr 14949 } /* thread-shared-types.h:82:9 */ 14950 14951 // Lock elision support. 14952 14953 type __pthread_mutex_s = struct { 14954 F__lock int32 14955 F__count uint32 14956 F__owner int32 14957 F__nusers uint32 14958 F__kind int32 14959 F__spins int16 14960 F__elision int16 14961 F__list struct { 14962 F__prev uintptr 14963 F__next uintptr 14964 } 14965 } /* thread-shared-types.h:118:1 */ 14966 14967 // Common definition of pthread_cond_t. 14968 14969 type __pthread_cond_s = struct { 14970 F__0 struct{ F__wseq uint64 } 14971 F__8 struct{ F__g1_start uint64 } 14972 F__g_refs [2]uint32 14973 F__g_size [2]uint32 14974 F__g1_orig_size uint32 14975 F__wrefs uint32 14976 F__g_signals [2]uint32 14977 } /* thread-shared-types.h:171:1 */ 14978 14979 // Thread identifiers. The structure of the attribute type is not 14980 // exposed on purpose. 14981 type pthread_t = uint64 /* pthreadtypes.h:27:27 */ 14982 14983 // Data structures for mutex handling. The structure of the attribute 14984 // type is not exposed on purpose. 14985 type pthread_mutexattr_t = struct { 14986 _ [0]uint32 14987 F__size [4]int8 14988 } /* pthreadtypes.h:36:3 */ 14989 14990 // Data structure for condition variable handling. The structure of 14991 // the attribute type is not exposed on purpose. 14992 type pthread_condattr_t = struct { 14993 _ [0]uint32 14994 F__size [4]int8 14995 } /* pthreadtypes.h:45:3 */ 14996 14997 // Keys for thread-specific data 14998 type pthread_key_t = uint32 /* pthreadtypes.h:49:22 */ 14999 15000 // Once-only execution 15001 type pthread_once_t = int32 /* pthreadtypes.h:53:30 */ 15002 15003 type pthread_attr_t1 = struct { 15004 _ [0]uint64 15005 F__size [56]int8 15006 } /* pthreadtypes.h:56:1 */ 15007 15008 type pthread_attr_t = pthread_attr_t1 /* pthreadtypes.h:62:30 */ 15009 15010 type pthread_mutex_t = struct{ F__data __pthread_mutex_s } /* pthreadtypes.h:72:3 */ 15011 15012 type pthread_cond_t = struct{ F__data __pthread_cond_s } /* pthreadtypes.h:80:3 */ 15013 15014 // Data structure for reader-writer lock variable handling. The 15015 // structure of the attribute type is deliberately not exposed. 15016 type pthread_rwlock_t = struct{ F__data __pthread_rwlock_arch_t } /* pthreadtypes.h:91:3 */ 15017 15018 type pthread_rwlockattr_t = struct { 15019 _ [0]uint64 15020 F__size [8]int8 15021 } /* pthreadtypes.h:97:3 */ 15022 15023 // POSIX spinlock data type. 15024 type pthread_spinlock_t = int32 /* pthreadtypes.h:103:22 */ 15025 15026 // POSIX barriers data type. The structure of the type is 15027 // deliberately not exposed. 15028 type pthread_barrier_t = struct { 15029 _ [0]uint64 15030 F__size [32]int8 15031 } /* pthreadtypes.h:112:3 */ 15032 15033 type pthread_barrierattr_t = struct { 15034 _ [0]uint32 15035 F__size [4]int8 15036 } /* pthreadtypes.h:118:3 */ 15037 15038 // Reentrant versions of the `random' family of functions. 15039 // These functions all use the following data structure to contain 15040 // state, rather than global state variables. 15041 15042 type random_data = struct { 15043 Ffptr uintptr 15044 Frptr uintptr 15045 Fstate uintptr 15046 Frand_type int32 15047 Frand_deg int32 15048 Frand_sep int32 15049 _ [4]byte 15050 Fend_ptr uintptr 15051 } /* stdlib.h:423:1 */ 15052 15053 // Data structure for communication with thread safe versions. This 15054 // type is to be regarded as opaque. It's only exported because users 15055 // have to allocate objects of this type. 15056 type drand48_data = struct { 15057 F__x [3]uint16 15058 F__old_x [3]uint16 15059 F__c uint16 15060 F__init uint16 15061 F__a uint64 15062 } /* stdlib.h:490:1 */ 15063 15064 // Forward declaration of objects used by this implementation 15065 type amatch_vtab1 = struct { 15066 Fbase sqlite3_vtab 15067 FzClassName uintptr 15068 FzDb uintptr 15069 FzSelf uintptr 15070 FzCostTab uintptr 15071 FzVocabTab uintptr 15072 FzVocabWord uintptr 15073 FzVocabLang uintptr 15074 FpRule uintptr 15075 FrIns amatch_cost 15076 FrDel amatch_cost 15077 FrSub amatch_cost 15078 _ [4]byte 15079 Fdb uintptr 15080 FpVCheck uintptr 15081 FnCursor int32 15082 _ [4]byte 15083 } /* amatch.c:172:9 */ 15084 15085 // Forward declaration of objects used by this implementation 15086 type amatch_vtab = amatch_vtab1 /* amatch.c:172:28 */ 15087 type amatch_cursor1 = struct { 15088 Fbase sqlite3_vtab_cursor 15089 FiRowid sqlite3_int64 15090 FiLang amatch_langid 15091 FrLimit amatch_cost 15092 FnBuf int32 15093 FoomErr int32 15094 FnWord int32 15095 _ [4]byte 15096 FzBuf uintptr 15097 FzInput uintptr 15098 FpVtab uintptr 15099 FpAllWords uintptr 15100 FpCurrent uintptr 15101 FpCost uintptr 15102 FpWord uintptr 15103 } /* amatch.c:173:9 */ 15104 15105 type amatch_cursor = amatch_cursor1 /* amatch.c:173:30 */ 15106 type amatch_rule1 = struct { 15107 FpNext uintptr 15108 FzFrom uintptr 15109 FrCost amatch_cost 15110 FiLang amatch_langid 15111 FnFrom amatch_len 15112 FnTo amatch_len 15113 FzTo [4]int8 15114 _ [2]byte 15115 } /* amatch.c:172:9 */ 15116 15117 type amatch_rule = amatch_rule1 /* amatch.c:174:28 */ 15118 type amatch_word1 = struct { 15119 FpNext uintptr 15120 FsCost amatch_avl 15121 FsWord amatch_avl 15122 FrCost amatch_cost 15123 FiSeq int32 15124 FzCost [10]int8 15125 FnMatch int16 15126 FzWord [4]int8 15127 } /* amatch.c:173:9 */ 15128 15129 type amatch_word = amatch_word1 /* amatch.c:175:28 */ 15130 type amatch_avl1 = struct { 15131 FpWord uintptr 15132 FzKey uintptr 15133 FpBefore uintptr 15134 FpAfter uintptr 15135 FpUp uintptr 15136 Fheight int16 15137 Fimbalance int16 15138 _ [4]byte 15139 } /* amatch.c:173:9 */ 15140 15141 type amatch_avl = amatch_avl1 /* amatch.c:176:27 */ 15142 15143 // Recompute the amatch_avl.height and amatch_avl.imbalance fields for p. 15144 // Assume that the children of p have correct heights. 15145 func amatchAvlRecomputeHeight(tls *libc.TLS, p uintptr) { /* amatch.c:199:13: */ 15146 var hBefore int16 15147 if (*amatch_avl)(unsafe.Pointer(p)).FpBefore != 0 { 15148 hBefore = (*amatch_avl)(unsafe.Pointer((*amatch_avl)(unsafe.Pointer(p)).FpBefore)).Fheight 15149 } else { 15150 hBefore = int16(0) 15151 } 15152 var hAfter int16 15153 if (*amatch_avl)(unsafe.Pointer(p)).FpAfter != 0 { 15154 hAfter = (*amatch_avl)(unsafe.Pointer((*amatch_avl)(unsafe.Pointer(p)).FpAfter)).Fheight 15155 } else { 15156 hAfter = int16(0) 15157 } 15158 (*amatch_avl)(unsafe.Pointer(p)).Fimbalance = (int16(int32(hBefore) - int32(hAfter))) // -: pAfter higher. +: pBefore higher 15159 (*amatch_avl)(unsafe.Pointer(p)).Fheight = (int16((func() int32 { 15160 if int32(hBefore) > int32(hAfter) { 15161 return int32(hBefore) 15162 } 15163 return int32(hAfter) 15164 }()) + 1)) 15165 } 15166 15167 // P B 15168 // / \ / ** B Z ==> X P 15169 // / \ / ** X Y Y Z 15170 // 15171 func amatchAvlRotateBefore(tls *libc.TLS, pP uintptr) uintptr { /* amatch.c:214:19: */ 15172 var pB uintptr = (*amatch_avl)(unsafe.Pointer(pP)).FpBefore 15173 var pY uintptr = (*amatch_avl)(unsafe.Pointer(pB)).FpAfter 15174 (*amatch_avl)(unsafe.Pointer(pB)).FpUp = (*amatch_avl)(unsafe.Pointer(pP)).FpUp 15175 (*amatch_avl)(unsafe.Pointer(pB)).FpAfter = pP 15176 (*amatch_avl)(unsafe.Pointer(pP)).FpUp = pB 15177 (*amatch_avl)(unsafe.Pointer(pP)).FpBefore = pY 15178 if pY != 0 { 15179 (*amatch_avl)(unsafe.Pointer(pY)).FpUp = pP 15180 } 15181 amatchAvlRecomputeHeight(tls, pP) 15182 amatchAvlRecomputeHeight(tls, pB) 15183 return pB 15184 } 15185 15186 // P A 15187 // / \ / ** X A ==> P Z 15188 // / \ / ** Y Z X Y 15189 // 15190 func amatchAvlRotateAfter(tls *libc.TLS, pP uintptr) uintptr { /* amatch.c:235:19: */ 15191 var pA uintptr = (*amatch_avl)(unsafe.Pointer(pP)).FpAfter 15192 var pY uintptr = (*amatch_avl)(unsafe.Pointer(pA)).FpBefore 15193 (*amatch_avl)(unsafe.Pointer(pA)).FpUp = (*amatch_avl)(unsafe.Pointer(pP)).FpUp 15194 (*amatch_avl)(unsafe.Pointer(pA)).FpBefore = pP 15195 (*amatch_avl)(unsafe.Pointer(pP)).FpUp = pA 15196 (*amatch_avl)(unsafe.Pointer(pP)).FpAfter = pY 15197 if pY != 0 { 15198 (*amatch_avl)(unsafe.Pointer(pY)).FpUp = pP 15199 } 15200 amatchAvlRecomputeHeight(tls, pP) 15201 amatchAvlRecomputeHeight(tls, pA) 15202 return pA 15203 } 15204 15205 // Return a pointer to the pBefore or pAfter pointer in the parent 15206 // of p that points to p. Or if p is the root node, return pp. 15207 func amatchAvlFromPtr(tls *libc.TLS, p uintptr, pp uintptr) uintptr { /* amatch.c:252:19: */ 15208 var pUp uintptr = (*amatch_avl)(unsafe.Pointer(p)).FpUp 15209 if pUp == uintptr(0) { 15210 return pp 15211 } 15212 if (*amatch_avl)(unsafe.Pointer(pUp)).FpAfter == p { 15213 return (pUp + 24 /* &.pAfter */) 15214 } 15215 return (pUp + 16 /* &.pBefore */) 15216 } 15217 15218 // Rebalance all nodes starting with p and working up to the root. 15219 // Return the new root. 15220 func amatchAvlBalance(tls *libc.TLS, p uintptr) uintptr { /* amatch.c:263:19: */ 15221 bp := tls.Alloc(8) 15222 defer tls.Free(8) 15223 *(*uintptr)(unsafe.Pointer(bp)) = p 15224 15225 var pTop uintptr = *(*uintptr)(unsafe.Pointer(bp /* p */)) 15226 var pp uintptr 15227 for *(*uintptr)(unsafe.Pointer(bp /* p */)) != 0 { 15228 amatchAvlRecomputeHeight(tls, *(*uintptr)(unsafe.Pointer(bp /* p */))) 15229 if int32((*amatch_avl)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* p */)))).Fimbalance) >= 2 { 15230 var pB uintptr = (*amatch_avl)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* p */)))).FpBefore 15231 if int32((*amatch_avl)(unsafe.Pointer(pB)).Fimbalance) < 0 { 15232 (*amatch_avl)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* p */)))).FpBefore = amatchAvlRotateAfter(tls, pB) 15233 } 15234 pp = amatchAvlFromPtr(tls, *(*uintptr)(unsafe.Pointer(bp /* p */)), bp /* &p */) 15235 *(*uintptr)(unsafe.Pointer(bp /* p */)) = libc.AssignPtrUintptr(pp, amatchAvlRotateBefore(tls, *(*uintptr)(unsafe.Pointer(bp /* p */)))) 15236 } else if int32((*amatch_avl)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* p */)))).Fimbalance) <= (-2) { 15237 var pA uintptr = (*amatch_avl)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* p */)))).FpAfter 15238 if int32((*amatch_avl)(unsafe.Pointer(pA)).Fimbalance) > 0 { 15239 (*amatch_avl)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* p */)))).FpAfter = amatchAvlRotateBefore(tls, pA) 15240 } 15241 pp = amatchAvlFromPtr(tls, *(*uintptr)(unsafe.Pointer(bp /* p */)), bp /* &p */) 15242 *(*uintptr)(unsafe.Pointer(bp /* p */)) = libc.AssignPtrUintptr(pp, amatchAvlRotateAfter(tls, *(*uintptr)(unsafe.Pointer(bp /* p */)))) 15243 } 15244 pTop = *(*uintptr)(unsafe.Pointer(bp /* p */)) 15245 *(*uintptr)(unsafe.Pointer(bp /* p */)) = (*amatch_avl)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* p */)))).FpUp 15246 } 15247 return pTop 15248 } 15249 15250 // Search the tree rooted at p for an entry with zKey. Return a pointer 15251 // to the entry or return NULL. 15252 func amatchAvlSearch(tls *libc.TLS, p uintptr, zKey uintptr) uintptr { /* amatch.c:288:19: */ 15253 var c int32 15254 for (p != 0) && ((libc.AssignInt32(&c, libc.Xstrcmp(tls, zKey, (*amatch_avl)(unsafe.Pointer(p)).FzKey))) != 0) { 15255 if c < 0 { 15256 p = (*amatch_avl)(unsafe.Pointer(p)).FpBefore 15257 } else { 15258 p = (*amatch_avl)(unsafe.Pointer(p)).FpAfter 15259 } 15260 } 15261 return p 15262 } 15263 15264 // Find the first node (the one with the smallest key). 15265 func amatchAvlFirst(tls *libc.TLS, p uintptr) uintptr { /* amatch.c:298:19: */ 15266 if p != 0 { 15267 for (*amatch_avl)(unsafe.Pointer(p)).FpBefore != 0 { 15268 p = (*amatch_avl)(unsafe.Pointer(p)).FpBefore 15269 } 15270 } 15271 return p 15272 } 15273 15274 // Insert a new node pNew. Return NULL on success. If the key is not 15275 // unique, then do not perform the insert but instead leave pNew unchanged 15276 // and return a pointer to an existing node with the same key. 15277 func amatchAvlInsert(tls *libc.TLS, ppHead uintptr, pNew uintptr) uintptr { /* amatch.c:356:19: */ 15278 var c int32 15279 var p uintptr = *(*uintptr)(unsafe.Pointer(ppHead)) 15280 if p == uintptr(0) { 15281 p = pNew 15282 (*amatch_avl)(unsafe.Pointer(pNew)).FpUp = uintptr(0) 15283 } else { 15284 for p != 0 { 15285 c = libc.Xstrcmp(tls, (*amatch_avl)(unsafe.Pointer(pNew)).FzKey, (*amatch_avl)(unsafe.Pointer(p)).FzKey) 15286 if c < 0 { 15287 if (*amatch_avl)(unsafe.Pointer(p)).FpBefore != 0 { 15288 p = (*amatch_avl)(unsafe.Pointer(p)).FpBefore 15289 } else { 15290 (*amatch_avl)(unsafe.Pointer(p)).FpBefore = pNew 15291 (*amatch_avl)(unsafe.Pointer(pNew)).FpUp = p 15292 break 15293 } 15294 } else if c > 0 { 15295 if (*amatch_avl)(unsafe.Pointer(p)).FpAfter != 0 { 15296 p = (*amatch_avl)(unsafe.Pointer(p)).FpAfter 15297 } else { 15298 (*amatch_avl)(unsafe.Pointer(p)).FpAfter = pNew 15299 (*amatch_avl)(unsafe.Pointer(pNew)).FpUp = p 15300 break 15301 } 15302 } else { 15303 return p 15304 } 15305 } 15306 } 15307 (*amatch_avl)(unsafe.Pointer(pNew)).FpBefore = uintptr(0) 15308 (*amatch_avl)(unsafe.Pointer(pNew)).FpAfter = uintptr(0) 15309 (*amatch_avl)(unsafe.Pointer(pNew)).Fheight = int16(1) 15310 (*amatch_avl)(unsafe.Pointer(pNew)).Fimbalance = int16(0) 15311 *(*uintptr)(unsafe.Pointer(ppHead)) = amatchAvlBalance(tls, p) 15312 // assert( amatchAvlIntegrity(*ppHead) ); 15313 // assert( amatchAvlIntegrity2(*ppHead) ); 15314 return uintptr(0) 15315 } 15316 15317 // Remove node pOld from the tree. pOld must be an element of the tree or 15318 // the AVL tree will become corrupt. 15319 func amatchAvlRemove(tls *libc.TLS, ppHead uintptr, pOld uintptr) { /* amatch.c:399:13: */ 15320 var ppParent uintptr 15321 var pBalance uintptr = uintptr(0) 15322 // assert( amatchAvlSearch(*ppHead, pOld->zKey)==pOld ); 15323 ppParent = amatchAvlFromPtr(tls, pOld, ppHead) 15324 if ((*amatch_avl)(unsafe.Pointer(pOld)).FpBefore == uintptr(0)) && ((*amatch_avl)(unsafe.Pointer(pOld)).FpAfter == uintptr(0)) { 15325 *(*uintptr)(unsafe.Pointer(ppParent)) = uintptr(0) 15326 pBalance = (*amatch_avl)(unsafe.Pointer(pOld)).FpUp 15327 } else if ((*amatch_avl)(unsafe.Pointer(pOld)).FpBefore != 0) && ((*amatch_avl)(unsafe.Pointer(pOld)).FpAfter != 0) { 15328 var pX uintptr 15329 var pY uintptr 15330 pX = amatchAvlFirst(tls, (*amatch_avl)(unsafe.Pointer(pOld)).FpAfter) 15331 *(*uintptr)(unsafe.Pointer(amatchAvlFromPtr(tls, pX, uintptr(0)))) = (*amatch_avl)(unsafe.Pointer(pX)).FpAfter 15332 if (*amatch_avl)(unsafe.Pointer(pX)).FpAfter != 0 { 15333 (*amatch_avl)(unsafe.Pointer((*amatch_avl)(unsafe.Pointer(pX)).FpAfter)).FpUp = (*amatch_avl)(unsafe.Pointer(pX)).FpUp 15334 } 15335 pBalance = (*amatch_avl)(unsafe.Pointer(pX)).FpUp 15336 (*amatch_avl)(unsafe.Pointer(pX)).FpAfter = (*amatch_avl)(unsafe.Pointer(pOld)).FpAfter 15337 if (*amatch_avl)(unsafe.Pointer(pX)).FpAfter != 0 { 15338 (*amatch_avl)(unsafe.Pointer((*amatch_avl)(unsafe.Pointer(pX)).FpAfter)).FpUp = pX 15339 } else { 15340 15341 pBalance = pX 15342 } 15343 (*amatch_avl)(unsafe.Pointer(pX)).FpBefore = libc.AssignUintptr(&pY, (*amatch_avl)(unsafe.Pointer(pOld)).FpBefore) 15344 if pY != 0 { 15345 (*amatch_avl)(unsafe.Pointer(pY)).FpUp = pX 15346 } 15347 (*amatch_avl)(unsafe.Pointer(pX)).FpUp = (*amatch_avl)(unsafe.Pointer(pOld)).FpUp 15348 *(*uintptr)(unsafe.Pointer(ppParent)) = pX 15349 } else if (*amatch_avl)(unsafe.Pointer(pOld)).FpBefore == uintptr(0) { 15350 *(*uintptr)(unsafe.Pointer(ppParent)) = libc.AssignUintptr(&pBalance, (*amatch_avl)(unsafe.Pointer(pOld)).FpAfter) 15351 (*amatch_avl)(unsafe.Pointer(pBalance)).FpUp = (*amatch_avl)(unsafe.Pointer(pOld)).FpUp 15352 } else if (*amatch_avl)(unsafe.Pointer(pOld)).FpAfter == uintptr(0) { 15353 *(*uintptr)(unsafe.Pointer(ppParent)) = libc.AssignUintptr(&pBalance, (*amatch_avl)(unsafe.Pointer(pOld)).FpBefore) 15354 (*amatch_avl)(unsafe.Pointer(pBalance)).FpUp = (*amatch_avl)(unsafe.Pointer(pOld)).FpUp 15355 } 15356 *(*uintptr)(unsafe.Pointer(ppHead)) = amatchAvlBalance(tls, pBalance) 15357 (*amatch_avl)(unsafe.Pointer(pOld)).FpUp = uintptr(0) 15358 (*amatch_avl)(unsafe.Pointer(pOld)).FpBefore = uintptr(0) 15359 (*amatch_avl)(unsafe.Pointer(pOld)).FpAfter = uintptr(0) 15360 // assert( amatchAvlIntegrity(*ppHead) ); 15361 // assert( amatchAvlIntegrity2(*ppHead) ); 15362 } 15363 15364 // 15365 // End of the AVL Tree implementation 15366 // 15367 15368 // Various types. 15369 // 15370 // amatch_cost is the "cost" of an edit operation. 15371 // 15372 // amatch_len is the length of a matching string. 15373 // 15374 // amatch_langid is an ruleset identifier. 15375 type amatch_cost = int32 /* amatch.c:452:13 */ 15376 type amatch_len = int8 /* amatch.c:453:21 */ 15377 type amatch_langid = int32 /* amatch.c:454:13 */ 15378 15379 // The two input rule lists are both sorted in order of increasing 15380 // cost. Merge them together into a single list, sorted by cost, and 15381 // return a pointer to the head of that list. 15382 func amatchMergeRules(tls *libc.TLS, pA uintptr, pB uintptr) uintptr { /* amatch.c:534:20: */ 15383 bp := tls.Alloc(32) 15384 defer tls.Free(32) 15385 15386 // var head amatch_rule at bp, 32 15387 15388 var pTail uintptr 15389 15390 pTail = bp /* &head */ 15391 for (pA != 0) && (pB != 0) { 15392 if (*amatch_rule)(unsafe.Pointer(pA)).FrCost <= (*amatch_rule)(unsafe.Pointer(pB)).FrCost { 15393 (*amatch_rule)(unsafe.Pointer(pTail)).FpNext = pA 15394 pTail = pA 15395 pA = (*amatch_rule)(unsafe.Pointer(pA)).FpNext 15396 } else { 15397 (*amatch_rule)(unsafe.Pointer(pTail)).FpNext = pB 15398 pTail = pB 15399 pB = (*amatch_rule)(unsafe.Pointer(pB)).FpNext 15400 } 15401 } 15402 if pA == uintptr(0) { 15403 (*amatch_rule)(unsafe.Pointer(pTail)).FpNext = pB 15404 } else { 15405 (*amatch_rule)(unsafe.Pointer(pTail)).FpNext = pA 15406 } 15407 return (*amatch_rule)(unsafe.Pointer(bp /* &head */)).FpNext 15408 } 15409 15410 // Statement pStmt currently points to a row in the amatch data table. This 15411 // function allocates and populates a amatch_rule structure according to 15412 // the content of the row. 15413 // 15414 // If successful, *ppRule is set to point to the new object and SQLITE_OK 15415 // is returned. Otherwise, *ppRule is zeroed, *pzErr may be set to point 15416 // to an error message and an SQLite error code returned. 15417 func amatchLoadOneRule(tls *libc.TLS, p uintptr, pStmt uintptr, ppRule uintptr, pzErr uintptr) int32 { /* amatch.c:567:12: */ 15418 bp := tls.Alloc(48) 15419 defer tls.Free(48) 15420 15421 var iLang sqlite3_int64 = sqlite3.Xsqlite3_column_int64(tls, pStmt, 0) 15422 var zFrom uintptr = sqlite3.Xsqlite3_column_text(tls, pStmt, 1) 15423 var zTo uintptr = sqlite3.Xsqlite3_column_text(tls, pStmt, 2) 15424 var rCost amatch_cost = sqlite3.Xsqlite3_column_int(tls, pStmt, 3) 15425 15426 var rc int32 = SQLITE_OK // Return code 15427 var nFrom int32 // Size of string zFrom, in bytes 15428 var nTo int32 // Size of string zTo, in bytes 15429 var pRule uintptr = uintptr(0) // New rule object to return 15430 15431 if zFrom == uintptr(0) { 15432 zFrom = ts + 489 /* "" */ 15433 } 15434 if zTo == uintptr(0) { 15435 zTo = ts + 489 /* "" */ 15436 } 15437 nFrom = int32(libc.Xstrlen(tls, zFrom)) 15438 nTo = int32(libc.Xstrlen(tls, zTo)) 15439 15440 // Silently ignore null transformations 15441 if libc.Xstrcmp(tls, zFrom, zTo) == 0 { 15442 if (int32(*(*int8)(unsafe.Pointer(zFrom))) == '?') && (int32(*(*int8)(unsafe.Pointer(zFrom + 1))) == 0) { 15443 if ((*amatch_vtab)(unsafe.Pointer(p)).FrSub == 0) || ((*amatch_vtab)(unsafe.Pointer(p)).FrSub > rCost) { 15444 (*amatch_vtab)(unsafe.Pointer(p)).FrSub = rCost 15445 } 15446 } 15447 *(*uintptr)(unsafe.Pointer(ppRule)) = uintptr(0) 15448 return SQLITE_OK 15449 } 15450 15451 if (rCost <= 0) || (rCost > AMATCH_MX_COST) { 15452 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3175, /* "%s: cost must be..." */ 15453 libc.VaList(bp, (*amatch_vtab)(unsafe.Pointer(p)).FzClassName, AMATCH_MX_COST)) 15454 rc = SQLITE_ERROR 15455 } else if (nFrom > AMATCH_MX_LENGTH) || (nTo > AMATCH_MX_LENGTH) { 15456 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3209, /* "%s: maximum stri..." */ 15457 libc.VaList(bp+16, (*amatch_vtab)(unsafe.Pointer(p)).FzClassName, AMATCH_MX_LENGTH)) 15458 rc = SQLITE_ERROR 15459 } else if (iLang < int64(0)) || (iLang > int64(AMATCH_MX_LANGID)) { 15460 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3241, /* "%s: iLang must b..." */ 15461 libc.VaList(bp+32, (*amatch_vtab)(unsafe.Pointer(p)).FzClassName, AMATCH_MX_LANGID)) 15462 rc = SQLITE_ERROR 15463 } else if (libc.Xstrcmp(tls, zFrom, ts+489 /* "" */) == 0) && (libc.Xstrcmp(tls, zTo, ts+3276 /* "?" */) == 0) { 15464 if ((*amatch_vtab)(unsafe.Pointer(p)).FrIns == 0) || ((*amatch_vtab)(unsafe.Pointer(p)).FrIns > rCost) { 15465 (*amatch_vtab)(unsafe.Pointer(p)).FrIns = rCost 15466 } 15467 } else if (libc.Xstrcmp(tls, zFrom, ts+3276 /* "?" */) == 0) && (libc.Xstrcmp(tls, zTo, ts+489 /* "" */) == 0) { 15468 if ((*amatch_vtab)(unsafe.Pointer(p)).FrDel == 0) || ((*amatch_vtab)(unsafe.Pointer(p)).FrDel > rCost) { 15469 (*amatch_vtab)(unsafe.Pointer(p)).FrDel = rCost 15470 } 15471 } else { 15472 pRule = sqlite3.Xsqlite3_malloc64(tls, (uint64((uint64(unsafe.Sizeof(amatch_rule{})) + uint64(nFrom)) + uint64(nTo)))) 15473 if pRule == uintptr(0) { 15474 rc = SQLITE_NOMEM 15475 } else { 15476 libc.Xmemset(tls, pRule, 0, uint64(unsafe.Sizeof(amatch_rule{}))) 15477 (*amatch_rule)(unsafe.Pointer(pRule)).FzFrom = ((pRule + 26 /* &.zTo */) + uintptr((nTo + 1))) 15478 (*amatch_rule)(unsafe.Pointer(pRule)).FnFrom = amatch_len(nFrom) 15479 libc.Xmemcpy(tls, (*amatch_rule)(unsafe.Pointer(pRule)).FzFrom, zFrom, (uint64(nFrom + 1))) 15480 libc.Xmemcpy(tls, pRule+26 /* &.zTo */, zTo, (uint64(nTo + 1))) 15481 (*amatch_rule)(unsafe.Pointer(pRule)).FnTo = amatch_len(nTo) 15482 (*amatch_rule)(unsafe.Pointer(pRule)).FrCost = rCost 15483 (*amatch_rule)(unsafe.Pointer(pRule)).FiLang = int32(iLang) 15484 } 15485 } 15486 15487 *(*uintptr)(unsafe.Pointer(ppRule)) = pRule 15488 return rc 15489 } 15490 15491 // Free all the content in the edit-cost-table 15492 func amatchFreeRules(tls *libc.TLS, p uintptr) { /* amatch.c:644:13: */ 15493 for (*amatch_vtab)(unsafe.Pointer(p)).FpRule != 0 { 15494 var pRule uintptr = (*amatch_vtab)(unsafe.Pointer(p)).FpRule 15495 (*amatch_vtab)(unsafe.Pointer(p)).FpRule = (*amatch_rule)(unsafe.Pointer(pRule)).FpNext 15496 sqlite3.Xsqlite3_free(tls, pRule) 15497 } 15498 (*amatch_vtab)(unsafe.Pointer(p)).FpRule = uintptr(0) 15499 } 15500 15501 // Load the content of the amatch data table into memory. 15502 func amatchLoadRules(tls *libc.TLS, db uintptr, p uintptr, pzErr uintptr) int32 { /* amatch.c:656:12: */ 15503 bp := tls.Alloc(192) 15504 defer tls.Free(192) 15505 15506 var rc int32 = SQLITE_OK // Return code 15507 var zSql uintptr // SELECT used to read from rules table 15508 var pHead uintptr = uintptr(0) 15509 15510 zSql = sqlite3.Xsqlite3_mprintf(tls, ts+3278 /* "SELECT * FROM %Q..." */, libc.VaList(bp, (*amatch_vtab)(unsafe.Pointer(p)).FzDb, (*amatch_vtab)(unsafe.Pointer(p)).FzCostTab)) 15511 if zSql == uintptr(0) { 15512 rc = SQLITE_NOMEM 15513 } else { 15514 var rc2 int32 // finalize() return code 15515 *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)) = uintptr(0) 15516 rc = sqlite3.Xsqlite3_prepare_v2(tls, db, zSql, -1, bp+56 /* &pStmt */, uintptr(0)) 15517 if rc != SQLITE_OK { 15518 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3298 /* "%s: %s" */, libc.VaList(bp+16, (*amatch_vtab)(unsafe.Pointer(p)).FzClassName, sqlite3.Xsqlite3_errmsg(tls, db))) 15519 } else if sqlite3.Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) != 4 { 15520 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3305, /* "%s: %s has %d co..." */ 15521 libc.VaList(bp+32, (*amatch_vtab)(unsafe.Pointer(p)).FzClassName, (*amatch_vtab)(unsafe.Pointer(p)).FzCostTab, sqlite3.Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))))) 15522 rc = SQLITE_ERROR 15523 } else { 15524 for (rc == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)))) { 15525 *(*uintptr)(unsafe.Pointer(bp + 64 /* pRule */)) = uintptr(0) 15526 rc = amatchLoadOneRule(tls, p, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)), bp+64 /* &pRule */, pzErr) 15527 if *(*uintptr)(unsafe.Pointer(bp + 64 /* pRule */)) != 0 { 15528 (*amatch_rule)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 64 /* pRule */)))).FpNext = pHead 15529 pHead = *(*uintptr)(unsafe.Pointer(bp + 64 /* pRule */)) 15530 } 15531 } 15532 } 15533 rc2 = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) 15534 if rc == SQLITE_OK { 15535 rc = rc2 15536 } 15537 } 15538 sqlite3.Xsqlite3_free(tls, zSql) 15539 15540 // All rules are now in a singly linked list starting at pHead. This 15541 // block sorts them by cost and then sets amatch_vtab.pRule to point to 15542 // point to the head of the sorted list. 15543 if rc == SQLITE_OK { 15544 var i uint32 15545 var pX uintptr 15546 // var a [15]uintptr at bp+72, 120 15547 15548 for i = uint32(0); uint64(i) < (uint64(unsafe.Sizeof([15]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0)))); i++ { 15549 *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)) = uintptr(0) 15550 } 15551 for (libc.AssignUintptr(&pX, pHead)) != uintptr(0) { 15552 pHead = (*amatch_rule)(unsafe.Pointer(pX)).FpNext 15553 (*amatch_rule)(unsafe.Pointer(pX)).FpNext = uintptr(0) 15554 for i = uint32(0); (*(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)) != 0) && (uint64(i) < ((uint64(unsafe.Sizeof([15]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0)))) - uint64(1))); i++ { 15555 pX = amatchMergeRules(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)), pX) 15556 *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)) = uintptr(0) 15557 } 15558 *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)) = amatchMergeRules(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)), pX) 15559 } 15560 pX = *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */)) 15561 i = uint32(1) 15562 for ; uint64(i) < (uint64(unsafe.Sizeof([15]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0)))); i++ { 15563 pX = amatchMergeRules(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)), pX) 15564 } 15565 (*amatch_vtab)(unsafe.Pointer(p)).FpRule = amatchMergeRules(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpRule, pX) 15566 } else { 15567 // An error has occurred. Setting p->pRule to point to the head of the 15568 // allocated list ensures that the list will be cleaned up in this case. 15569 15570 (*amatch_vtab)(unsafe.Pointer(p)).FpRule = pHead 15571 } 15572 15573 return rc 15574 } 15575 15576 // This function converts an SQL quoted string into an unquoted string 15577 // and returns a pointer to a buffer allocated using sqlite3_malloc() 15578 // containing the result. The caller should eventually free this buffer 15579 // using sqlite3_free. 15580 // 15581 // Examples: 15582 // 15583 // "abc" becomes abc 15584 // 'xyz' becomes xyz 15585 // [pqr] becomes pqr 15586 // `mno` becomes mno 15587 func amatchDequote(tls *libc.TLS, zIn uintptr) uintptr { /* amatch.c:740:13: */ 15588 var nIn sqlite3_int64 // Size of input string, in bytes 15589 var zOut uintptr // Output (dequoted) string 15590 15591 nIn = sqlite3_int64(libc.Xstrlen(tls, zIn)) 15592 zOut = sqlite3.Xsqlite3_malloc64(tls, (uint64(nIn + int64(1)))) 15593 if zOut != 0 { 15594 var q int8 = *(*int8)(unsafe.Pointer(zIn)) // Quote character (if any ) 15595 15596 if (((int32(q) != '[') && (int32(q) != '\'')) && (int32(q) != '"')) && (int32(q) != '`') { 15597 libc.Xmemcpy(tls, zOut, zIn, (size_t(nIn + int64(1)))) 15598 } else { 15599 var iOut int32 = 0 // Index of next byte to write to output 15600 var iIn int32 // Index of next byte to read from input 15601 15602 if int32(q) == '[' { 15603 q = int8(']') 15604 } 15605 for iIn = 1; sqlite3_int64(iIn) < nIn; iIn++ { 15606 if int32(*(*int8)(unsafe.Pointer(zIn + uintptr(iIn)))) == int32(q) { 15607 iIn++ 15608 } 15609 *(*int8)(unsafe.Pointer(zOut + uintptr(libc.PostIncInt32(&iOut, 1)))) = *(*int8)(unsafe.Pointer(zIn + uintptr(iIn))) 15610 } 15611 } 15612 15613 } 15614 return zOut 15615 } 15616 15617 // Deallocate the pVCheck prepared statement. 15618 func amatchVCheckClear(tls *libc.TLS, p uintptr) { /* amatch.c:769:13: */ 15619 if (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck != 0 { 15620 sqlite3.Xsqlite3_finalize(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck) 15621 (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck = uintptr(0) 15622 } 15623 } 15624 15625 // Deallocate an amatch_vtab object 15626 func amatchFree(tls *libc.TLS, p uintptr) { /* amatch.c:779:13: */ 15627 if p != 0 { 15628 amatchFreeRules(tls, p) 15629 amatchVCheckClear(tls, p) 15630 sqlite3.Xsqlite3_free(tls, (*amatch_vtab)(unsafe.Pointer(p)).FzClassName) 15631 sqlite3.Xsqlite3_free(tls, (*amatch_vtab)(unsafe.Pointer(p)).FzDb) 15632 sqlite3.Xsqlite3_free(tls, (*amatch_vtab)(unsafe.Pointer(p)).FzCostTab) 15633 sqlite3.Xsqlite3_free(tls, (*amatch_vtab)(unsafe.Pointer(p)).FzVocabTab) 15634 sqlite3.Xsqlite3_free(tls, (*amatch_vtab)(unsafe.Pointer(p)).FzVocabWord) 15635 sqlite3.Xsqlite3_free(tls, (*amatch_vtab)(unsafe.Pointer(p)).FzVocabLang) 15636 sqlite3.Xsqlite3_free(tls, (*amatch_vtab)(unsafe.Pointer(p)).FzSelf) 15637 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(amatch_vtab{}))) 15638 sqlite3.Xsqlite3_free(tls, p) 15639 } 15640 } 15641 15642 // xDisconnect/xDestroy method for the amatch module. 15643 func amatchDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* amatch.c:798:12: */ 15644 var p uintptr = pVtab 15645 15646 amatchFree(tls, p) 15647 return SQLITE_OK 15648 } 15649 15650 // Check to see if the argument is of the form: 15651 // 15652 // KEY = VALUE 15653 // 15654 // If it is, return a pointer to the first character of VALUE. 15655 // If not, return NULL. Spaces around the = are ignored. 15656 func amatchValueOfKey(tls *libc.TLS, zKey uintptr, zStr uintptr) uintptr { /* amatch.c:813:19: */ 15657 var nKey int32 = int32(libc.Xstrlen(tls, zKey)) 15658 var nStr int32 = int32(libc.Xstrlen(tls, zStr)) 15659 var i int32 15660 if nStr < (nKey + 1) { 15661 return uintptr(0) 15662 } 15663 if libc.Xmemcmp(tls, zStr, zKey, uint64(nKey)) != 0 { 15664 return uintptr(0) 15665 } 15666 for i = nKey; (int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(zStr + uintptr(i))))))*2))) & int32(_ISspace)) != 0; i++ { 15667 } 15668 if int32(*(*int8)(unsafe.Pointer(zStr + uintptr(i)))) != '=' { 15669 return uintptr(0) 15670 } 15671 i++ 15672 for (int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(zStr + uintptr(i))))))*2))) & int32(_ISspace)) != 0 { 15673 i++ 15674 } 15675 return (zStr + uintptr(i)) 15676 } 15677 15678 // xConnect/xCreate method for the amatch module. Arguments are: 15679 // 15680 // argv[0] -> module name ("approximate_match") 15681 // argv[1] -> database name 15682 // argv[2] -> table name 15683 // argv[3...] -> arguments 15684 func amatchConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* amatch.c:834:12: */ 15685 bp := tls.Alloc(32) 15686 defer tls.Free(32) 15687 15688 var rc int32 // Return code 15689 var pNew uintptr // New virtual table 15690 var zModule uintptr 15691 var zDb uintptr 15692 var zVal uintptr 15693 var i int32 15694 rc = SQLITE_OK 15695 pNew = uintptr(0) 15696 zModule = *(*uintptr)(unsafe.Pointer(argv)) 15697 zDb = *(*uintptr)(unsafe.Pointer(argv + 1*8)) 15698 15699 _ = pAux 15700 *(*uintptr)(unsafe.Pointer(ppVtab)) = uintptr(0) 15701 pNew = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(amatch_vtab{}))) 15702 if !(pNew == uintptr(0)) { 15703 goto __1 15704 } 15705 return SQLITE_NOMEM 15706 __1: 15707 ; 15708 rc = SQLITE_NOMEM 15709 libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(amatch_vtab{}))) 15710 (*amatch_vtab)(unsafe.Pointer(pNew)).Fdb = db 15711 (*amatch_vtab)(unsafe.Pointer(pNew)).FzClassName = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zModule)) 15712 if !((*amatch_vtab)(unsafe.Pointer(pNew)).FzClassName == uintptr(0)) { 15713 goto __2 15714 } 15715 goto amatchConnectError 15716 __2: 15717 ; 15718 (*amatch_vtab)(unsafe.Pointer(pNew)).FzDb = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+8, zDb)) 15719 if !((*amatch_vtab)(unsafe.Pointer(pNew)).FzDb == uintptr(0)) { 15720 goto __3 15721 } 15722 goto amatchConnectError 15723 __3: 15724 ; 15725 (*amatch_vtab)(unsafe.Pointer(pNew)).FzSelf = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) 15726 if !((*amatch_vtab)(unsafe.Pointer(pNew)).FzSelf == uintptr(0)) { 15727 goto __4 15728 } 15729 goto amatchConnectError 15730 __4: 15731 ; 15732 i = 3 15733 __5: 15734 if !(i < argc) { 15735 goto __7 15736 } 15737 zVal = amatchValueOfKey(tls, ts+3339 /* "vocabulary_table" */, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) 15738 if !(zVal != 0) { 15739 goto __8 15740 } 15741 sqlite3.Xsqlite3_free(tls, (*amatch_vtab)(unsafe.Pointer(pNew)).FzVocabTab) 15742 (*amatch_vtab)(unsafe.Pointer(pNew)).FzVocabTab = amatchDequote(tls, zVal) 15743 if !((*amatch_vtab)(unsafe.Pointer(pNew)).FzVocabTab == uintptr(0)) { 15744 goto __9 15745 } 15746 goto amatchConnectError 15747 __9: 15748 ; 15749 goto __6 15750 __8: 15751 ; 15752 zVal = amatchValueOfKey(tls, ts+3356 /* "vocabulary_word" */, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) 15753 if !(zVal != 0) { 15754 goto __10 15755 } 15756 sqlite3.Xsqlite3_free(tls, (*amatch_vtab)(unsafe.Pointer(pNew)).FzVocabWord) 15757 (*amatch_vtab)(unsafe.Pointer(pNew)).FzVocabWord = amatchDequote(tls, zVal) 15758 if !((*amatch_vtab)(unsafe.Pointer(pNew)).FzVocabWord == uintptr(0)) { 15759 goto __11 15760 } 15761 goto amatchConnectError 15762 __11: 15763 ; 15764 goto __6 15765 __10: 15766 ; 15767 zVal = amatchValueOfKey(tls, ts+3372 /* "vocabulary_langu..." */, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) 15768 if !(zVal != 0) { 15769 goto __12 15770 } 15771 sqlite3.Xsqlite3_free(tls, (*amatch_vtab)(unsafe.Pointer(pNew)).FzVocabLang) 15772 (*amatch_vtab)(unsafe.Pointer(pNew)).FzVocabLang = amatchDequote(tls, zVal) 15773 if !((*amatch_vtab)(unsafe.Pointer(pNew)).FzVocabLang == uintptr(0)) { 15774 goto __13 15775 } 15776 goto amatchConnectError 15777 __13: 15778 ; 15779 goto __6 15780 __12: 15781 ; 15782 zVal = amatchValueOfKey(tls, ts+3392 /* "edit_distances" */, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) 15783 if !(zVal != 0) { 15784 goto __14 15785 } 15786 sqlite3.Xsqlite3_free(tls, (*amatch_vtab)(unsafe.Pointer(pNew)).FzCostTab) 15787 (*amatch_vtab)(unsafe.Pointer(pNew)).FzCostTab = amatchDequote(tls, zVal) 15788 if !((*amatch_vtab)(unsafe.Pointer(pNew)).FzCostTab == uintptr(0)) { 15789 goto __15 15790 } 15791 goto amatchConnectError 15792 __15: 15793 ; 15794 goto __6 15795 __14: 15796 ; 15797 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3407 /* "unrecognized arg..." */, libc.VaList(bp+24, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)))) 15798 amatchFree(tls, pNew) 15799 *(*uintptr)(unsafe.Pointer(ppVtab)) = uintptr(0) 15800 return SQLITE_ERROR 15801 goto __6 15802 __6: 15803 i++ 15804 goto __5 15805 goto __7 15806 __7: 15807 ; 15808 rc = SQLITE_OK 15809 if !((*amatch_vtab)(unsafe.Pointer(pNew)).FzCostTab == uintptr(0)) { 15810 goto __16 15811 } 15812 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3436 /* "no edit_distance..." */, 0) 15813 rc = SQLITE_ERROR 15814 goto __17 15815 __16: 15816 rc = amatchLoadRules(tls, db, pNew, pzErr) 15817 __17: 15818 ; 15819 if !(rc == SQLITE_OK) { 15820 goto __18 15821 } 15822 sqlite3.Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_INNOCUOUS, 0) 15823 rc = sqlite3.Xsqlite3_declare_vtab(tls, db, 15824 15825 ts+3470 /* "CREATE TABLE x(w..." */) 15826 __18: 15827 ; 15828 if !(rc != SQLITE_OK) { 15829 goto __19 15830 } 15831 amatchFree(tls, pNew) 15832 __19: 15833 ; 15834 *(*uintptr)(unsafe.Pointer(ppVtab)) = (pNew /* &.base */) 15835 return rc 15836 15837 amatchConnectError: 15838 amatchFree(tls, pNew) 15839 return rc 15840 } 15841 15842 // Open a new amatch cursor. 15843 func amatchOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* amatch.c:928:12: */ 15844 var p uintptr = pVTab 15845 var pCur uintptr 15846 pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(amatch_cursor{}))) 15847 if pCur == uintptr(0) { 15848 return SQLITE_NOMEM 15849 } 15850 libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(amatch_cursor{}))) 15851 (*amatch_cursor)(unsafe.Pointer(pCur)).FpVtab = p 15852 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) 15853 (*amatch_vtab)(unsafe.Pointer(p)).FnCursor++ 15854 return SQLITE_OK 15855 } 15856 15857 // Free up all the memory allocated by a cursor. Set it rLimit to 0 15858 // to indicate that it is at EOF. 15859 func amatchClearCursor(tls *libc.TLS, pCur uintptr) { /* amatch.c:944:13: */ 15860 var pWord uintptr 15861 var pNextWord uintptr 15862 for pWord = (*amatch_cursor)(unsafe.Pointer(pCur)).FpAllWords; pWord != 0; pWord = pNextWord { 15863 pNextWord = (*amatch_word)(unsafe.Pointer(pWord)).FpNext 15864 sqlite3.Xsqlite3_free(tls, pWord) 15865 } 15866 (*amatch_cursor)(unsafe.Pointer(pCur)).FpAllWords = uintptr(0) 15867 sqlite3.Xsqlite3_free(tls, (*amatch_cursor)(unsafe.Pointer(pCur)).FzInput) 15868 (*amatch_cursor)(unsafe.Pointer(pCur)).FzInput = uintptr(0) 15869 sqlite3.Xsqlite3_free(tls, (*amatch_cursor)(unsafe.Pointer(pCur)).FzBuf) 15870 (*amatch_cursor)(unsafe.Pointer(pCur)).FzBuf = uintptr(0) 15871 (*amatch_cursor)(unsafe.Pointer(pCur)).FnBuf = 0 15872 (*amatch_cursor)(unsafe.Pointer(pCur)).FpCost = uintptr(0) 15873 (*amatch_cursor)(unsafe.Pointer(pCur)).FpWord = uintptr(0) 15874 (*amatch_cursor)(unsafe.Pointer(pCur)).FpCurrent = uintptr(0) 15875 (*amatch_cursor)(unsafe.Pointer(pCur)).FrLimit = 1000000 15876 (*amatch_cursor)(unsafe.Pointer(pCur)).FiLang = 0 15877 (*amatch_cursor)(unsafe.Pointer(pCur)).FnWord = 0 15878 } 15879 15880 // Close a amatch cursor. 15881 func amatchClose(tls *libc.TLS, cur uintptr) int32 { /* amatch.c:967:12: */ 15882 var pCur uintptr = cur 15883 amatchClearCursor(tls, pCur) 15884 (*amatch_vtab)(unsafe.Pointer((*amatch_cursor)(unsafe.Pointer(pCur)).FpVtab)).FnCursor-- 15885 sqlite3.Xsqlite3_free(tls, pCur) 15886 return SQLITE_OK 15887 } 15888 15889 // Render a 24-bit unsigned integer as a 4-byte base-64 number. 15890 func amatchEncodeInt(tls *libc.TLS, x int32, z uintptr) { /* amatch.c:978:13: */ 15891 *(*int8)(unsafe.Pointer(z)) = a[((x >> 18) & 0x3f)] 15892 *(*int8)(unsafe.Pointer(z + 1)) = a[((x >> 12) & 0x3f)] 15893 *(*int8)(unsafe.Pointer(z + 2)) = a[((x >> 6) & 0x3f)] 15894 *(*int8)(unsafe.Pointer(z + 3)) = a[(x & 0x3f)] 15895 } 15896 15897 var a = *(*[65]int8)(unsafe.Pointer(ts + 3537 /* "0123456789ABCDEF..." */)) /* amatch.c:979:21 */ 15898 15899 // Write the zCost[] field for a amatch_word object 15900 func amatchWriteCost(tls *libc.TLS, pWord uintptr) { /* amatch.c:996:13: */ 15901 amatchEncodeInt(tls, (*amatch_word)(unsafe.Pointer(pWord)).FrCost, pWord+112 /* &.zCost */) 15902 amatchEncodeInt(tls, (*amatch_word)(unsafe.Pointer(pWord)).FiSeq, ((pWord + 112 /* &.zCost */) + uintptr(4))) 15903 *(*int8)(unsafe.Pointer((pWord + 112 /* &.zCost */) + 8)) = int8(0) 15904 } 15905 15906 // Circumvent compiler warnings about the use of strcpy() by supplying 15907 // our own implementation. 15908 func amatchStrcpy(tls *libc.TLS, dest uintptr, src uintptr) { /* amatch.c:1005:13: */ 15909 for (int32(libc.AssignPtrInt8(libc.PostIncUintptr(&dest, 1), *(*int8)(unsafe.Pointer(libc.PostIncUintptr(&src, 1)))))) != 0 { 15910 } 15911 } 15912 15913 func amatchStrcat(tls *libc.TLS, dest uintptr, src uintptr) { /* amatch.c:1008:13: */ 15914 for *(*int8)(unsafe.Pointer(dest)) != 0 { 15915 dest++ 15916 } 15917 amatchStrcpy(tls, dest, src) 15918 } 15919 15920 // Add a new amatch_word object to the queue. 15921 // 15922 // If a prior amatch_word object with the same zWord, and nMatch 15923 // already exists, update its rCost (if the new rCost is less) but 15924 // otherwise leave it unchanged. Do not add a duplicate. 15925 // 15926 // Do nothing if the cost exceeds threshold. 15927 func amatchAddWord(tls *libc.TLS, pCur uintptr, rCost amatch_cost, nMatch int32, zWordBase uintptr, zWordTail uintptr) { /* amatch.c:1022:13: */ 15928 bp := tls.Alloc(4) 15929 defer tls.Free(4) 15930 15931 var pWord uintptr 15932 var pNode uintptr 15933 var pOther uintptr 15934 _ = pOther 15935 var nBase int32 15936 var nTail int32 15937 // var zBuf [4]int8 at bp, 4 15938 15939 if rCost > (*amatch_cursor)(unsafe.Pointer(pCur)).FrLimit { 15940 return 15941 } 15942 nBase = int32(libc.Xstrlen(tls, zWordBase)) 15943 nTail = int32(libc.Xstrlen(tls, zWordTail)) 15944 if ((nBase + nTail) + 3) > (*amatch_cursor)(unsafe.Pointer(pCur)).FnBuf { 15945 (*amatch_cursor)(unsafe.Pointer(pCur)).FnBuf = ((nBase + nTail) + 100) 15946 (*amatch_cursor)(unsafe.Pointer(pCur)).FzBuf = sqlite3.Xsqlite3_realloc(tls, (*amatch_cursor)(unsafe.Pointer(pCur)).FzBuf, (*amatch_cursor)(unsafe.Pointer(pCur)).FnBuf) 15947 if (*amatch_cursor)(unsafe.Pointer(pCur)).FzBuf == uintptr(0) { 15948 (*amatch_cursor)(unsafe.Pointer(pCur)).FnBuf = 0 15949 return 15950 } 15951 } 15952 amatchEncodeInt(tls, nMatch, bp /* &zBuf[0] */) 15953 libc.Xmemcpy(tls, (*amatch_cursor)(unsafe.Pointer(pCur)).FzBuf, (bp /* &zBuf[0] */ + uintptr(2)), uint64(2)) 15954 libc.Xmemcpy(tls, ((*amatch_cursor)(unsafe.Pointer(pCur)).FzBuf + uintptr(2)), zWordBase, uint64(nBase)) 15955 libc.Xmemcpy(tls, (((*amatch_cursor)(unsafe.Pointer(pCur)).FzBuf + uintptr(2)) + uintptr(nBase)), zWordTail, (uint64(nTail + 1))) 15956 pNode = amatchAvlSearch(tls, (*amatch_cursor)(unsafe.Pointer(pCur)).FpWord, (*amatch_cursor)(unsafe.Pointer(pCur)).FzBuf) 15957 if pNode != 0 { 15958 pWord = (*amatch_avl)(unsafe.Pointer(pNode)).FpWord 15959 if (*amatch_word)(unsafe.Pointer(pWord)).FrCost > rCost { 15960 amatchAvlRemove(tls, (pCur + 80 /* &.pCost */), (pWord + 8 /* &.sCost */)) 15961 (*amatch_word)(unsafe.Pointer(pWord)).FrCost = rCost 15962 amatchWriteCost(tls, pWord) 15963 pOther = amatchAvlInsert(tls, (pCur + 80 /* &.pCost */), (pWord + 8 /* &.sCost */)) 15964 _ = pOther 15965 } 15966 return 15967 } 15968 pWord = sqlite3.Xsqlite3_malloc64(tls, (uint64(((uint64(unsafe.Sizeof(amatch_word{})) + uint64(nBase)) + uint64(nTail)) - uint64(1)))) 15969 if pWord == uintptr(0) { 15970 return 15971 } 15972 libc.Xmemset(tls, pWord, 0, uint64(unsafe.Sizeof(amatch_word{}))) 15973 (*amatch_word)(unsafe.Pointer(pWord)).FrCost = rCost 15974 (*amatch_word)(unsafe.Pointer(pWord)).FiSeq = libc.PostIncInt32(&(*amatch_cursor)(unsafe.Pointer(pCur)).FnWord, 1) 15975 amatchWriteCost(tls, pWord) 15976 (*amatch_word)(unsafe.Pointer(pWord)).FnMatch = int16(nMatch) 15977 (*amatch_word)(unsafe.Pointer(pWord)).FpNext = (*amatch_cursor)(unsafe.Pointer(pCur)).FpAllWords 15978 (*amatch_cursor)(unsafe.Pointer(pCur)).FpAllWords = pWord 15979 (*amatch_word)(unsafe.Pointer(pWord)).FsCost.FzKey = pWord + 112 /* &.zCost */ 15980 (*amatch_word)(unsafe.Pointer(pWord)).FsCost.FpWord = pWord 15981 pOther = amatchAvlInsert(tls, (pCur + 80 /* &.pCost */), (pWord + 8 /* &.sCost */)) 15982 _ = pOther 15983 (*amatch_word)(unsafe.Pointer(pWord)).FsWord.FzKey = pWord + 124 /* &.zWord */ 15984 (*amatch_word)(unsafe.Pointer(pWord)).FsWord.FpWord = pWord 15985 amatchStrcpy(tls, pWord+124 /* &.zWord */, (*amatch_cursor)(unsafe.Pointer(pCur)).FzBuf) 15986 pOther = amatchAvlInsert(tls, (pCur + 88 /* &.pWord */), (pWord + 56 /* &.sWord */)) 15987 _ = pOther 15988 } 15989 15990 // Advance a cursor to its next row of output 15991 func amatchNext(tls *libc.TLS, cur uintptr) int32 { /* amatch.c:1102:12: */ 15992 bp := tls.Alloc(80) 15993 defer tls.Free(80) 15994 15995 var pCur uintptr = cur 15996 var pWord uintptr = uintptr(0) 15997 var pNode uintptr 15998 var isMatch int32 = 0 15999 var p uintptr = (*amatch_cursor)(unsafe.Pointer(pCur)).FpVtab 16000 var nWord int32 16001 var rc int32 16002 var i int32 16003 var zW uintptr 16004 var pRule uintptr 16005 var zBuf uintptr = uintptr(0) 16006 var nBuf int8 = int8(0) 16007 // var zNext [8]int8 at bp+64, 8 16008 16009 // var zNextIn [8]int8 at bp+72, 8 16010 16011 var nNextIn int32 16012 16013 if (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck == uintptr(0) { 16014 var zSql uintptr 16015 if ((*amatch_vtab)(unsafe.Pointer(p)).FzVocabLang != 0) && (*(*int8)(unsafe.Pointer((*amatch_vtab)(unsafe.Pointer(p)).FzVocabLang)) != 0) { 16016 zSql = sqlite3.Xsqlite3_mprintf(tls, 16017 ts+3602, /* "SELECT \"%w\" FROM..." */ 16018 16019 libc.VaList(bp, ts+3624, /* " WHERE \"%w\">=?1 ..." */ 16020 (*amatch_vtab)(unsafe.Pointer(p)).FzVocabWord, (*amatch_vtab)(unsafe.Pointer(p)).FzVocabTab, 16021 (*amatch_vtab)(unsafe.Pointer(p)).FzVocabWord, (*amatch_vtab)(unsafe.Pointer(p)).FzVocabLang)) 16022 } else { 16023 zSql = sqlite3.Xsqlite3_mprintf(tls, 16024 16025 ts+3663, /* "SELECT \"%w\" FROM..." */ 16026 libc.VaList(bp+40, (*amatch_vtab)(unsafe.Pointer(p)).FzVocabWord, (*amatch_vtab)(unsafe.Pointer(p)).FzVocabTab, 16027 (*amatch_vtab)(unsafe.Pointer(p)).FzVocabWord)) 16028 } 16029 rc = sqlite3.Xsqlite3_prepare_v2(tls, (*amatch_vtab)(unsafe.Pointer(p)).Fdb, zSql, -1, (p + 112 /* &.pVCheck */), uintptr(0)) 16030 sqlite3.Xsqlite3_free(tls, zSql) 16031 if rc != 0 { 16032 return rc 16033 } 16034 } 16035 sqlite3.Xsqlite3_bind_int(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck, 2, (*amatch_cursor)(unsafe.Pointer(pCur)).FiLang) 16036 16037 for ok := true; ok; ok = !(isMatch != 0) { 16038 pNode = amatchAvlFirst(tls, (*amatch_cursor)(unsafe.Pointer(pCur)).FpCost) 16039 if pNode == uintptr(0) { 16040 pWord = uintptr(0) 16041 break 16042 } 16043 pWord = (*amatch_avl)(unsafe.Pointer(pNode)).FpWord 16044 amatchAvlRemove(tls, (pCur + 80 /* &.pCost */), (pWord + 8 /* &.sCost */)) 16045 16046 nWord = int32(libc.Xstrlen(tls, ((pWord + 124 /* &.zWord */) + uintptr(2)))) 16047 if (nWord + 20) > int32(nBuf) { 16048 nBuf = (int8(nWord + 100)) 16049 zBuf = sqlite3.Xsqlite3_realloc(tls, zBuf, int32(nBuf)) 16050 if zBuf == uintptr(0) { 16051 return SQLITE_NOMEM 16052 } 16053 } 16054 amatchStrcpy(tls, zBuf, ((pWord + 124 /* &.zWord */) + uintptr(2))) 16055 *(*int8)(unsafe.Pointer(bp + 64 /* &zNext[0] */)) = int8(0) 16056 *(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */)) = *(*int8)(unsafe.Pointer((*amatch_cursor)(unsafe.Pointer(pCur)).FzInput + uintptr((*amatch_word)(unsafe.Pointer(pWord)).FnMatch))) 16057 if *(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */)) != 0 { 16058 for i = 1; (i <= 4) && ((int32(*(*int8)(unsafe.Pointer((*amatch_cursor)(unsafe.Pointer(pCur)).FzInput + uintptr((int32((*amatch_word)(unsafe.Pointer(pWord)).FnMatch) + i))))) & 0xc0) == 0x80); i++ { 16059 *(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */ + uintptr(i))) = *(*int8)(unsafe.Pointer((*amatch_cursor)(unsafe.Pointer(pCur)).FzInput + uintptr((int32((*amatch_word)(unsafe.Pointer(pWord)).FnMatch) + i)))) 16060 } 16061 *(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */ + uintptr(i))) = int8(0) 16062 nNextIn = i 16063 } else { 16064 nNextIn = 0 16065 } 16066 16067 if (*(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */)) != 0) && (int32(*(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */))) != '*') { 16068 sqlite3.Xsqlite3_reset(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck) 16069 amatchStrcat(tls, zBuf, bp+72 /* &zNextIn[0] */) 16070 sqlite3.Xsqlite3_bind_text(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck, 1, zBuf, (nWord + nNextIn), uintptr(0)) 16071 rc = sqlite3.Xsqlite3_step(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck) 16072 if rc == SQLITE_ROW { 16073 zW = sqlite3.Xsqlite3_column_text(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck, 0) 16074 if libc.Xstrncmp(tls, zBuf, zW, (uint64(nWord+nNextIn))) == 0 { 16075 amatchAddWord(tls, pCur, (*amatch_word)(unsafe.Pointer(pWord)).FrCost, (int32((*amatch_word)(unsafe.Pointer(pWord)).FnMatch) + nNextIn), zBuf, ts+489 /* "" */) 16076 } 16077 } 16078 *(*int8)(unsafe.Pointer(zBuf + uintptr(nWord))) = int8(0) 16079 } 16080 16081 for 1 != 0 { 16082 amatchStrcpy(tls, (zBuf + uintptr(nWord)), bp+64 /* &zNext[0] */) 16083 sqlite3.Xsqlite3_reset(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck) 16084 sqlite3.Xsqlite3_bind_text(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck, 1, zBuf, -1, libc.UintptrFromInt32(-1)) 16085 rc = sqlite3.Xsqlite3_step(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck) 16086 if rc != SQLITE_ROW { 16087 break 16088 } 16089 zW = sqlite3.Xsqlite3_column_text(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck, 0) 16090 amatchStrcpy(tls, (zBuf + uintptr(nWord)), bp+64 /* &zNext[0] */) 16091 if libc.Xstrncmp(tls, zW, zBuf, uint64(nWord)) != 0 { 16092 break 16093 } 16094 if ((int32(*(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */))) == '*') && (int32(*(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */ + 1))) == 0)) || 16095 ((int32(*(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */))) == 0) && (int32(*(*int8)(unsafe.Pointer(zW + uintptr(nWord)))) == 0)) { 16096 isMatch = 1 16097 *(*int8)(unsafe.Pointer(bp + 72 /* &zNextIn[0] */)) = int8(0) 16098 nNextIn = 0 16099 break 16100 } 16101 *(*int8)(unsafe.Pointer(bp + 64 /* &zNext[0] */)) = *(*int8)(unsafe.Pointer(zW + uintptr(nWord))) 16102 for i = 1; (i <= 4) && ((int32(*(*int8)(unsafe.Pointer(zW + uintptr((nWord + i))))) & 0xc0) == 0x80); i++ { 16103 *(*int8)(unsafe.Pointer(bp + 64 /* &zNext[0] */ + uintptr(i))) = *(*int8)(unsafe.Pointer(zW + uintptr((nWord + i)))) 16104 } 16105 *(*int8)(unsafe.Pointer(bp + 64 /* &zNext[0] */ + uintptr(i))) = int8(0) 16106 *(*int8)(unsafe.Pointer(zBuf + uintptr(nWord))) = int8(0) 16107 if (*amatch_vtab)(unsafe.Pointer(p)).FrIns > 0 { 16108 amatchAddWord(tls, pCur, ((*amatch_word)(unsafe.Pointer(pWord)).FrCost + (*amatch_vtab)(unsafe.Pointer(p)).FrIns), int32((*amatch_word)(unsafe.Pointer(pWord)).FnMatch), 16109 zBuf, bp+64 /* &zNext[0] */) 16110 } 16111 if (*amatch_vtab)(unsafe.Pointer(p)).FrSub > 0 { 16112 amatchAddWord(tls, pCur, ((*amatch_word)(unsafe.Pointer(pWord)).FrCost + (*amatch_vtab)(unsafe.Pointer(p)).FrSub), (int32((*amatch_word)(unsafe.Pointer(pWord)).FnMatch) + nNextIn), 16113 zBuf, bp+64 /* &zNext[0] */) 16114 } 16115 if ((*amatch_vtab)(unsafe.Pointer(p)).FrIns < 0) && ((*amatch_vtab)(unsafe.Pointer(p)).FrSub < 0) { 16116 break 16117 } 16118 *(*int8)(unsafe.Pointer(bp + 64 /* &zNext[0] */ + uintptr((i - 1))))++ // FIX ME 16119 } 16120 sqlite3.Xsqlite3_reset(tls, (*amatch_vtab)(unsafe.Pointer(p)).FpVCheck) 16121 16122 if (*amatch_vtab)(unsafe.Pointer(p)).FrDel > 0 { 16123 *(*int8)(unsafe.Pointer(zBuf + uintptr(nWord))) = int8(0) 16124 amatchAddWord(tls, pCur, ((*amatch_word)(unsafe.Pointer(pWord)).FrCost + (*amatch_vtab)(unsafe.Pointer(p)).FrDel), (int32((*amatch_word)(unsafe.Pointer(pWord)).FnMatch) + nNextIn), 16125 zBuf, ts+489 /* "" */) 16126 } 16127 16128 for pRule = (*amatch_vtab)(unsafe.Pointer(p)).FpRule; pRule != 0; pRule = (*amatch_rule)(unsafe.Pointer(pRule)).FpNext { 16129 if (*amatch_rule)(unsafe.Pointer(pRule)).FiLang != (*amatch_cursor)(unsafe.Pointer(pCur)).FiLang { 16130 continue 16131 } 16132 if libc.Xstrncmp(tls, (*amatch_rule)(unsafe.Pointer(pRule)).FzFrom, ((*amatch_cursor)(unsafe.Pointer(pCur)).FzInput+uintptr((*amatch_word)(unsafe.Pointer(pWord)).FnMatch)), uint64((*amatch_rule)(unsafe.Pointer(pRule)).FnFrom)) == 0 { 16133 amatchAddWord(tls, pCur, ((*amatch_word)(unsafe.Pointer(pWord)).FrCost + (*amatch_rule)(unsafe.Pointer(pRule)).FrCost), 16134 (int32((*amatch_word)(unsafe.Pointer(pWord)).FnMatch) + int32((*amatch_rule)(unsafe.Pointer(pRule)).FnFrom)), ((pWord + 124 /* &.zWord */) + uintptr(2)), pRule+26 /* &.zTo */) 16135 } 16136 } 16137 } 16138 (*amatch_cursor)(unsafe.Pointer(pCur)).FpCurrent = pWord 16139 sqlite3.Xsqlite3_free(tls, zBuf) 16140 return SQLITE_OK 16141 } 16142 16143 // Called to "rewind" a cursor back to the beginning so that 16144 // it starts its output over again. Always called at least once 16145 // prior to any amatchColumn, amatchRowid, or amatchEof call. 16146 func amatchFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* amatch.c:1251:12: */ 16147 bp := tls.Alloc(8) 16148 defer tls.Free(8) 16149 16150 var pCur uintptr = pVtabCursor 16151 var zWord uintptr = ts + 3711 /* "*" */ 16152 var idx int32 16153 16154 amatchClearCursor(tls, pCur) 16155 idx = 0 16156 if (idxNum & 1) != 0 { 16157 zWord = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 16158 idx++ 16159 } 16160 if (idxNum & 2) != 0 { 16161 (*amatch_cursor)(unsafe.Pointer(pCur)).FrLimit = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(idx)*8))) 16162 idx++ 16163 } 16164 if (idxNum & 4) != 0 { 16165 (*amatch_cursor)(unsafe.Pointer(pCur)).FiLang = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(idx)*8))) 16166 idx++ 16167 } 16168 (*amatch_cursor)(unsafe.Pointer(pCur)).FzInput = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zWord)) 16169 if (*amatch_cursor)(unsafe.Pointer(pCur)).FzInput == uintptr(0) { 16170 return SQLITE_NOMEM 16171 } 16172 amatchAddWord(tls, pCur, 0, 0, ts+489 /* "" */, ts+489 /* "" */) 16173 amatchNext(tls, pVtabCursor) 16174 16175 return SQLITE_OK 16176 } 16177 16178 // Only the word and distance columns have values. All other columns 16179 // return NULL 16180 func amatchColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* amatch.c:1286:12: */ 16181 var pCur uintptr = cur 16182 switch i { 16183 case AMATCH_COL_WORD: 16184 { 16185 sqlite3.Xsqlite3_result_text(tls, ctx, (((*amatch_cursor)(unsafe.Pointer(pCur)).FpCurrent + 124 /* &.zWord */) + uintptr(2)), -1, uintptr(0)) 16186 break 16187 16188 } 16189 case AMATCH_COL_DISTANCE: 16190 { 16191 sqlite3.Xsqlite3_result_int(tls, ctx, (*amatch_word)(unsafe.Pointer((*amatch_cursor)(unsafe.Pointer(pCur)).FpCurrent)).FrCost) 16192 break 16193 16194 } 16195 case AMATCH_COL_LANGUAGE: 16196 { 16197 sqlite3.Xsqlite3_result_int(tls, ctx, (*amatch_cursor)(unsafe.Pointer(pCur)).FiLang) 16198 break 16199 16200 } 16201 case AMATCH_COL_NWORD: 16202 { 16203 sqlite3.Xsqlite3_result_int(tls, ctx, (*amatch_cursor)(unsafe.Pointer(pCur)).FnWord) 16204 break 16205 16206 } 16207 default: 16208 { 16209 sqlite3.Xsqlite3_result_null(tls, ctx) 16210 break 16211 16212 } 16213 } 16214 return SQLITE_OK 16215 } 16216 16217 // The rowid. 16218 func amatchRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* amatch.c:1316:12: */ 16219 var pCur uintptr = cur 16220 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*amatch_cursor)(unsafe.Pointer(pCur)).FiRowid 16221 return SQLITE_OK 16222 } 16223 16224 // EOF indicator 16225 func amatchEof(tls *libc.TLS, cur uintptr) int32 { /* amatch.c:1325:12: */ 16226 var pCur uintptr = cur 16227 return (libc.Bool32((*amatch_cursor)(unsafe.Pointer(pCur)).FpCurrent == uintptr(0))) 16228 } 16229 16230 // Search for terms of these forms: 16231 // 16232 // (A) word MATCH $str 16233 // (B1) distance < $value 16234 // (B2) distance <= $value 16235 // (C) language == $language 16236 // 16237 // The distance< and distance<= are both treated as distance<=. 16238 // The query plan number is a bit vector: 16239 // 16240 // bit 1: Term of the form (A) found 16241 // bit 2: Term like (B1) or (B2) found 16242 // bit 3: Term like (C) found 16243 // 16244 // If bit-1 is set, $str is always in filter.argv[0]. If bit-2 is set 16245 // then $value is in filter.argv[0] if bit-1 is clear and is in 16246 // filter.argv[1] if bit-1 is set. If bit-3 is set, then $ruleid is 16247 // in filter.argv[0] if bit-1 and bit-2 are both zero, is in 16248 // filter.argv[1] if exactly one of bit-1 and bit-2 are set, and is in 16249 // filter.argv[2] if both bit-1 and bit-2 are set. 16250 func amatchBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* amatch.c:1352:12: */ 16251 var iPlan int32 = 0 16252 var iDistTerm int32 = -1 16253 var iLangTerm int32 = -1 16254 var i int32 16255 var pConstraint uintptr 16256 16257 _ = tab 16258 pConstraint = (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint 16259 i = 0 16260 __1: 16261 if !(i < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { 16262 goto __3 16263 } 16264 { 16265 if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 { 16266 goto __2 16267 } 16268 if (((iPlan & 1) == 0) && 16269 ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 0)) && 16270 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH) { 16271 iPlan = iPlan | (1) 16272 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 1 16273 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) 16274 } 16275 if (((iPlan & 2) == 0) && 16276 ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 1)) && 16277 ((int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LT) || 16278 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LE)) { 16279 iPlan = iPlan | (2) 16280 iDistTerm = i 16281 } 16282 if (((iPlan & 4) == 0) && 16283 ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 2)) && 16284 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { 16285 iPlan = iPlan | (4) 16286 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) 16287 iLangTerm = i 16288 } 16289 16290 } 16291 goto __2 16292 __2: 16293 i++ 16294 pConstraint += 12 16295 goto __1 16296 goto __3 16297 __3: 16298 ; 16299 if (iPlan & 2) != 0 { 16300 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iDistTerm)*8)).FargvIndex = (1 + (libc.Bool32((iPlan & 1) != 0))) 16301 } 16302 if (iPlan & 4) != 0 { 16303 var idx int32 = 1 16304 if (iPlan & 1) != 0 { 16305 idx++ 16306 } 16307 if (iPlan & 2) != 0 { 16308 idx++ 16309 } 16310 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iLangTerm)*8)).FargvIndex = idx 16311 } 16312 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = iPlan 16313 if (((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy == 1) && 16314 ((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).FiColumn == 1)) && 16315 (int32((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).Fdesc) == 0) { 16316 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 1 16317 } 16318 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(10000) 16319 16320 return SQLITE_OK 16321 } 16322 16323 // The xUpdate() method. 16324 // 16325 // This implementation disallows DELETE and UPDATE. The only thing 16326 // allowed is INSERT into the "command" column. 16327 func amatchUpdate(tls *libc.TLS, pVTab uintptr, argc int32, argv uintptr, pRowid uintptr) int32 { /* amatch.c:1418:12: */ 16328 bp := tls.Alloc(24) 16329 defer tls.Free(24) 16330 16331 var p uintptr = pVTab 16332 var zCmd uintptr 16333 _ = pRowid 16334 if argc == 1 { 16335 (*sqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+3713, /* "DELETE from %s i..." */ 16336 libc.VaList(bp, (*amatch_vtab)(unsafe.Pointer(p)).FzSelf)) 16337 return SQLITE_ERROR 16338 } 16339 if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) != SQLITE_NULL { 16340 (*sqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+3743, /* "UPDATE of %s is ..." */ 16341 libc.VaList(bp+8, (*amatch_vtab)(unsafe.Pointer(p)).FzSelf)) 16342 return SQLITE_ERROR 16343 } 16344 if ((sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) != SQLITE_NULL) || 16345 (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) != SQLITE_NULL)) || 16346 (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8))) != SQLITE_NULL) { 16347 (*sqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, 16348 ts+3771 /* "INSERT INTO %s a..." */, libc.VaList(bp+16, (*amatch_vtab)(unsafe.Pointer(p)).FzSelf)) 16349 return SQLITE_ERROR 16350 } 16351 zCmd = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 5*8))) 16352 if zCmd == uintptr(0) { 16353 return SQLITE_OK 16354 } 16355 16356 return SQLITE_OK 16357 } 16358 16359 // A virtual table module that implements the "approximate_match". 16360 var amatchModule = sqlite3_module{ // iVersion 16361 FxCreate: 0, // xCreate 16362 FxConnect: 0, // xConnect 16363 FxBestIndex: 0, // xBestIndex 16364 FxDisconnect: 0, // xDisconnect 16365 FxDestroy: 0, // xDestroy 16366 FxOpen: 0, // xOpen - open a cursor 16367 FxClose: 0, // xClose - close a cursor 16368 FxFilter: 0, // xFilter - configure scan constraints 16369 FxNext: 0, // xNext - advance a cursor 16370 FxEof: 0, // xEof - check for end of scan 16371 FxColumn: 0, // xColumn - read data 16372 FxRowid: 0, // xRowid - read data 16373 FxUpdate: 0, // xShadowName 16374 } /* amatch.c:1454:23 */ 16375 16376 // Register the amatch virtual table 16377 func sqlite3_amatch_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* amatch.c:1489:5: */ 16378 var rc int32 = SQLITE_OK 16379 _ = pApi 16380 16381 _ = pzErrMsg // Not used 16382 rc = sqlite3.Xsqlite3_create_module(tls, db, ts+3820 /* "approximate_matc..." */, uintptr(unsafe.Pointer(&amatchModule)), uintptr(0)) 16383 return rc 16384 } 16385 16386 // Allowed values for the mFlags parameter to sqlite3_carray_bind(). 16387 // Must exactly match the definitions in carray.h. 16388 16389 // Names of allowed datatypes 16390 var azType = [4]uintptr{ts + 3838 /* "int32" */, ts + 3844 /* "int64" */, ts + 2423 /* "double" */, ts + 3850 /* "char*" */} /* carray.c:73:19 */ 16391 16392 // Structure used to hold the sqlite3_carray_bind() information 16393 type carray_bind1 = struct { 16394 FaData uintptr 16395 FnData int32 16396 FmFlags int32 16397 FxDel uintptr 16398 } /* carray.c:78:9 */ 16399 16400 // Structure used to hold the sqlite3_carray_bind() information 16401 type carray_bind = carray_bind1 /* carray.c:78:28 */ 16402 16403 // carray_cursor is a subclass of sqlite3_vtab_cursor which will 16404 // serve as the underlying representation of a cursor that scans 16405 // over rows of the result 16406 type carray_cursor1 = struct { 16407 Fbase sqlite3_vtab_cursor 16408 FiRowid sqlite3_int64 16409 FpPtr uintptr 16410 FiCnt sqlite3_int64 16411 FeType uint8 16412 _ [7]byte 16413 } /* carray.c:91:9 */ 16414 16415 // carray_cursor is a subclass of sqlite3_vtab_cursor which will 16416 // serve as the underlying representation of a cursor that scans 16417 // over rows of the result 16418 type carray_cursor = carray_cursor1 /* carray.c:91:30 */ 16419 16420 // The carrayConnect() method is invoked to create a new 16421 // carray_vtab that describes the carray virtual table. 16422 // 16423 // Think of this routine as the constructor for carray_vtab objects. 16424 // 16425 // All this routine needs to do is: 16426 // 16427 // (1) Allocate the carray_vtab object and initialize all fields. 16428 // 16429 // (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the 16430 // result set of queries against carray will look like. 16431 func carrayConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* carray.c:113:12: */ 16432 var pNew uintptr 16433 var rc int32 16434 16435 // Column numbers 16436 16437 rc = sqlite3.Xsqlite3_declare_vtab(tls, db, 16438 ts+3856 /* "CREATE TABLE x(v..." */) 16439 if rc == SQLITE_OK { 16440 pNew = libc.AssignPtrUintptr(ppVtab, sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(sqlite3_vtab{})))) 16441 if pNew == uintptr(0) { 16442 return SQLITE_NOMEM 16443 } 16444 libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(sqlite3_vtab{}))) 16445 } 16446 return rc 16447 } 16448 16449 // This method is the destructor for carray_cursor objects. 16450 func carrayDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* carray.c:142:12: */ 16451 sqlite3.Xsqlite3_free(tls, pVtab) 16452 return SQLITE_OK 16453 } 16454 16455 // Constructor for a new carray_cursor object. 16456 func carrayOpen(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* carray.c:150:12: */ 16457 var pCur uintptr 16458 pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(carray_cursor{}))) 16459 if pCur == uintptr(0) { 16460 return SQLITE_NOMEM 16461 } 16462 libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(carray_cursor{}))) 16463 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) 16464 return SQLITE_OK 16465 } 16466 16467 // Destructor for a carray_cursor. 16468 func carrayClose(tls *libc.TLS, cur uintptr) int32 { /* carray.c:162:12: */ 16469 sqlite3.Xsqlite3_free(tls, cur) 16470 return SQLITE_OK 16471 } 16472 16473 // Advance a carray_cursor to its next row of output. 16474 func carrayNext(tls *libc.TLS, cur uintptr) int32 { /* carray.c:171:12: */ 16475 var pCur uintptr = cur 16476 (*carray_cursor)(unsafe.Pointer(pCur)).FiRowid++ 16477 return SQLITE_OK 16478 } 16479 16480 // Return values of columns for the row at which the carray_cursor 16481 // is currently pointing. 16482 func carrayColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* carray.c:181:12: */ 16483 var pCur uintptr = cur 16484 var x sqlite3_int64 = int64(0) 16485 switch i { 16486 case CARRAY_COLUMN_POINTER: 16487 return SQLITE_OK 16488 case CARRAY_COLUMN_COUNT: 16489 x = (*carray_cursor)(unsafe.Pointer(pCur)).FiCnt 16490 break 16491 case CARRAY_COLUMN_CTYPE: 16492 { 16493 sqlite3.Xsqlite3_result_text(tls, ctx, azType[(*carray_cursor)(unsafe.Pointer(pCur)).FeType], -1, uintptr(0)) 16494 return SQLITE_OK 16495 16496 } 16497 default: 16498 { 16499 switch int32((*carray_cursor)(unsafe.Pointer(pCur)).FeType) { 16500 case CARRAY_INT32: 16501 { 16502 var p uintptr = (*carray_cursor)(unsafe.Pointer(pCur)).FpPtr 16503 sqlite3.Xsqlite3_result_int(tls, ctx, *(*int32)(unsafe.Pointer(p + uintptr(((*carray_cursor)(unsafe.Pointer(pCur)).FiRowid-int64(1)))*4))) 16504 return SQLITE_OK 16505 16506 } 16507 case CARRAY_INT64: 16508 { 16509 var p uintptr = (*carray_cursor)(unsafe.Pointer(pCur)).FpPtr 16510 sqlite3.Xsqlite3_result_int64(tls, ctx, *(*sqlite3_int64)(unsafe.Pointer(p + uintptr(((*carray_cursor)(unsafe.Pointer(pCur)).FiRowid-int64(1)))*8))) 16511 return SQLITE_OK 16512 16513 } 16514 case CARRAY_DOUBLE: 16515 { 16516 var p uintptr = (*carray_cursor)(unsafe.Pointer(pCur)).FpPtr 16517 sqlite3.Xsqlite3_result_double(tls, ctx, *(*float64)(unsafe.Pointer(p + uintptr(((*carray_cursor)(unsafe.Pointer(pCur)).FiRowid-int64(1)))*8))) 16518 return SQLITE_OK 16519 16520 } 16521 case CARRAY_TEXT: 16522 { 16523 var p uintptr = (*carray_cursor)(unsafe.Pointer(pCur)).FpPtr 16524 sqlite3.Xsqlite3_result_text(tls, ctx, *(*uintptr)(unsafe.Pointer(p + uintptr(((*carray_cursor)(unsafe.Pointer(pCur)).FiRowid-int64(1)))*8)), -1, libc.UintptrFromInt32(-1)) 16525 return SQLITE_OK 16526 16527 } 16528 } 16529 16530 } 16531 } 16532 sqlite3.Xsqlite3_result_int64(tls, ctx, x) 16533 return SQLITE_OK 16534 } 16535 16536 // Return the rowid for the current row. In this implementation, the 16537 // rowid is the same as the output value. 16538 func carrayRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* carray.c:228:12: */ 16539 var pCur uintptr = cur 16540 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*carray_cursor)(unsafe.Pointer(pCur)).FiRowid 16541 return SQLITE_OK 16542 } 16543 16544 // Return TRUE if the cursor has been moved off of the last 16545 // row of output. 16546 func carrayEof(tls *libc.TLS, cur uintptr) int32 { /* carray.c:238:12: */ 16547 var pCur uintptr = cur 16548 return (libc.Bool32((*carray_cursor)(unsafe.Pointer(pCur)).FiRowid > (*carray_cursor)(unsafe.Pointer(pCur)).FiCnt)) 16549 } 16550 16551 // This method is called to "rewind" the carray_cursor object back 16552 // to the first row of output. 16553 func carrayFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* carray.c:247:12: */ 16554 bp := tls.Alloc(8) 16555 defer tls.Free(8) 16556 16557 var pCur uintptr = pVtabCursor 16558 (*carray_cursor)(unsafe.Pointer(pCur)).FpPtr = uintptr(0) 16559 (*carray_cursor)(unsafe.Pointer(pCur)).FiCnt = int64(0) 16560 switch idxNum { 16561 case 1: 16562 { 16563 var pBind uintptr = sqlite3.Xsqlite3_value_pointer(tls, *(*uintptr)(unsafe.Pointer(argv)), ts+3919 /* "carray-bind" */) 16564 if pBind == uintptr(0) { 16565 break 16566 } 16567 (*carray_cursor)(unsafe.Pointer(pCur)).FpPtr = (*carray_bind)(unsafe.Pointer(pBind)).FaData 16568 (*carray_cursor)(unsafe.Pointer(pCur)).FiCnt = sqlite3_int64((*carray_bind)(unsafe.Pointer(pBind)).FnData) 16569 (*carray_cursor)(unsafe.Pointer(pCur)).FeType = (uint8((*carray_bind)(unsafe.Pointer(pBind)).FmFlags & 0x03)) 16570 break 16571 16572 } 16573 case 2: 16574 fallthrough 16575 case 3: 16576 { 16577 (*carray_cursor)(unsafe.Pointer(pCur)).FpPtr = sqlite3.Xsqlite3_value_pointer(tls, *(*uintptr)(unsafe.Pointer(argv)), ts+3931 /* "carray" */) 16578 (*carray_cursor)(unsafe.Pointer(pCur)).FiCnt = func() int64 { 16579 if (*carray_cursor)(unsafe.Pointer(pCur)).FpPtr != 0 { 16580 return sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 16581 } 16582 return int64(0) 16583 }() 16584 if idxNum < 3 { 16585 (*carray_cursor)(unsafe.Pointer(pCur)).FeType = uint8(CARRAY_INT32) 16586 } else { 16587 var i uint8 16588 var zType uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) 16589 for i = uint8(0); uint64(i) < (uint64(unsafe.Sizeof(azType)) / uint64(unsafe.Sizeof(uintptr(0)))); i++ { 16590 if sqlite3.Xsqlite3_stricmp(tls, zType, azType[i]) == 0 { 16591 break 16592 } 16593 } 16594 if uint64(i) >= (uint64(unsafe.Sizeof(azType)) / uint64(unsafe.Sizeof(uintptr(0)))) { 16595 (*sqlite3_vtab)(unsafe.Pointer((*sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab)).FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, 16596 ts+3938 /* "unknown datatype..." */, libc.VaList(bp, zType)) 16597 return SQLITE_ERROR 16598 } else { 16599 (*carray_cursor)(unsafe.Pointer(pCur)).FeType = i 16600 } 16601 } 16602 break 16603 16604 } 16605 } 16606 (*carray_cursor)(unsafe.Pointer(pCur)).FiRowid = int64(1) 16607 return SQLITE_OK 16608 } 16609 16610 // SQLite will invoke this method one or more times while planning a query 16611 // that uses the carray virtual table. This routine needs to create 16612 // a query plan for each invocation and compute an estimated cost for that 16613 // plan. 16614 // 16615 // In this implementation idxNum is used to represent the 16616 // query plan. idxStr is unused. 16617 // 16618 // idxNum is: 16619 // 16620 // 1 If only the pointer= constraint exists. In this case, the 16621 // parameter must be bound using sqlite3_carray_bind(). 16622 // 16623 // 2 if the pointer= and count= constraints exist. 16624 // 16625 // 3 if the ctype= constraint also exists. 16626 // 16627 // idxNum is 0 otherwise and carray becomes an empty table. 16628 func carrayBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* carray.c:311:12: */ 16629 var i int32 // Loop over constraints 16630 var ptrIdx int32 = -1 // Index of the pointer= constraint, or -1 if none 16631 var cntIdx int32 = -1 // Index of the count= constraint, or -1 if none 16632 var ctypeIdx int32 = -1 // Index of the ctype= constraint, or -1 if none 16633 16634 var pConstraint uintptr 16635 pConstraint = (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint 16636 i = 0 16637 __1: 16638 if !(i < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { 16639 goto __3 16640 } 16641 { 16642 if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 { 16643 goto __2 16644 } 16645 if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) != SQLITE_INDEX_CONSTRAINT_EQ { 16646 goto __2 16647 } 16648 switch (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn { 16649 case CARRAY_COLUMN_POINTER: 16650 ptrIdx = i 16651 break 16652 case CARRAY_COLUMN_COUNT: 16653 cntIdx = i 16654 break 16655 case CARRAY_COLUMN_CTYPE: 16656 ctypeIdx = i 16657 break 16658 } 16659 16660 } 16661 goto __2 16662 __2: 16663 i++ 16664 pConstraint += 12 16665 goto __1 16666 goto __3 16667 __3: 16668 ; 16669 if ptrIdx >= 0 { 16670 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ptrIdx)*8)).FargvIndex = 1 16671 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ptrIdx)*8)).Fomit = uint8(1) 16672 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(1) 16673 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(100) 16674 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 1 16675 if cntIdx >= 0 { 16676 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(cntIdx)*8)).FargvIndex = 2 16677 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(cntIdx)*8)).Fomit = uint8(1) 16678 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 2 16679 if ctypeIdx >= 0 { 16680 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ctypeIdx)*8)).FargvIndex = 3 16681 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ctypeIdx)*8)).Fomit = uint8(1) 16682 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 3 16683 } 16684 } 16685 } else { 16686 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(2147483647) 16687 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(2147483647) 16688 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 0 16689 } 16690 return SQLITE_OK 16691 } 16692 16693 // This following structure defines all the methods for the 16694 // carray virtual table. 16695 var carrayModule = sqlite3_module{ // xCreate 16696 FxConnect: 0, // xConnect 16697 FxBestIndex: 0, // xBestIndex 16698 FxDisconnect: 0, // xDestroy 16699 FxOpen: 0, // xOpen - open a cursor 16700 FxClose: 0, // xClose - close a cursor 16701 FxFilter: 0, // xFilter - configure scan constraints 16702 FxNext: 0, // xNext - advance a cursor 16703 FxEof: 0, // xEof - check for end of scan 16704 FxColumn: 0, // xColumn - read data 16705 FxRowid: 0, // xRename 16706 } /* carray.c:365:23 */ 16707 16708 // Destructor for the carray_bind object 16709 func carrayBindDel(tls *libc.TLS, pPtr uintptr) { /* carray.c:391:13: */ 16710 var p uintptr = pPtr 16711 if (*carray_bind)(unsafe.Pointer(p)).FxDel != (uintptr(0)) { 16712 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((p + 16 /* &.xDel */))))(tls, (*carray_bind)(unsafe.Pointer(p)).FaData) 16713 } 16714 sqlite3.Xsqlite3_free(tls, p) 16715 } 16716 16717 // Invoke this interface in order to bind to the single-argument 16718 // version of CARRAY(). 16719 func sqlite3_carray_bind(tls *libc.TLS, pStmt uintptr, idx int32, aData uintptr, nData int32, mFlags int32, xDestroy uintptr) int32 { /* carray.c:406:5: */ 16720 var pNew uintptr 16721 var i int32 16722 pNew = sqlite3.Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(carray_bind{}))) 16723 if pNew == uintptr(0) { 16724 if (xDestroy != (uintptr(0))) && (xDestroy != (libc.UintptrFromInt32(-1))) { 16725 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&xDestroy)))(tls, aData) 16726 } 16727 return SQLITE_NOMEM 16728 } 16729 (*carray_bind)(unsafe.Pointer(pNew)).FnData = nData 16730 (*carray_bind)(unsafe.Pointer(pNew)).FmFlags = mFlags 16731 if xDestroy == (libc.UintptrFromInt32(-1)) { 16732 var sz sqlite3_int64 = sqlite3_int64(nData) 16733 switch mFlags & 0x03 { 16734 case CARRAY_INT32: 16735 sz = sz * (int64(4)) 16736 break 16737 fallthrough 16738 case CARRAY_INT64: 16739 sz = sz * (int64(8)) 16740 break 16741 fallthrough 16742 case CARRAY_DOUBLE: 16743 sz = sz * (int64(8)) 16744 break 16745 fallthrough 16746 case CARRAY_TEXT: 16747 sz = int64(uint64(sz) * (uint64(unsafe.Sizeof(uintptr(0))))) 16748 break 16749 } 16750 if (mFlags & 0x03) == CARRAY_TEXT { 16751 for i = 0; i < nData; i++ { 16752 var z uintptr = *(*uintptr)(unsafe.Pointer((aData) + uintptr(i)*8)) 16753 if z != 0 { 16754 sz = sqlite3_int64(uint64(sz) + (uint64(libc.Xstrlen(tls, z) + uint64(1)))) 16755 } 16756 } 16757 } 16758 (*carray_bind)(unsafe.Pointer(pNew)).FaData = sqlite3.Xsqlite3_malloc64(tls, uint64(sz)) 16759 if (*carray_bind)(unsafe.Pointer(pNew)).FaData == uintptr(0) { 16760 sqlite3.Xsqlite3_free(tls, pNew) 16761 return SQLITE_NOMEM 16762 } 16763 if (mFlags & 0x03) == CARRAY_TEXT { 16764 var az uintptr = (*carray_bind)(unsafe.Pointer(pNew)).FaData 16765 var z uintptr = (az + uintptr(nData)*8) 16766 for i = 0; i < nData; i++ { 16767 var zData uintptr = *(*uintptr)(unsafe.Pointer((aData) + uintptr(i)*8)) 16768 var n sqlite3_int64 16769 if zData == uintptr(0) { 16770 *(*uintptr)(unsafe.Pointer(az + uintptr(i)*8)) = uintptr(0) 16771 continue 16772 } 16773 *(*uintptr)(unsafe.Pointer(az + uintptr(i)*8)) = z 16774 n = sqlite3_int64(libc.Xstrlen(tls, zData)) 16775 libc.Xmemcpy(tls, z, zData, (uint64(n + int64(1)))) 16776 z += (uintptr(n + int64(1))) 16777 } 16778 } else { 16779 libc.Xmemcpy(tls, (*carray_bind)(unsafe.Pointer(pNew)).FaData, aData, (uint64(sz * sqlite3_int64(nData)))) 16780 } 16781 (*carray_bind)(unsafe.Pointer(pNew)).FxDel = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free})) 16782 } else { 16783 (*carray_bind)(unsafe.Pointer(pNew)).FaData = aData 16784 (*carray_bind)(unsafe.Pointer(pNew)).FxDel = xDestroy 16785 } 16786 return sqlite3.Xsqlite3_bind_pointer(tls, pStmt, idx, pNew, ts+3919 /* "carray-bind" */, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{carrayBindDel}))) 16787 } 16788 16789 // For testing purpose in the TCL test harness, we need a method for 16790 // setting the pointer value. The inttoptr(X) SQL function accomplishes 16791 // this. Tcl script will bind an integer to X and the inttoptr() SQL 16792 // function will use sqlite3_result_pointer() to convert that integer into 16793 // a pointer. 16794 // 16795 // This is for testing on TCL only. 16796 func inttoptrFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* carray.c:481:13: */ 16797 bp := tls.Alloc(20) 16798 defer tls.Free(20) 16799 16800 // var p uintptr at bp, 8 16801 16802 // var i64 sqlite3_int64 at bp+8, 8 16803 16804 *(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* i64 */)) = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) 16805 if uint64(unsafe.Sizeof(sqlite3_int64(0))) == uint64(unsafe.Sizeof(uintptr(0))) { 16806 libc.Xmemcpy(tls, bp /* &p */, bp+8 /* &i64 */, uint64(unsafe.Sizeof(uintptr(0)))) 16807 } else { 16808 *(*int32)(unsafe.Pointer(bp + 16 /* i32 */)) = (int32(*(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* i64 */)) & int64(0xffffffff))) 16809 libc.Xmemcpy(tls, bp /* &p */, bp+16 /* &i32 */, uint64(unsafe.Sizeof(uintptr(0)))) 16810 } 16811 sqlite3.Xsqlite3_result_pointer(tls, context, *(*uintptr)(unsafe.Pointer(bp /* p */)), ts+3931 /* "carray" */, uintptr(0)) 16812 } 16813 16814 func sqlite3_carray_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* carray.c:504:5: */ 16815 var rc int32 = SQLITE_OK 16816 _ = pApi 16817 16818 rc = sqlite3.Xsqlite3_create_module(tls, db, ts+3931 /* "carray" */, uintptr(unsafe.Pointer(&carrayModule)), uintptr(0)) 16819 if rc == SQLITE_OK { 16820 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+3959 /* "inttoptr" */, 1, SQLITE_UTF8, uintptr(0), 16821 *(*uintptr)(unsafe.Pointer(&struct { 16822 f func(*libc.TLS, uintptr, int32, uintptr) 16823 }{inttoptrFunc})), uintptr(0), uintptr(0)) 16824 } 16825 return rc 16826 } 16827 16828 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 16829 // This file is part of the GNU C Library. 16830 // 16831 // The GNU C Library is free software; you can redistribute it and/or 16832 // modify it under the terms of the GNU Lesser General Public 16833 // License as published by the Free Software Foundation; either 16834 // version 2.1 of the License, or (at your option) any later version. 16835 // 16836 // The GNU C Library is distributed in the hope that it will be useful, 16837 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16838 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16839 // Lesser General Public License for more details. 16840 // 16841 // You should have received a copy of the GNU Lesser General Public 16842 // License along with the GNU C Library; if not, see 16843 // <http://www.gnu.org/licenses/>. 16844 16845 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 16846 16847 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 16848 // This file is part of the GNU C Library. 16849 // 16850 // The GNU C Library is free software; you can redistribute it and/or 16851 // modify it under the terms of the GNU Lesser General Public 16852 // License as published by the Free Software Foundation; either 16853 // version 2.1 of the License, or (at your option) any later version. 16854 // 16855 // The GNU C Library is distributed in the hope that it will be useful, 16856 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16857 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16858 // Lesser General Public License for more details. 16859 // 16860 // You should have received a copy of the GNU Lesser General Public 16861 // License along with the GNU C Library; if not, see 16862 // <http://www.gnu.org/licenses/>. 16863 16864 // void assert (int expression); 16865 // 16866 // If NDEBUG is defined, do nothing. 16867 // If not, and EXPRESSION is zero, print an error message and abort. 16868 16869 // void assert_perror (int errnum); 16870 // 16871 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 16872 // error message with the error text for ERRNUM and abort. 16873 // (This is a GNU extension.) 16874 16875 // Forward declaration of objects used by this utility 16876 type CksmVfs = sqlite3_vfs1 /* cksumvfs.c:176:28 */ 16877 type CksmFile1 = struct { 16878 Fbase sqlite3_file 16879 FzFName uintptr 16880 FcomputeCksm int8 16881 FverifyCksm int8 16882 FisWal int8 16883 FinCkpt int8 16884 _ [4]byte 16885 FpPartner uintptr 16886 } /* cksumvfs.c:177:9 */ 16887 16888 type CksmFile = CksmFile1 /* cksumvfs.c:177:25 */ 16889 16890 // Useful datatype abbreviations 16891 type u8 = uint8 /* cksumvfs.c:183:25 */ 16892 16893 var cksm_vfs = sqlite3_vfs{ 16894 FiVersion: 3, // szOsFile (set when registered) 16895 FmxPathname: 1024, // pNext 16896 FzName: ts + 3968, /* "cksmvfs" */ /* pAppData (set when registered) */ 16897 FxOpen: 0, // xOpen 16898 FxDelete: 0, // xDelete 16899 FxAccess: 0, // xAccess 16900 FxFullPathname: 0, // xFullPathname 16901 FxDlOpen: 0, // xDlOpen 16902 FxDlError: 0, // xDlError 16903 FxDlSym: 0, // xDlSym 16904 FxDlClose: 0, // xDlClose 16905 FxRandomness: 0, // xRandomness 16906 FxSleep: 0, // xSleep 16907 FxCurrentTime: 0, // xCurrentTime 16908 FxGetLastError: 0, // xGetLastError 16909 FxCurrentTimeInt64: 0, // xCurrentTimeInt64 16910 FxSetSystemCall: 0, // xSetSystemCall 16911 FxGetSystemCall: 0, // xGetSystemCall 16912 FxNextSystemCall: 0, // xNextSystemCall 16913 } /* cksumvfs.c:247:20 */ 16914 16915 var cksm_io_methods = sqlite3_io_methods{ 16916 FiVersion: 3, // iVersion 16917 FxClose: 0, // xClose 16918 FxRead: 0, // xRead 16919 FxWrite: 0, // xWrite 16920 FxTruncate: 0, // xTruncate 16921 FxSync: 0, // xSync 16922 FxFileSize: 0, // xFileSize 16923 FxLock: 0, // xLock 16924 FxUnlock: 0, // xUnlock 16925 FxCheckReservedLock: 0, // xCheckReservedLock 16926 FxFileControl: 0, // xFileControl 16927 FxSectorSize: 0, // xSectorSize 16928 FxDeviceCharacteristics: 0, // xDeviceCharacteristics 16929 FxShmMap: 0, // xShmMap 16930 FxShmLock: 0, // xShmLock 16931 FxShmBarrier: 0, // xShmBarrier 16932 FxShmUnmap: 0, // xShmUnmap 16933 FxFetch: 0, // xFetch 16934 FxUnfetch: 0, // xUnfetch 16935 } /* cksumvfs.c:272:33 */ 16936 16937 // Do byte swapping on a unsigned 32-bit integer 16938 16939 // Compute a checksum on a buffer 16940 func cksmCompute(tls *libc.TLS, a uintptr, nByte int32, aOut uintptr) { /* cksumvfs.c:301:13: */ 16941 bp := tls.Alloc(12) 16942 defer tls.Free(12) 16943 16944 *(*u32)(unsafe.Pointer(bp + 4 /* s1 */)) = u32(0) 16945 *(*u32)(unsafe.Pointer(bp + 8 /* s2 */)) = u32(0) 16946 var aData uintptr = a 16947 var aEnd uintptr = (a + uintptr(nByte)) 16948 *(*u32)(unsafe.Pointer(bp /* x */)) = u32(1) 16949 16950 if 1 == int32(*(*u8)(unsafe.Pointer(bp /* &x */))) { 16951 // Little-endian 16952 for ok := true; ok; ok = (aData < aEnd) { 16953 *(*u32)(unsafe.Pointer(bp + 4 /* s1 */)) += (*(*u32)(unsafe.Pointer(libc.PostIncUintptr(&aData, 4))) + *(*u32)(unsafe.Pointer(bp + 8 /* s2 */))) 16954 *(*u32)(unsafe.Pointer(bp + 8 /* s2 */)) += (*(*u32)(unsafe.Pointer(libc.PostIncUintptr(&aData, 4))) + *(*u32)(unsafe.Pointer(bp + 4 /* s1 */))) 16955 } 16956 } else { 16957 // Big-endian 16958 for ok1 := true; ok1; ok1 = (aData < aEnd) { 16959 *(*u32)(unsafe.Pointer(bp + 4 /* 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)) + *(*u32)(unsafe.Pointer(bp + 8 /* s2 */))) 16960 *(*u32)(unsafe.Pointer(bp + 8 /* 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)) + *(*u32)(unsafe.Pointer(bp + 4 /* s1 */))) 16961 aData += 4 * (uintptr(2)) 16962 } 16963 *(*u32)(unsafe.Pointer(bp + 4 /* s1 */)) = ((((((*(*u32)(unsafe.Pointer(bp + 4 /* s1 */))) & u32(0x000000FF)) << 24) + (((*(*u32)(unsafe.Pointer(bp + 4 /* s1 */))) & u32(0x0000FF00)) << 8)) + (((*(*u32)(unsafe.Pointer(bp + 4 /* s1 */))) & u32(0x00FF0000)) >> 8)) + (((*(*u32)(unsafe.Pointer(bp + 4 /* s1 */))) & 0xFF000000) >> 24)) 16964 *(*u32)(unsafe.Pointer(bp + 8 /* s2 */)) = ((((((*(*u32)(unsafe.Pointer(bp + 8 /* s2 */))) & u32(0x000000FF)) << 24) + (((*(*u32)(unsafe.Pointer(bp + 8 /* s2 */))) & u32(0x0000FF00)) << 8)) + (((*(*u32)(unsafe.Pointer(bp + 8 /* s2 */))) & u32(0x00FF0000)) >> 8)) + (((*(*u32)(unsafe.Pointer(bp + 8 /* s2 */))) & 0xFF000000) >> 24)) 16965 } 16966 libc.Xmemcpy(tls, aOut, bp+4 /* &s1 */, uint64(4)) 16967 libc.Xmemcpy(tls, (aOut + uintptr(4)), bp+8 /* &s2 */, uint64(4)) 16968 } 16969 16970 // SQL function: verify_checksum(BLOB) 16971 // 16972 // Return 0 or 1 if the checksum is invalid or valid. Or return 16973 // NULL if the input is not a BLOB that is the right size for a 16974 // database page. 16975 func cksmVerifyFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* cksumvfs.c:342:13: */ 16976 bp := tls.Alloc(8) 16977 defer tls.Free(8) 16978 16979 var nByte int32 16980 var data uintptr 16981 // var cksum [8]u8 at bp, 8 16982 16983 data = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) 16984 if data == uintptr(0) { 16985 return 16986 } 16987 if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) != SQLITE_BLOB { 16988 return 16989 } 16990 nByte = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) 16991 if ((nByte < 512) || (nByte > 65536)) || ((nByte & (nByte - 1)) != 0) { 16992 return 16993 } 16994 cksmCompute(tls, data, (nByte - 8), bp /* &cksum[0] */) 16995 sqlite3.Xsqlite3_result_int(tls, context, (libc.Bool32(libc.Xmemcmp(tls, ((data+uintptr(nByte))-uintptr(8)), bp /* &cksum[0] */, uint64(8)) == 0))) 16996 } 16997 16998 // Close a cksm-file. 16999 func cksmClose(tls *libc.TLS, pFile uintptr) int32 { /* cksumvfs.c:397:12: */ 17000 var p uintptr = pFile 17001 if (*CksmFile)(unsafe.Pointer(p)).FpPartner != 0 { 17002 17003 (*CksmFile)(unsafe.Pointer((*CksmFile)(unsafe.Pointer(p)).FpPartner)).FpPartner = uintptr(0) 17004 (*CksmFile)(unsafe.Pointer(p)).FpPartner = uintptr(0) 17005 } 17006 pFile = ((pFile) + uintptr(1)*32) 17007 return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 8 /* &.xClose */))))(tls, pFile) 17008 } 17009 17010 // Set the computeCkSm and verifyCksm flags, if they need to be 17011 // changed. 17012 func cksmSetFlags(tls *libc.TLS, p uintptr, hasCorrectReserveSize int32) { /* cksumvfs.c:412:13: */ 17013 if hasCorrectReserveSize != int32((*CksmFile)(unsafe.Pointer(p)).FcomputeCksm) { 17014 (*CksmFile)(unsafe.Pointer(p)).FcomputeCksm = libc.AssignPtrInt8(p+17 /* &.verifyCksm */, int8(hasCorrectReserveSize)) 17015 if (*CksmFile)(unsafe.Pointer(p)).FpPartner != 0 { 17016 (*CksmFile)(unsafe.Pointer((*CksmFile)(unsafe.Pointer(p)).FpPartner)).FverifyCksm = int8(hasCorrectReserveSize) 17017 (*CksmFile)(unsafe.Pointer((*CksmFile)(unsafe.Pointer(p)).FpPartner)).FcomputeCksm = int8(hasCorrectReserveSize) 17018 } 17019 } 17020 } 17021 17022 // Read data from a cksm-file. 17023 func cksmRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* cksumvfs.c:425:12: */ 17024 bp := tls.Alloc(24) 17025 defer tls.Free(24) 17026 17027 var rc int32 17028 var p uintptr = pFile 17029 pFile = ((pFile) + uintptr(1)*32) 17030 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 16 /* &.xRead */))))(tls, pFile, zBuf, iAmt, iOfst) 17031 if rc == SQLITE_OK { 17032 if ((iOfst == int64(0)) && (iAmt >= 100)) && ((libc.Xmemcmp(tls, zBuf, ts+3159 /* "SQLite format 3" */, uint64(16)) == 0) || (libc.Xmemcmp(tls, zBuf, ts+3976 /* "ZV-" */, uint64(3)) == 0)) { 17033 var d uintptr = zBuf 17034 var hasCorrectReserveSize int8 = (int8(libc.Bool32(int32(*(*u8)(unsafe.Pointer(d + 20))) == 8))) 17035 cksmSetFlags(tls, p, int32(hasCorrectReserveSize)) 17036 } 17037 // Verify the checksum if 17038 // (1) the size indicates that we are dealing with a complete 17039 // database page 17040 // (2) checksum verification is enabled 17041 // (3) we are not in the middle of checkpoint 17042 if ((iAmt >= 512) && // (1) 17043 ((*CksmFile)(unsafe.Pointer(p)).FverifyCksm != 0)) && // (2) 17044 !(int32((*CksmFile)(unsafe.Pointer(p)).FinCkpt) != 0) { 17045 // var cksum [8]u8 at bp+16, 8 17046 17047 cksmCompute(tls, zBuf, (iAmt - 8), bp+16 /* &cksum[0] */) 17048 if libc.Xmemcmp(tls, ((zBuf+uintptr(iAmt))-uintptr(8)), bp+16 /* &cksum[0] */, uint64(8)) != 0 { 17049 sqlite3.Xsqlite3_log(tls, (SQLITE_IOERR | (int32(32) << 8)), 17050 ts+3980, /* "checksum fault o..." */ 17051 libc.VaList(bp, iOfst, (*CksmFile)(unsafe.Pointer(p)).FzFName)) 17052 rc = (SQLITE_IOERR | (int32(32) << 8)) 17053 } 17054 } 17055 } 17056 return rc 17057 } 17058 17059 // Write data to a cksm-file. 17060 func cksmWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* cksumvfs.c:469:12: */ 17061 var p uintptr = pFile 17062 pFile = ((pFile) + uintptr(1)*32) 17063 if ((iOfst == int64(0)) && (iAmt >= 100)) && ((libc.Xmemcmp(tls, zBuf, ts+3159 /* "SQLite format 3" */, uint64(16)) == 0) || (libc.Xmemcmp(tls, zBuf, ts+3976 /* "ZV-" */, uint64(3)) == 0)) { 17064 var d uintptr = zBuf 17065 var hasCorrectReserveSize int8 = (int8(libc.Bool32(int32(*(*u8)(unsafe.Pointer(d + 20))) == 8))) 17066 cksmSetFlags(tls, p, int32(hasCorrectReserveSize)) 17067 } 17068 // If the write size is appropriate for a database page and if 17069 // checksums where ever enabled, then it will be safe to compute 17070 // the checksums. The reserve byte size might have increased, but 17071 // it will never decrease. And because it cannot decrease, the 17072 // checksum will not overwrite anything. 17073 if ((iAmt >= 512) && 17074 ((*CksmFile)(unsafe.Pointer(p)).FcomputeCksm != 0)) && 17075 !(int32((*CksmFile)(unsafe.Pointer(p)).FinCkpt) != 0) { 17076 cksmCompute(tls, zBuf, (iAmt - 8), (((zBuf) + uintptr(iAmt)) - uintptr(8))) 17077 } 17078 return (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 24 /* &.xWrite */))))(tls, pFile, zBuf, iAmt, iOfst) 17079 } 17080 17081 // Truncate a cksm-file. 17082 func cksmTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { /* cksumvfs.c:502:12: */ 17083 pFile = ((pFile) + uintptr(1)*32) 17084 return (*(*func(*libc.TLS, uintptr, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 32 /* &.xTruncate */))))(tls, pFile, size) 17085 } 17086 17087 // Sync a cksm-file. 17088 func cksmSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* cksumvfs.c:510:12: */ 17089 pFile = ((pFile) + uintptr(1)*32) 17090 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 40 /* &.xSync */))))(tls, pFile, flags) 17091 } 17092 17093 // Return the current file-size of a cksm-file. 17094 func cksmFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { /* cksumvfs.c:518:12: */ 17095 var p uintptr = pFile 17096 pFile = ((p) + uintptr(1)*32) 17097 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 48 /* &.xFileSize */))))(tls, pFile, pSize) 17098 } 17099 17100 // Lock a cksm-file. 17101 func cksmLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* cksumvfs.c:527:12: */ 17102 pFile = ((pFile) + uintptr(1)*32) 17103 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 56 /* &.xLock */))))(tls, pFile, eLock) 17104 } 17105 17106 // Unlock a cksm-file. 17107 func cksmUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* cksumvfs.c:535:12: */ 17108 pFile = ((pFile) + uintptr(1)*32) 17109 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 64 /* &.xUnlock */))))(tls, pFile, eLock) 17110 } 17111 17112 // Check if another file-handle holds a RESERVED lock on a cksm-file. 17113 func cksmCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int32 { /* cksumvfs.c:543:12: */ 17114 pFile = ((pFile) + uintptr(1)*32) 17115 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 72 /* &.xCheckReservedLock */))))(tls, pFile, pResOut) 17116 } 17117 17118 // File control method. For custom operations on a cksm-file. 17119 func cksmFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 { /* cksumvfs.c:551:12: */ 17120 bp := tls.Alloc(16) 17121 defer tls.Free(16) 17122 17123 var rc int32 17124 var p uintptr = pFile 17125 pFile = ((pFile) + uintptr(1)*32) 17126 if op == SQLITE_FCNTL_PRAGMA { 17127 var azArg uintptr = pArg 17128 17129 if sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + 1*8)), ts+4015 /* "checksum_verific..." */) == 0 { 17130 var zArg uintptr = *(*uintptr)(unsafe.Pointer(azArg + 2*8)) 17131 if zArg != uintptr(0) { 17132 if ((((int32(*(*int8)(unsafe.Pointer(zArg))) >= '1') && (int32(*(*int8)(unsafe.Pointer(zArg))) <= '9')) || 17133 (sqlite3.Xsqlite3_strlike(tls, ts+4037 /* "enable%" */, zArg, uint32(0)) == 0)) || 17134 (sqlite3.Xsqlite3_stricmp(tls, ts+4045 /* "yes" */, zArg) == 0)) || 17135 (sqlite3.Xsqlite3_stricmp(tls, ts+4049 /* "on" */, zArg) == 0) { 17136 (*CksmFile)(unsafe.Pointer(p)).FverifyCksm = (*CksmFile)(unsafe.Pointer(p)).FcomputeCksm 17137 } else { 17138 (*CksmFile)(unsafe.Pointer(p)).FverifyCksm = int8(0) 17139 } 17140 if (*CksmFile)(unsafe.Pointer(p)).FpPartner != 0 { 17141 (*CksmFile)(unsafe.Pointer((*CksmFile)(unsafe.Pointer(p)).FpPartner)).FverifyCksm = (*CksmFile)(unsafe.Pointer(p)).FverifyCksm 17142 } 17143 } 17144 *(*uintptr)(unsafe.Pointer(azArg)) = sqlite3.Xsqlite3_mprintf(tls, ts+1238 /* "%d" */, libc.VaList(bp, int32((*CksmFile)(unsafe.Pointer(p)).FverifyCksm))) 17145 return SQLITE_OK 17146 } else if (((*CksmFile)(unsafe.Pointer(p)).FcomputeCksm != 0) && (*(*uintptr)(unsafe.Pointer(azArg + 2*8)) != uintptr(0))) && 17147 (sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(azArg + 1*8)), ts+4052 /* "page_size" */) == 0) { 17148 // Do not allow page size changes on a checksum database 17149 return SQLITE_OK 17150 } 17151 } else if (op == SQLITE_FCNTL_CKPT_START) || (op == SQLITE_FCNTL_CKPT_DONE) { 17152 (*CksmFile)(unsafe.Pointer(p)).FinCkpt = (int8(libc.Bool32(op == SQLITE_FCNTL_CKPT_START))) 17153 if (*CksmFile)(unsafe.Pointer(p)).FpPartner != 0 { 17154 (*CksmFile)(unsafe.Pointer((*CksmFile)(unsafe.Pointer(p)).FpPartner)).FinCkpt = (*CksmFile)(unsafe.Pointer(p)).FinCkpt 17155 } 17156 } 17157 rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 80 /* &.xFileControl */))))(tls, pFile, op, pArg) 17158 if (rc == SQLITE_OK) && (op == SQLITE_FCNTL_VFSNAME) { 17159 *(*uintptr)(unsafe.Pointer(pArg)) = sqlite3.Xsqlite3_mprintf(tls, ts+4062 /* "cksm/%z" */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(pArg)))) 17160 } 17161 return rc 17162 } 17163 17164 // Return the sector-size in bytes for a cksm-file. 17165 func cksmSectorSize(tls *libc.TLS, pFile uintptr) int32 { /* cksumvfs.c:593:12: */ 17166 pFile = ((pFile) + uintptr(1)*32) 17167 return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 88 /* &.xSectorSize */))))(tls, pFile) 17168 } 17169 17170 // Return the device characteristic flags supported by a cksm-file. 17171 func cksmDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { /* cksumvfs.c:601:12: */ 17172 pFile = ((pFile) + uintptr(1)*32) 17173 return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 96 /* &.xDeviceCharacteristics */))))(tls, pFile) 17174 } 17175 17176 // Create a shared memory file mapping 17177 func cksmShmMap(tls *libc.TLS, pFile uintptr, iPg int32, pgsz int32, bExtend int32, pp uintptr) int32 { /* cksumvfs.c:607:12: */ 17178 pFile = ((pFile) + uintptr(1)*32) 17179 return (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 104 /* &.xShmMap */))))(tls, pFile, iPg, pgsz, bExtend, libc.AtomicLoadUintptr(&pp)) 17180 } 17181 17182 // Perform locking on a shared-memory segment 17183 func cksmShmLock(tls *libc.TLS, pFile uintptr, offset int32, n int32, flags int32) int32 { /* cksumvfs.c:619:12: */ 17184 pFile = ((pFile) + uintptr(1)*32) 17185 return (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 112 /* &.xShmLock */))))(tls, pFile, offset, n, flags) 17186 } 17187 17188 // Memory barrier operation on shared memory 17189 func cksmShmBarrier(tls *libc.TLS, pFile uintptr) { /* cksumvfs.c:625:13: */ 17190 pFile = ((pFile) + uintptr(1)*32) 17191 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 120 /* &.xShmBarrier */))))(tls, pFile) 17192 } 17193 17194 // Unmap a shared memory segment 17195 func cksmShmUnmap(tls *libc.TLS, pFile uintptr, deleteFlag int32) int32 { /* cksumvfs.c:631:12: */ 17196 pFile = ((pFile) + uintptr(1)*32) 17197 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 128 /* &.xShmUnmap */))))(tls, pFile, deleteFlag) 17198 } 17199 17200 // Fetch a page of a memory-mapped file 17201 func cksmFetch(tls *libc.TLS, pFile uintptr, iOfst sqlite3_int64, iAmt int32, pp uintptr) int32 { /* cksumvfs.c:637:12: */ 17202 var p uintptr = pFile 17203 if (*CksmFile)(unsafe.Pointer(p)).FcomputeCksm != 0 { 17204 *(*uintptr)(unsafe.Pointer(pp)) = uintptr(0) 17205 return SQLITE_OK 17206 } 17207 pFile = ((pFile) + uintptr(1)*32) 17208 if ((*sqlite3_io_methods1)(unsafe.Pointer((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods)).FiVersion > 2) && ((*sqlite3_io_methods1)(unsafe.Pointer((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods)).FxFetch != 0) { 17209 return (*(*func(*libc.TLS, uintptr, sqlite3_int64, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 136 /* &.xFetch */))))(tls, pFile, iOfst, iAmt, pp) 17210 } 17211 *(*uintptr)(unsafe.Pointer(pp)) = uintptr(0) 17212 return SQLITE_OK 17213 } 17214 17215 // Release a memory-mapped page 17216 func cksmUnfetch(tls *libc.TLS, pFile uintptr, iOfst sqlite3_int64, pPage uintptr) int32 { /* cksumvfs.c:657:12: */ 17217 pFile = ((pFile) + uintptr(1)*32) 17218 if ((*sqlite3_io_methods1)(unsafe.Pointer((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods)).FiVersion > 2) && ((*sqlite3_io_methods1)(unsafe.Pointer((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods)).FxUnfetch != 0) { 17219 return (*(*func(*libc.TLS, uintptr, sqlite3_int64, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods + 144 /* &.xUnfetch */))))(tls, pFile, iOfst, pPage) 17220 } 17221 return SQLITE_OK 17222 } 17223 17224 // Open a cksm file handle. 17225 func cksmOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags int32, pOutFlags uintptr) int32 { /* cksumvfs.c:668:12: */ 17226 var p uintptr 17227 var pSubFile uintptr 17228 var pSubVfs uintptr 17229 var rc int32 17230 var pDb uintptr 17231 pSubVfs = (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData 17232 if !((flags & (SQLITE_OPEN_MAIN_DB | SQLITE_OPEN_WAL)) == 0) { 17233 goto __1 17234 } 17235 return (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pSubVfs + 40 /* &.xOpen */))))(tls, pSubVfs, zName, pFile, flags, pOutFlags) 17236 __1: 17237 ; 17238 p = pFile 17239 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(CksmFile{}))) 17240 pSubFile = ((pFile) + uintptr(1)*32) 17241 (*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&cksm_io_methods)) 17242 rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pSubVfs + 40 /* &.xOpen */))))(tls, pSubVfs, zName, pSubFile, flags, pOutFlags) 17243 if !(rc != 0) { 17244 goto __2 17245 } 17246 goto cksm_open_done 17247 __2: 17248 ; 17249 if !((flags & SQLITE_OPEN_WAL) != 0) { 17250 goto __3 17251 } 17252 pDb = sqlite3.Xsqlite3_database_file_object(tls, zName) 17253 (*CksmFile)(unsafe.Pointer(p)).FpPartner = pDb 17254 17255 (*CksmFile)(unsafe.Pointer((*CksmFile)(unsafe.Pointer(p)).FpPartner)).FpPartner = p 17256 (*CksmFile)(unsafe.Pointer(p)).FisWal = int8(1) 17257 (*CksmFile)(unsafe.Pointer(p)).FcomputeCksm = (*CksmFile)(unsafe.Pointer((*CksmFile)(unsafe.Pointer(p)).FpPartner)).FcomputeCksm 17258 goto __4 17259 __3: 17260 (*CksmFile)(unsafe.Pointer(p)).FisWal = int8(0) 17261 (*CksmFile)(unsafe.Pointer(p)).FcomputeCksm = int8(0) 17262 __4: 17263 ; 17264 (*CksmFile)(unsafe.Pointer(p)).FzFName = zName 17265 cksm_open_done: 17266 if !(rc != 0) { 17267 goto __5 17268 } 17269 (*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(0) 17270 __5: 17271 ; 17272 return rc 17273 } 17274 17275 // All other VFS methods are pass-thrus. 17276 func cksmDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) int32 { /* cksumvfs.c:709:12: */ 17277 return (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 48 /* &.xDelete */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, zPath, dirSync) 17278 } 17279 17280 func cksmAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut uintptr) int32 { /* cksumvfs.c:712:12: */ 17281 return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 56 /* &.xAccess */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, zPath, flags, pResOut) 17282 } 17283 17284 func cksmFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zOut uintptr) int32 { /* cksumvfs.c:720:12: */ 17285 return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 64 /* &.xFullPathname */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, zPath, nOut, zOut) 17286 } 17287 17288 func cksmDlOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr) uintptr { /* cksumvfs.c:728:13: */ 17289 return (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 72 /* &.xDlOpen */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, zPath) 17290 } 17291 17292 func cksmDlError(tls *libc.TLS, pVfs uintptr, nByte int32, zErrMsg uintptr) { /* cksumvfs.c:731:13: */ 17293 (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 80 /* &.xDlError */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, nByte, zErrMsg) 17294 } 17295 17296 func cksmDlSym(tls *libc.TLS, pVfs uintptr, p uintptr, zSym uintptr) uintptr { /* cksumvfs.c:734:13: */ 17297 return (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 88 /* &.xDlSym */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, p, zSym) 17298 } 17299 17300 func cksmDlClose(tls *libc.TLS, pVfs uintptr, pHandle uintptr) { /* cksumvfs.c:737:13: */ 17301 (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 96 /* &.xDlClose */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, pHandle) 17302 } 17303 17304 func cksmRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uintptr) int32 { /* cksumvfs.c:740:12: */ 17305 return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 104 /* &.xRandomness */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, nByte, zBufOut) 17306 } 17307 17308 func cksmSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) int32 { /* cksumvfs.c:743:12: */ 17309 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 112 /* &.xSleep */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, nMicro) 17310 } 17311 17312 func cksmCurrentTime(tls *libc.TLS, pVfs uintptr, pTimeOut uintptr) int32 { /* cksumvfs.c:746:12: */ 17313 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 120 /* &.xCurrentTime */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, pTimeOut) 17314 } 17315 17316 func cksmGetLastError(tls *libc.TLS, pVfs uintptr, a int32, b uintptr) int32 { /* cksumvfs.c:749:12: */ 17317 return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 128 /* &.xGetLastError */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, a, b) 17318 } 17319 17320 func cksmCurrentTimeInt64(tls *libc.TLS, pVfs uintptr, p uintptr) int32 { /* cksumvfs.c:752:12: */ 17321 bp := tls.Alloc(8) 17322 defer tls.Free(8) 17323 17324 var pOrig uintptr = (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData 17325 var rc int32 17326 17327 if (*sqlite3_vfs)(unsafe.Pointer(pOrig)).FxCurrentTimeInt64 != 0 { 17328 rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pOrig + 136 /* &.xCurrentTimeInt64 */))))(tls, pOrig, p) 17329 } else { 17330 // var r float64 at bp, 8 17331 17332 rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pOrig + 120 /* &.xCurrentTime */))))(tls, pOrig, bp /* &r */) 17333 *(*sqlite3_int64)(unsafe.Pointer(p)) = (sqlite3_int64(*(*float64)(unsafe.Pointer(bp /* r */)) * 86400000.0)) 17334 } 17335 return rc 17336 } 17337 17338 func cksmSetSystemCall(tls *libc.TLS, pVfs uintptr, zName uintptr, pCall sqlite3_syscall_ptr) int32 { /* cksumvfs.c:765:12: */ 17339 return (*(*func(*libc.TLS, uintptr, uintptr, sqlite3_syscall_ptr) int32)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 144 /* &.xSetSystemCall */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, zName, pCall) 17340 } 17341 17342 func cksmGetSystemCall(tls *libc.TLS, pVfs uintptr, zName uintptr) sqlite3_syscall_ptr { /* cksumvfs.c:772:28: */ 17343 return (*(*func(*libc.TLS, uintptr, uintptr) sqlite3_syscall_ptr)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 152 /* &.xGetSystemCall */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, zName) 17344 } 17345 17346 func cksmNextSystemCall(tls *libc.TLS, pVfs uintptr, zName uintptr) uintptr { /* cksumvfs.c:778:19: */ 17347 return (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData + 160 /* &.xNextSystemCall */))))(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData, zName) 17348 } 17349 17350 // Register the verify_checksum() SQL function. 17351 func cksmRegisterFunc(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* cksumvfs.c:784:12: */ 17352 var rc int32 17353 if db == uintptr(0) { 17354 return SQLITE_OK 17355 } 17356 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+4070 /* "verify_checksum" */, 1, 17357 ((SQLITE_UTF8 | SQLITE_INNOCUOUS) | SQLITE_DETERMINISTIC), 17358 uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 17359 f func(*libc.TLS, uintptr, int32, uintptr) 17360 }{cksmVerifyFunc})), uintptr(0), uintptr(0)) 17361 return rc 17362 } 17363 17364 // Register the cksum VFS as the default VFS for the system. 17365 // Also make arrangements to automatically register the "verify_checksum()" 17366 // SQL function on each new database connection. 17367 func cksmRegisterVfs(tls *libc.TLS) int32 { /* cksumvfs.c:807:12: */ 17368 var rc int32 = SQLITE_OK 17369 var pOrig uintptr 17370 if sqlite3.Xsqlite3_vfs_find(tls, ts+3968 /* "cksmvfs" */) != uintptr(0) { 17371 return SQLITE_OK 17372 } 17373 pOrig = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 17374 cksm_vfs.FiVersion = (*sqlite3_vfs)(unsafe.Pointer(pOrig)).FiVersion 17375 cksm_vfs.FpAppData = pOrig 17376 cksm_vfs.FszOsFile = (int32(uint64((*sqlite3_vfs)(unsafe.Pointer(pOrig)).FszOsFile) + uint64(unsafe.Sizeof(CksmFile{})))) 17377 rc = sqlite3.Xsqlite3_vfs_register(tls, uintptr(unsafe.Pointer(&cksm_vfs)), 1) 17378 if rc == SQLITE_OK { 17379 rc = sqlite3.Xsqlite3_auto_extension(tls, *(*uintptr)(unsafe.Pointer(&struct { 17380 f func(*libc.TLS, uintptr, uintptr, uintptr) int32 17381 }{cksmRegisterFunc}))) 17382 } 17383 return rc 17384 } 17385 17386 // This variant of the initializer runs when the extension is 17387 // statically linked. 17388 func sqlite3_register_cksumvfs(tls *libc.TLS, NotUsed uintptr) int32 { /* cksumvfs.c:826:5: */ 17389 _ = NotUsed 17390 return cksmRegisterVfs(tls) 17391 } 17392 17393 func sqlite3_unregister_cksumvfs(tls *libc.TLS) int32 { /* cksumvfs.c:830:5: */ 17394 if sqlite3.Xsqlite3_vfs_find(tls, ts+3968 /* "cksmvfs" */) != 0 { 17395 sqlite3.Xsqlite3_vfs_unregister(tls, uintptr(unsafe.Pointer(&cksm_vfs))) 17396 sqlite3.Xsqlite3_cancel_auto_extension(tls, *(*uintptr)(unsafe.Pointer(&struct { 17397 f func(*libc.TLS, uintptr, uintptr, uintptr) int32 17398 }{cksmRegisterFunc}))) 17399 } 17400 return SQLITE_OK 17401 } 17402 17403 // Forward declaration of objects used by this implementation 17404 type closure_vtab1 = struct { 17405 Fbase sqlite3_vtab 17406 FzDb uintptr 17407 FzSelf uintptr 17408 FzTableName uintptr 17409 FzIdColumn uintptr 17410 FzParentColumn uintptr 17411 Fdb uintptr 17412 FnCursor int32 17413 _ [4]byte 17414 } /* closure.c:156:9 */ 17415 17416 // Forward declaration of objects used by this implementation 17417 type closure_vtab = closure_vtab1 /* closure.c:156:29 */ 17418 type closure_cursor1 = struct { 17419 Fbase sqlite3_vtab_cursor 17420 FpVtab uintptr 17421 FzTableName uintptr 17422 FzIdColumn uintptr 17423 FzParentColumn uintptr 17424 FpCurrent uintptr 17425 FpClosure uintptr 17426 } /* closure.c:157:9 */ 17427 17428 type closure_cursor = closure_cursor1 /* closure.c:157:31 */ 17429 type closure_queue1 = struct { 17430 FpFirst uintptr 17431 FpLast uintptr 17432 } /* closure.c:158:9 */ 17433 17434 type closure_queue = closure_queue1 /* closure.c:158:30 */ 17435 type closure_avl1 = struct { 17436 Fid sqlite3_int64 17437 FiGeneration int32 17438 _ [4]byte 17439 FpList uintptr 17440 FpBefore uintptr 17441 FpAfter uintptr 17442 FpUp uintptr 17443 Fheight int16 17444 Fimbalance int16 17445 _ [4]byte 17446 } /* closure.c:157:9 */ 17447 17448 type closure_avl = closure_avl1 /* closure.c:159:28 */ 17449 17450 // Recompute the closure_avl.height and closure_avl.imbalance fields for p. 17451 // Assume that the children of p have correct heights. 17452 func closureAvlRecomputeHeight(tls *libc.TLS, p uintptr) { /* closure.c:182:13: */ 17453 var hBefore int16 17454 if (*closure_avl)(unsafe.Pointer(p)).FpBefore != 0 { 17455 hBefore = (*closure_avl)(unsafe.Pointer((*closure_avl)(unsafe.Pointer(p)).FpBefore)).Fheight 17456 } else { 17457 hBefore = int16(0) 17458 } 17459 var hAfter int16 17460 if (*closure_avl)(unsafe.Pointer(p)).FpAfter != 0 { 17461 hAfter = (*closure_avl)(unsafe.Pointer((*closure_avl)(unsafe.Pointer(p)).FpAfter)).Fheight 17462 } else { 17463 hAfter = int16(0) 17464 } 17465 (*closure_avl)(unsafe.Pointer(p)).Fimbalance = (int16(int32(hBefore) - int32(hAfter))) // -: pAfter higher. +: pBefore higher 17466 (*closure_avl)(unsafe.Pointer(p)).Fheight = (int16((func() int32 { 17467 if int32(hBefore) > int32(hAfter) { 17468 return int32(hBefore) 17469 } 17470 return int32(hAfter) 17471 }()) + 1)) 17472 } 17473 17474 // P B 17475 // / \ / ** B Z ==> X P 17476 // / \ / ** X Y Y Z 17477 // 17478 func closureAvlRotateBefore(tls *libc.TLS, pP uintptr) uintptr { /* closure.c:197:20: */ 17479 var pB uintptr = (*closure_avl)(unsafe.Pointer(pP)).FpBefore 17480 var pY uintptr = (*closure_avl)(unsafe.Pointer(pB)).FpAfter 17481 (*closure_avl)(unsafe.Pointer(pB)).FpUp = (*closure_avl)(unsafe.Pointer(pP)).FpUp 17482 (*closure_avl)(unsafe.Pointer(pB)).FpAfter = pP 17483 (*closure_avl)(unsafe.Pointer(pP)).FpUp = pB 17484 (*closure_avl)(unsafe.Pointer(pP)).FpBefore = pY 17485 if pY != 0 { 17486 (*closure_avl)(unsafe.Pointer(pY)).FpUp = pP 17487 } 17488 closureAvlRecomputeHeight(tls, pP) 17489 closureAvlRecomputeHeight(tls, pB) 17490 return pB 17491 } 17492 17493 // P A 17494 // / \ / ** X A ==> P Z 17495 // / \ / ** Y Z X Y 17496 // 17497 func closureAvlRotateAfter(tls *libc.TLS, pP uintptr) uintptr { /* closure.c:218:20: */ 17498 var pA uintptr = (*closure_avl)(unsafe.Pointer(pP)).FpAfter 17499 var pY uintptr = (*closure_avl)(unsafe.Pointer(pA)).FpBefore 17500 (*closure_avl)(unsafe.Pointer(pA)).FpUp = (*closure_avl)(unsafe.Pointer(pP)).FpUp 17501 (*closure_avl)(unsafe.Pointer(pA)).FpBefore = pP 17502 (*closure_avl)(unsafe.Pointer(pP)).FpUp = pA 17503 (*closure_avl)(unsafe.Pointer(pP)).FpAfter = pY 17504 if pY != 0 { 17505 (*closure_avl)(unsafe.Pointer(pY)).FpUp = pP 17506 } 17507 closureAvlRecomputeHeight(tls, pP) 17508 closureAvlRecomputeHeight(tls, pA) 17509 return pA 17510 } 17511 17512 // Return a pointer to the pBefore or pAfter pointer in the parent 17513 // of p that points to p. Or if p is the root node, return pp. 17514 func closureAvlFromPtr(tls *libc.TLS, p uintptr, pp uintptr) uintptr { /* closure.c:235:20: */ 17515 var pUp uintptr = (*closure_avl)(unsafe.Pointer(p)).FpUp 17516 if pUp == uintptr(0) { 17517 return pp 17518 } 17519 if (*closure_avl)(unsafe.Pointer(pUp)).FpAfter == p { 17520 return (pUp + 32 /* &.pAfter */) 17521 } 17522 return (pUp + 24 /* &.pBefore */) 17523 } 17524 17525 // Rebalance all nodes starting with p and working up to the root. 17526 // Return the new root. 17527 func closureAvlBalance(tls *libc.TLS, p uintptr) uintptr { /* closure.c:246:20: */ 17528 bp := tls.Alloc(8) 17529 defer tls.Free(8) 17530 *(*uintptr)(unsafe.Pointer(bp)) = p 17531 17532 var pTop uintptr = *(*uintptr)(unsafe.Pointer(bp /* p */)) 17533 var pp uintptr 17534 for *(*uintptr)(unsafe.Pointer(bp /* p */)) != 0 { 17535 closureAvlRecomputeHeight(tls, *(*uintptr)(unsafe.Pointer(bp /* p */))) 17536 if int32((*closure_avl)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* p */)))).Fimbalance) >= 2 { 17537 var pB uintptr = (*closure_avl)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* p */)))).FpBefore 17538 if int32((*closure_avl)(unsafe.Pointer(pB)).Fimbalance) < 0 { 17539 (*closure_avl)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* p */)))).FpBefore = closureAvlRotateAfter(tls, pB) 17540 } 17541 pp = closureAvlFromPtr(tls, *(*uintptr)(unsafe.Pointer(bp /* p */)), bp /* &p */) 17542 *(*uintptr)(unsafe.Pointer(bp /* p */)) = libc.AssignPtrUintptr(pp, closureAvlRotateBefore(tls, *(*uintptr)(unsafe.Pointer(bp /* p */)))) 17543 } else if int32((*closure_avl)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* p */)))).Fimbalance) <= (-2) { 17544 var pA uintptr = (*closure_avl)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* p */)))).FpAfter 17545 if int32((*closure_avl)(unsafe.Pointer(pA)).Fimbalance) > 0 { 17546 (*closure_avl)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* p */)))).FpAfter = closureAvlRotateBefore(tls, pA) 17547 } 17548 pp = closureAvlFromPtr(tls, *(*uintptr)(unsafe.Pointer(bp /* p */)), bp /* &p */) 17549 *(*uintptr)(unsafe.Pointer(bp /* p */)) = libc.AssignPtrUintptr(pp, closureAvlRotateAfter(tls, *(*uintptr)(unsafe.Pointer(bp /* p */)))) 17550 } 17551 pTop = *(*uintptr)(unsafe.Pointer(bp /* p */)) 17552 *(*uintptr)(unsafe.Pointer(bp /* p */)) = (*closure_avl)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* p */)))).FpUp 17553 } 17554 return pTop 17555 } 17556 17557 // Search the tree rooted at p for an entry with id. Return a pointer 17558 // to the entry or return NULL. 17559 func closureAvlSearch(tls *libc.TLS, p uintptr, id sqlite3_int64) uintptr { /* closure.c:271:20: */ 17560 for (p != 0) && (id != (*closure_avl)(unsafe.Pointer(p)).Fid) { 17561 if id < (*closure_avl)(unsafe.Pointer(p)).Fid { 17562 p = (*closure_avl)(unsafe.Pointer(p)).FpBefore 17563 } else { 17564 p = (*closure_avl)(unsafe.Pointer(p)).FpAfter 17565 } 17566 } 17567 return p 17568 } 17569 17570 // Find the first node (the one with the smallest key). 17571 func closureAvlFirst(tls *libc.TLS, p uintptr) uintptr { /* closure.c:280:20: */ 17572 if p != 0 { 17573 for (*closure_avl)(unsafe.Pointer(p)).FpBefore != 0 { 17574 p = (*closure_avl)(unsafe.Pointer(p)).FpBefore 17575 } 17576 } 17577 return p 17578 } 17579 17580 // Return the node with the next larger key after p. 17581 func closureAvlNext(tls *libc.TLS, p uintptr) uintptr { /* closure.c:287:13: */ 17582 var pPrev uintptr = uintptr(0) 17583 for (p != 0) && ((*closure_avl)(unsafe.Pointer(p)).FpAfter == pPrev) { 17584 pPrev = p 17585 p = (*closure_avl)(unsafe.Pointer(p)).FpUp 17586 } 17587 if (p != 0) && (pPrev == uintptr(0)) { 17588 p = closureAvlFirst(tls, (*closure_avl)(unsafe.Pointer(p)).FpAfter) 17589 } 17590 return p 17591 } 17592 17593 // Insert a new node pNew. Return NULL on success. If the key is not 17594 // unique, then do not perform the insert but instead leave pNew unchanged 17595 // and return a pointer to an existing node with the same key. 17596 func closureAvlInsert(tls *libc.TLS, ppHead uintptr, pNew uintptr) uintptr { /* closure.c:303:20: */ 17597 var p uintptr = *(*uintptr)(unsafe.Pointer(ppHead)) 17598 if p == uintptr(0) { 17599 p = pNew 17600 (*closure_avl)(unsafe.Pointer(pNew)).FpUp = uintptr(0) 17601 } else { 17602 for p != 0 { 17603 if (*closure_avl)(unsafe.Pointer(pNew)).Fid < (*closure_avl)(unsafe.Pointer(p)).Fid { 17604 if (*closure_avl)(unsafe.Pointer(p)).FpBefore != 0 { 17605 p = (*closure_avl)(unsafe.Pointer(p)).FpBefore 17606 } else { 17607 (*closure_avl)(unsafe.Pointer(p)).FpBefore = pNew 17608 (*closure_avl)(unsafe.Pointer(pNew)).FpUp = p 17609 break 17610 } 17611 } else if (*closure_avl)(unsafe.Pointer(pNew)).Fid > (*closure_avl)(unsafe.Pointer(p)).Fid { 17612 if (*closure_avl)(unsafe.Pointer(p)).FpAfter != 0 { 17613 p = (*closure_avl)(unsafe.Pointer(p)).FpAfter 17614 } else { 17615 (*closure_avl)(unsafe.Pointer(p)).FpAfter = pNew 17616 (*closure_avl)(unsafe.Pointer(pNew)).FpUp = p 17617 break 17618 } 17619 } else { 17620 return p 17621 } 17622 } 17623 } 17624 (*closure_avl)(unsafe.Pointer(pNew)).FpBefore = uintptr(0) 17625 (*closure_avl)(unsafe.Pointer(pNew)).FpAfter = uintptr(0) 17626 (*closure_avl)(unsafe.Pointer(pNew)).Fheight = int16(1) 17627 (*closure_avl)(unsafe.Pointer(pNew)).Fimbalance = int16(0) 17628 *(*uintptr)(unsafe.Pointer(ppHead)) = closureAvlBalance(tls, p) 17629 return uintptr(0) 17630 } 17631 17632 // Walk the tree can call xDestroy on each node 17633 func closureAvlDestroy(tls *libc.TLS, p uintptr, xDestroy uintptr) { /* closure.c:344:13: */ 17634 if p != 0 { 17635 closureAvlDestroy(tls, (*closure_avl)(unsafe.Pointer(p)).FpBefore, xDestroy) 17636 closureAvlDestroy(tls, (*closure_avl)(unsafe.Pointer(p)).FpAfter, xDestroy) 17637 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&xDestroy)))(tls, p) 17638 } 17639 } 17640 17641 // Add a node to the end of the queue 17642 func queuePush(tls *libc.TLS, pQueue uintptr, pNode uintptr) { /* closure.c:389:13: */ 17643 (*closure_avl)(unsafe.Pointer(pNode)).FpList = uintptr(0) 17644 if (*closure_queue)(unsafe.Pointer(pQueue)).FpLast != 0 { 17645 (*closure_avl)(unsafe.Pointer((*closure_queue)(unsafe.Pointer(pQueue)).FpLast)).FpList = pNode 17646 } else { 17647 (*closure_queue)(unsafe.Pointer(pQueue)).FpFirst = pNode 17648 } 17649 (*closure_queue)(unsafe.Pointer(pQueue)).FpLast = pNode 17650 } 17651 17652 // Extract the oldest element (the front element) from the queue. 17653 func queuePull(tls *libc.TLS, pQueue uintptr) uintptr { /* closure.c:402:20: */ 17654 var p uintptr = (*closure_queue)(unsafe.Pointer(pQueue)).FpFirst 17655 if p != 0 { 17656 (*closure_queue)(unsafe.Pointer(pQueue)).FpFirst = (*closure_avl)(unsafe.Pointer(p)).FpList 17657 if (*closure_queue)(unsafe.Pointer(pQueue)).FpFirst == uintptr(0) { 17658 (*closure_queue)(unsafe.Pointer(pQueue)).FpLast = uintptr(0) 17659 } 17660 } 17661 return p 17662 } 17663 17664 // This function converts an SQL quoted string into an unquoted string 17665 // and returns a pointer to a buffer allocated using sqlite3_malloc() 17666 // containing the result. The caller should eventually free this buffer 17667 // using sqlite3_free. 17668 // 17669 // Examples: 17670 // 17671 // "abc" becomes abc 17672 // 'xyz' becomes xyz 17673 // [pqr] becomes pqr 17674 // `mno` becomes mno 17675 func closureDequote(tls *libc.TLS, zIn uintptr) uintptr { /* closure.c:424:13: */ 17676 var nIn sqlite3_int64 // Size of input string, in bytes 17677 var zOut uintptr // Output (dequoted) string 17678 17679 nIn = sqlite3_int64(libc.Xstrlen(tls, zIn)) 17680 zOut = sqlite3.Xsqlite3_malloc64(tls, (uint64(nIn + int64(1)))) 17681 if zOut != 0 { 17682 var q int8 = *(*int8)(unsafe.Pointer(zIn)) // Quote character (if any ) 17683 17684 if (((int32(q) != '[') && (int32(q) != '\'')) && (int32(q) != '"')) && (int32(q) != '`') { 17685 libc.Xmemcpy(tls, zOut, zIn, (size_t(nIn + int64(1)))) 17686 } else { 17687 var iOut int32 = 0 // Index of next byte to write to output 17688 var iIn int32 // Index of next byte to read from input 17689 17690 if int32(q) == '[' { 17691 q = int8(']') 17692 } 17693 for iIn = 1; sqlite3_int64(iIn) < nIn; iIn++ { 17694 if int32(*(*int8)(unsafe.Pointer(zIn + uintptr(iIn)))) == int32(q) { 17695 iIn++ 17696 } 17697 *(*int8)(unsafe.Pointer(zOut + uintptr(libc.PostIncInt32(&iOut, 1)))) = *(*int8)(unsafe.Pointer(zIn + uintptr(iIn))) 17698 } 17699 } 17700 17701 } 17702 return zOut 17703 } 17704 17705 // Deallocate an closure_vtab object 17706 func closureFree(tls *libc.TLS, p uintptr) { /* closure.c:453:13: */ 17707 if p != 0 { 17708 sqlite3.Xsqlite3_free(tls, (*closure_vtab)(unsafe.Pointer(p)).FzDb) 17709 sqlite3.Xsqlite3_free(tls, (*closure_vtab)(unsafe.Pointer(p)).FzSelf) 17710 sqlite3.Xsqlite3_free(tls, (*closure_vtab)(unsafe.Pointer(p)).FzTableName) 17711 sqlite3.Xsqlite3_free(tls, (*closure_vtab)(unsafe.Pointer(p)).FzIdColumn) 17712 sqlite3.Xsqlite3_free(tls, (*closure_vtab)(unsafe.Pointer(p)).FzParentColumn) 17713 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(closure_vtab{}))) 17714 sqlite3.Xsqlite3_free(tls, p) 17715 } 17716 } 17717 17718 // xDisconnect/xDestroy method for the closure module. 17719 func closureDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* closure.c:468:12: */ 17720 var p uintptr = pVtab 17721 17722 closureFree(tls, p) 17723 return SQLITE_OK 17724 } 17725 17726 // Check to see if the argument is of the form: 17727 // 17728 // KEY = VALUE 17729 // 17730 // If it is, return a pointer to the first character of VALUE. 17731 // If not, return NULL. Spaces around the = are ignored. 17732 func closureValueOfKey(tls *libc.TLS, zKey uintptr, zStr uintptr) uintptr { /* closure.c:483:19: */ 17733 var nKey int32 = int32(libc.Xstrlen(tls, zKey)) 17734 var nStr int32 = int32(libc.Xstrlen(tls, zStr)) 17735 var i int32 17736 if nStr < (nKey + 1) { 17737 return uintptr(0) 17738 } 17739 if libc.Xmemcmp(tls, zStr, zKey, uint64(nKey)) != 0 { 17740 return uintptr(0) 17741 } 17742 for i = nKey; (int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(zStr + uintptr(i))))))*2))) & int32(_ISspace)) != 0; i++ { 17743 } 17744 if int32(*(*int8)(unsafe.Pointer(zStr + uintptr(i)))) != '=' { 17745 return uintptr(0) 17746 } 17747 i++ 17748 for (int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(zStr + uintptr(i))))))*2))) & int32(_ISspace)) != 0 { 17749 i++ 17750 } 17751 return (zStr + uintptr(i)) 17752 } 17753 17754 // xConnect/xCreate method for the closure module. Arguments are: 17755 // 17756 // argv[0] -> module name ("transitive_closure") 17757 // argv[1] -> database name 17758 // argv[2] -> table name 17759 // argv[3...] -> arguments 17760 func closureConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* closure.c:504:12: */ 17761 bp := tls.Alloc(24) 17762 defer tls.Free(24) 17763 17764 var rc int32 // Return code 17765 var pNew uintptr // New virtual table 17766 var zDb uintptr 17767 var zVal uintptr 17768 var i int32 17769 rc = SQLITE_OK 17770 pNew = uintptr(0) 17771 zDb = *(*uintptr)(unsafe.Pointer(argv + 1*8)) 17772 17773 _ = pAux 17774 *(*uintptr)(unsafe.Pointer(ppVtab)) = uintptr(0) 17775 pNew = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(closure_vtab{}))) 17776 if !(pNew == uintptr(0)) { 17777 goto __1 17778 } 17779 return SQLITE_NOMEM 17780 __1: 17781 ; 17782 rc = SQLITE_NOMEM 17783 libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(closure_vtab{}))) 17784 (*closure_vtab)(unsafe.Pointer(pNew)).Fdb = db 17785 (*closure_vtab)(unsafe.Pointer(pNew)).FzDb = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zDb)) 17786 if !((*closure_vtab)(unsafe.Pointer(pNew)).FzDb == uintptr(0)) { 17787 goto __2 17788 } 17789 goto closureConnectError 17790 __2: 17791 ; 17792 (*closure_vtab)(unsafe.Pointer(pNew)).FzSelf = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) 17793 if !((*closure_vtab)(unsafe.Pointer(pNew)).FzSelf == uintptr(0)) { 17794 goto __3 17795 } 17796 goto closureConnectError 17797 __3: 17798 ; 17799 i = 3 17800 __4: 17801 if !(i < argc) { 17802 goto __6 17803 } 17804 zVal = closureValueOfKey(tls, ts+4086 /* "tablename" */, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) 17805 if !(zVal != 0) { 17806 goto __7 17807 } 17808 sqlite3.Xsqlite3_free(tls, (*closure_vtab)(unsafe.Pointer(pNew)).FzTableName) 17809 (*closure_vtab)(unsafe.Pointer(pNew)).FzTableName = closureDequote(tls, zVal) 17810 if !((*closure_vtab)(unsafe.Pointer(pNew)).FzTableName == uintptr(0)) { 17811 goto __8 17812 } 17813 goto closureConnectError 17814 __8: 17815 ; 17816 goto __5 17817 __7: 17818 ; 17819 zVal = closureValueOfKey(tls, ts+4096 /* "idcolumn" */, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) 17820 if !(zVal != 0) { 17821 goto __9 17822 } 17823 sqlite3.Xsqlite3_free(tls, (*closure_vtab)(unsafe.Pointer(pNew)).FzIdColumn) 17824 (*closure_vtab)(unsafe.Pointer(pNew)).FzIdColumn = closureDequote(tls, zVal) 17825 if !((*closure_vtab)(unsafe.Pointer(pNew)).FzIdColumn == uintptr(0)) { 17826 goto __10 17827 } 17828 goto closureConnectError 17829 __10: 17830 ; 17831 goto __5 17832 __9: 17833 ; 17834 zVal = closureValueOfKey(tls, ts+4105 /* "parentcolumn" */, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) 17835 if !(zVal != 0) { 17836 goto __11 17837 } 17838 sqlite3.Xsqlite3_free(tls, (*closure_vtab)(unsafe.Pointer(pNew)).FzParentColumn) 17839 (*closure_vtab)(unsafe.Pointer(pNew)).FzParentColumn = closureDequote(tls, zVal) 17840 if !((*closure_vtab)(unsafe.Pointer(pNew)).FzParentColumn == uintptr(0)) { 17841 goto __12 17842 } 17843 goto closureConnectError 17844 __12: 17845 ; 17846 goto __5 17847 __11: 17848 ; 17849 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3407 /* "unrecognized arg..." */, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)))) 17850 closureFree(tls, pNew) 17851 *(*uintptr)(unsafe.Pointer(ppVtab)) = uintptr(0) 17852 return SQLITE_ERROR 17853 goto __5 17854 __5: 17855 i++ 17856 goto __4 17857 goto __6 17858 __6: 17859 ; 17860 rc = sqlite3.Xsqlite3_declare_vtab(tls, db, 17861 17862 ts+4118 /* "CREATE TABLE x(i..." */) 17863 if !(rc != SQLITE_OK) { 17864 goto __13 17865 } 17866 closureFree(tls, pNew) 17867 __13: 17868 ; 17869 *(*uintptr)(unsafe.Pointer(ppVtab)) = (pNew /* &.base */) 17870 return rc 17871 17872 closureConnectError: 17873 closureFree(tls, pNew) 17874 return rc 17875 } 17876 17877 // Open a new closure cursor. 17878 func closureOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* closure.c:579:12: */ 17879 var p uintptr = pVTab 17880 var pCur uintptr 17881 pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(closure_cursor{}))) 17882 if pCur == uintptr(0) { 17883 return SQLITE_NOMEM 17884 } 17885 libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(closure_cursor{}))) 17886 (*closure_cursor)(unsafe.Pointer(pCur)).FpVtab = p 17887 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) 17888 (*closure_vtab)(unsafe.Pointer(p)).FnCursor++ 17889 return SQLITE_OK 17890 } 17891 17892 // Free up all the memory allocated by a cursor. Set it rLimit to 0 17893 // to indicate that it is at EOF. 17894 func closureClearCursor(tls *libc.TLS, pCur uintptr) { /* closure.c:595:13: */ 17895 closureAvlDestroy(tls, (*closure_cursor)(unsafe.Pointer(pCur)).FpClosure, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) 17896 sqlite3.Xsqlite3_free(tls, (*closure_cursor)(unsafe.Pointer(pCur)).FzTableName) 17897 sqlite3.Xsqlite3_free(tls, (*closure_cursor)(unsafe.Pointer(pCur)).FzIdColumn) 17898 sqlite3.Xsqlite3_free(tls, (*closure_cursor)(unsafe.Pointer(pCur)).FzParentColumn) 17899 (*closure_cursor)(unsafe.Pointer(pCur)).FzTableName = uintptr(0) 17900 (*closure_cursor)(unsafe.Pointer(pCur)).FzIdColumn = uintptr(0) 17901 (*closure_cursor)(unsafe.Pointer(pCur)).FzParentColumn = uintptr(0) 17902 (*closure_cursor)(unsafe.Pointer(pCur)).FpCurrent = uintptr(0) 17903 (*closure_cursor)(unsafe.Pointer(pCur)).FpClosure = uintptr(0) 17904 } 17905 17906 // Close a closure cursor. 17907 func closureClose(tls *libc.TLS, cur uintptr) int32 { /* closure.c:610:12: */ 17908 var pCur uintptr = cur 17909 closureClearCursor(tls, pCur) 17910 (*closure_vtab)(unsafe.Pointer((*closure_cursor)(unsafe.Pointer(pCur)).FpVtab)).FnCursor-- 17911 sqlite3.Xsqlite3_free(tls, pCur) 17912 return SQLITE_OK 17913 } 17914 17915 // Advance a cursor to its next row of output 17916 func closureNext(tls *libc.TLS, cur uintptr) int32 { /* closure.c:621:12: */ 17917 var pCur uintptr = cur 17918 (*closure_cursor)(unsafe.Pointer(pCur)).FpCurrent = closureAvlNext(tls, (*closure_cursor)(unsafe.Pointer(pCur)).FpCurrent) 17919 return SQLITE_OK 17920 } 17921 17922 // Allocate and insert a node 17923 func closureInsertNode(tls *libc.TLS, pQueue uintptr, pCur uintptr, id sqlite3_int64, iGeneration int32) int32 { /* closure.c:630:12: */ 17924 var pNew uintptr = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(closure_avl{}))) 17925 if pNew == uintptr(0) { 17926 return SQLITE_NOMEM 17927 } 17928 libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(closure_avl{}))) 17929 (*closure_avl)(unsafe.Pointer(pNew)).Fid = id 17930 (*closure_avl)(unsafe.Pointer(pNew)).FiGeneration = iGeneration 17931 closureAvlInsert(tls, (pCur + 48 /* &.pClosure */), pNew) 17932 queuePush(tls, pQueue, pNew) 17933 return SQLITE_OK 17934 } 17935 17936 // Called to "rewind" a cursor back to the beginning so that 17937 // it starts its output over again. Always called at least once 17938 // prior to any closureColumn, closureRowid, or closureEof call. 17939 // 17940 // This routine actually computes the closure. 17941 // 17942 // See the comment at the beginning of closureBestIndex() for a 17943 // description of the meaning of idxNum. The idxStr parameter is 17944 // not used. 17945 func closureFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* closure.c:657:12: */ 17946 bp := tls.Alloc(96) 17947 defer tls.Free(96) 17948 17949 var pCur uintptr = pVtabCursor 17950 var pVtab uintptr = (*closure_cursor)(unsafe.Pointer(pCur)).FpVtab 17951 var iRoot sqlite3_int64 17952 var mxGen int32 = 999999999 17953 var zSql uintptr 17954 // var pStmt uintptr at bp+88, 8 17955 17956 var pAvl uintptr 17957 var rc int32 = SQLITE_OK 17958 var zTableName uintptr = (*closure_vtab)(unsafe.Pointer(pVtab)).FzTableName 17959 var zIdColumn uintptr = (*closure_vtab)(unsafe.Pointer(pVtab)).FzIdColumn 17960 var zParentColumn uintptr = (*closure_vtab)(unsafe.Pointer(pVtab)).FzParentColumn 17961 // var sQueue closure_queue at bp+72, 16 17962 17963 _ = idxStr // Unused parameter 17964 _ = argc // Unused parameter 17965 closureClearCursor(tls, pCur) 17966 libc.Xmemset(tls, bp+72 /* &sQueue */, 0, uint64(unsafe.Sizeof(closure_queue{}))) 17967 if (idxNum & 1) == 0 { 17968 // No root=$root in the WHERE clause. Return an empty set 17969 return SQLITE_OK 17970 } 17971 iRoot = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) 17972 if (idxNum & 0x000f0) != 0 { 17973 mxGen = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(((idxNum>>4)&0x0f))*8))) 17974 if (idxNum & 0x00002) != 0 { 17975 mxGen-- 17976 } 17977 } 17978 if (idxNum & 0x00f00) != 0 { 17979 zTableName = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(((idxNum>>8)&0x0f))*8))) 17980 (*closure_cursor)(unsafe.Pointer(pCur)).FzTableName = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zTableName)) 17981 } 17982 if (idxNum & 0x0f000) != 0 { 17983 zIdColumn = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(((idxNum>>12)&0x0f))*8))) 17984 (*closure_cursor)(unsafe.Pointer(pCur)).FzIdColumn = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+8, zIdColumn)) 17985 } 17986 if (idxNum & 0x0f0000) != 0 { 17987 zParentColumn = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(((idxNum>>16)&0x0f))*8))) 17988 (*closure_cursor)(unsafe.Pointer(pCur)).FzParentColumn = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+16, zParentColumn)) 17989 } 17990 17991 zSql = sqlite3.Xsqlite3_mprintf(tls, 17992 ts+4208, /* "SELECT \"%w\".\"%w\"..." */ 17993 libc.VaList(bp+24, zTableName, zIdColumn, zTableName, zTableName, zParentColumn)) 17994 if zSql == uintptr(0) { 17995 return SQLITE_NOMEM 17996 } else { 17997 rc = sqlite3.Xsqlite3_prepare_v2(tls, (*closure_vtab)(unsafe.Pointer(pVtab)).Fdb, zSql, -1, bp+88 /* &pStmt */, uintptr(0)) 17998 sqlite3.Xsqlite3_free(tls, zSql) 17999 if rc != 0 { 18000 sqlite3.Xsqlite3_free(tls, (*closure_vtab)(unsafe.Pointer(pVtab)).Fbase.FzErrMsg) 18001 (*closure_vtab)(unsafe.Pointer(pVtab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+64, sqlite3.Xsqlite3_errmsg(tls, (*closure_vtab)(unsafe.Pointer(pVtab)).Fdb))) 18002 return rc 18003 } 18004 } 18005 if rc == SQLITE_OK { 18006 rc = closureInsertNode(tls, bp+72 /* &sQueue */, pCur, iRoot, 0) 18007 } 18008 for (libc.AssignUintptr(&pAvl, queuePull(tls, bp+72 /* &sQueue */))) != uintptr(0) { 18009 if (*closure_avl)(unsafe.Pointer(pAvl)).FiGeneration >= mxGen { 18010 continue 18011 } 18012 sqlite3.Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */)), 1, (*closure_avl)(unsafe.Pointer(pAvl)).Fid) 18013 for (rc == SQLITE_OK) && (sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */))) == SQLITE_ROW) { 18014 if sqlite3.Xsqlite3_column_type(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */)), 0) == SQLITE_INTEGER { 18015 var iNew sqlite3_int64 = sqlite3.Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */)), 0) 18016 if closureAvlSearch(tls, (*closure_cursor)(unsafe.Pointer(pCur)).FpClosure, iNew) == uintptr(0) { 18017 rc = closureInsertNode(tls, bp+72 /* &sQueue */, pCur, iNew, ((*closure_avl)(unsafe.Pointer(pAvl)).FiGeneration + 1)) 18018 } 18019 } 18020 } 18021 sqlite3.Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */))) 18022 } 18023 sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */))) 18024 if rc == SQLITE_OK { 18025 (*closure_cursor)(unsafe.Pointer(pCur)).FpCurrent = closureAvlFirst(tls, (*closure_cursor)(unsafe.Pointer(pCur)).FpClosure) 18026 } 18027 18028 return rc 18029 } 18030 18031 // Only the word and distance columns have values. All other columns 18032 // return NULL 18033 func closureColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* closure.c:743:12: */ 18034 var pCur uintptr = cur 18035 switch i { 18036 case CLOSURE_COL_ID: 18037 { 18038 sqlite3.Xsqlite3_result_int64(tls, ctx, (*closure_avl)(unsafe.Pointer((*closure_cursor)(unsafe.Pointer(pCur)).FpCurrent)).Fid) 18039 break 18040 18041 } 18042 case CLOSURE_COL_DEPTH: 18043 { 18044 sqlite3.Xsqlite3_result_int(tls, ctx, (*closure_avl)(unsafe.Pointer((*closure_cursor)(unsafe.Pointer(pCur)).FpCurrent)).FiGeneration) 18045 break 18046 18047 } 18048 case CLOSURE_COL_ROOT: 18049 { 18050 sqlite3.Xsqlite3_result_null(tls, ctx) 18051 break 18052 18053 } 18054 case CLOSURE_COL_TABLENAME: 18055 { 18056 sqlite3.Xsqlite3_result_text(tls, ctx, 18057 func() uintptr { 18058 if (*closure_cursor)(unsafe.Pointer(pCur)).FzTableName != 0 { 18059 return (*closure_cursor)(unsafe.Pointer(pCur)).FzTableName 18060 } 18061 return (*closure_vtab)(unsafe.Pointer((*closure_cursor)(unsafe.Pointer(pCur)).FpVtab)).FzTableName 18062 }(), 18063 -1, libc.UintptrFromInt32(-1)) 18064 break 18065 18066 } 18067 case CLOSURE_COL_IDCOLUMN: 18068 { 18069 sqlite3.Xsqlite3_result_text(tls, ctx, 18070 func() uintptr { 18071 if (*closure_cursor)(unsafe.Pointer(pCur)).FzIdColumn != 0 { 18072 return (*closure_cursor)(unsafe.Pointer(pCur)).FzIdColumn 18073 } 18074 return (*closure_vtab)(unsafe.Pointer((*closure_cursor)(unsafe.Pointer(pCur)).FpVtab)).FzIdColumn 18075 }(), 18076 -1, libc.UintptrFromInt32(-1)) 18077 break 18078 18079 } 18080 case CLOSURE_COL_PARENTCOLUMN: 18081 { 18082 sqlite3.Xsqlite3_result_text(tls, ctx, 18083 func() uintptr { 18084 if (*closure_cursor)(unsafe.Pointer(pCur)).FzParentColumn != 0 { 18085 return (*closure_cursor)(unsafe.Pointer(pCur)).FzParentColumn 18086 } 18087 return (*closure_vtab)(unsafe.Pointer((*closure_cursor)(unsafe.Pointer(pCur)).FpVtab)).FzParentColumn 18088 }(), 18089 -1, libc.UintptrFromInt32(-1)) 18090 break 18091 18092 } 18093 } 18094 return SQLITE_OK 18095 } 18096 18097 // The rowid. For the closure table, this is the same as the "id" column. 18098 func closureRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* closure.c:783:12: */ 18099 var pCur uintptr = cur 18100 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*closure_avl)(unsafe.Pointer((*closure_cursor)(unsafe.Pointer(pCur)).FpCurrent)).Fid 18101 return SQLITE_OK 18102 } 18103 18104 // EOF indicator 18105 func closureEof(tls *libc.TLS, cur uintptr) int32 { /* closure.c:792:12: */ 18106 var pCur uintptr = cur 18107 return (libc.Bool32((*closure_cursor)(unsafe.Pointer(pCur)).FpCurrent == uintptr(0))) 18108 } 18109 18110 // Search for terms of these forms: 18111 // 18112 // (A) root = $root 18113 // (B1) depth < $depth 18114 // (B2) depth <= $depth 18115 // (B3) depth = $depth 18116 // (C) tablename = $tablename 18117 // (D) idcolumn = $idcolumn 18118 // (E) parentcolumn = $parentcolumn 18119 // 18120 // 18121 // 18122 // idxNum meaning 18123 // ---------- ------------------------------------------------------ 18124 // 0x00000001 Term of the form (A) found 18125 // 0x00000002 The term of bit-2 is like (B1) 18126 // 0x000000f0 Index in filter.argv[] of $depth. 0 if not used. 18127 // 0x00000f00 Index in filter.argv[] of $tablename. 0 if not used. 18128 // 0x0000f000 Index in filter.argv[] of $idcolumn. 0 if not used 18129 // 0x000f0000 Index in filter.argv[] of $parentcolumn. 0 if not used. 18130 // 18131 // There must be a term of type (A). If there is not, then the index type 18132 // is 0 and the query will return an empty set. 18133 func closureBestIndex(tls *libc.TLS, pTab uintptr, pIdxInfo uintptr) int32 { /* closure.c:822:12: */ 18134 var iPlan int32 = 0 18135 var i int32 18136 var idx int32 = 1 18137 var pConstraint uintptr 18138 var pVtab uintptr = pTab 18139 var rCost float64 = 10000000.0 18140 18141 pConstraint = (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint 18142 i = 0 18143 __1: 18144 if !(i < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { 18145 goto __3 18146 } 18147 { 18148 if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 { 18149 goto __2 18150 } 18151 if (((iPlan & 1) == 0) && 18152 ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == CLOSURE_COL_ROOT)) && 18153 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { 18154 iPlan = iPlan | (1) 18155 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 1 18156 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) 18157 rCost = rCost / (100.0) 18158 } 18159 if (((iPlan & 0x0000f0) == 0) && 18160 ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == CLOSURE_COL_DEPTH)) && 18161 (((int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LT) || 18162 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LE)) || 18163 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ)) { 18164 iPlan = iPlan | (idx << 4) 18165 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = libc.PreIncInt32(&idx, 1) 18166 if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LT { 18167 iPlan = iPlan | (0x000002) 18168 } 18169 rCost = rCost / (5.0) 18170 } 18171 if (((iPlan & 0x000f00) == 0) && 18172 ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == CLOSURE_COL_TABLENAME)) && 18173 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { 18174 iPlan = iPlan | (idx << 8) 18175 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = libc.PreIncInt32(&idx, 1) 18176 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) 18177 rCost = rCost / (5.0) 18178 } 18179 if (((iPlan & 0x00f000) == 0) && 18180 ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == CLOSURE_COL_IDCOLUMN)) && 18181 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { 18182 iPlan = iPlan | (idx << 12) 18183 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = libc.PreIncInt32(&idx, 1) 18184 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) 18185 } 18186 if (((iPlan & 0x0f0000) == 0) && 18187 ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == CLOSURE_COL_PARENTCOLUMN)) && 18188 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { 18189 iPlan = iPlan | (idx << 16) 18190 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = libc.PreIncInt32(&idx, 1) 18191 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) 18192 } 18193 18194 } 18195 goto __2 18196 __2: 18197 i++ 18198 pConstraint += 12 18199 goto __1 18200 goto __3 18201 __3: 18202 ; 18203 if ((((*closure_vtab)(unsafe.Pointer(pVtab)).FzTableName == uintptr(0)) && ((iPlan & 0x000f00) == 0)) || 18204 (((*closure_vtab)(unsafe.Pointer(pVtab)).FzIdColumn == uintptr(0)) && ((iPlan & 0x00f000) == 0))) || 18205 (((*closure_vtab)(unsafe.Pointer(pVtab)).FzParentColumn == uintptr(0)) && ((iPlan & 0x0f0000) == 0)) { 18206 // All of tablename, idcolumn, and parentcolumn must be specified 18207 // in either the CREATE VIRTUAL TABLE or in the WHERE clause constraints 18208 // or else the result is an empty set. 18209 iPlan = 0 18210 } 18211 if (iPlan & 1) == 0 { 18212 // If there is no usable "root=?" term, then set the index-type to 0. 18213 // Also clear any argvIndex variables already set. This is necessary 18214 // to prevent the core from throwing an "xBestIndex malfunction error" 18215 // error (because the argvIndex values are not contiguously assigned 18216 // starting from 1). 18217 rCost = rCost * (1e30) 18218 i = 0 18219 __4: 18220 if !(i < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { 18221 goto __6 18222 } 18223 { 18224 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 0 18225 18226 } 18227 goto __5 18228 __5: 18229 i++ 18230 pConstraint += 12 18231 goto __4 18232 goto __6 18233 __6: 18234 ; 18235 iPlan = 0 18236 } 18237 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = iPlan 18238 if (((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy == 1) && 18239 ((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).FiColumn == CLOSURE_COL_ID)) && 18240 (int32((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).Fdesc) == 0) { 18241 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 1 18242 } 18243 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = rCost 18244 18245 return SQLITE_OK 18246 } 18247 18248 // A virtual table module that implements the "transitive_closure". 18249 var closureModule = sqlite3_module{ // iVersion 18250 FxCreate: 0, // xCreate 18251 FxConnect: 0, // xConnect 18252 FxBestIndex: 0, // xBestIndex 18253 FxDisconnect: 0, // xDisconnect 18254 FxDestroy: 0, // xDestroy 18255 FxOpen: 0, // xOpen - open a cursor 18256 FxClose: 0, // xClose - close a cursor 18257 FxFilter: 0, // xFilter - configure scan constraints 18258 FxNext: 0, // xNext - advance a cursor 18259 FxEof: 0, // xEof - check for end of scan 18260 FxColumn: 0, // xColumn - read data 18261 FxRowid: 0, // xShadowName 18262 } /* closure.c:918:23 */ 18263 18264 // Register the closure virtual table 18265 func sqlite3_closure_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* closure.c:953:5: */ 18266 var rc int32 = SQLITE_OK 18267 _ = pApi 18268 18269 _ = pzErrMsg 18270 rc = sqlite3.Xsqlite3_create_module(tls, db, ts+4254 /* "transitive_closu..." */, uintptr(unsafe.Pointer(&closureModule)), uintptr(0)) 18271 return rc 18272 } 18273 18274 // If we are compiling with optimizing read this file. It contains 18275 // several optimizing inline functions and macros. 18276 18277 // A macro to hint to the compiler that a function should not be 18278 // inlined. 18279 18280 // Max size of the error message in a CsvReader 18281 18282 // Size of the CsvReader input buffer 18283 18284 // A context object used when read a CSV file. 18285 type CsvReader1 = struct { 18286 Fin uintptr 18287 Fz uintptr 18288 Fn int32 18289 FnAlloc int32 18290 FnLine int32 18291 FbNotFirst int32 18292 FcTerm int32 18293 _ [4]byte 18294 FiIn size_t 18295 FnIn size_t 18296 FzIn uintptr 18297 FzErr [200]int8 18298 } /* csv.c:73:9 */ 18299 18300 // If we are compiling with optimizing read this file. It contains 18301 // several optimizing inline functions and macros. 18302 18303 // A macro to hint to the compiler that a function should not be 18304 // inlined. 18305 18306 // Max size of the error message in a CsvReader 18307 18308 // Size of the CsvReader input buffer 18309 18310 // A context object used when read a CSV file. 18311 type CsvReader = CsvReader1 /* csv.c:73:26 */ 18312 18313 // Initialize a CsvReader object 18314 func csv_reader_init(tls *libc.TLS, p uintptr) { /* csv.c:89:13: */ 18315 (*CsvReader)(unsafe.Pointer(p)).Fin = uintptr(0) 18316 (*CsvReader)(unsafe.Pointer(p)).Fz = uintptr(0) 18317 (*CsvReader)(unsafe.Pointer(p)).Fn = 0 18318 (*CsvReader)(unsafe.Pointer(p)).FnAlloc = 0 18319 (*CsvReader)(unsafe.Pointer(p)).FnLine = 0 18320 (*CsvReader)(unsafe.Pointer(p)).FbNotFirst = 0 18321 (*CsvReader)(unsafe.Pointer(p)).FnIn = uint64(0) 18322 (*CsvReader)(unsafe.Pointer(p)).FzIn = uintptr(0) 18323 *(*int8)(unsafe.Pointer((p + 64 /* &.zErr */))) = int8(0) 18324 } 18325 18326 // Close and reset a CsvReader object 18327 func csv_reader_reset(tls *libc.TLS, p uintptr) { /* csv.c:102:13: */ 18328 if (*CsvReader)(unsafe.Pointer(p)).Fin != 0 { 18329 libc.Xfclose(tls, (*CsvReader)(unsafe.Pointer(p)).Fin) 18330 sqlite3.Xsqlite3_free(tls, (*CsvReader)(unsafe.Pointer(p)).FzIn) 18331 } 18332 sqlite3.Xsqlite3_free(tls, (*CsvReader)(unsafe.Pointer(p)).Fz) 18333 csv_reader_init(tls, p) 18334 } 18335 18336 // Report an error on a CsvReader 18337 func csv_errmsg(tls *libc.TLS, p uintptr, zFormat uintptr, va uintptr) { /* csv.c:112:13: */ 18338 var ap va_list 18339 _ = ap 18340 ap = va 18341 sqlite3.Xsqlite3_vsnprintf(tls, CSV_MXERR, p+64 /* &.zErr */, zFormat, ap) 18342 _ = ap 18343 } 18344 18345 // Open the file associated with a CsvReader 18346 // Return the number of errors. 18347 func csv_reader_open(tls *libc.TLS, p uintptr, zFilename uintptr, zData uintptr) int32 { /* csv.c:122:12: */ 18348 bp := tls.Alloc(8) 18349 defer tls.Free(8) 18350 18351 if zFilename != 0 { 18352 (*CsvReader)(unsafe.Pointer(p)).FzIn = sqlite3.Xsqlite3_malloc(tls, CSV_INBUFSZ) 18353 if (*CsvReader)(unsafe.Pointer(p)).FzIn == uintptr(0) { 18354 csv_errmsg(tls, p, ts+1930 /* "out of memory" */, 0) 18355 return 1 18356 } 18357 (*CsvReader)(unsafe.Pointer(p)).Fin = libc.Xfopen(tls, zFilename, ts+4273 /* "rb" */) 18358 if (*CsvReader)(unsafe.Pointer(p)).Fin == uintptr(0) { 18359 sqlite3.Xsqlite3_free(tls, (*CsvReader)(unsafe.Pointer(p)).FzIn) 18360 csv_reader_reset(tls, p) 18361 csv_errmsg(tls, p, ts+4276 /* "cannot open '%s'..." */, libc.VaList(bp, zFilename)) 18362 return 1 18363 } 18364 } else { 18365 18366 (*CsvReader)(unsafe.Pointer(p)).FzIn = zData 18367 (*CsvReader)(unsafe.Pointer(p)).FnIn = libc.Xstrlen(tls, zData) 18368 } 18369 return 0 18370 } 18371 18372 // The input buffer has overflowed. Refill the input buffer, then 18373 // return the next character 18374 func csv_getc_refill(tls *libc.TLS, p uintptr) int32 { /* csv.c:151:25: */ 18375 var got size_t 18376 18377 // Only called on an empty input buffer 18378 // Only called if reading froma file 18379 18380 got = libc.Xfread(tls, (*CsvReader)(unsafe.Pointer(p)).FzIn, uint64(1), uint64(CSV_INBUFSZ), (*CsvReader)(unsafe.Pointer(p)).Fin) 18381 if got == uint64(0) { 18382 return -1 18383 } 18384 (*CsvReader)(unsafe.Pointer(p)).FnIn = got 18385 (*CsvReader)(unsafe.Pointer(p)).FiIn = uint64(1) 18386 return int32(*(*int8)(unsafe.Pointer((*CsvReader)(unsafe.Pointer(p)).FzIn))) 18387 } 18388 18389 // Return the next character of input. Return EOF at end of input. 18390 func csv_getc(tls *libc.TLS, p uintptr) int32 { /* csv.c:165:12: */ 18391 if (*CsvReader)(unsafe.Pointer(p)).FiIn >= (*CsvReader)(unsafe.Pointer(p)).FnIn { 18392 if (*CsvReader)(unsafe.Pointer(p)).Fin != uintptr(0) { 18393 return csv_getc_refill(tls, p) 18394 } 18395 return -1 18396 } 18397 return int32(*(*uint8)(unsafe.Pointer(((*CsvReader)(unsafe.Pointer(p)).FzIn) + uintptr(libc.PostIncUint64(&(*CsvReader)(unsafe.Pointer(p)).FiIn, 1))))) 18398 } 18399 18400 // Increase the size of p->z and append character c to the end. 18401 // Return 0 on success and non-zero if there is an OOM error 18402 func csv_resize_and_append(tls *libc.TLS, p uintptr, c int8) int32 { /* csv.c:175:25: */ 18403 var zNew uintptr 18404 var nNew int32 = (((*CsvReader)(unsafe.Pointer(p)).FnAlloc * 2) + 100) 18405 zNew = sqlite3.Xsqlite3_realloc64(tls, (*CsvReader)(unsafe.Pointer(p)).Fz, uint64(nNew)) 18406 if zNew != 0 { 18407 (*CsvReader)(unsafe.Pointer(p)).Fz = zNew 18408 (*CsvReader)(unsafe.Pointer(p)).FnAlloc = nNew 18409 *(*int8)(unsafe.Pointer((*CsvReader)(unsafe.Pointer(p)).Fz + uintptr(libc.PostIncInt32(&(*CsvReader)(unsafe.Pointer(p)).Fn, 1)))) = c 18410 return 0 18411 } else { 18412 csv_errmsg(tls, p, ts+1930 /* "out of memory" */, 0) 18413 return 1 18414 } 18415 return int32(0) 18416 } 18417 18418 // Append a single character to the CsvReader.z[] array. 18419 // Return 0 on success and non-zero if there is an OOM error 18420 func csv_append(tls *libc.TLS, p uintptr, c int8) int32 { /* csv.c:192:12: */ 18421 if (*CsvReader)(unsafe.Pointer(p)).Fn >= ((*CsvReader)(unsafe.Pointer(p)).FnAlloc - 1) { 18422 return csv_resize_and_append(tls, p, c) 18423 } 18424 *(*int8)(unsafe.Pointer((*CsvReader)(unsafe.Pointer(p)).Fz + uintptr(libc.PostIncInt32(&(*CsvReader)(unsafe.Pointer(p)).Fn, 1)))) = c 18425 return 0 18426 } 18427 18428 // Read a single field of CSV text. Compatible with rfc4180 and extended 18429 // with the option of having a separator other than ",". 18430 // 18431 // + Input comes from p->in. 18432 // + Store results in p->z of length p->n. Space to hold p->z comes 18433 // from sqlite3_malloc64(). 18434 // + Keep track of the line number in p->nLine. 18435 // + Store the character that terminates the field in p->cTerm. Store 18436 // EOF on end-of-file. 18437 // 18438 // Return 0 at EOF or on OOM. On EOF, the p->cTerm character will have 18439 // been set to EOF. 18440 func csv_read_one_field(tls *libc.TLS, p uintptr) uintptr { /* csv.c:211:13: */ 18441 bp := tls.Alloc(32) 18442 defer tls.Free(32) 18443 18444 var c int32 18445 (*CsvReader)(unsafe.Pointer(p)).Fn = 0 18446 c = csv_getc(tls, p) 18447 if c == (-1) { 18448 (*CsvReader)(unsafe.Pointer(p)).FcTerm = -1 18449 return uintptr(0) 18450 } 18451 if c == '"' { 18452 var pc int32 18453 var ppc int32 18454 var startLine int32 = (*CsvReader)(unsafe.Pointer(p)).FnLine 18455 pc = libc.AssignInt32(&ppc, 0) 18456 for 1 != 0 { 18457 c = csv_getc(tls, p) 18458 if (c <= '"') || (pc == '"') { 18459 if c == '\n' { 18460 (*CsvReader)(unsafe.Pointer(p)).FnLine++ 18461 } 18462 if c == '"' { 18463 if pc == '"' { 18464 pc = 0 18465 continue 18466 } 18467 } 18468 if ((((c == ',') && (pc == '"')) || 18469 ((c == '\n') && (pc == '"'))) || 18470 (((c == '\n') && (pc == '\r')) && (ppc == '"'))) || 18471 ((c == (-1)) && (pc == '"')) { 18472 for ok := true; ok; ok = (int32(*(*int8)(unsafe.Pointer((*CsvReader)(unsafe.Pointer(p)).Fz + uintptr((*CsvReader)(unsafe.Pointer(p)).Fn)))) != '"') { 18473 (*CsvReader)(unsafe.Pointer(p)).Fn-- 18474 } 18475 (*CsvReader)(unsafe.Pointer(p)).FcTerm = int32(int8(c)) 18476 break 18477 } 18478 if (pc == '"') && (c != '\r') { 18479 csv_errmsg(tls, p, ts+4305 /* "line %d: unescap..." */, libc.VaList(bp, (*CsvReader)(unsafe.Pointer(p)).FnLine, '"')) 18480 break 18481 } 18482 if c == (-1) { 18483 csv_errmsg(tls, p, ts+4337, /* "line %d: untermi..." */ 18484 libc.VaList(bp+16, startLine, '"')) 18485 (*CsvReader)(unsafe.Pointer(p)).FcTerm = int32(int8(c)) 18486 break 18487 } 18488 } 18489 if csv_append(tls, p, int8(c)) != 0 { 18490 return uintptr(0) 18491 } 18492 ppc = pc 18493 pc = c 18494 } 18495 } else { 18496 // If this is the first field being parsed and it begins with the 18497 // UTF-8 BOM (0xEF BB BF) then skip the BOM 18498 if ((c & 0xff) == 0xef) && ((*CsvReader)(unsafe.Pointer(p)).FbNotFirst == 0) { 18499 csv_append(tls, p, int8(c)) 18500 c = csv_getc(tls, p) 18501 if (c & 0xff) == 0xbb { 18502 csv_append(tls, p, int8(c)) 18503 c = csv_getc(tls, p) 18504 if (c & 0xff) == 0xbf { 18505 (*CsvReader)(unsafe.Pointer(p)).FbNotFirst = 1 18506 (*CsvReader)(unsafe.Pointer(p)).Fn = 0 18507 return csv_read_one_field(tls, p) 18508 } 18509 } 18510 } 18511 for (c > ',') || (((c != (-1)) && (c != ',')) && (c != '\n')) { 18512 if csv_append(tls, p, int8(c)) != 0 { 18513 return uintptr(0) 18514 } 18515 c = csv_getc(tls, p) 18516 } 18517 if c == '\n' { 18518 (*CsvReader)(unsafe.Pointer(p)).FnLine++ 18519 if ((*CsvReader)(unsafe.Pointer(p)).Fn > 0) && (int32(*(*int8)(unsafe.Pointer((*CsvReader)(unsafe.Pointer(p)).Fz + uintptr(((*CsvReader)(unsafe.Pointer(p)).Fn - 1))))) == '\r') { 18520 (*CsvReader)(unsafe.Pointer(p)).Fn-- 18521 } 18522 } 18523 (*CsvReader)(unsafe.Pointer(p)).FcTerm = int32(int8(c)) 18524 } 18525 if (*CsvReader)(unsafe.Pointer(p)).Fz != 0 { 18526 *(*int8)(unsafe.Pointer((*CsvReader)(unsafe.Pointer(p)).Fz + uintptr((*CsvReader)(unsafe.Pointer(p)).Fn))) = int8(0) 18527 } 18528 (*CsvReader)(unsafe.Pointer(p)).FbNotFirst = 1 18529 return (*CsvReader)(unsafe.Pointer(p)).Fz 18530 } 18531 18532 // An instance of the CSV virtual table 18533 type CsvTable1 = struct { 18534 Fbase sqlite3_vtab 18535 FzFilename uintptr 18536 FzData uintptr 18537 FiStart int64 18538 FnCol int32 18539 FtstFlags uint32 18540 } /* csv.c:307:9 */ 18541 18542 // An instance of the CSV virtual table 18543 type CsvTable = CsvTable1 /* csv.c:314:3 */ 18544 18545 // Allowed values for tstFlags 18546 18547 // A cursor for the CSV virtual table 18548 type CsvCursor1 = struct { 18549 Fbase sqlite3_vtab_cursor 18550 Frdr CsvReader 18551 FazVal uintptr 18552 FaLen uintptr 18553 FiRowid sqlite3_int64 18554 } /* csv.c:320:9 */ 18555 18556 // Allowed values for tstFlags 18557 18558 // A cursor for the CSV virtual table 18559 type CsvCursor = CsvCursor1 /* csv.c:326:3 */ 18560 18561 // Transfer error message text from a reader into a CsvTable 18562 func csv_xfer_error(tls *libc.TLS, pTab uintptr, pRdr uintptr) { /* csv.c:329:13: */ 18563 bp := tls.Alloc(8) 18564 defer tls.Free(8) 18565 18566 sqlite3.Xsqlite3_free(tls, (*CsvTable)(unsafe.Pointer(pTab)).Fbase.FzErrMsg) 18567 (*CsvTable)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, pRdr+64 /* &.zErr */)) 18568 } 18569 18570 // This method is the destructor fo a CsvTable object. 18571 func csvtabDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* csv.c:337:12: */ 18572 var p uintptr = pVtab 18573 sqlite3.Xsqlite3_free(tls, (*CsvTable)(unsafe.Pointer(p)).FzFilename) 18574 sqlite3.Xsqlite3_free(tls, (*CsvTable)(unsafe.Pointer(p)).FzData) 18575 sqlite3.Xsqlite3_free(tls, p) 18576 return SQLITE_OK 18577 } 18578 18579 // Skip leading whitespace. Return a pointer to the first non-whitespace 18580 // character, or to the zero terminator if the string has only whitespace 18581 func csv_skip_whitespace(tls *libc.TLS, z uintptr) uintptr { /* csv.c:347:19: */ 18582 for (int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(z)))))*2))) & int32(_ISspace)) != 0 { 18583 z++ 18584 } 18585 return z 18586 } 18587 18588 // Remove trailing whitespace from the end of string z[] 18589 func csv_trim_whitespace(tls *libc.TLS, z uintptr) { /* csv.c:353:13: */ 18590 var n size_t = libc.Xstrlen(tls, z) 18591 for (n > uint64(0)) && ((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(z + uintptr(n))))))*2))) & int32(_ISspace)) != 0) { 18592 n-- 18593 } 18594 *(*int8)(unsafe.Pointer(z + uintptr(n))) = int8(0) 18595 } 18596 18597 // Dequote the string 18598 func csv_dequote(tls *libc.TLS, z uintptr) { /* csv.c:360:13: */ 18599 var j int32 18600 var cQuote int8 = *(*int8)(unsafe.Pointer(z)) 18601 var i size_t 18602 var n size_t 18603 18604 if (int32(cQuote) != '\'') && (int32(cQuote) != '"') { 18605 return 18606 } 18607 n = libc.Xstrlen(tls, z) 18608 if (n < uint64(2)) || (int32(*(*int8)(unsafe.Pointer(z + uintptr((n - uint64(1)))))) != int32(*(*int8)(unsafe.Pointer(z)))) { 18609 return 18610 } 18611 i = uint64(1) 18612 j = 0 18613 for ; i < (n - uint64(1)); i++ { 18614 if (int32(*(*int8)(unsafe.Pointer(z + uintptr(i)))) == int32(cQuote)) && (int32(*(*int8)(unsafe.Pointer(z + uintptr((i + uint64(1)))))) == int32(cQuote)) { 18615 i++ 18616 } 18617 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&j, 1)))) = *(*int8)(unsafe.Pointer(z + uintptr(i))) 18618 } 18619 *(*int8)(unsafe.Pointer(z + uintptr(j))) = int8(0) 18620 } 18621 18622 // Check to see if the string is of the form: "TAG = VALUE" with optional 18623 // whitespace before and around tokens. If it is, return a pointer to the 18624 // first character of VALUE. If it is not, return NULL. 18625 func csv_parameter(tls *libc.TLS, zTag uintptr, nTag int32, z uintptr) uintptr { /* csv.c:379:19: */ 18626 z = csv_skip_whitespace(tls, z) 18627 if libc.Xstrncmp(tls, zTag, z, uint64(nTag)) != 0 { 18628 return uintptr(0) 18629 } 18630 z = csv_skip_whitespace(tls, (z + uintptr(nTag))) 18631 if int32(*(*int8)(unsafe.Pointer(z))) != '=' { 18632 return uintptr(0) 18633 } 18634 return csv_skip_whitespace(tls, (z + uintptr(1))) 18635 } 18636 18637 // Decode a parameter that requires a dequoted string. 18638 // 18639 // Return 1 if the parameter is seen, or 0 if not. 1 is returned 18640 // even if there is an error. If an error occurs, then an error message 18641 // is left in p->zErr. If there are no errors, p->zErr[0]==0. 18642 func csv_string_parameter(tls *libc.TLS, p uintptr, zParam uintptr, zArg uintptr, pzVal uintptr) int32 { /* csv.c:393:12: */ 18643 bp := tls.Alloc(16) 18644 defer tls.Free(16) 18645 18646 var zValue uintptr 18647 zValue = csv_parameter(tls, zParam, int32(libc.Xstrlen(tls, zParam)), zArg) 18648 if zValue == uintptr(0) { 18649 return 0 18650 } 18651 *(*int8)(unsafe.Pointer((p + 64 /* &.zErr */))) = int8(0) 18652 if *(*uintptr)(unsafe.Pointer(pzVal)) != 0 { 18653 csv_errmsg(tls, p, ts+4376 /* "more than one '%..." */, libc.VaList(bp, zParam)) 18654 return 1 18655 } 18656 *(*uintptr)(unsafe.Pointer(pzVal)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+8, zValue)) 18657 if *(*uintptr)(unsafe.Pointer(pzVal)) == uintptr(0) { 18658 csv_errmsg(tls, p, ts+1930 /* "out of memory" */, 0) 18659 return 1 18660 } 18661 csv_trim_whitespace(tls, *(*uintptr)(unsafe.Pointer(pzVal))) 18662 csv_dequote(tls, *(*uintptr)(unsafe.Pointer(pzVal))) 18663 return 1 18664 } 18665 18666 // Return 0 if the argument is false and 1 if it is true. Return -1 if 18667 // we cannot really tell. 18668 func csv_boolean(tls *libc.TLS, z uintptr) int32 { /* csv.c:421:12: */ 18669 if (((sqlite3.Xsqlite3_stricmp(tls, ts+4045 /* "yes" */, z) == 0) || 18670 (sqlite3.Xsqlite3_stricmp(tls, ts+4049 /* "on" */, z) == 0)) || 18671 (sqlite3.Xsqlite3_stricmp(tls, ts+4405 /* "true" */, z) == 0)) || 18672 ((int32(*(*int8)(unsafe.Pointer(z))) == '1') && (int32(*(*int8)(unsafe.Pointer(z + 1))) == 0)) { 18673 return 1 18674 } 18675 if (((sqlite3.Xsqlite3_stricmp(tls, ts+4410 /* "no" */, z) == 0) || 18676 (sqlite3.Xsqlite3_stricmp(tls, ts+4413 /* "off" */, z) == 0)) || 18677 (sqlite3.Xsqlite3_stricmp(tls, ts+4417 /* "false" */, z) == 0)) || 18678 ((int32(*(*int8)(unsafe.Pointer(z))) == '0') && (int32(*(*int8)(unsafe.Pointer(z + 1))) == 0)) { 18679 return 0 18680 } 18681 return -1 18682 } 18683 18684 // Check to see if the string is of the form: "TAG = BOOLEAN" or just "TAG". 18685 // If it is, set *pValue to be the value of the boolean ("true" if there is 18686 // not "= BOOLEAN" component) and return non-zero. If the input string 18687 // does not begin with TAG, return zero. 18688 func csv_boolean_parameter(tls *libc.TLS, zTag uintptr, nTag int32, z uintptr, pValue uintptr) int32 { /* csv.c:444:12: */ 18689 var b int32 18690 z = csv_skip_whitespace(tls, z) 18691 if libc.Xstrncmp(tls, zTag, z, uint64(nTag)) != 0 { 18692 return 0 18693 } 18694 z = csv_skip_whitespace(tls, (z + uintptr(nTag))) 18695 if int32(*(*int8)(unsafe.Pointer(z))) == 0 { 18696 *(*int32)(unsafe.Pointer(pValue)) = 1 18697 return 1 18698 } 18699 if int32(*(*int8)(unsafe.Pointer(z))) != '=' { 18700 return 0 18701 } 18702 z = csv_skip_whitespace(tls, (z + uintptr(1))) 18703 b = csv_boolean(tls, z) 18704 if b >= 0 { 18705 *(*int32)(unsafe.Pointer(pValue)) = b 18706 return 1 18707 } 18708 return 0 18709 } 18710 18711 // Parameters: 18712 // filename=FILENAME Name of file containing CSV content 18713 // data=TEXT Direct CSV content. 18714 // schema=SCHEMA Alternative CSV schema. 18715 // header=YES|NO First row of CSV defines the names of 18716 // columns if "yes". Default "no". 18717 // columns=N Assume the CSV file contains N columns. 18718 // 18719 // Only available if compiled with SQLITE_TEST: 18720 // 18721 // testflags=N Bitmask of test flags. Optional 18722 // 18723 // If schema= is omitted, then the columns are named "c0", "c1", "c2", 18724 // and so forth. If columns=N is omitted, then the file is opened and 18725 // the number of columns in the first row is counted to determine the 18726 // column count. If header=YES, then the first row is skipped. 18727 func csvtabConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* csv.c:486:12: */ 18728 bp := tls.Alloc(372) 18729 defer tls.Free(372) 18730 18731 var pNew uintptr // The CsvTable object to construct 18732 var bHeader int32 // header= flags. -1 means not seen yet 18733 var rc int32 // Result code from this routine 18734 var i int32 18735 var j int32 // Loop counters 18736 var tstFlags int32 // Value for testflags=N parameter 18737 // var b int32 at bp+368, 4 18738 // Value of a boolean parameter 18739 var nCol int32 // Value of the columns= parameter 18740 // var sRdr CsvReader at bp+80, 264 18741 18742 // var azPValue [3]uintptr at bp+344, 24 18743 18744 var z uintptr 18745 var zValue uintptr 18746 var z1 uintptr 18747 var pStr uintptr 18748 var zSep uintptr 18749 var iCol int32 18750 pNew = uintptr(0) 18751 bHeader = -1 18752 rc = SQLITE_OK 18753 tstFlags = 0 18754 nCol = -99 // Parameter values 18755 18756 libc.Xmemset(tls, bp+80 /* &sRdr */, 0, uint64(unsafe.Sizeof(CsvReader{}))) 18757 libc.Xmemset(tls, bp+344 /* &azPValue[0] */, 0, uint64(unsafe.Sizeof([3]uintptr{}))) 18758 i = 3 18759 __1: 18760 if !(i < argc) { 18761 goto __3 18762 } 18763 z = *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)) 18764 j = 0 18765 __4: 18766 if !(uint64(j) < (uint64(unsafe.Sizeof(azParam)) / uint64(unsafe.Sizeof(uintptr(0))))) { 18767 goto __6 18768 } 18769 if !(csv_string_parameter(tls, bp+80 /* &sRdr */, azParam[j], z, (bp+344 /* &azPValue */ +uintptr(j)*8)) != 0) { 18770 goto __7 18771 } 18772 goto __6 18773 __7: 18774 ; 18775 goto __5 18776 __5: 18777 j++ 18778 goto __4 18779 goto __6 18780 __6: 18781 ; 18782 if !(uint64(j) < (uint64(unsafe.Sizeof(azParam)) / uint64(unsafe.Sizeof(uintptr(0))))) { 18783 goto __8 18784 } 18785 if !(*(*int8)(unsafe.Pointer((bp + 80 /* &sRdr */ + 64 /* &.zErr */))) != 0) { 18786 goto __10 18787 } 18788 goto csvtab_connect_error 18789 __10: 18790 ; 18791 goto __9 18792 __8: 18793 if !(csv_boolean_parameter(tls, ts+4423 /* "header" */, 6, z, bp+368 /* &b */) != 0) { 18794 goto __11 18795 } 18796 if !(bHeader >= 0) { 18797 goto __13 18798 } 18799 csv_errmsg(tls, bp+80 /* &sRdr */, ts+4430 /* "more than one 'h..." */, 0) 18800 goto csvtab_connect_error 18801 __13: 18802 ; 18803 bHeader = *(*int32)(unsafe.Pointer(bp + 368 /* b */)) 18804 goto __12 18805 __11: 18806 if !((libc.AssignUintptr(&zValue, csv_parameter(tls, ts+4463 /* "testflags" */, 9, z))) != uintptr(0)) { 18807 goto __14 18808 } 18809 tstFlags = int32(uint32(libc.Xatoi(tls, zValue))) 18810 goto __15 18811 __14: 18812 if !((libc.AssignUintptr(&zValue, csv_parameter(tls, ts+4473 /* "columns" */, 7, z))) != uintptr(0)) { 18813 goto __16 18814 } 18815 if !(nCol > 0) { 18816 goto __18 18817 } 18818 csv_errmsg(tls, bp+80 /* &sRdr */, ts+4481 /* "more than one 'c..." */, 0) 18819 goto csvtab_connect_error 18820 __18: 18821 ; 18822 nCol = libc.Xatoi(tls, zValue) 18823 if !(nCol <= 0) { 18824 goto __19 18825 } 18826 csv_errmsg(tls, bp+80 /* &sRdr */, ts+4515 /* "column= value mu..." */, 0) 18827 goto csvtab_connect_error 18828 __19: 18829 ; 18830 goto __17 18831 __16: 18832 18833 csv_errmsg(tls, bp+80 /* &sRdr */, ts+4546 /* "bad parameter: '..." */, libc.VaList(bp, z)) 18834 goto csvtab_connect_error 18835 __17: 18836 ; 18837 __15: 18838 ; 18839 __12: 18840 ; 18841 __9: 18842 ; 18843 goto __2 18844 __2: 18845 i++ 18846 goto __1 18847 goto __3 18848 __3: 18849 ; 18850 if !((libc.Bool32((*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */))) == uintptr(0))) == (libc.Bool32((*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + 1*8))) == uintptr(0)))) { 18851 goto __20 18852 } 18853 csv_errmsg(tls, bp+80 /* &sRdr */, ts+4566 /* "must specify eit..." */, 0) 18854 goto csvtab_connect_error 18855 __20: 18856 ; 18857 18858 if !(((nCol <= 0) || (bHeader == 1)) && 18859 (csv_reader_open(tls, bp+80 /* &sRdr */, *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */)), *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + 1*8))) != 0)) { 18860 goto __21 18861 } 18862 goto csvtab_connect_error 18863 __21: 18864 ; 18865 pNew = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(CsvTable{}))) 18866 *(*uintptr)(unsafe.Pointer(ppVtab)) = pNew 18867 if !(pNew == uintptr(0)) { 18868 goto __22 18869 } 18870 goto csvtab_connect_oom 18871 __22: 18872 ; 18873 libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(CsvTable{}))) 18874 if !((*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + 2*8))) == uintptr(0)) { 18875 goto __23 18876 } 18877 pStr = sqlite3.Xsqlite3_str_new(tls, uintptr(0)) 18878 zSep = ts + 489 /* "" */ 18879 iCol = 0 18880 sqlite3.Xsqlite3_str_appendf(tls, pStr, ts+884 /* "CREATE TABLE x(" */, 0) 18881 if !((nCol < 0) && (bHeader < 1)) { 18882 goto __25 18883 } 18884 nCol = 0 18885 __26: 18886 csv_read_one_field(tls, bp+80 /* &sRdr */) 18887 nCol++ 18888 goto __27 18889 __27: 18890 if (*CsvReader)(unsafe.Pointer(bp+80 /* &sRdr */)).FcTerm == ',' { 18891 goto __26 18892 } 18893 goto __28 18894 __28: 18895 ; 18896 __25: 18897 ; 18898 if !((nCol > 0) && (bHeader < 1)) { 18899 goto __29 18900 } 18901 iCol = 0 18902 __31: 18903 if !(iCol < nCol) { 18904 goto __33 18905 } 18906 sqlite3.Xsqlite3_str_appendf(tls, pStr, ts+4618 /* "%sc%d TEXT" */, libc.VaList(bp+8, zSep, iCol)) 18907 zSep = ts + 4629 /* "," */ 18908 goto __32 18909 __32: 18910 iCol++ 18911 goto __31 18912 goto __33 18913 __33: 18914 ; 18915 goto __30 18916 __29: 18917 __34: 18918 z1 = csv_read_one_field(tls, bp+80 /* &sRdr */) 18919 if !(((nCol > 0) && (iCol < nCol)) || ((nCol < 0) && (bHeader != 0))) { 18920 goto __37 18921 } 18922 sqlite3.Xsqlite3_str_appendf(tls, pStr, ts+4631 /* "%s\"%w\" TEXT" */, libc.VaList(bp+24, zSep, z1)) 18923 zSep = ts + 4629 /* "," */ 18924 iCol++ 18925 __37: 18926 ; 18927 goto __35 18928 __35: 18929 if (*CsvReader)(unsafe.Pointer(bp+80 /* &sRdr */)).FcTerm == ',' { 18930 goto __34 18931 } 18932 goto __36 18933 __36: 18934 ; 18935 if !(nCol < 0) { 18936 goto __38 18937 } 18938 nCol = iCol 18939 goto __39 18940 __38: 18941 __40: 18942 if !(iCol < nCol) { 18943 goto __41 18944 } 18945 sqlite3.Xsqlite3_str_appendf(tls, pStr, ts+4618 /* "%sc%d TEXT" */, libc.VaList(bp+40, zSep, libc.PreIncInt32(&iCol, 1))) 18946 zSep = ts + 4629 /* "," */ 18947 goto __40 18948 __41: 18949 ; 18950 __39: 18951 ; 18952 __30: 18953 ; 18954 (*CsvTable)(unsafe.Pointer(pNew)).FnCol = nCol 18955 sqlite3.Xsqlite3_str_appendf(tls, pStr, ts+490 /* ")" */, 0) 18956 (*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + 2*8))) = sqlite3.Xsqlite3_str_finish(tls, pStr) 18957 if !((*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + 2*8))) == uintptr(0)) { 18958 goto __42 18959 } 18960 goto csvtab_connect_oom 18961 __42: 18962 ; 18963 goto __24 18964 __23: 18965 if !(nCol < 0) { 18966 goto __43 18967 } 18968 __45: 18969 csv_read_one_field(tls, bp+80 /* &sRdr */) 18970 (*CsvTable)(unsafe.Pointer(pNew)).FnCol++ 18971 goto __46 18972 __46: 18973 if (*CsvReader)(unsafe.Pointer(bp+80 /* &sRdr */)).FcTerm == ',' { 18974 goto __45 18975 } 18976 goto __47 18977 __47: 18978 ; 18979 goto __44 18980 __43: 18981 (*CsvTable)(unsafe.Pointer(pNew)).FnCol = nCol 18982 __44: 18983 ; 18984 __24: 18985 ; 18986 (*CsvTable)(unsafe.Pointer(pNew)).FzFilename = *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */)) 18987 (*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */))) = uintptr(0) 18988 (*CsvTable)(unsafe.Pointer(pNew)).FzData = *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + 1*8)) 18989 (*(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + 1*8))) = uintptr(0) 18990 (*CsvTable)(unsafe.Pointer(pNew)).FtstFlags = uint32(tstFlags) 18991 if !(bHeader != 1) { 18992 goto __48 18993 } 18994 (*CsvTable)(unsafe.Pointer(pNew)).FiStart = int64(0) 18995 goto __49 18996 __48: 18997 if !((*CsvTable)(unsafe.Pointer(pNew)).FzData != 0) { 18998 goto __50 18999 } 19000 (*CsvTable)(unsafe.Pointer(pNew)).FiStart = int64(int32((*CsvReader)(unsafe.Pointer(bp + 80 /* &sRdr */)).FiIn)) 19001 goto __51 19002 __50: 19003 (*CsvTable)(unsafe.Pointer(pNew)).FiStart = int64((int32((size_t(libc.Xftell(tls, (*CsvReader)(unsafe.Pointer(bp+80 /* &sRdr */)).Fin)) - (*CsvReader)(unsafe.Pointer(bp+80 /* &sRdr */)).FnIn) + (*CsvReader)(unsafe.Pointer(bp+80 /* &sRdr */)).FiIn))) 19004 __51: 19005 ; 19006 __49: 19007 ; 19008 csv_reader_reset(tls, bp+80 /* &sRdr */) 19009 rc = sqlite3.Xsqlite3_declare_vtab(tls, db, *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + 2*8))) 19010 if !(rc != 0) { 19011 goto __52 19012 } 19013 csv_errmsg(tls, bp+80 /* &sRdr */, ts+4643 /* "bad schema: '%s'..." */, libc.VaList(bp+56, *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + 2*8)), sqlite3.Xsqlite3_errmsg(tls, db))) 19014 goto csvtab_connect_error 19015 __52: 19016 ; 19017 i = 0 19018 __53: 19019 if !(uint64(i) < (uint64(unsafe.Sizeof([3]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0))))) { 19020 goto __55 19021 } 19022 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + uintptr(i)*8))) 19023 goto __54 19024 __54: 19025 i++ 19026 goto __53 19027 goto __55 19028 __55: 19029 ; 19030 // Rationale for DIRECTONLY: 19031 // An attacker who controls a database schema could use this vtab 19032 // to exfiltrate sensitive data from other files in the filesystem. 19033 // And, recommended practice is to put all CSV virtual tables in the 19034 // TEMP namespace, so they should still be usable from within TEMP 19035 // views, so there shouldn't be a serious loss of functionality by 19036 // prohibiting the use of this vtab from persistent triggers and views. 19037 sqlite3.Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_DIRECTONLY, 0) 19038 return SQLITE_OK 19039 19040 csvtab_connect_oom: 19041 rc = SQLITE_NOMEM 19042 csv_errmsg(tls, bp+80 /* &sRdr */, ts+1930 /* "out of memory" */, 0) 19043 19044 csvtab_connect_error: 19045 if !(pNew != 0) { 19046 goto __56 19047 } 19048 csvtabDisconnect(tls, (pNew /* &.base */)) 19049 __56: 19050 ; 19051 i = 0 19052 __57: 19053 if !(uint64(i) < (uint64(unsafe.Sizeof([3]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0))))) { 19054 goto __59 19055 } 19056 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 344 /* &azPValue[0] */ + uintptr(i)*8))) 19057 goto __58 19058 __58: 19059 i++ 19060 goto __57 19061 goto __59 19062 __59: 19063 ; 19064 if !(*(*int8)(unsafe.Pointer((bp + 80 /* &sRdr */ + 64 /* &.zErr */))) != 0) { 19065 goto __60 19066 } 19067 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(pzErr))) 19068 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+72, bp+80 /* &sRdr */ +64 /* &.zErr */)) 19069 __60: 19070 ; 19071 csv_reader_reset(tls, bp+80 /* &sRdr */) 19072 if !(rc == SQLITE_OK) { 19073 goto __61 19074 } 19075 rc = SQLITE_ERROR 19076 __61: 19077 ; 19078 return rc 19079 } 19080 19081 var azParam = [3]uintptr{ 19082 ts + 4665 /* "filename" */, ts + 4674 /* "data" */, ts + 4679, /* "schema" */ 19083 } /* csv.c:504:21 */ 19084 19085 // Reset the current row content held by a CsvCursor. 19086 func csvtabCursorRowReset(tls *libc.TLS, pCur uintptr) { /* csv.c:667:13: */ 19087 var pTab uintptr = (*CsvCursor)(unsafe.Pointer(pCur)).Fbase.FpVtab 19088 var i int32 19089 for i = 0; i < (*CsvTable)(unsafe.Pointer(pTab)).FnCol; i++ { 19090 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer((*CsvCursor)(unsafe.Pointer(pCur)).FazVal + uintptr(i)*8))) 19091 *(*uintptr)(unsafe.Pointer((*CsvCursor)(unsafe.Pointer(pCur)).FazVal + uintptr(i)*8)) = uintptr(0) 19092 *(*int32)(unsafe.Pointer((*CsvCursor)(unsafe.Pointer(pCur)).FaLen + uintptr(i)*4)) = 0 19093 } 19094 } 19095 19096 // The xConnect and xCreate methods do the same thing, but they must be 19097 // different so that the virtual table is not an eponymous virtual table. 19098 func csvtabCreate(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* csv.c:681:12: */ 19099 return csvtabConnect(tls, db, pAux, argc, argv, ppVtab, pzErr) 19100 } 19101 19102 // Destructor for a CsvCursor. 19103 func csvtabClose(tls *libc.TLS, cur uintptr) int32 { /* csv.c:694:12: */ 19104 var pCur uintptr = cur 19105 csvtabCursorRowReset(tls, pCur) 19106 csv_reader_reset(tls, (pCur + 8 /* &.rdr */)) 19107 sqlite3.Xsqlite3_free(tls, cur) 19108 return SQLITE_OK 19109 } 19110 19111 // Constructor for a new CsvTable cursor object. 19112 func csvtabOpen(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* csv.c:705:12: */ 19113 var pTab uintptr = p 19114 var pCur uintptr 19115 var nByte size_t 19116 nByte = (uint64(unsafe.Sizeof(CsvCursor{})) + ((uint64(unsafe.Sizeof(uintptr(0))) + uint64(unsafe.Sizeof(int32(0)))) * uint64((*CsvTable)(unsafe.Pointer(pTab)).FnCol))) 19117 pCur = sqlite3.Xsqlite3_malloc64(tls, uint64(nByte)) 19118 if pCur == uintptr(0) { 19119 return SQLITE_NOMEM 19120 } 19121 libc.Xmemset(tls, pCur, 0, nByte) 19122 (*CsvCursor)(unsafe.Pointer(pCur)).FazVal = (pCur + 1*296) 19123 (*CsvCursor)(unsafe.Pointer(pCur)).FaLen = ((*CsvCursor)(unsafe.Pointer(pCur)).FazVal + uintptr((*CsvTable)(unsafe.Pointer(pTab)).FnCol)*8) 19124 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) 19125 if csv_reader_open(tls, (pCur+8 /* &.rdr */), (*CsvTable)(unsafe.Pointer(pTab)).FzFilename, (*CsvTable)(unsafe.Pointer(pTab)).FzData) != 0 { 19126 csv_xfer_error(tls, pTab, (pCur + 8 /* &.rdr */)) 19127 return SQLITE_ERROR 19128 } 19129 return SQLITE_OK 19130 } 19131 19132 // Advance a CsvCursor to its next row of input. 19133 // Set the EOF marker if we reach the end of input. 19134 func csvtabNext(tls *libc.TLS, cur uintptr) int32 { /* csv.c:728:12: */ 19135 var pCur uintptr = cur 19136 var pTab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab 19137 var i int32 = 0 19138 var z uintptr 19139 for ok := true; ok; ok = ((*CsvCursor)(unsafe.Pointer(pCur)).Frdr.FcTerm == ',') { 19140 z = csv_read_one_field(tls, (pCur + 8 /* &.rdr */)) 19141 if z == uintptr(0) { 19142 break 19143 } 19144 if i < (*CsvTable)(unsafe.Pointer(pTab)).FnCol { 19145 if *(*int32)(unsafe.Pointer((*CsvCursor)(unsafe.Pointer(pCur)).FaLen + uintptr(i)*4)) < ((*CsvCursor)(unsafe.Pointer(pCur)).Frdr.Fn + 1) { 19146 var zNew uintptr = sqlite3.Xsqlite3_realloc64(tls, *(*uintptr)(unsafe.Pointer((*CsvCursor)(unsafe.Pointer(pCur)).FazVal + uintptr(i)*8)), (uint64((*CsvCursor)(unsafe.Pointer(pCur)).Frdr.Fn + 1))) 19147 if zNew == uintptr(0) { 19148 csv_errmsg(tls, (pCur + 8 /* &.rdr */), ts+1930 /* "out of memory" */, 0) 19149 csv_xfer_error(tls, pTab, (pCur + 8 /* &.rdr */)) 19150 break 19151 } 19152 *(*uintptr)(unsafe.Pointer((*CsvCursor)(unsafe.Pointer(pCur)).FazVal + uintptr(i)*8)) = zNew 19153 *(*int32)(unsafe.Pointer((*CsvCursor)(unsafe.Pointer(pCur)).FaLen + uintptr(i)*4)) = ((*CsvCursor)(unsafe.Pointer(pCur)).Frdr.Fn + 1) 19154 } 19155 libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer((*CsvCursor)(unsafe.Pointer(pCur)).FazVal + uintptr(i)*8)), z, (uint64((*CsvCursor)(unsafe.Pointer(pCur)).Frdr.Fn + 1))) 19156 i++ 19157 } 19158 } 19159 if (z == uintptr(0)) || (((*CsvCursor)(unsafe.Pointer(pCur)).Frdr.FcTerm == (-1)) && (i < (*CsvTable)(unsafe.Pointer(pTab)).FnCol)) { 19160 (*CsvCursor)(unsafe.Pointer(pCur)).FiRowid = int64(-1) 19161 } else { 19162 (*CsvCursor)(unsafe.Pointer(pCur)).FiRowid++ 19163 for i < (*CsvTable)(unsafe.Pointer(pTab)).FnCol { 19164 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer((*CsvCursor)(unsafe.Pointer(pCur)).FazVal + uintptr(i)*8))) 19165 *(*uintptr)(unsafe.Pointer((*CsvCursor)(unsafe.Pointer(pCur)).FazVal + uintptr(i)*8)) = uintptr(0) 19166 *(*int32)(unsafe.Pointer((*CsvCursor)(unsafe.Pointer(pCur)).FaLen + uintptr(i)*4)) = 0 19167 i++ 19168 } 19169 } 19170 return SQLITE_OK 19171 } 19172 19173 // Return values of columns for the row at which the CsvCursor 19174 // is currently pointing. 19175 func csvtabColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* csv.c:771:12: */ 19176 var pCur uintptr = cur 19177 var pTab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab 19178 if ((i >= 0) && (i < (*CsvTable)(unsafe.Pointer(pTab)).FnCol)) && (*(*uintptr)(unsafe.Pointer((*CsvCursor)(unsafe.Pointer(pCur)).FazVal + uintptr(i)*8)) != uintptr(0)) { 19179 sqlite3.Xsqlite3_result_text(tls, ctx, *(*uintptr)(unsafe.Pointer((*CsvCursor)(unsafe.Pointer(pCur)).FazVal + uintptr(i)*8)), -1, libc.UintptrFromInt32(-1)) 19180 } 19181 return SQLITE_OK 19182 } 19183 19184 // Return the rowid for the current row. 19185 func csvtabRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* csv.c:787:12: */ 19186 var pCur uintptr = cur 19187 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*CsvCursor)(unsafe.Pointer(pCur)).FiRowid 19188 return SQLITE_OK 19189 } 19190 19191 // Return TRUE if the cursor has been moved off of the last 19192 // row of output. 19193 func csvtabEof(tls *libc.TLS, cur uintptr) int32 { /* csv.c:797:12: */ 19194 var pCur uintptr = cur 19195 return (libc.Bool32((*CsvCursor)(unsafe.Pointer(pCur)).FiRowid < int64(0))) 19196 } 19197 19198 // Only a full table scan is supported. So xFilter simply rewinds to 19199 // the beginning. 19200 func csvtabFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* csv.c:806:12: */ 19201 var pCur uintptr = pVtabCursor 19202 var pTab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab 19203 (*CsvCursor)(unsafe.Pointer(pCur)).FiRowid = int64(0) 19204 if (*CsvCursor)(unsafe.Pointer(pCur)).Frdr.Fin == uintptr(0) { 19205 19206 (*CsvCursor)(unsafe.Pointer(pCur)).Frdr.FiIn = size_t((*CsvTable)(unsafe.Pointer(pTab)).FiStart) 19207 } else { 19208 libc.Xfseek(tls, (*CsvCursor)(unsafe.Pointer(pCur)).Frdr.Fin, (*CsvTable)(unsafe.Pointer(pTab)).FiStart, SEEK_SET) 19209 (*CsvCursor)(unsafe.Pointer(pCur)).Frdr.FiIn = uint64(0) 19210 (*CsvCursor)(unsafe.Pointer(pCur)).Frdr.FnIn = uint64(0) 19211 } 19212 return csvtabNext(tls, pVtabCursor) 19213 } 19214 19215 // Only a forward full table scan is supported. xBestIndex is mostly 19216 // a no-op. If CSVTEST_FIDX is set, then the presence of equality 19217 // constraints lowers the estimated cost, which is fiction, but is useful 19218 // for testing certain kinds of virtual table behavior. 19219 func csvtabBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* csv.c:833:12: */ 19220 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(1000000) 19221 if ((*CsvTable)(unsafe.Pointer((tab))).FtstFlags & uint32(CSVTEST_FIDX)) != uint32(0) { 19222 // The usual (and sensible) case is to always do a full table scan. 19223 // The code in this branch only runs when testflags=1. This code 19224 // generates an artifical and unrealistic plan which is useful 19225 // for testing virtual table logic but is not helpful to real applications. 19226 // 19227 // Any ==, LIKE, or GLOB constraint is marked as usable by the virtual 19228 // table (even though it is not) and the cost of running the virtual table 19229 // is reduced from 1 million to just 10. The constraints are *not* marked 19230 // as omittable, however, so the query planner should still generate a 19231 // plan that gives a correct answer, even if they plan is not optimal. 19232 var i int32 19233 var nConst int32 = 0 19234 for i = 0; i < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; i++ { 19235 var op uint8 19236 if int32((*sqlite3_index_constraint)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint+uintptr(i)*12)).Fusable) == 0 { 19237 continue 19238 } 19239 op = (*sqlite3_index_constraint)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12)).Fop 19240 if ((int32(op) == SQLITE_INDEX_CONSTRAINT_EQ) || 19241 (int32(op) == SQLITE_INDEX_CONSTRAINT_LIKE)) || 19242 (int32(op) == SQLITE_INDEX_CONSTRAINT_GLOB) { 19243 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(10) 19244 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(nConst)*8)).FargvIndex = (nConst + 1) 19245 nConst++ 19246 } 19247 } 19248 } 19249 return SQLITE_OK 19250 } 19251 19252 var CsvModule = sqlite3_module{ // iVersion 19253 FxCreate: 0, // xCreate 19254 FxConnect: 0, // xConnect 19255 FxBestIndex: 0, // xBestIndex 19256 FxDisconnect: 0, // xDisconnect 19257 FxDestroy: 0, // xDestroy 19258 FxOpen: 0, // xOpen - open a cursor 19259 FxClose: 0, // xClose - close a cursor 19260 FxFilter: 0, // xFilter - configure scan constraints 19261 FxNext: 0, // xNext - advance a cursor 19262 FxEof: 0, // xEof - check for end of scan 19263 FxColumn: 0, // xColumn - read data 19264 FxRowid: 0, // xRename 19265 } /* csv.c:872:23 */ 19266 19267 // For virtual table testing, make a version of the CSV virtual table 19268 // available that has an xUpdate function. But the xUpdate always returns 19269 // SQLITE_READONLY since the CSV file is not really writable. 19270 func csvtabUpdate(tls *libc.TLS, p uintptr, n int32, v uintptr, x uintptr) int32 { /* csv.c:901:12: */ 19271 return SQLITE_READONLY 19272 } 19273 19274 var CsvModuleFauxWrite = sqlite3_module{ // iVersion 19275 FxCreate: 0, // xCreate 19276 FxConnect: 0, // xConnect 19277 FxBestIndex: 0, // xBestIndex 19278 FxDisconnect: 0, // xDisconnect 19279 FxDestroy: 0, // xDestroy 19280 FxOpen: 0, // xOpen - open a cursor 19281 FxClose: 0, // xClose - close a cursor 19282 FxFilter: 0, // xFilter - configure scan constraints 19283 FxNext: 0, // xNext - advance a cursor 19284 FxEof: 0, // xEof - check for end of scan 19285 FxColumn: 0, // xColumn - read data 19286 FxRowid: 0, // xRowid - read data 19287 FxUpdate: 0, // xRename 19288 } /* csv.c:904:23 */ 19289 19290 // This routine is called when the extension is loaded. The new 19291 // CSV virtual table module is registered with the calling database 19292 // connection. 19293 func sqlite3_csv_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* csv.c:939:5: */ 19294 var rc int32 19295 _ = pApi 19296 19297 rc = sqlite3.Xsqlite3_create_module(tls, db, ts+4686 /* "csv" */, uintptr(unsafe.Pointer(&CsvModule)), uintptr(0)) 19298 if rc == SQLITE_OK { 19299 rc = sqlite3.Xsqlite3_create_module(tls, db, ts+4690 /* "csv_wr" */, uintptr(unsafe.Pointer(&CsvModuleFauxWrite)), uintptr(0)) 19300 } 19301 return rc 19302 } 19303 19304 // Floating-point inline functions for stdlib.h. 19305 // Copyright (C) 2012-2018 Free Software Foundation, Inc. 19306 // This file is part of the GNU C Library. 19307 // 19308 // The GNU C Library is free software; you can redistribute it and/or 19309 // modify it under the terms of the GNU Lesser General Public 19310 // License as published by the Free Software Foundation; either 19311 // version 2.1 of the License, or (at your option) any later version. 19312 // 19313 // The GNU C Library is distributed in the hope that it will be useful, 19314 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19315 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19316 // Lesser General Public License for more details. 19317 // 19318 // You should have received a copy of the GNU Lesser General Public 19319 // License along with the GNU C Library; if not, see 19320 // <http://www.gnu.org/licenses/>. 19321 19322 // Define some macros helping to catch buffer overflows. 19323 19324 // Mark a function parameter as unused, to suppress nuisance compiler 19325 // warnings. 19326 19327 // A decimal object 19328 type Decimal1 = struct { 19329 Fsign int8 19330 Foom int8 19331 FisNull int8 19332 FisInit int8 19333 FnDigit int32 19334 FnFrac int32 19335 _ [4]byte 19336 Fa uintptr 19337 } /* decimal.c:32:9 */ 19338 19339 // Floating-point inline functions for stdlib.h. 19340 // Copyright (C) 2012-2018 Free Software Foundation, Inc. 19341 // This file is part of the GNU C Library. 19342 // 19343 // The GNU C Library is free software; you can redistribute it and/or 19344 // modify it under the terms of the GNU Lesser General Public 19345 // License as published by the Free Software Foundation; either 19346 // version 2.1 of the License, or (at your option) any later version. 19347 // 19348 // The GNU C Library is distributed in the hope that it will be useful, 19349 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19350 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19351 // Lesser General Public License for more details. 19352 // 19353 // You should have received a copy of the GNU Lesser General Public 19354 // License along with the GNU C Library; if not, see 19355 // <http://www.gnu.org/licenses/>. 19356 19357 // Define some macros helping to catch buffer overflows. 19358 19359 // Mark a function parameter as unused, to suppress nuisance compiler 19360 // warnings. 19361 19362 // A decimal object 19363 type Decimal = Decimal1 /* decimal.c:32:24 */ 19364 19365 // Release memory held by a Decimal, but do not free the object itself. 19366 func decimal_clear(tls *libc.TLS, p uintptr) { /* decimal.c:46:13: */ 19367 sqlite3.Xsqlite3_free(tls, (*Decimal)(unsafe.Pointer(p)).Fa) 19368 } 19369 19370 // Destroy a Decimal object 19371 func decimal_free(tls *libc.TLS, p uintptr) { /* decimal.c:53:13: */ 19372 if p != 0 { 19373 decimal_clear(tls, p) 19374 sqlite3.Xsqlite3_free(tls, p) 19375 } 19376 } 19377 19378 // Allocate a new Decimal object. Initialize it to the number given 19379 // by the input string. 19380 func decimal_new(tls *libc.TLS, pCtx uintptr, pIn uintptr, nAlt int32, zAlt uintptr) uintptr { /* decimal.c:64:16: */ 19381 var p uintptr 19382 var n int32 19383 var i int32 19384 var zIn uintptr 19385 var iExp int32 19386 var j int32 19387 var neg int32 19388 var c int8 19389 var nExtra int32 19390 iExp = 0 19391 p = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Decimal{}))) 19392 if !(p == uintptr(0)) { 19393 goto __1 19394 } 19395 goto new_no_mem 19396 __1: 19397 ; 19398 (*Decimal)(unsafe.Pointer(p)).Fsign = int8(0) 19399 (*Decimal)(unsafe.Pointer(p)).Foom = int8(0) 19400 (*Decimal)(unsafe.Pointer(p)).FisInit = int8(1) 19401 (*Decimal)(unsafe.Pointer(p)).FisNull = int8(0) 19402 (*Decimal)(unsafe.Pointer(p)).FnDigit = 0 19403 (*Decimal)(unsafe.Pointer(p)).FnFrac = 0 19404 if !(zAlt != 0) { 19405 goto __2 19406 } 19407 n = nAlt 19408 zIn = zAlt 19409 goto __3 19410 __2: 19411 if !(sqlite3.Xsqlite3_value_type(tls, pIn) == SQLITE_NULL) { 19412 goto __4 19413 } 19414 (*Decimal)(unsafe.Pointer(p)).Fa = uintptr(0) 19415 (*Decimal)(unsafe.Pointer(p)).FisNull = int8(1) 19416 return p 19417 __4: 19418 ; 19419 n = sqlite3.Xsqlite3_value_bytes(tls, pIn) 19420 zIn = sqlite3.Xsqlite3_value_text(tls, pIn) 19421 __3: 19422 ; 19423 (*Decimal)(unsafe.Pointer(p)).Fa = sqlite3.Xsqlite3_malloc64(tls, (uint64(n + 1))) 19424 if !((*Decimal)(unsafe.Pointer(p)).Fa == uintptr(0)) { 19425 goto __5 19426 } 19427 goto new_no_mem 19428 __5: 19429 ; 19430 i = 0 19431 __6: 19432 if !((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(i)))))*2))) & int32(_ISspace)) != 0) { 19433 goto __8 19434 } 19435 goto __7 19436 __7: 19437 i++ 19438 goto __6 19439 goto __8 19440 __8: 19441 ; 19442 if !(int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(i)))) == '-') { 19443 goto __9 19444 } 19445 (*Decimal)(unsafe.Pointer(p)).Fsign = int8(1) 19446 i++ 19447 goto __10 19448 __9: 19449 if !(int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(i)))) == '+') { 19450 goto __11 19451 } 19452 i++ 19453 __11: 19454 ; 19455 __10: 19456 ; 19457 __12: 19458 if !((i < n) && (int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(i)))) == '0')) { 19459 goto __13 19460 } 19461 i++ 19462 goto __12 19463 __13: 19464 ; 19465 __14: 19466 if !(i < n) { 19467 goto __15 19468 } 19469 c = int8(*(*uint8)(unsafe.Pointer(zIn + uintptr(i)))) 19470 if !((int32(c) >= '0') && (int32(c) <= '9')) { 19471 goto __16 19472 } 19473 *(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(p)).Fa + uintptr(libc.PostIncInt32(&(*Decimal)(unsafe.Pointer(p)).FnDigit, 1)))) = (int8(int32(c) - '0')) 19474 goto __17 19475 __16: 19476 if !(int32(c) == '.') { 19477 goto __18 19478 } 19479 (*Decimal)(unsafe.Pointer(p)).FnFrac = ((*Decimal)(unsafe.Pointer(p)).FnDigit + 1) 19480 goto __19 19481 __18: 19482 if !((int32(c) == 'e') || (int32(c) == 'E')) { 19483 goto __20 19484 } 19485 j = (i + 1) 19486 neg = 0 19487 if !(j >= n) { 19488 goto __21 19489 } 19490 goto __15 19491 __21: 19492 ; 19493 if !(int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(j)))) == '-') { 19494 goto __22 19495 } 19496 neg = 1 19497 j++ 19498 goto __23 19499 __22: 19500 if !(int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(j)))) == '+') { 19501 goto __24 19502 } 19503 j++ 19504 __24: 19505 ; 19506 __23: 19507 ; 19508 __25: 19509 if !((j < n) && (iExp < 1000000)) { 19510 goto __26 19511 } 19512 if !((int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(j)))) >= '0') && (int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(j)))) <= '9')) { 19513 goto __27 19514 } 19515 iExp = (((iExp * 10) + int32(*(*uint8)(unsafe.Pointer(zIn + uintptr(j))))) - '0') 19516 __27: 19517 ; 19518 j++ 19519 goto __25 19520 __26: 19521 ; 19522 if !(neg != 0) { 19523 goto __28 19524 } 19525 iExp = -iExp 19526 __28: 19527 ; 19528 goto __15 19529 __20: 19530 ; 19531 __19: 19532 ; 19533 __17: 19534 ; 19535 i++ 19536 goto __14 19537 __15: 19538 ; 19539 if !((*Decimal)(unsafe.Pointer(p)).FnFrac != 0) { 19540 goto __29 19541 } 19542 (*Decimal)(unsafe.Pointer(p)).FnFrac = ((*Decimal)(unsafe.Pointer(p)).FnDigit - ((*Decimal)(unsafe.Pointer(p)).FnFrac - 1)) 19543 __29: 19544 ; 19545 if !(iExp > 0) { 19546 goto __30 19547 } 19548 if !((*Decimal)(unsafe.Pointer(p)).FnFrac > 0) { 19549 goto __32 19550 } 19551 if !(iExp <= (*Decimal)(unsafe.Pointer(p)).FnFrac) { 19552 goto __33 19553 } 19554 *(*int32)(unsafe.Pointer(p + 8 /* &.nFrac */)) -= (iExp) 19555 iExp = 0 19556 goto __34 19557 __33: 19558 iExp = iExp - ((*Decimal)(unsafe.Pointer(p)).FnFrac) 19559 (*Decimal)(unsafe.Pointer(p)).FnFrac = 0 19560 __34: 19561 ; 19562 __32: 19563 ; 19564 if !(iExp > 0) { 19565 goto __35 19566 } 19567 (*Decimal)(unsafe.Pointer(p)).Fa = sqlite3.Xsqlite3_realloc64(tls, (*Decimal)(unsafe.Pointer(p)).Fa, (uint64(((*Decimal)(unsafe.Pointer(p)).FnDigit + iExp) + 1))) 19568 if !((*Decimal)(unsafe.Pointer(p)).Fa == uintptr(0)) { 19569 goto __36 19570 } 19571 goto new_no_mem 19572 __36: 19573 ; 19574 libc.Xmemset(tls, ((*Decimal)(unsafe.Pointer(p)).Fa + uintptr((*Decimal)(unsafe.Pointer(p)).FnDigit)), 0, uint64(iExp)) 19575 *(*int32)(unsafe.Pointer(p + 4 /* &.nDigit */)) += (iExp) 19576 __35: 19577 ; 19578 goto __31 19579 __30: 19580 if !(iExp < 0) { 19581 goto __37 19582 } 19583 iExp = -iExp 19584 nExtra = (((*Decimal)(unsafe.Pointer(p)).FnDigit - (*Decimal)(unsafe.Pointer(p)).FnFrac) - 1) 19585 if !(nExtra != 0) { 19586 goto __38 19587 } 19588 if !(nExtra >= iExp) { 19589 goto __39 19590 } 19591 *(*int32)(unsafe.Pointer(p + 8 /* &.nFrac */)) += (iExp) 19592 iExp = 0 19593 goto __40 19594 __39: 19595 iExp = iExp - (nExtra) 19596 (*Decimal)(unsafe.Pointer(p)).FnFrac = ((*Decimal)(unsafe.Pointer(p)).FnDigit - 1) 19597 __40: 19598 ; 19599 __38: 19600 ; 19601 if !(iExp > 0) { 19602 goto __41 19603 } 19604 (*Decimal)(unsafe.Pointer(p)).Fa = sqlite3.Xsqlite3_realloc64(tls, (*Decimal)(unsafe.Pointer(p)).Fa, (uint64(((*Decimal)(unsafe.Pointer(p)).FnDigit + iExp) + 1))) 19605 if !((*Decimal)(unsafe.Pointer(p)).Fa == uintptr(0)) { 19606 goto __42 19607 } 19608 goto new_no_mem 19609 __42: 19610 ; 19611 libc.Xmemmove(tls, ((*Decimal)(unsafe.Pointer(p)).Fa + uintptr(iExp)), (*Decimal)(unsafe.Pointer(p)).Fa, uint64((*Decimal)(unsafe.Pointer(p)).FnDigit)) 19612 libc.Xmemset(tls, (*Decimal)(unsafe.Pointer(p)).Fa, 0, uint64(iExp)) 19613 *(*int32)(unsafe.Pointer(p + 4 /* &.nDigit */)) += (iExp) 19614 *(*int32)(unsafe.Pointer(p + 8 /* &.nFrac */)) += (iExp) 19615 __41: 19616 ; 19617 __37: 19618 ; 19619 __31: 19620 ; 19621 return p 19622 19623 new_no_mem: 19624 if !(pCtx != 0) { 19625 goto __43 19626 } 19627 sqlite3.Xsqlite3_result_error_nomem(tls, pCtx) 19628 __43: 19629 ; 19630 sqlite3.Xsqlite3_free(tls, p) 19631 return uintptr(0) 19632 } 19633 19634 // Make the given Decimal the result. 19635 func decimal_result(tls *libc.TLS, pCtx uintptr, p uintptr) { /* decimal.c:183:13: */ 19636 var z uintptr 19637 var i int32 19638 var j int32 19639 var n int32 19640 if (p == uintptr(0)) || ((*Decimal)(unsafe.Pointer(p)).Foom != 0) { 19641 sqlite3.Xsqlite3_result_error_nomem(tls, pCtx) 19642 return 19643 } 19644 if (*Decimal)(unsafe.Pointer(p)).FisNull != 0 { 19645 sqlite3.Xsqlite3_result_null(tls, pCtx) 19646 return 19647 } 19648 z = sqlite3.Xsqlite3_malloc(tls, ((*Decimal)(unsafe.Pointer(p)).FnDigit + 4)) 19649 if z == uintptr(0) { 19650 sqlite3.Xsqlite3_result_error_nomem(tls, pCtx) 19651 return 19652 } 19653 i = 0 19654 if ((*Decimal)(unsafe.Pointer(p)).FnDigit == 0) || (((*Decimal)(unsafe.Pointer(p)).FnDigit == 1) && (int32(*(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(p)).Fa))) == 0)) { 19655 (*Decimal)(unsafe.Pointer(p)).Fsign = int8(0) 19656 } 19657 if (*Decimal)(unsafe.Pointer(p)).Fsign != 0 { 19658 *(*int8)(unsafe.Pointer(z)) = int8('-') 19659 i = 1 19660 } 19661 n = ((*Decimal)(unsafe.Pointer(p)).FnDigit - (*Decimal)(unsafe.Pointer(p)).FnFrac) 19662 if n <= 0 { 19663 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&i, 1)))) = int8('0') 19664 } 19665 j = 0 19666 for (n > 1) && (int32(*(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(p)).Fa + uintptr(j)))) == 0) { 19667 j++ 19668 n-- 19669 } 19670 for n > 0 { 19671 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&i, 1)))) = (int8(int32(*(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(p)).Fa + uintptr(j)))) + '0')) 19672 j++ 19673 n-- 19674 } 19675 if (*Decimal)(unsafe.Pointer(p)).FnFrac != 0 { 19676 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&i, 1)))) = int8('.') 19677 for ok := true; ok; ok = (j < (*Decimal)(unsafe.Pointer(p)).FnDigit) { 19678 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&i, 1)))) = (int8(int32(*(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(p)).Fa + uintptr(j)))) + '0')) 19679 j++ 19680 } 19681 } 19682 *(*int8)(unsafe.Pointer(z + uintptr(i))) = int8(0) 19683 sqlite3.Xsqlite3_result_text(tls, pCtx, z, i, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) 19684 } 19685 19686 // SQL Function: decimal(X) 19687 // 19688 // Convert input X into decimal and then back into text 19689 func decimalFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* decimal.c:238:13: */ 19690 var p uintptr = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv)), 0, uintptr(0)) 19691 _ = argc 19692 decimal_result(tls, context, p) 19693 decimal_free(tls, p) 19694 } 19695 19696 // Compare to Decimal objects. Return negative, 0, or positive if the 19697 // first object is less than, equal to, or greater than the second. 19698 // 19699 // Preconditions for this routine: 19700 // 19701 // pA!=0 19702 // pA->isNull==0 19703 // pB!=0 19704 // pB->isNull==0 19705 func decimal_cmp(tls *libc.TLS, pA uintptr, pB uintptr) int32 { /* decimal.c:260:12: */ 19706 var nASig int32 19707 var nBSig int32 19708 var rc int32 19709 var n int32 19710 if int32((*Decimal)(unsafe.Pointer(pA)).Fsign) != int32((*Decimal)(unsafe.Pointer(pB)).Fsign) { 19711 if (*Decimal)(unsafe.Pointer(pA)).Fsign != 0 { 19712 return -1 19713 } 19714 return +1 19715 } 19716 if (*Decimal)(unsafe.Pointer(pA)).Fsign != 0 { 19717 var pTemp uintptr = pA 19718 pA = pB 19719 pB = pTemp 19720 } 19721 nASig = ((*Decimal)(unsafe.Pointer(pA)).FnDigit - (*Decimal)(unsafe.Pointer(pA)).FnFrac) 19722 nBSig = ((*Decimal)(unsafe.Pointer(pB)).FnDigit - (*Decimal)(unsafe.Pointer(pB)).FnFrac) 19723 if nASig != nBSig { 19724 return (nASig - nBSig) 19725 } 19726 n = (*Decimal)(unsafe.Pointer(pA)).FnDigit 19727 if n > (*Decimal)(unsafe.Pointer(pB)).FnDigit { 19728 n = (*Decimal)(unsafe.Pointer(pB)).FnDigit 19729 } 19730 rc = libc.Xmemcmp(tls, (*Decimal)(unsafe.Pointer(pA)).Fa, (*Decimal)(unsafe.Pointer(pB)).Fa, uint64(n)) 19731 if rc == 0 { 19732 rc = ((*Decimal)(unsafe.Pointer(pA)).FnDigit - (*Decimal)(unsafe.Pointer(pB)).FnDigit) 19733 } 19734 return rc 19735 } 19736 19737 // SQL Function: decimal_cmp(X, Y) 19738 // 19739 // Return negative, zero, or positive if X is less then, equal to, or 19740 // greater than Y. 19741 func decimalCmpFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* decimal.c:290:13: */ 19742 var pA uintptr 19743 var pB uintptr 19744 var rc int32 19745 pA = uintptr(0) 19746 pB = uintptr(0) 19747 19748 _ = argc 19749 pA = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv)), 0, uintptr(0)) 19750 if !((pA == uintptr(0)) || ((*Decimal)(unsafe.Pointer(pA)).FisNull != 0)) { 19751 goto __1 19752 } 19753 goto cmp_done 19754 __1: 19755 ; 19756 pB = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + 1*8)), 0, uintptr(0)) 19757 if !((pB == uintptr(0)) || ((*Decimal)(unsafe.Pointer(pB)).FisNull != 0)) { 19758 goto __2 19759 } 19760 goto cmp_done 19761 __2: 19762 ; 19763 rc = decimal_cmp(tls, pA, pB) 19764 if !(rc < 0) { 19765 goto __3 19766 } 19767 rc = -1 19768 goto __4 19769 __3: 19770 if !(rc > 0) { 19771 goto __5 19772 } 19773 rc = +1 19774 __5: 19775 ; 19776 __4: 19777 ; 19778 sqlite3.Xsqlite3_result_int(tls, context, rc) 19779 cmp_done: 19780 decimal_free(tls, pA) 19781 decimal_free(tls, pB) 19782 } 19783 19784 // Expand the Decimal so that it has a least nDigit digits and nFrac 19785 // digits to the right of the decimal point. 19786 func decimal_expand(tls *libc.TLS, p uintptr, nDigit int32, nFrac int32) { /* decimal.c:316:13: */ 19787 var nAddSig int32 19788 var nAddFrac int32 19789 if p == uintptr(0) { 19790 return 19791 } 19792 nAddFrac = (nFrac - (*Decimal)(unsafe.Pointer(p)).FnFrac) 19793 nAddSig = ((nDigit - (*Decimal)(unsafe.Pointer(p)).FnDigit) - nAddFrac) 19794 if (nAddFrac == 0) && (nAddSig == 0) { 19795 return 19796 } 19797 (*Decimal)(unsafe.Pointer(p)).Fa = sqlite3.Xsqlite3_realloc64(tls, (*Decimal)(unsafe.Pointer(p)).Fa, (uint64(nDigit + 1))) 19798 if (*Decimal)(unsafe.Pointer(p)).Fa == uintptr(0) { 19799 (*Decimal)(unsafe.Pointer(p)).Foom = int8(1) 19800 return 19801 } 19802 if nAddSig != 0 { 19803 libc.Xmemmove(tls, ((*Decimal)(unsafe.Pointer(p)).Fa + uintptr(nAddSig)), (*Decimal)(unsafe.Pointer(p)).Fa, uint64((*Decimal)(unsafe.Pointer(p)).FnDigit)) 19804 libc.Xmemset(tls, (*Decimal)(unsafe.Pointer(p)).Fa, 0, uint64(nAddSig)) 19805 *(*int32)(unsafe.Pointer(p + 4 /* &.nDigit */)) += (nAddSig) 19806 } 19807 if nAddFrac != 0 { 19808 libc.Xmemset(tls, ((*Decimal)(unsafe.Pointer(p)).Fa + uintptr((*Decimal)(unsafe.Pointer(p)).FnDigit)), 0, uint64(nAddFrac)) 19809 *(*int32)(unsafe.Pointer(p + 4 /* &.nDigit */)) += (nAddFrac) 19810 *(*int32)(unsafe.Pointer(p + 8 /* &.nFrac */)) += (nAddFrac) 19811 } 19812 } 19813 19814 // Add the value pB into pA. 19815 // 19816 // Both pA and pB might become denormalized by this routine. 19817 func decimal_add(tls *libc.TLS, pA uintptr, pB uintptr) { /* decimal.c:345:13: */ 19818 var nSig int32 19819 var nFrac int32 19820 var nDigit int32 19821 var i int32 19822 var rc int32 19823 if pA == uintptr(0) { 19824 return 19825 } 19826 if (((*Decimal)(unsafe.Pointer(pA)).Foom != 0) || (pB == uintptr(0))) || ((*Decimal)(unsafe.Pointer(pB)).Foom != 0) { 19827 (*Decimal)(unsafe.Pointer(pA)).Foom = int8(1) 19828 return 19829 } 19830 if ((*Decimal)(unsafe.Pointer(pA)).FisNull != 0) || ((*Decimal)(unsafe.Pointer(pB)).FisNull != 0) { 19831 (*Decimal)(unsafe.Pointer(pA)).FisNull = int8(1) 19832 return 19833 } 19834 nSig = ((*Decimal)(unsafe.Pointer(pA)).FnDigit - (*Decimal)(unsafe.Pointer(pA)).FnFrac) 19835 if (nSig != 0) && (int32(*(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(pA)).Fa))) == 0) { 19836 nSig-- 19837 } 19838 if nSig < ((*Decimal)(unsafe.Pointer(pB)).FnDigit - (*Decimal)(unsafe.Pointer(pB)).FnFrac) { 19839 nSig = ((*Decimal)(unsafe.Pointer(pB)).FnDigit - (*Decimal)(unsafe.Pointer(pB)).FnFrac) 19840 } 19841 nFrac = (*Decimal)(unsafe.Pointer(pA)).FnFrac 19842 if nFrac < (*Decimal)(unsafe.Pointer(pB)).FnFrac { 19843 nFrac = (*Decimal)(unsafe.Pointer(pB)).FnFrac 19844 } 19845 nDigit = ((nSig + nFrac) + 1) 19846 decimal_expand(tls, pA, nDigit, nFrac) 19847 decimal_expand(tls, pB, nDigit, nFrac) 19848 if ((*Decimal)(unsafe.Pointer(pA)).Foom != 0) || ((*Decimal)(unsafe.Pointer(pB)).Foom != 0) { 19849 (*Decimal)(unsafe.Pointer(pA)).Foom = int8(1) 19850 } else { 19851 if int32((*Decimal)(unsafe.Pointer(pA)).Fsign) == int32((*Decimal)(unsafe.Pointer(pB)).Fsign) { 19852 var carry int32 = 0 19853 for i = (nDigit - 1); i >= 0; i-- { 19854 var x int32 = ((int32(*(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(pA)).Fa + uintptr(i)))) + int32(*(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(pB)).Fa + uintptr(i))))) + carry) 19855 if x >= 10 { 19856 carry = 1 19857 *(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(pA)).Fa + uintptr(i))) = (int8(x - 10)) 19858 } else { 19859 carry = 0 19860 *(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(pA)).Fa + uintptr(i))) = int8(x) 19861 } 19862 } 19863 } else { 19864 var aA uintptr 19865 var aB uintptr 19866 var borrow int32 = 0 19867 rc = libc.Xmemcmp(tls, (*Decimal)(unsafe.Pointer(pA)).Fa, (*Decimal)(unsafe.Pointer(pB)).Fa, uint64(nDigit)) 19868 if rc < 0 { 19869 aA = (*Decimal)(unsafe.Pointer(pB)).Fa 19870 aB = (*Decimal)(unsafe.Pointer(pA)).Fa 19871 (*Decimal)(unsafe.Pointer(pA)).Fsign = libc.BoolInt8(!((*Decimal)(unsafe.Pointer(pA)).Fsign != 0)) 19872 } else { 19873 aA = (*Decimal)(unsafe.Pointer(pA)).Fa 19874 aB = (*Decimal)(unsafe.Pointer(pB)).Fa 19875 } 19876 for i = (nDigit - 1); i >= 0; i-- { 19877 var x int32 = ((int32(*(*int8)(unsafe.Pointer(aA + uintptr(i)))) - int32(*(*int8)(unsafe.Pointer(aB + uintptr(i))))) - borrow) 19878 if x < 0 { 19879 *(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(pA)).Fa + uintptr(i))) = (int8(x + 10)) 19880 borrow = 1 19881 } else { 19882 *(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(pA)).Fa + uintptr(i))) = int8(x) 19883 borrow = 0 19884 } 19885 } 19886 } 19887 } 19888 } 19889 19890 // Compare text in decimal order. 19891 func decimalCollFunc(tls *libc.TLS, notUsed uintptr, nKey1 int32, pKey1 uintptr, nKey2 int32, pKey2 uintptr) int32 { /* decimal.c:413:12: */ 19892 var zA uintptr = pKey1 19893 var zB uintptr = pKey2 19894 var pA uintptr = decimal_new(tls, uintptr(0), uintptr(0), nKey1, zA) 19895 var pB uintptr = decimal_new(tls, uintptr(0), uintptr(0), nKey2, zB) 19896 var rc int32 19897 _ = notUsed 19898 if (pA == uintptr(0)) || (pB == uintptr(0)) { 19899 rc = 0 19900 } else { 19901 rc = decimal_cmp(tls, pA, pB) 19902 } 19903 decimal_free(tls, pA) 19904 decimal_free(tls, pB) 19905 return rc 19906 } 19907 19908 // SQL Function: decimal_add(X, Y) 19909 // decimal_sub(X, Y) 19910 // 19911 // Return the sum or difference of X and Y. 19912 func decimalAddFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* decimal.c:441:13: */ 19913 var pA uintptr = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv)), 0, uintptr(0)) 19914 var pB uintptr = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + 1*8)), 0, uintptr(0)) 19915 _ = argc 19916 decimal_add(tls, pA, pB) 19917 decimal_result(tls, context, pA) 19918 decimal_free(tls, pA) 19919 decimal_free(tls, pB) 19920 } 19921 19922 func decimalSubFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* decimal.c:454:13: */ 19923 var pA uintptr = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv)), 0, uintptr(0)) 19924 var pB uintptr = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + 1*8)), 0, uintptr(0)) 19925 _ = argc 19926 if pB == uintptr(0) { 19927 return 19928 } 19929 (*Decimal)(unsafe.Pointer(pB)).Fsign = libc.BoolInt8(!((*Decimal)(unsafe.Pointer(pB)).Fsign != 0)) 19930 decimal_add(tls, pA, pB) 19931 decimal_result(tls, context, pA) 19932 decimal_free(tls, pA) 19933 decimal_free(tls, pB) 19934 } 19935 19936 // Aggregate funcion: decimal_sum(X) 19937 // 19938 // Works like sum() except that it uses decimal arithmetic for unlimited 19939 // precision. 19940 func decimalSumStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* decimal.c:475:13: */ 19941 var p uintptr 19942 var pArg uintptr 19943 _ = argc 19944 p = sqlite3.Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(Decimal{}))) 19945 if p == uintptr(0) { 19946 return 19947 } 19948 if !(int32((*Decimal)(unsafe.Pointer(p)).FisInit) != 0) { 19949 (*Decimal)(unsafe.Pointer(p)).FisInit = int8(1) 19950 (*Decimal)(unsafe.Pointer(p)).Fa = sqlite3.Xsqlite3_malloc(tls, 2) 19951 if (*Decimal)(unsafe.Pointer(p)).Fa == uintptr(0) { 19952 (*Decimal)(unsafe.Pointer(p)).Foom = int8(1) 19953 } else { 19954 *(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(p)).Fa)) = int8(0) 19955 } 19956 (*Decimal)(unsafe.Pointer(p)).FnDigit = 1 19957 (*Decimal)(unsafe.Pointer(p)).FnFrac = 0 19958 } 19959 if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { 19960 return 19961 } 19962 pArg = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv)), 0, uintptr(0)) 19963 decimal_add(tls, p, pArg) 19964 decimal_free(tls, pArg) 19965 } 19966 19967 func decimalSumInverse(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* decimal.c:501:13: */ 19968 var p uintptr 19969 var pArg uintptr 19970 _ = argc 19971 p = sqlite3.Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(Decimal{}))) 19972 if p == uintptr(0) { 19973 return 19974 } 19975 if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { 19976 return 19977 } 19978 pArg = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv)), 0, uintptr(0)) 19979 if pArg != 0 { 19980 (*Decimal)(unsafe.Pointer(pArg)).Fsign = libc.BoolInt8(!((*Decimal)(unsafe.Pointer(pArg)).Fsign != 0)) 19981 } 19982 decimal_add(tls, p, pArg) 19983 decimal_free(tls, pArg) 19984 } 19985 19986 func decimalSumValue(tls *libc.TLS, context uintptr) { /* decimal.c:517:13: */ 19987 var p uintptr = sqlite3.Xsqlite3_aggregate_context(tls, context, 0) 19988 if p == uintptr(0) { 19989 return 19990 } 19991 decimal_result(tls, context, p) 19992 } 19993 19994 func decimalSumFinalize(tls *libc.TLS, context uintptr) { /* decimal.c:522:13: */ 19995 var p uintptr = sqlite3.Xsqlite3_aggregate_context(tls, context, 0) 19996 if p == uintptr(0) { 19997 return 19998 } 19999 decimal_result(tls, context, p) 20000 decimal_clear(tls, p) 20001 } 20002 20003 // SQL Function: decimal_mul(X, Y) 20004 // 20005 // Return the product of X and Y. 20006 // 20007 // All significant digits after the decimal point are retained. 20008 // Trailing zeros after the decimal point are omitted as long as 20009 // the number of digits after the decimal point is no less than 20010 // either the number of digits in either input. 20011 func decimalMulFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* decimal.c:539:13: */ 20012 var pA uintptr 20013 var pB uintptr 20014 var acc uintptr 20015 var i int32 20016 var j int32 20017 var k int32 20018 var minFrac int32 20019 var f int8 20020 var carry int32 20021 var x int32 20022 pA = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv)), 0, uintptr(0)) 20023 pB = decimal_new(tls, context, *(*uintptr)(unsafe.Pointer(argv + 1*8)), 0, uintptr(0)) 20024 acc = uintptr(0) 20025 _ = argc 20026 if !((((((pA == uintptr(0)) || ((*Decimal)(unsafe.Pointer(pA)).Foom != 0)) || ((*Decimal)(unsafe.Pointer(pA)).FisNull != 0)) || 20027 (pB == uintptr(0))) || ((*Decimal)(unsafe.Pointer(pB)).Foom != 0)) || ((*Decimal)(unsafe.Pointer(pB)).FisNull != 0)) { 20028 goto __1 20029 } 20030 goto mul_end 20031 __1: 20032 ; 20033 acc = sqlite3.Xsqlite3_malloc64(tls, (uint64(((*Decimal)(unsafe.Pointer(pA)).FnDigit + (*Decimal)(unsafe.Pointer(pB)).FnDigit) + 2))) 20034 if !(acc == uintptr(0)) { 20035 goto __2 20036 } 20037 sqlite3.Xsqlite3_result_error_nomem(tls, context) 20038 goto mul_end 20039 __2: 20040 ; 20041 libc.Xmemset(tls, acc, 0, (uint64(((*Decimal)(unsafe.Pointer(pA)).FnDigit + (*Decimal)(unsafe.Pointer(pB)).FnDigit) + 2))) 20042 minFrac = (*Decimal)(unsafe.Pointer(pA)).FnFrac 20043 if !((*Decimal)(unsafe.Pointer(pB)).FnFrac < minFrac) { 20044 goto __3 20045 } 20046 minFrac = (*Decimal)(unsafe.Pointer(pB)).FnFrac 20047 __3: 20048 ; 20049 i = ((*Decimal)(unsafe.Pointer(pA)).FnDigit - 1) 20050 __4: 20051 if !(i >= 0) { 20052 goto __6 20053 } 20054 f = *(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(pA)).Fa + uintptr(i))) 20055 carry = 0 20056 j = ((*Decimal)(unsafe.Pointer(pB)).FnDigit - 1) 20057 k = ((i + j) + 3) 20058 __7: 20059 if !(j >= 0) { 20060 goto __9 20061 } 20062 x = ((int32(*(*int8)(unsafe.Pointer(acc + uintptr(k)))) + (int32(f) * int32(*(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(pB)).Fa + uintptr(j)))))) + carry) 20063 *(*int8)(unsafe.Pointer(acc + uintptr(k))) = (int8(x % 10)) 20064 carry = (x / 10) 20065 goto __8 20066 __8: 20067 j-- 20068 k-- 20069 goto __7 20070 goto __9 20071 __9: 20072 ; 20073 x = (int32(*(*int8)(unsafe.Pointer(acc + uintptr(k)))) + carry) 20074 *(*int8)(unsafe.Pointer(acc + uintptr(k))) = (int8(x % 10)) 20075 *(*int8)(unsafe.Pointer(acc + uintptr((k - 1)))) += int8((x / 10)) 20076 goto __5 20077 __5: 20078 i-- 20079 goto __4 20080 goto __6 20081 __6: 20082 ; 20083 sqlite3.Xsqlite3_free(tls, (*Decimal)(unsafe.Pointer(pA)).Fa) 20084 (*Decimal)(unsafe.Pointer(pA)).Fa = acc 20085 acc = uintptr(0) 20086 *(*int32)(unsafe.Pointer(pA + 4 /* &.nDigit */)) += ((*Decimal)(unsafe.Pointer(pB)).FnDigit + 2) 20087 *(*int32)(unsafe.Pointer(pA + 8 /* &.nFrac */)) += ((*Decimal)(unsafe.Pointer(pB)).FnFrac) 20088 *(*int8)(unsafe.Pointer(pA /* &.sign */)) ^= int8((int32((*Decimal)(unsafe.Pointer(pB)).Fsign))) 20089 __10: 20090 if !(((*Decimal)(unsafe.Pointer(pA)).FnFrac > minFrac) && (int32(*(*int8)(unsafe.Pointer((*Decimal)(unsafe.Pointer(pA)).Fa + uintptr(((*Decimal)(unsafe.Pointer(pA)).FnDigit - 1))))) == 0)) { 20091 goto __11 20092 } 20093 (*Decimal)(unsafe.Pointer(pA)).FnFrac-- 20094 (*Decimal)(unsafe.Pointer(pA)).FnDigit-- 20095 goto __10 20096 __11: 20097 ; 20098 decimal_result(tls, context, pA) 20099 20100 mul_end: 20101 sqlite3.Xsqlite3_free(tls, acc) 20102 decimal_free(tls, pA) 20103 decimal_free(tls, pB) 20104 } 20105 20106 func sqlite3_decimal_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* decimal.c:596:5: */ 20107 var rc int32 = SQLITE_OK 20108 var i uint32 20109 _ = pzErrMsg // Unused parameter 20110 20111 _ = pApi 20112 20113 for i = uint32(0); (uint64(i) < (uint64(unsafe.Sizeof(aFunc)) / uint64(unsafe.Sizeof(struct { 20114 FzFuncName uintptr 20115 FnArg int32 20116 _ [4]byte 20117 FxFunc uintptr 20118 }{})))) && (rc == SQLITE_OK); i++ { 20119 rc = sqlite3.Xsqlite3_create_function(tls, db, aFunc[i].FzFuncName, aFunc[i].FnArg, 20120 ((SQLITE_UTF8 | SQLITE_INNOCUOUS) | SQLITE_DETERMINISTIC), 20121 uintptr(0), aFunc[i].FxFunc, uintptr(0), uintptr(0)) 20122 } 20123 if rc == SQLITE_OK { 20124 rc = sqlite3.Xsqlite3_create_window_function(tls, db, ts+4697 /* "decimal_sum" */, 1, 20125 ((SQLITE_UTF8 | SQLITE_INNOCUOUS) | SQLITE_DETERMINISTIC), uintptr(0), 20126 *(*uintptr)(unsafe.Pointer(&struct { 20127 f func(*libc.TLS, uintptr, int32, uintptr) 20128 }{decimalSumStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{decimalSumFinalize})), 20129 *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{decimalSumValue})), *(*uintptr)(unsafe.Pointer(&struct { 20130 f func(*libc.TLS, uintptr, int32, uintptr) 20131 }{decimalSumInverse})), uintptr(0)) 20132 } 20133 if rc == SQLITE_OK { 20134 rc = sqlite3.Xsqlite3_create_collation(tls, db, ts+4709 /* "decimal" */, SQLITE_UTF8, 20135 uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 20136 f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 20137 }{decimalCollFunc}))) 20138 } 20139 return rc 20140 } 20141 20142 var aFunc = [5]struct { 20143 FzFuncName uintptr 20144 FnArg int32 20145 _ [4]byte 20146 FxFunc uintptr 20147 }{ 20148 {FzFuncName: ts + 4709 /* "decimal" */, FnArg: 1, FxFunc: 0}, 20149 {FzFuncName: ts + 4717 /* "decimal_cmp" */, FnArg: 2, FxFunc: 0}, 20150 {FzFuncName: ts + 4729 /* "decimal_add" */, FnArg: 2, FxFunc: 0}, 20151 {FzFuncName: ts + 4741 /* "decimal_sub" */, FnArg: 2, FxFunc: 0}, 20152 {FzFuncName: ts + 4753 /* "decimal_mul" */, FnArg: 2, FxFunc: 0}, 20153 } /* decimal.c:606:5 */ 20154 20155 // Structure used to accumulate the output 20156 type EvalResult = struct { 20157 Fz uintptr 20158 FzSep uintptr 20159 FszSep int32 20160 _ [4]byte 20161 FnAlloc sqlite3_int64 20162 FnUsed sqlite3_int64 20163 } /* eval.c:23:1 */ 20164 20165 // Callback from sqlite_exec() for the eval() function. 20166 func callback(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr, colnames uintptr) int32 { /* eval.c:34:12: */ 20167 var p uintptr = pCtx 20168 var i int32 20169 if argv == uintptr(0) { 20170 return 0 20171 } 20172 for i = 0; i < argc; i++ { 20173 var z uintptr 20174 if *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)) != 0 { 20175 z = *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)) 20176 } else { 20177 z = ts + 489 /* "" */ 20178 } 20179 var sz size_t = libc.Xstrlen(tls, z) 20180 if (((sqlite3_int64(sz) + (*EvalResult)(unsafe.Pointer(p)).FnUsed) + sqlite3_int64((*EvalResult)(unsafe.Pointer(p)).FszSep)) + int64(1)) > (*EvalResult)(unsafe.Pointer(p)).FnAlloc { 20181 var zNew uintptr 20182 (*EvalResult)(unsafe.Pointer(p)).FnAlloc = (sqlite3_int64((((uint64((*EvalResult)(unsafe.Pointer(p)).FnAlloc * int64(2))) + uint64(sz)) + uint64((*EvalResult)(unsafe.Pointer(p)).FszSep)) + uint64(1))) 20183 // Using sqlite3_realloc64() would be better, but it is a recent 20184 // addition and will cause a segfault if loaded by an older version 20185 // of SQLite. 20186 if (*EvalResult)(unsafe.Pointer(p)).FnAlloc <= int64(0x7fffffff) { 20187 zNew = sqlite3.Xsqlite3_realloc64(tls, (*EvalResult)(unsafe.Pointer(p)).Fz, uint64((*EvalResult)(unsafe.Pointer(p)).FnAlloc)) 20188 } else { 20189 zNew = uintptr(0) 20190 } 20191 if zNew == uintptr(0) { 20192 sqlite3.Xsqlite3_free(tls, (*EvalResult)(unsafe.Pointer(p)).Fz) 20193 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(EvalResult{}))) 20194 return 1 20195 } 20196 (*EvalResult)(unsafe.Pointer(p)).Fz = zNew 20197 } 20198 if (*EvalResult)(unsafe.Pointer(p)).FnUsed > int64(0) { 20199 libc.Xmemcpy(tls, ((*EvalResult)(unsafe.Pointer(p)).Fz + uintptr((*EvalResult)(unsafe.Pointer(p)).FnUsed)), (*EvalResult)(unsafe.Pointer(p)).FzSep, uint64((*EvalResult)(unsafe.Pointer(p)).FszSep)) 20200 *(*sqlite3_int64)(unsafe.Pointer(p + 32 /* &.nUsed */)) += (sqlite3_int64((*EvalResult)(unsafe.Pointer(p)).FszSep)) 20201 } 20202 libc.Xmemcpy(tls, ((*EvalResult)(unsafe.Pointer(p)).Fz + uintptr((*EvalResult)(unsafe.Pointer(p)).FnUsed)), z, sz) 20203 *(*sqlite3_int64)(unsafe.Pointer(p + 32 /* &.nUsed */)) += sqlite3_int64((uint64(sz))) 20204 } 20205 return 0 20206 } 20207 20208 // Implementation of the eval(X) and eval(X,Y) SQL functions. 20209 // 20210 // Evaluate the SQL text in X. Return the results, using string 20211 // Y as the separator. If Y is omitted, use a single space character. 20212 func sqlEvalFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* eval.c:71:13: */ 20213 bp := tls.Alloc(48) 20214 defer tls.Free(48) 20215 20216 var zSql uintptr 20217 var db uintptr 20218 *(*uintptr)(unsafe.Pointer(bp + 40 /* zErr */)) = uintptr(0) 20219 var rc int32 20220 // var x EvalResult at bp, 40 20221 20222 libc.Xmemset(tls, bp /* &x */, 0, uint64(unsafe.Sizeof(EvalResult{}))) 20223 (*EvalResult)(unsafe.Pointer(bp /* &x */)).FzSep = ts + 4765 /* " " */ 20224 zSql = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 20225 if zSql == uintptr(0) { 20226 return 20227 } 20228 if argc > 1 { 20229 (*EvalResult)(unsafe.Pointer(bp /* &x */)).FzSep = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 20230 if (*EvalResult)(unsafe.Pointer(bp /* &x */)).FzSep == uintptr(0) { 20231 return 20232 } 20233 } 20234 (*EvalResult)(unsafe.Pointer(bp /* &x */)).FszSep = int32(libc.Xstrlen(tls, (*EvalResult)(unsafe.Pointer(bp /* &x */)).FzSep)) 20235 db = sqlite3.Xsqlite3_context_db_handle(tls, context) 20236 rc = sqlite3.Xsqlite3_exec(tls, db, zSql, *(*uintptr)(unsafe.Pointer(&struct { 20237 f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 20238 }{callback})), bp /* &x */, bp+40 /* &zErr */) 20239 if rc != SQLITE_OK { 20240 sqlite3.Xsqlite3_result_error(tls, context, *(*uintptr)(unsafe.Pointer(bp + 40 /* zErr */)), -1) 20241 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* zErr */))) 20242 } else if (*EvalResult)(unsafe.Pointer(bp /* &x */)).FzSep == uintptr(0) { 20243 sqlite3.Xsqlite3_result_error_nomem(tls, context) 20244 sqlite3.Xsqlite3_free(tls, (*EvalResult)(unsafe.Pointer(bp /* &x */)).Fz) 20245 } else { 20246 sqlite3.Xsqlite3_result_text(tls, context, (*EvalResult)(unsafe.Pointer(bp /* &x */)).Fz, int32((*EvalResult)(unsafe.Pointer(bp /* &x */)).FnUsed), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) 20247 } 20248 } 20249 20250 func sqlite3_eval_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* eval.c:108:5: */ 20251 var rc int32 = SQLITE_OK 20252 _ = pApi 20253 20254 _ = pzErrMsg // Unused parameter 20255 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+4767 /* "eval" */, 1, 20256 (SQLITE_UTF8 | SQLITE_DIRECTONLY), uintptr(0), 20257 *(*uintptr)(unsafe.Pointer(&struct { 20258 f func(*libc.TLS, uintptr, int32, uintptr) 20259 }{sqlEvalFunc})), uintptr(0), uintptr(0)) 20260 if rc == SQLITE_OK { 20261 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+4767 /* "eval" */, 2, 20262 (SQLITE_UTF8 | SQLITE_DIRECTONLY), uintptr(0), 20263 *(*uintptr)(unsafe.Pointer(&struct { 20264 f func(*libc.TLS, uintptr, int32, uintptr) 20265 }{sqlEvalFunc})), uintptr(0), uintptr(0)) 20266 } 20267 return rc 20268 } 20269 20270 // explain_vtab is a subclass of sqlite3_vtab which will 20271 // serve as the underlying representation of a explain virtual table 20272 type explain_vtab1 = struct { 20273 Fbase sqlite3_vtab 20274 Fdb uintptr 20275 } /* explain.c:38:9 */ 20276 20277 // explain_vtab is a subclass of sqlite3_vtab which will 20278 // serve as the underlying representation of a explain virtual table 20279 type explain_vtab = explain_vtab1 /* explain.c:38:29 */ 20280 20281 // explain_cursor is a subclass of sqlite3_vtab_cursor which will 20282 // serve as the underlying representation of a cursor that scans 20283 // over rows of the result from an EXPLAIN operation. 20284 type explain_cursor1 = struct { 20285 Fbase sqlite3_vtab_cursor 20286 Fdb uintptr 20287 FzSql uintptr 20288 FpExplain uintptr 20289 Frc int32 20290 _ [4]byte 20291 } /* explain.c:48:9 */ 20292 20293 // explain_cursor is a subclass of sqlite3_vtab_cursor which will 20294 // serve as the underlying representation of a cursor that scans 20295 // over rows of the result from an EXPLAIN operation. 20296 type explain_cursor = explain_cursor1 /* explain.c:48:31 */ 20297 20298 // The explainConnect() method is invoked to create a new 20299 // explain_vtab that describes the explain virtual table. 20300 // 20301 // Think of this routine as the constructor for explain_vtab objects. 20302 // 20303 // All this routine needs to do is: 20304 // 20305 // (1) Allocate the explain_vtab object and initialize all fields. 20306 // 20307 // (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the 20308 // result set of queries against explain will look like. 20309 func explainConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* explain.c:70:12: */ 20310 var pNew uintptr 20311 var rc int32 20312 20313 // Column numbers 20314 20315 rc = sqlite3.Xsqlite3_declare_vtab(tls, db, 20316 ts+4772 /* "CREATE TABLE x(a..." */) 20317 if rc == SQLITE_OK { 20318 pNew = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(explain_vtab{}))) 20319 *(*uintptr)(unsafe.Pointer(ppVtab)) = pNew 20320 if pNew == uintptr(0) { 20321 return SQLITE_NOMEM 20322 } 20323 libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(explain_vtab{}))) 20324 (*explain_vtab)(unsafe.Pointer(pNew)).Fdb = db 20325 } 20326 return rc 20327 } 20328 20329 // This method is the destructor for explain_cursor objects. 20330 func explainDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* explain.c:107:12: */ 20331 sqlite3.Xsqlite3_free(tls, pVtab) 20332 return SQLITE_OK 20333 } 20334 20335 // Constructor for a new explain_cursor object. 20336 func explainOpen(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* explain.c:115:12: */ 20337 var pCur uintptr 20338 pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(explain_cursor{}))) 20339 if pCur == uintptr(0) { 20340 return SQLITE_NOMEM 20341 } 20342 libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(explain_cursor{}))) 20343 (*explain_cursor)(unsafe.Pointer(pCur)).Fdb = (*explain_vtab)(unsafe.Pointer(p)).Fdb 20344 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) 20345 return SQLITE_OK 20346 } 20347 20348 // Destructor for a explain_cursor. 20349 func explainClose(tls *libc.TLS, cur uintptr) int32 { /* explain.c:128:12: */ 20350 var pCur uintptr = cur 20351 sqlite3.Xsqlite3_finalize(tls, (*explain_cursor)(unsafe.Pointer(pCur)).FpExplain) 20352 sqlite3.Xsqlite3_free(tls, (*explain_cursor)(unsafe.Pointer(pCur)).FzSql) 20353 sqlite3.Xsqlite3_free(tls, pCur) 20354 return SQLITE_OK 20355 } 20356 20357 // Advance a explain_cursor to its next row of output. 20358 func explainNext(tls *libc.TLS, cur uintptr) int32 { /* explain.c:140:12: */ 20359 var pCur uintptr = cur 20360 (*explain_cursor)(unsafe.Pointer(pCur)).Frc = sqlite3.Xsqlite3_step(tls, (*explain_cursor)(unsafe.Pointer(pCur)).FpExplain) 20361 if ((*explain_cursor)(unsafe.Pointer(pCur)).Frc != SQLITE_DONE) && ((*explain_cursor)(unsafe.Pointer(pCur)).Frc != SQLITE_ROW) { 20362 return (*explain_cursor)(unsafe.Pointer(pCur)).Frc 20363 } 20364 return SQLITE_OK 20365 } 20366 20367 // Return values of columns for the row at which the explain_cursor 20368 // is currently pointing. 20369 func explainColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* explain.c:151:12: */ 20370 var pCur uintptr = cur 20371 if i == EXPLN_COLUMN_SQL { 20372 sqlite3.Xsqlite3_result_text(tls, ctx, (*explain_cursor)(unsafe.Pointer(pCur)).FzSql, -1, libc.UintptrFromInt32(-1)) 20373 } else { 20374 sqlite3.Xsqlite3_result_value(tls, ctx, sqlite3.Xsqlite3_column_value(tls, (*explain_cursor)(unsafe.Pointer(pCur)).FpExplain, i)) 20375 } 20376 return SQLITE_OK 20377 } 20378 20379 // Return the rowid for the current row. In this implementation, the 20380 // rowid is the same as the output value. 20381 func explainRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* explain.c:169:12: */ 20382 var pCur uintptr = cur 20383 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite3.Xsqlite3_column_int64(tls, (*explain_cursor)(unsafe.Pointer(pCur)).FpExplain, 0) 20384 return SQLITE_OK 20385 } 20386 20387 // Return TRUE if the cursor has been moved off of the last 20388 // row of output. 20389 func explainEof(tls *libc.TLS, cur uintptr) int32 { /* explain.c:179:12: */ 20390 var pCur uintptr = cur 20391 return (libc.Bool32((*explain_cursor)(unsafe.Pointer(pCur)).Frc != SQLITE_ROW)) 20392 } 20393 20394 // This method is called to "rewind" the explain_cursor object back 20395 // to the first row of output. This method is always called at least 20396 // once prior to any call to explainColumn() or explainRowid() or 20397 // explainEof(). 20398 // 20399 // The argv[0] is the SQL statement that is to be explained. 20400 func explainFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* explain.c:192:12: */ 20401 bp := tls.Alloc(16) 20402 defer tls.Free(16) 20403 20404 var pCur uintptr = pVtabCursor 20405 var zSql uintptr = uintptr(0) 20406 var rc int32 20407 sqlite3.Xsqlite3_finalize(tls, (*explain_cursor)(unsafe.Pointer(pCur)).FpExplain) 20408 (*explain_cursor)(unsafe.Pointer(pCur)).FpExplain = uintptr(0) 20409 if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) != SQLITE_TEXT { 20410 (*explain_cursor)(unsafe.Pointer(pCur)).Frc = SQLITE_DONE 20411 return SQLITE_OK 20412 } 20413 sqlite3.Xsqlite3_free(tls, (*explain_cursor)(unsafe.Pointer(pCur)).FzSql) 20414 (*explain_cursor)(unsafe.Pointer(pCur)).FzSql = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))))) 20415 if (*explain_cursor)(unsafe.Pointer(pCur)).FzSql != 0 { 20416 zSql = sqlite3.Xsqlite3_mprintf(tls, ts+4834 /* "EXPLAIN %s" */, libc.VaList(bp+8, (*explain_cursor)(unsafe.Pointer(pCur)).FzSql)) 20417 } 20418 if zSql == uintptr(0) { 20419 rc = SQLITE_NOMEM 20420 } else { 20421 rc = sqlite3.Xsqlite3_prepare_v2(tls, (*explain_cursor)(unsafe.Pointer(pCur)).Fdb, zSql, -1, (pCur + 24 /* &.pExplain */), uintptr(0)) 20422 sqlite3.Xsqlite3_free(tls, zSql) 20423 } 20424 if rc != 0 { 20425 sqlite3.Xsqlite3_finalize(tls, (*explain_cursor)(unsafe.Pointer(pCur)).FpExplain) 20426 (*explain_cursor)(unsafe.Pointer(pCur)).FpExplain = uintptr(0) 20427 sqlite3.Xsqlite3_free(tls, (*explain_cursor)(unsafe.Pointer(pCur)).FzSql) 20428 (*explain_cursor)(unsafe.Pointer(pCur)).FzSql = uintptr(0) 20429 } else { 20430 (*explain_cursor)(unsafe.Pointer(pCur)).Frc = sqlite3.Xsqlite3_step(tls, (*explain_cursor)(unsafe.Pointer(pCur)).FpExplain) 20431 if ((*explain_cursor)(unsafe.Pointer(pCur)).Frc == SQLITE_DONE) || ((*explain_cursor)(unsafe.Pointer(pCur)).Frc == SQLITE_ROW) { 20432 rc = SQLITE_OK 20433 } else { 20434 rc = (*explain_cursor)(unsafe.Pointer(pCur)).Frc 20435 } 20436 } 20437 return rc 20438 } 20439 20440 // SQLite will invoke this method one or more times while planning a query 20441 // that uses the explain virtual table. This routine needs to create 20442 // a query plan for each invocation and compute an estimated cost for that 20443 // plan. 20444 func explainBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* explain.c:235:12: */ 20445 var i int32 // Loop counter 20446 var idx int32 = -1 // Index of a usable == constraint against SQL 20447 var unusable int32 = 0 // True if there are unusable constraints on SQL 20448 20449 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(500) 20450 for i = 0; i < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; i++ { 20451 var p uintptr = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12) 20452 if (*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn != EXPLN_COLUMN_SQL { 20453 continue 20454 } 20455 if !(int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable) != 0) { 20456 unusable = 1 20457 } else if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ { 20458 idx = i 20459 } 20460 } 20461 if idx >= 0 { 20462 // There exists a usable == constraint against the SQL column 20463 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 10.0 20464 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 1 20465 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(idx)*8)).FargvIndex = 1 20466 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(idx)*8)).Fomit = uint8(1) 20467 } else if unusable != 0 { 20468 // There are unusable constraints against the SQL column. Do not allow 20469 // this plan to continue forward. 20470 return SQLITE_CONSTRAINT 20471 } 20472 return SQLITE_OK 20473 } 20474 20475 // This following structure defines all the methods for the 20476 // explain virtual table. 20477 var explainModule = sqlite3_module{ // xCreate 20478 FxConnect: 0, // xConnect 20479 FxBestIndex: 0, // xBestIndex 20480 FxDisconnect: 0, // xDestroy 20481 FxOpen: 0, // xOpen - open a cursor 20482 FxClose: 0, // xClose - close a cursor 20483 FxFilter: 0, // xFilter - configure scan constraints 20484 FxNext: 0, // xNext - advance a cursor 20485 FxEof: 0, // xEof - check for end of scan 20486 FxColumn: 0, // xColumn - read data 20487 FxRowid: 0, // xShadowName 20488 } /* explain.c:271:23 */ 20489 20490 func sqlite3ExplainVtabInit(tls *libc.TLS, db uintptr) int32 { /* explain.c:300:5: */ 20491 var rc int32 = SQLITE_OK 20492 rc = sqlite3.Xsqlite3_create_module(tls, db, ts+4845 /* "explain" */, uintptr(unsafe.Pointer(&explainModule)), uintptr(0)) 20493 return rc 20494 } 20495 20496 func sqlite3_explain_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* explain.c:311:5: */ 20497 var rc int32 = SQLITE_OK 20498 _ = pApi 20499 20500 rc = sqlite3ExplainVtabInit(tls, db) 20501 return rc 20502 } 20503 20504 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 20505 // This file is part of the GNU C Library. 20506 // 20507 // The GNU C Library is free software; you can redistribute it and/or 20508 // modify it under the terms of the GNU Lesser General Public 20509 // License as published by the Free Software Foundation; either 20510 // version 2.1 of the License, or (at your option) any later version. 20511 // 20512 // The GNU C Library is distributed in the hope that it will be useful, 20513 // but WITHOUT ANY WARRANTY; without even the implied warranty of 20514 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20515 // Lesser General Public License for more details. 20516 // 20517 // You should have received a copy of the GNU Lesser General Public 20518 // License along with the GNU C Library; if not, see 20519 // <http://www.gnu.org/licenses/>. 20520 20521 // POSIX Standard: 6.5 File Control Operations <fcntl.h> 20522 20523 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 20524 // This file is part of the GNU C Library. 20525 // 20526 // The GNU C Library is free software; you can redistribute it and/or 20527 // modify it under the terms of the GNU Lesser General Public 20528 // License as published by the Free Software Foundation; either 20529 // version 2.1 of the License, or (at your option) any later version. 20530 // 20531 // The GNU C Library is distributed in the hope that it will be useful, 20532 // but WITHOUT ANY WARRANTY; without even the implied warranty of 20533 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20534 // Lesser General Public License for more details. 20535 // 20536 // You should have received a copy of the GNU Lesser General Public 20537 // License along with the GNU C Library; if not, see 20538 // <http://www.gnu.org/licenses/>. 20539 20540 // This must be early so <bits/fcntl.h> can define types winningly. 20541 20542 // Get __mode_t, __dev_t and __off_t . 20543 // bits/types.h -- definitions of __*_t types underlying *_t types. 20544 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 20545 // This file is part of the GNU C Library. 20546 // 20547 // The GNU C Library is free software; you can redistribute it and/or 20548 // modify it under the terms of the GNU Lesser General Public 20549 // License as published by the Free Software Foundation; either 20550 // version 2.1 of the License, or (at your option) any later version. 20551 // 20552 // The GNU C Library is distributed in the hope that it will be useful, 20553 // but WITHOUT ANY WARRANTY; without even the implied warranty of 20554 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20555 // Lesser General Public License for more details. 20556 // 20557 // You should have received a copy of the GNU Lesser General Public 20558 // License along with the GNU C Library; if not, see 20559 // <http://www.gnu.org/licenses/>. 20560 20561 // Never include this file directly; use <sys/types.h> instead. 20562 20563 // Get the definitions of O_*, F_*, FD_*: all the 20564 // numbers and flag bits for `open', `fcntl', et al. 20565 // O_*, F_*, FD_* bit values for Linux. 20566 // Copyright (C) 2000-2018 Free Software Foundation, Inc. 20567 // This file is part of the GNU C Library. 20568 // 20569 // The GNU C Library is free software; you can redistribute it and/or 20570 // modify it under the terms of the GNU Lesser General Public 20571 // License as published by the Free Software Foundation; either 20572 // version 2.1 of the License, or (at your option) any later version. 20573 // 20574 // The GNU C Library is distributed in the hope that it will be useful, 20575 // but WITHOUT ANY WARRANTY; without even the implied warranty of 20576 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20577 // Lesser General Public License for more details. 20578 // 20579 // You should have received a copy of the GNU Lesser General Public 20580 // License along with the GNU C Library; if not, see 20581 // <http://www.gnu.org/licenses/>. 20582 20583 // Determine the wordsize from the preprocessor defines. 20584 20585 // Not necessary, files are always with 64bit off_t. 20586 20587 // Not necessary, we always have 64-bit offsets. 20588 20589 type flock = struct { 20590 Fl_type int16 20591 Fl_whence int16 20592 _ [4]byte 20593 Fl_start int64 20594 Fl_len int64 20595 Fl_pid int32 20596 _ [4]byte 20597 } /* fcntl.h:37:1 */ 20598 20599 // Define some inlines helping to catch common problems. 20600 20601 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 20602 // This file is part of the GNU C Library. 20603 // 20604 // The GNU C Library is free software; you can redistribute it and/or 20605 // modify it under the terms of the GNU Lesser General Public 20606 // License as published by the Free Software Foundation; either 20607 // version 2.1 of the License, or (at your option) any later version. 20608 // 20609 // The GNU C Library is distributed in the hope that it will be useful, 20610 // but WITHOUT ANY WARRANTY; without even the implied warranty of 20611 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20612 // Lesser General Public License for more details. 20613 // 20614 // You should have received a copy of the GNU Lesser General Public 20615 // License along with the GNU C Library; if not, see 20616 // <http://www.gnu.org/licenses/>. 20617 20618 // POSIX Standard: 2.10 Symbolic Constants <unistd.h> 20619 20620 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 20621 // This file is part of the GNU C Library. 20622 // 20623 // The GNU C Library is free software; you can redistribute it and/or 20624 // modify it under the terms of the GNU Lesser General Public 20625 // License as published by the Free Software Foundation; either 20626 // version 2.1 of the License, or (at your option) any later version. 20627 // 20628 // The GNU C Library is distributed in the hope that it will be useful, 20629 // but WITHOUT ANY WARRANTY; without even the implied warranty of 20630 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20631 // Lesser General Public License for more details. 20632 // 20633 // You should have received a copy of the GNU Lesser General Public 20634 // License along with the GNU C Library; if not, see 20635 // <http://www.gnu.org/licenses/>. 20636 20637 // These may be used to determine what facilities are present at compile time. 20638 // Their values can be obtained at run time from `sysconf'. 20639 20640 // POSIX Standard approved as ISO/IEC 9945-1 as of September 2008. 20641 20642 // These are not #ifdef __USE_POSIX2 because they are 20643 // in the theoretically application-owned namespace. 20644 20645 // The utilities on GNU systems also correspond to this version. 20646 20647 // The utilities on GNU systems also correspond to this version. 20648 20649 // This symbol was required until the 2001 edition of POSIX. 20650 20651 // If defined, the implementation supports the 20652 // C Language Bindings Option. 20653 20654 // If defined, the implementation supports the 20655 // C Language Development Utilities Option. 20656 20657 // If defined, the implementation supports the 20658 // Software Development Utilities Option. 20659 20660 // If defined, the implementation supports the 20661 // creation of locales with the localedef utility. 20662 20663 // X/Open version number to which the library conforms. It is selectable. 20664 20665 // Commands and utilities from XPG4 are available. 20666 20667 // We are compatible with the old published standards as well. 20668 20669 // The X/Open Unix extensions are available. 20670 20671 // The enhanced internationalization capabilities according to XPG4.2 20672 // are present. 20673 20674 // The legacy interfaces are also available. 20675 20676 // Get values of POSIX options: 20677 // 20678 // If these symbols are defined, the corresponding features are 20679 // always available. If not, they may be available sometimes. 20680 // The current values can be obtained with `sysconf'. 20681 // 20682 // _POSIX_JOB_CONTROL Job control is supported. 20683 // _POSIX_SAVED_IDS Processes have a saved set-user-ID 20684 // and a saved set-group-ID. 20685 // _POSIX_REALTIME_SIGNALS Real-time, queued signals are supported. 20686 // _POSIX_PRIORITY_SCHEDULING Priority scheduling is supported. 20687 // _POSIX_TIMERS POSIX.4 clocks and timers are supported. 20688 // _POSIX_ASYNCHRONOUS_IO Asynchronous I/O is supported. 20689 // _POSIX_PRIORITIZED_IO Prioritized asynchronous I/O is supported. 20690 // _POSIX_SYNCHRONIZED_IO Synchronizing file data is supported. 20691 // _POSIX_FSYNC The fsync function is present. 20692 // _POSIX_MAPPED_FILES Mapping of files to memory is supported. 20693 // _POSIX_MEMLOCK Locking of all memory is supported. 20694 // _POSIX_MEMLOCK_RANGE Locking of ranges of memory is supported. 20695 // _POSIX_MEMORY_PROTECTION Setting of memory protections is supported. 20696 // _POSIX_MESSAGE_PASSING POSIX.4 message queues are supported. 20697 // _POSIX_SEMAPHORES POSIX.4 counting semaphores are supported. 20698 // _POSIX_SHARED_MEMORY_OBJECTS POSIX.4 shared memory objects are supported. 20699 // _POSIX_THREADS POSIX.1c pthreads are supported. 20700 // _POSIX_THREAD_ATTR_STACKADDR Thread stack address attribute option supported. 20701 // _POSIX_THREAD_ATTR_STACKSIZE Thread stack size attribute option supported. 20702 // _POSIX_THREAD_SAFE_FUNCTIONS Thread-safe functions are supported. 20703 // _POSIX_THREAD_PRIORITY_SCHEDULING 20704 // POSIX.1c thread execution scheduling supported. 20705 // _POSIX_THREAD_PRIO_INHERIT Thread priority inheritance option supported. 20706 // _POSIX_THREAD_PRIO_PROTECT Thread priority protection option supported. 20707 // _POSIX_THREAD_PROCESS_SHARED Process-shared synchronization supported. 20708 // _POSIX_PII Protocol-independent interfaces are supported. 20709 // _POSIX_PII_XTI XTI protocol-indep. interfaces are supported. 20710 // _POSIX_PII_SOCKET Socket protocol-indep. interfaces are supported. 20711 // _POSIX_PII_INTERNET Internet family of protocols supported. 20712 // _POSIX_PII_INTERNET_STREAM Connection-mode Internet protocol supported. 20713 // _POSIX_PII_INTERNET_DGRAM Connectionless Internet protocol supported. 20714 // _POSIX_PII_OSI ISO/OSI family of protocols supported. 20715 // _POSIX_PII_OSI_COTS Connection-mode ISO/OSI service supported. 20716 // _POSIX_PII_OSI_CLTS Connectionless ISO/OSI service supported. 20717 // _POSIX_POLL Implementation supports `poll' function. 20718 // _POSIX_SELECT Implementation supports `select' and `pselect'. 20719 // 20720 // _XOPEN_REALTIME X/Open realtime support is available. 20721 // _XOPEN_REALTIME_THREADS X/Open realtime thread support is available. 20722 // _XOPEN_SHM Shared memory interface according to XPG4.2. 20723 // 20724 // _XBS5_ILP32_OFF32 Implementation provides environment with 32-bit 20725 // int, long, pointer, and off_t types. 20726 // _XBS5_ILP32_OFFBIG Implementation provides environment with 32-bit 20727 // int, long, and pointer and off_t with at least 20728 // 64 bits. 20729 // _XBS5_LP64_OFF64 Implementation provides environment with 32-bit 20730 // int, and 64-bit long, pointer, and off_t types. 20731 // _XBS5_LPBIG_OFFBIG Implementation provides environment with at 20732 // least 32 bits int and long, pointer, and off_t 20733 // with at least 64 bits. 20734 // 20735 // If any of these symbols is defined as -1, the corresponding option is not 20736 // true for any file. If any is defined as other than -1, the corresponding 20737 // option is true for all files. If a symbol is not defined at all, the value 20738 // for a specific file can be obtained from `pathconf' and `fpathconf'. 20739 // 20740 // _POSIX_CHOWN_RESTRICTED Only the super user can use `chown' to change 20741 // the owner of a file. `chown' can only be used 20742 // to change the group ID of a file to a group of 20743 // which the calling process is a member. 20744 // _POSIX_NO_TRUNC Pathname components longer than 20745 // NAME_MAX generate an error. 20746 // _POSIX_VDISABLE If defined, if the value of an element of the 20747 // `c_cc' member of `struct termios' is 20748 // _POSIX_VDISABLE, no character will have the 20749 // effect associated with that element. 20750 // _POSIX_SYNC_IO Synchronous I/O may be performed. 20751 // _POSIX_ASYNC_IO Asynchronous I/O may be performed. 20752 // _POSIX_PRIO_IO Prioritized Asynchronous I/O may be performed. 20753 // 20754 // Support for the Large File Support interface is not generally available. 20755 // If it is available the following constants are defined to one. 20756 // _LFS64_LARGEFILE Low-level I/O supports large files. 20757 // _LFS64_STDIO Standard I/O supports large files. 20758 // 20759 20760 // Define POSIX options for Linux. 20761 // Copyright (C) 1996-2018 Free Software Foundation, Inc. 20762 // This file is part of the GNU C Library. 20763 // 20764 // The GNU C Library is free software; you can redistribute it and/or 20765 // modify it under the terms of the GNU Lesser General Public License as 20766 // published by the Free Software Foundation; either version 2.1 of the 20767 // License, or (at your option) any later version. 20768 // 20769 // The GNU C Library is distributed in the hope that it will be useful, 20770 // but WITHOUT ANY WARRANTY; without even the implied warranty of 20771 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20772 // Lesser General Public License for more details. 20773 // 20774 // You should have received a copy of the GNU Lesser General Public 20775 // License along with the GNU C Library; see the file COPYING.LIB. If 20776 // not, see <http://www.gnu.org/licenses/>. 20777 20778 // Job control is supported. 20779 20780 // Processes have a saved set-user-ID and a saved set-group-ID. 20781 20782 // Priority scheduling is supported. 20783 20784 // Synchronizing file data is supported. 20785 20786 // The fsync function is present. 20787 20788 // Mapping of files to memory is supported. 20789 20790 // Locking of all memory is supported. 20791 20792 // Locking of ranges of memory is supported. 20793 20794 // Setting of memory protections is supported. 20795 20796 // Some filesystems allow all users to change file ownership. 20797 20798 // `c_cc' member of 'struct termios' structure can be disabled by 20799 // using the value _POSIX_VDISABLE. 20800 20801 // Filenames are not silently truncated. 20802 20803 // X/Open realtime support is available. 20804 20805 // X/Open thread realtime support is available. 20806 20807 // XPG4.2 shared memory is supported. 20808 20809 // Tell we have POSIX threads. 20810 20811 // We have the reentrant functions described in POSIX. 20812 20813 // We provide priority scheduling for threads. 20814 20815 // We support user-defined stack sizes. 20816 20817 // We support user-defined stacks. 20818 20819 // We support priority inheritence. 20820 20821 // We support priority protection, though only for non-robust 20822 // mutexes. 20823 20824 // We support priority inheritence for robust mutexes. 20825 20826 // We do not support priority protection for robust mutexes. 20827 20828 // We support POSIX.1b semaphores. 20829 20830 // Real-time signals are supported. 20831 20832 // We support asynchronous I/O. 20833 // Alternative name for Unix98. 20834 // Support for prioritization is also available. 20835 20836 // The LFS support in asynchronous I/O is also available. 20837 20838 // The rest of the LFS is also available. 20839 20840 // POSIX shared memory objects are implemented. 20841 20842 // CPU-time clocks support needs to be checked at runtime. 20843 20844 // Clock support in threads must be also checked at runtime. 20845 20846 // GNU libc provides regular expression handling. 20847 20848 // Reader/Writer locks are available. 20849 20850 // We have a POSIX shell. 20851 20852 // We support the Timeouts option. 20853 20854 // We support spinlocks. 20855 20856 // The `spawn' function family is supported. 20857 20858 // We have POSIX timers. 20859 20860 // The barrier functions are available. 20861 20862 // POSIX message queues are available. 20863 20864 // Thread process-shared synchronization is supported. 20865 20866 // The monotonic clock might be available. 20867 20868 // The clock selection interfaces are available. 20869 20870 // Advisory information interfaces are available. 20871 20872 // IPv6 support is available. 20873 20874 // Raw socket support is available. 20875 20876 // We have at least one terminal. 20877 20878 // Neither process nor thread sporadic server interfaces is available. 20879 20880 // trace.h is not available. 20881 20882 // Typed memory objects are not available. 20883 20884 // Get the environment definitions from Unix98. 20885 // Copyright (C) 1999-2018 Free Software Foundation, Inc. 20886 // This file is part of the GNU C Library. 20887 // 20888 // The GNU C Library is free software; you can redistribute it and/or 20889 // modify it under the terms of the GNU Lesser General Public 20890 // License as published by the Free Software Foundation; either 20891 // version 2.1 of the License, or (at your option) any later version. 20892 // 20893 // The GNU C Library is distributed in the hope that it will be useful, 20894 // but WITHOUT ANY WARRANTY; without even the implied warranty of 20895 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20896 // Lesser General Public License for more details. 20897 // 20898 // You should have received a copy of the GNU Lesser General Public 20899 // License along with the GNU C Library; if not, see 20900 // <http://www.gnu.org/licenses/>. 20901 20902 // Determine the wordsize from the preprocessor defines. 20903 20904 // This header should define the following symbols under the described 20905 // situations. A value `1' means that the model is always supported, 20906 // `-1' means it is never supported. Undefined means it cannot be 20907 // statically decided. 20908 // 20909 // _POSIX_V7_ILP32_OFF32 32bit int, long, pointers, and off_t type 20910 // _POSIX_V7_ILP32_OFFBIG 32bit int, long, and pointers and larger off_t type 20911 // 20912 // _POSIX_V7_LP64_OFF32 64bit long and pointers and 32bit off_t type 20913 // _POSIX_V7_LPBIG_OFFBIG 64bit long and pointers and large off_t type 20914 // 20915 // The macros _POSIX_V6_ILP32_OFF32, _POSIX_V6_ILP32_OFFBIG, 20916 // _POSIX_V6_LP64_OFF32, _POSIX_V6_LPBIG_OFFBIG, _XBS5_ILP32_OFF32, 20917 // _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and _XBS5_LPBIG_OFFBIG were 20918 // used in previous versions of the Unix standard and are available 20919 // only for compatibility. 20920 20921 // Environments with 32-bit wide pointers are optionally provided. 20922 // Therefore following macros aren't defined: 20923 // # undef _POSIX_V7_ILP32_OFF32 20924 // # undef _POSIX_V7_ILP32_OFFBIG 20925 // # undef _POSIX_V6_ILP32_OFF32 20926 // # undef _POSIX_V6_ILP32_OFFBIG 20927 // # undef _XBS5_ILP32_OFF32 20928 // # undef _XBS5_ILP32_OFFBIG 20929 // and users need to check at runtime. 20930 20931 // We also have no use (for now) for an environment with bigger pointers 20932 // and offsets. 20933 20934 // By default we have 64-bit wide `long int', pointers and `off_t'. 20935 20936 // Standard file descriptors. 20937 20938 // All functions that are not declared anywhere else. 20939 20940 // bits/types.h -- definitions of __*_t types underlying *_t types. 20941 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 20942 // This file is part of the GNU C Library. 20943 // 20944 // The GNU C Library is free software; you can redistribute it and/or 20945 // modify it under the terms of the GNU Lesser General Public 20946 // License as published by the Free Software Foundation; either 20947 // version 2.1 of the License, or (at your option) any later version. 20948 // 20949 // The GNU C Library is distributed in the hope that it will be useful, 20950 // but WITHOUT ANY WARRANTY; without even the implied warranty of 20951 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20952 // Lesser General Public License for more details. 20953 // 20954 // You should have received a copy of the GNU Lesser General Public 20955 // License along with the GNU C Library; if not, see 20956 // <http://www.gnu.org/licenses/>. 20957 20958 // Never include this file directly; use <sys/types.h> instead. 20959 20960 // Copyright (C) 1989-2018 Free Software Foundation, Inc. 20961 // 20962 // This file is part of GCC. 20963 // 20964 // GCC is free software; you can redistribute it and/or modify 20965 // it under the terms of the GNU General Public License as published by 20966 // the Free Software Foundation; either version 3, or (at your option) 20967 // any later version. 20968 // 20969 // GCC is distributed in the hope that it will be useful, 20970 // but WITHOUT ANY WARRANTY; without even the implied warranty of 20971 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20972 // GNU General Public License for more details. 20973 // 20974 // Under Section 7 of GPL version 3, you are granted additional 20975 // permissions described in the GCC Runtime Library Exception, version 20976 // 3.1, as published by the Free Software Foundation. 20977 // 20978 // You should have received a copy of the GNU General Public License and 20979 // a copy of the GCC Runtime Library Exception along with this program; 20980 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 20981 // <http://www.gnu.org/licenses/>. 20982 20983 // ISO C Standard: 7.17 Common definitions <stddef.h> 20984 20985 // Any one of these symbols __need_* means that GNU libc 20986 // wants us just to define one data type. So don't define 20987 // the symbols that indicate this file's entire job has been done. 20988 20989 // This avoids lossage on SunOS but only if stdtypes.h comes first. 20990 // There's no way to win with the other order! Sun lossage. 20991 20992 // On 4.3bsd-net2, make sure ansi.h is included, so we have 20993 // one less case to deal with in the following. 20994 // On FreeBSD 5, machine/ansi.h does not exist anymore... 20995 20996 // In 4.3bsd-net2, machine/ansi.h defines these symbols, which are 20997 // defined if the corresponding type is *not* defined. 20998 // FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_. 20999 // NetBSD defines _I386_ANSI_H_ and _X86_64_ANSI_H_ instead of _ANSI_H_ 21000 21001 // Sequent's header files use _PTRDIFF_T_ in some conflicting way. 21002 // Just ignore it. 21003 21004 // On VxWorks, <type/vxTypesBase.h> may have defined macros like 21005 // _TYPE_size_t which will typedef size_t. fixincludes patched the 21006 // vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is 21007 // not defined, and so that defining this macro defines _GCC_SIZE_T. 21008 // If we find that the macros are still defined at this point, we must 21009 // invoke them so that the type is defined as expected. 21010 21011 // In case nobody has defined these types, but we aren't running under 21012 // GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and 21013 // __WCHAR_TYPE__ have reasonable values. This can happen if the 21014 // parts of GCC is compiled by an older compiler, that actually 21015 // include gstddef.h, such as collect2. 21016 21017 // Signed type of difference of two pointers. 21018 21019 // Define this type if we are doing the whole job, 21020 // or if we want this type in particular. 21021 21022 // Unsigned type of `sizeof' something. 21023 21024 // Define this type if we are doing the whole job, 21025 // or if we want this type in particular. 21026 21027 // Wide character type. 21028 // Locale-writers should change this as necessary to 21029 // be big enough to hold unique values not between 0 and 127, 21030 // and not (wchar_t) -1, for each defined multibyte character. 21031 21032 // Define this type if we are doing the whole job, 21033 // or if we want this type in particular. 21034 21035 // In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. 21036 // are already defined. 21037 // BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. 21038 // NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here. 21039 21040 // A null pointer constant. 21041 21042 // The Single Unix specification says that some more types are 21043 // available here. 21044 21045 type useconds_t = uint32 /* unistd.h:255:22 */ 21046 21047 type intptr_t = int64 /* unistd.h:267:20 */ 21048 21049 type socklen_t = uint32 /* unistd.h:274:21 */ 21050 21051 // Define some macros helping to catch buffer overflows. 21052 21053 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 21054 // This file is part of the GNU C Library. 21055 // 21056 // The GNU C Library is free software; you can redistribute it and/or 21057 // modify it under the terms of the GNU Lesser General Public 21058 // License as published by the Free Software Foundation; either 21059 // version 2.1 of the License, or (at your option) any later version. 21060 // 21061 // The GNU C Library is distributed in the hope that it will be useful, 21062 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21063 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21064 // Lesser General Public License for more details. 21065 // 21066 // You should have received a copy of the GNU Lesser General Public 21067 // License along with the GNU C Library; if not, see 21068 // <http://www.gnu.org/licenses/>. 21069 21070 // POSIX Standard: 5.1.2 Directory Operations <dirent.h> 21071 21072 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 21073 // This file is part of the GNU C Library. 21074 // 21075 // The GNU C Library is free software; you can redistribute it and/or 21076 // modify it under the terms of the GNU Lesser General Public 21077 // License as published by the Free Software Foundation; either 21078 // version 2.1 of the License, or (at your option) any later version. 21079 // 21080 // The GNU C Library is distributed in the hope that it will be useful, 21081 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21082 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21083 // Lesser General Public License for more details. 21084 // 21085 // You should have received a copy of the GNU Lesser General Public 21086 // License along with the GNU C Library; if not, see 21087 // <http://www.gnu.org/licenses/>. 21088 21089 // bits/types.h -- definitions of __*_t types underlying *_t types. 21090 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 21091 // This file is part of the GNU C Library. 21092 // 21093 // The GNU C Library is free software; you can redistribute it and/or 21094 // modify it under the terms of the GNU Lesser General Public 21095 // License as published by the Free Software Foundation; either 21096 // version 2.1 of the License, or (at your option) any later version. 21097 // 21098 // The GNU C Library is distributed in the hope that it will be useful, 21099 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21100 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21101 // Lesser General Public License for more details. 21102 // 21103 // You should have received a copy of the GNU Lesser General Public 21104 // License along with the GNU C Library; if not, see 21105 // <http://www.gnu.org/licenses/>. 21106 21107 // Never include this file directly; use <sys/types.h> instead. 21108 21109 // This file defines `struct dirent'. 21110 // 21111 // It defines the macro `_DIRENT_HAVE_D_NAMLEN' iff there is a `d_namlen' 21112 // member that gives the length of `d_name'. 21113 // 21114 // It defines the macro `_DIRENT_HAVE_D_RECLEN' iff there is a `d_reclen' 21115 // member that gives the size of the entire directory entry. 21116 // 21117 // It defines the macro `_DIRENT_HAVE_D_OFF' iff there is a `d_off' 21118 // member that gives the file offset of the next directory entry. 21119 // 21120 // It defines the macro `_DIRENT_HAVE_D_TYPE' iff there is a `d_type' 21121 // member that gives the type of the file. 21122 // 21123 21124 // Copyright (C) 1996-2018 Free Software Foundation, Inc. 21125 // This file is part of the GNU C Library. 21126 // 21127 // The GNU C Library is free software; you can redistribute it and/or 21128 // modify it under the terms of the GNU Lesser General Public 21129 // License as published by the Free Software Foundation; either 21130 // version 2.1 of the License, or (at your option) any later version. 21131 // 21132 // The GNU C Library is distributed in the hope that it will be useful, 21133 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21134 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21135 // Lesser General Public License for more details. 21136 // 21137 // You should have received a copy of the GNU Lesser General Public 21138 // License along with the GNU C Library; if not, see 21139 // <http://www.gnu.org/licenses/>. 21140 21141 type dirent = struct { 21142 Fd_ino uint64 21143 Fd_off int64 21144 Fd_reclen uint16 21145 Fd_type uint8 21146 Fd_name [256]int8 21147 _ [5]byte 21148 } /* dirent.h:22:1 */ 21149 21150 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 21151 // This file is part of the GNU C Library. 21152 // 21153 // The GNU C Library is free software; you can redistribute it and/or 21154 // modify it under the terms of the GNU Lesser General Public 21155 // License as published by the Free Software Foundation; either 21156 // version 2.1 of the License, or (at your option) any later version. 21157 // 21158 // The GNU C Library is distributed in the hope that it will be useful, 21159 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21160 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21161 // Lesser General Public License for more details. 21162 // 21163 // You should have received a copy of the GNU Lesser General Public 21164 // License along with the GNU C Library; if not, see 21165 // <http://www.gnu.org/licenses/>. 21166 21167 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 21168 // This file is part of the GNU C Library. 21169 // 21170 // The GNU C Library is free software; you can redistribute it and/or 21171 // modify it under the terms of the GNU Lesser General Public 21172 // License as published by the Free Software Foundation; either 21173 // version 2.1 of the License, or (at your option) any later version. 21174 // 21175 // The GNU C Library is distributed in the hope that it will be useful, 21176 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21177 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21178 // Lesser General Public License for more details. 21179 // 21180 // You should have received a copy of the GNU Lesser General Public 21181 // License along with the GNU C Library; if not, see 21182 // <http://www.gnu.org/licenses/>. 21183 21184 // bits/types.h -- definitions of __*_t types underlying *_t types. 21185 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 21186 // This file is part of the GNU C Library. 21187 // 21188 // The GNU C Library is free software; you can redistribute it and/or 21189 // modify it under the terms of the GNU Lesser General Public 21190 // License as published by the Free Software Foundation; either 21191 // version 2.1 of the License, or (at your option) any later version. 21192 // 21193 // The GNU C Library is distributed in the hope that it will be useful, 21194 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21195 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21196 // Lesser General Public License for more details. 21197 // 21198 // You should have received a copy of the GNU Lesser General Public 21199 // License along with the GNU C Library; if not, see 21200 // <http://www.gnu.org/licenses/>. 21201 21202 // Never include this file directly; use <sys/types.h> instead. 21203 21204 // `fd_set' type and related macros, and `select'/`pselect' declarations. 21205 // Copyright (C) 1996-2018 Free Software Foundation, Inc. 21206 // This file is part of the GNU C Library. 21207 // 21208 // The GNU C Library is free software; you can redistribute it and/or 21209 // modify it under the terms of the GNU Lesser General Public 21210 // License as published by the Free Software Foundation; either 21211 // version 2.1 of the License, or (at your option) any later version. 21212 // 21213 // The GNU C Library is distributed in the hope that it will be useful, 21214 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21215 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21216 // Lesser General Public License for more details. 21217 // 21218 // You should have received a copy of the GNU Lesser General Public 21219 // License along with the GNU C Library; if not, see 21220 // <http://www.gnu.org/licenses/>. 21221 21222 // POSIX 1003.1g: 6.2 Select from File Descriptor Sets <sys/select.h> 21223 21224 // Structure crudely representing a timezone. 21225 // This is obsolete and should never be used. 21226 type timezone = struct { 21227 Ftz_minuteswest int32 21228 Ftz_dsttime int32 21229 } /* time.h:52:1 */ 21230 21231 // Type of the second argument to `getitimer' and 21232 // the second and third arguments `setitimer'. 21233 type itimerval = struct { 21234 Fit_interval struct { 21235 Ftv_sec int64 21236 Ftv_usec int64 21237 } 21238 Fit_value struct { 21239 Ftv_sec int64 21240 Ftv_usec int64 21241 } 21242 } /* time.h:104:1 */ 21243 21244 // Convenience macros for operations on timevals. 21245 // NOTE: `timercmp' does not work for >= or <=. 21246 21247 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 21248 // This file is part of the GNU C Library. 21249 // 21250 // The GNU C Library is free software; you can redistribute it and/or 21251 // modify it under the terms of the GNU Lesser General Public 21252 // License as published by the Free Software Foundation; either 21253 // version 2.1 of the License, or (at your option) any later version. 21254 // 21255 // The GNU C Library is distributed in the hope that it will be useful, 21256 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21257 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21258 // Lesser General Public License for more details. 21259 // 21260 // You should have received a copy of the GNU Lesser General Public 21261 // License along with the GNU C Library; if not, see 21262 // <http://www.gnu.org/licenses/>. 21263 21264 // ISO C99 Standard: 7.23 Date and time <time.h> 21265 21266 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 21267 // This file is part of the GNU C Library. 21268 // 21269 // The GNU C Library is free software; you can redistribute it and/or 21270 // modify it under the terms of the GNU Lesser General Public 21271 // License as published by the Free Software Foundation; either 21272 // version 2.1 of the License, or (at your option) any later version. 21273 // 21274 // The GNU C Library is distributed in the hope that it will be useful, 21275 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21276 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21277 // Lesser General Public License for more details. 21278 // 21279 // You should have received a copy of the GNU Lesser General Public 21280 // License along with the GNU C Library; if not, see 21281 // <http://www.gnu.org/licenses/>. 21282 21283 // Copyright (C) 1989-2018 Free Software Foundation, Inc. 21284 // 21285 // This file is part of GCC. 21286 // 21287 // GCC is free software; you can redistribute it and/or modify 21288 // it under the terms of the GNU General Public License as published by 21289 // the Free Software Foundation; either version 3, or (at your option) 21290 // any later version. 21291 // 21292 // GCC is distributed in the hope that it will be useful, 21293 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21294 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21295 // GNU General Public License for more details. 21296 // 21297 // Under Section 7 of GPL version 3, you are granted additional 21298 // permissions described in the GCC Runtime Library Exception, version 21299 // 3.1, as published by the Free Software Foundation. 21300 // 21301 // You should have received a copy of the GNU General Public License and 21302 // a copy of the GCC Runtime Library Exception along with this program; 21303 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 21304 // <http://www.gnu.org/licenses/>. 21305 21306 // ISO C Standard: 7.17 Common definitions <stddef.h> 21307 21308 // Any one of these symbols __need_* means that GNU libc 21309 // wants us just to define one data type. So don't define 21310 // the symbols that indicate this file's entire job has been done. 21311 21312 // This avoids lossage on SunOS but only if stdtypes.h comes first. 21313 // There's no way to win with the other order! Sun lossage. 21314 21315 // On 4.3bsd-net2, make sure ansi.h is included, so we have 21316 // one less case to deal with in the following. 21317 // On FreeBSD 5, machine/ansi.h does not exist anymore... 21318 21319 // In 4.3bsd-net2, machine/ansi.h defines these symbols, which are 21320 // defined if the corresponding type is *not* defined. 21321 // FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_. 21322 // NetBSD defines _I386_ANSI_H_ and _X86_64_ANSI_H_ instead of _ANSI_H_ 21323 21324 // Sequent's header files use _PTRDIFF_T_ in some conflicting way. 21325 // Just ignore it. 21326 21327 // On VxWorks, <type/vxTypesBase.h> may have defined macros like 21328 // _TYPE_size_t which will typedef size_t. fixincludes patched the 21329 // vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is 21330 // not defined, and so that defining this macro defines _GCC_SIZE_T. 21331 // If we find that the macros are still defined at this point, we must 21332 // invoke them so that the type is defined as expected. 21333 21334 // In case nobody has defined these types, but we aren't running under 21335 // GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and 21336 // __WCHAR_TYPE__ have reasonable values. This can happen if the 21337 // parts of GCC is compiled by an older compiler, that actually 21338 // include gstddef.h, such as collect2. 21339 21340 // Signed type of difference of two pointers. 21341 21342 // Define this type if we are doing the whole job, 21343 // or if we want this type in particular. 21344 21345 // Unsigned type of `sizeof' something. 21346 21347 // Define this type if we are doing the whole job, 21348 // or if we want this type in particular. 21349 21350 // Wide character type. 21351 // Locale-writers should change this as necessary to 21352 // be big enough to hold unique values not between 0 and 127, 21353 // and not (wchar_t) -1, for each defined multibyte character. 21354 21355 // Define this type if we are doing the whole job, 21356 // or if we want this type in particular. 21357 21358 // In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. 21359 // are already defined. 21360 // BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. 21361 // NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here. 21362 21363 // A null pointer constant. 21364 21365 // This defines CLOCKS_PER_SEC, which is the number of processor clock 21366 // ticks per second, and possibly a number of other constants. 21367 // System-dependent timing definitions. Linux version. 21368 // Copyright (C) 1996-2018 Free Software Foundation, Inc. 21369 // This file is part of the GNU C Library. 21370 // 21371 // The GNU C Library is free software; you can redistribute it and/or 21372 // modify it under the terms of the GNU Lesser General Public 21373 // License as published by the Free Software Foundation; either 21374 // version 2.1 of the License, or (at your option) any later version. 21375 // 21376 // The GNU C Library is distributed in the hope that it will be useful, 21377 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21378 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21379 // Lesser General Public License for more details. 21380 // 21381 // You should have received a copy of the GNU Lesser General Public 21382 // License along with the GNU C Library; if not, see 21383 // <http://www.gnu.org/licenses/>. 21384 21385 // Never include this file directly; use <time.h> instead. 21386 21387 // bits/types.h -- definitions of __*_t types underlying *_t types. 21388 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 21389 // This file is part of the GNU C Library. 21390 // 21391 // The GNU C Library is free software; you can redistribute it and/or 21392 // modify it under the terms of the GNU Lesser General Public 21393 // License as published by the Free Software Foundation; either 21394 // version 2.1 of the License, or (at your option) any later version. 21395 // 21396 // The GNU C Library is distributed in the hope that it will be useful, 21397 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21398 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21399 // Lesser General Public License for more details. 21400 // 21401 // You should have received a copy of the GNU Lesser General Public 21402 // License along with the GNU C Library; if not, see 21403 // <http://www.gnu.org/licenses/>. 21404 21405 // Never include this file directly; use <sys/types.h> instead. 21406 21407 // ISO/IEC 9899:1999 7.23.1: Components of time 21408 // The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is 21409 // the number per second of the value returned by the `clock' function. 21410 // CAE XSH, Issue 4, Version 2: <time.h> 21411 // The value of CLOCKS_PER_SEC is required to be 1 million on all 21412 // XSI-conformant systems. 21413 21414 // Identifier for system-wide realtime clock. 21415 // Monotonic system-wide clock. 21416 // High-resolution timer from the CPU. 21417 // Thread-specific CPU-time clock. 21418 // Monotonic system-wide clock, not adjusted for frequency scaling. 21419 // Identifier for system-wide realtime clock, updated only on ticks. 21420 // Monotonic system-wide clock, updated only on ticks. 21421 // Monotonic system-wide clock that includes time spent in suspension. 21422 // Like CLOCK_REALTIME but also wakes suspended system. 21423 // Like CLOCK_BOOTTIME but also wakes suspended system. 21424 // Like CLOCK_REALTIME but in International Atomic Time. 21425 21426 // Flag to indicate time is absolute. 21427 21428 // Many of the typedefs and structs whose official home is this header 21429 // may also need to be defined by other headers. 21430 21431 // bits/types.h -- definitions of __*_t types underlying *_t types. 21432 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 21433 // This file is part of the GNU C Library. 21434 // 21435 // The GNU C Library is free software; you can redistribute it and/or 21436 // modify it under the terms of the GNU Lesser General Public 21437 // License as published by the Free Software Foundation; either 21438 // version 2.1 of the License, or (at your option) any later version. 21439 // 21440 // The GNU C Library is distributed in the hope that it will be useful, 21441 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21442 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21443 // Lesser General Public License for more details. 21444 // 21445 // You should have received a copy of the GNU Lesser General Public 21446 // License along with the GNU C Library; if not, see 21447 // <http://www.gnu.org/licenses/>. 21448 21449 // Never include this file directly; use <sys/types.h> instead. 21450 21451 // ISO C `broken-down time' structure. 21452 type tm = struct { 21453 Ftm_sec int32 21454 Ftm_min int32 21455 Ftm_hour int32 21456 Ftm_mday int32 21457 Ftm_mon int32 21458 Ftm_year int32 21459 Ftm_wday int32 21460 Ftm_yday int32 21461 Ftm_isdst int32 21462 _ [4]byte 21463 Ftm_gmtoff int64 21464 Ftm_zone uintptr 21465 } /* struct_tm.h:7:1 */ 21466 21467 // NB: Include guard matches what <linux/time.h> uses. 21468 21469 // bits/types.h -- definitions of __*_t types underlying *_t types. 21470 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 21471 // This file is part of the GNU C Library. 21472 // 21473 // The GNU C Library is free software; you can redistribute it and/or 21474 // modify it under the terms of the GNU Lesser General Public 21475 // License as published by the Free Software Foundation; either 21476 // version 2.1 of the License, or (at your option) any later version. 21477 // 21478 // The GNU C Library is distributed in the hope that it will be useful, 21479 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21480 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21481 // Lesser General Public License for more details. 21482 // 21483 // You should have received a copy of the GNU Lesser General Public 21484 // License along with the GNU C Library; if not, see 21485 // <http://www.gnu.org/licenses/>. 21486 21487 // Never include this file directly; use <sys/types.h> instead. 21488 21489 // NB: Include guard matches what <linux/time.h> uses. 21490 21491 // POSIX.1b structure for timer start values and intervals. 21492 type itimerspec = struct { 21493 Fit_interval struct { 21494 Ftv_sec int64 21495 Ftv_nsec int64 21496 } 21497 Fit_value struct { 21498 Ftv_sec int64 21499 Ftv_nsec int64 21500 } 21501 } /* struct_itimerspec.h:8:1 */ 21502 21503 type sigevent = struct { 21504 Fsigev_value struct { 21505 _ [0]uint64 21506 Fsival_int int32 21507 _ [4]byte 21508 } 21509 Fsigev_signo int32 21510 Fsigev_notify int32 21511 F_sigev_un struct { 21512 _ [0]uint64 21513 F_pad [12]int32 21514 } 21515 } /* sigevent_t.h:22:9 */ 21516 21517 // Structure of the fsdir() table-valued function 21518 // 0 1 2 3 4 5 21519 21520 // Set the result stored by context ctx to a blob containing the 21521 // contents of file zName. Or, leave the result unchanged (NULL) 21522 // if the file does not exist or is unreadable. 21523 // 21524 // If the file exceeds the SQLite blob size limit, through an 21525 // SQLITE_TOOBIG error. 21526 // 21527 // Throw an SQLITE_IOERR if there are difficulties pulling the file 21528 // off of disk. 21529 func readFileContents(tls *libc.TLS, ctx uintptr, zName uintptr) { /* fileio.c:133:13: */ 21530 var in uintptr 21531 var nIn sqlite3_int64 21532 var pBuf uintptr 21533 var db uintptr 21534 var mxBlob int32 21535 21536 in = libc.Xfopen(tls, zName, ts+4273 /* "rb" */) 21537 if in == uintptr(0) { 21538 // File does not exist or is unreadable. Leave the result set to NULL. 21539 return 21540 } 21541 libc.Xfseek(tls, in, int64(0), SEEK_END) 21542 nIn = sqlite3_int64(libc.Xftell(tls, in)) 21543 libc.Xrewind(tls, in) 21544 db = sqlite3.Xsqlite3_context_db_handle(tls, ctx) 21545 mxBlob = sqlite3.Xsqlite3_limit(tls, db, SQLITE_LIMIT_LENGTH, -1) 21546 if nIn > sqlite3_int64(mxBlob) { 21547 sqlite3.Xsqlite3_result_error_code(tls, ctx, SQLITE_TOOBIG) 21548 libc.Xfclose(tls, in) 21549 return 21550 } 21551 pBuf = sqlite3.Xsqlite3_malloc64(tls, func() uint64 { 21552 if nIn != 0 { 21553 return uint64(nIn) 21554 } 21555 return uint64(1) 21556 }()) 21557 if pBuf == uintptr(0) { 21558 sqlite3.Xsqlite3_result_error_nomem(tls, ctx) 21559 libc.Xfclose(tls, in) 21560 return 21561 } 21562 if nIn == sqlite3_int64(libc.Xfread(tls, pBuf, uint64(1), size_t(nIn), in)) { 21563 sqlite3.Xsqlite3_result_blob64(tls, ctx, pBuf, uint64(nIn), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) 21564 } else { 21565 sqlite3.Xsqlite3_result_error_code(tls, ctx, SQLITE_IOERR) 21566 sqlite3.Xsqlite3_free(tls, pBuf) 21567 } 21568 libc.Xfclose(tls, in) 21569 } 21570 21571 // Implementation of the "readfile(X)" SQL function. The entire content 21572 // of the file named X is read and returned as a BLOB. NULL is returned 21573 // if the file does not exist or is unreadable. 21574 func readfileFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* fileio.c:175:13: */ 21575 var zName uintptr 21576 _ = argc // Unused parameter 21577 zName = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 21578 if zName == uintptr(0) { 21579 return 21580 } 21581 readFileContents(tls, context, zName) 21582 } 21583 21584 // Set the error message contained in context ctx to the results of 21585 // vprintf(zFmt, ...). 21586 func ctxErrorMsg(tls *libc.TLS, ctx uintptr, zFmt uintptr, va uintptr) { /* fileio.c:191:13: */ 21587 var zMsg uintptr = uintptr(0) 21588 var ap va_list 21589 _ = ap 21590 ap = va 21591 zMsg = sqlite3.Xsqlite3_vmprintf(tls, zFmt, ap) 21592 sqlite3.Xsqlite3_result_error(tls, ctx, zMsg, -1) 21593 sqlite3.Xsqlite3_free(tls, zMsg) 21594 _ = ap 21595 } 21596 21597 // This function is used in place of stat(). On Windows, special handling 21598 // is required in order for the included time to be returned as UTC. On all 21599 // other systems, this function simply calls stat(). 21600 func fileStat(tls *libc.TLS, zPath uintptr, pStatBuf uintptr) int32 { /* fileio.c:261:12: */ 21601 return libc.Xstat(tls, zPath, pStatBuf) 21602 } 21603 21604 // This function is used in place of lstat(). On Windows, special handling 21605 // is required in order for the included time to be returned as UTC. On all 21606 // other systems, this function simply calls lstat(). 21607 func fileLinkStat(tls *libc.TLS, zPath uintptr, pStatBuf uintptr) int32 { /* fileio.c:279:12: */ 21608 return libc.Xlstat(tls, zPath, pStatBuf) 21609 } 21610 21611 // Argument zFile is the name of a file that will be created and/or written 21612 // by SQL function writefile(). This function ensures that the directory 21613 // zFile will be written to exists, creating it if required. The permissions 21614 // for any path components created by this function are set in accordance 21615 // with the current umask. 21616 // 21617 // If an OOM condition is encountered, SQLITE_NOMEM is returned. Otherwise, 21618 // SQLITE_OK is returned if the directory is successfully created, or 21619 // SQLITE_ERROR otherwise. 21620 func makeDirectory(tls *libc.TLS, zFile uintptr) int32 { /* fileio.c:303:12: */ 21621 bp := tls.Alloc(152) 21622 defer tls.Free(152) 21623 21624 var zCopy uintptr = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zFile)) 21625 var rc int32 = SQLITE_OK 21626 21627 if zCopy == uintptr(0) { 21628 rc = SQLITE_NOMEM 21629 } else { 21630 var nCopy int32 = int32(libc.Xstrlen(tls, zCopy)) 21631 var i int32 = 1 21632 21633 for rc == SQLITE_OK { 21634 // var sStat stat at bp+8, 144 21635 21636 var rc2 int32 21637 21638 for ; (int32(*(*int8)(unsafe.Pointer(zCopy + uintptr(i)))) != '/') && (i < nCopy); i++ { 21639 } 21640 if i == nCopy { 21641 break 21642 } 21643 *(*int8)(unsafe.Pointer(zCopy + uintptr(i))) = int8(0) 21644 21645 rc2 = fileStat(tls, zCopy, bp+8 /* &sStat */) 21646 if rc2 != 0 { 21647 if libc.Xmkdir(tls, zCopy, uint32(0777)) != 0 { 21648 rc = SQLITE_ERROR 21649 } 21650 } else { 21651 if !((((*stat)(unsafe.Pointer(bp + 8 /* &sStat */)).Fst_mode) & uint32(0170000)) == (uint32(0040000))) { 21652 rc = SQLITE_ERROR 21653 } 21654 } 21655 *(*int8)(unsafe.Pointer(zCopy + uintptr(i))) = int8('/') 21656 i++ 21657 } 21658 21659 sqlite3.Xsqlite3_free(tls, zCopy) 21660 } 21661 21662 return rc 21663 } 21664 21665 // This function does the work for the writefile() UDF. Refer to 21666 // header comments at the top of this file for details. 21667 func writeFile(tls *libc.TLS, pCtx uintptr, zFile uintptr, pData uintptr, mode mode_t, mtime sqlite3_int64) int32 { /* fileio.c:343:12: */ 21668 bp := tls.Alloc(176) 21669 defer tls.Free(176) 21670 21671 if ((mode) & mode_t(0170000)) == (mode_t(0120000)) { 21672 var zTo uintptr = sqlite3.Xsqlite3_value_text(tls, pData) 21673 if libc.Xsymlink(tls, zTo, zFile) < 0 { 21674 return 1 21675 } 21676 } else { 21677 if ((mode) & mode_t(0170000)) == (mode_t(0040000)) { 21678 if libc.Xmkdir(tls, zFile, mode) != 0 { 21679 // The mkdir() call to create the directory failed. This might not 21680 // be an error though - if there is already a directory at the same 21681 // path and either the permissions already match or can be changed 21682 // to do so using chmod(), it is not an error. 21683 // var sStat stat at bp, 144 21684 21685 if ((((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) != EEXIST) || 21686 (0 != fileStat(tls, zFile, bp /* &sStat */))) || 21687 !((((*stat)(unsafe.Pointer(bp /* &sStat */)).Fst_mode) & uint32(0170000)) == (uint32(0040000)))) || 21688 ((((*stat)(unsafe.Pointer(bp /* &sStat */)).Fst_mode & uint32(0777)) != (mode & mode_t(0777))) && (0 != libc.Xchmod(tls, zFile, (mode&mode_t(0777))))) { 21689 return 1 21690 } 21691 } 21692 } else { 21693 var nWrite sqlite3_int64 = int64(0) 21694 var z uintptr 21695 var rc int32 = 0 21696 var out uintptr = libc.Xfopen(tls, zFile, ts+4853 /* "wb" */) 21697 if out == uintptr(0) { 21698 return 1 21699 } 21700 z = sqlite3.Xsqlite3_value_blob(tls, pData) 21701 if z != 0 { 21702 var n sqlite3_int64 = sqlite3_int64(libc.Xfwrite(tls, z, uint64(1), uint64(sqlite3.Xsqlite3_value_bytes(tls, pData)), out)) 21703 nWrite = sqlite3_int64(sqlite3.Xsqlite3_value_bytes(tls, pData)) 21704 if nWrite != n { 21705 rc = 1 21706 } 21707 } 21708 libc.Xfclose(tls, out) 21709 if ((rc == 0) && (mode != 0)) && (libc.Xchmod(tls, zFile, (mode&mode_t(0777))) != 0) { 21710 rc = 1 21711 } 21712 if rc != 0 { 21713 return 2 21714 } 21715 sqlite3.Xsqlite3_result_int64(tls, pCtx, nWrite) 21716 } 21717 } 21718 21719 if mtime >= int64(0) { 21720 // Legacy unix 21721 // var times [2]timeval at bp+144, 32 21722 21723 (*timeval)(unsafe.Pointer(bp + 144 /* × */)).Ftv_usec = libc.AssignPtrInt64(bp+144 /* × */ +1*16+8 /* &.tv_usec */, int64(0)) 21724 (*timeval)(unsafe.Pointer(bp + 144 /* × */)).Ftv_sec = libc.Xtime(tls, uintptr(0)) 21725 (*timeval)(unsafe.Pointer(bp + 144 /* × */ + 1*16)).Ftv_sec = int64(mtime) 21726 if libc.Xutimes(tls, zFile, bp+144 /* ×[0] */) != 0 { 21727 return 1 21728 } 21729 } 21730 21731 return 0 21732 } 21733 21734 // Implementation of the "writefile(W,X[,Y[,Z]]])" SQL function. 21735 // Refer to header comments at the top of this file for details. 21736 func writefileFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* fileio.c:457:13: */ 21737 bp := tls.Alloc(24) 21738 defer tls.Free(24) 21739 21740 var zFile uintptr 21741 var mode mode_t = mode_t(0) 21742 var res int32 21743 var mtime sqlite3_int64 = int64(-1) 21744 21745 if (argc < 2) || (argc > 4) { 21746 sqlite3.Xsqlite3_result_error(tls, context, 21747 ts+4856 /* "wrong number of ..." */, -1) 21748 return 21749 } 21750 21751 zFile = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 21752 if zFile == uintptr(0) { 21753 return 21754 } 21755 if argc >= 3 { 21756 mode = mode_t(sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) 21757 } 21758 if argc == 4 { 21759 mtime = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) 21760 } 21761 21762 res = writeFile(tls, context, zFile, *(*uintptr)(unsafe.Pointer(argv + 1*8)), mode, mtime) 21763 if (res == 1) && ((*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == ENOENT) { 21764 if makeDirectory(tls, zFile) == SQLITE_OK { 21765 res = writeFile(tls, context, zFile, *(*uintptr)(unsafe.Pointer(argv + 1*8)), mode, mtime) 21766 } 21767 } 21768 21769 if (argc > 2) && (res != 0) { 21770 if ((mode) & mode_t(0170000)) == (mode_t(0120000)) { 21771 ctxErrorMsg(tls, context, ts+4906 /* "failed to create..." */, libc.VaList(bp, zFile)) 21772 } else if ((mode) & mode_t(0170000)) == (mode_t(0040000)) { 21773 ctxErrorMsg(tls, context, ts+4935 /* "failed to create..." */, libc.VaList(bp+8, zFile)) 21774 } else { 21775 ctxErrorMsg(tls, context, ts+4966 /* "failed to write ..." */, libc.VaList(bp+16, zFile)) 21776 } 21777 } 21778 } 21779 21780 // SQL function: lsmode(MODE) 21781 // 21782 // Given a numberic st_mode from stat(), convert it into a human-readable 21783 // text string in the style of "ls -l". 21784 func lsModeFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* fileio.c:507:13: */ 21785 bp := tls.Alloc(16) 21786 defer tls.Free(16) 21787 21788 var i int32 21789 var iMode int32 = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))) 21790 // var z [16]int8 at bp, 16 21791 21792 _ = argc 21793 if ((iMode) & 0170000) == (0120000) { 21794 *(*int8)(unsafe.Pointer(bp /* &z[0] */)) = int8('l') 21795 } else if ((iMode) & 0170000) == (0100000) { 21796 *(*int8)(unsafe.Pointer(bp /* &z[0] */)) = int8('-') 21797 } else if ((iMode) & 0170000) == (0040000) { 21798 *(*int8)(unsafe.Pointer(bp /* &z[0] */)) = int8('d') 21799 } else { 21800 *(*int8)(unsafe.Pointer(bp /* &z[0] */)) = int8('?') 21801 } 21802 for i = 0; i < 3; i++ { 21803 var m int32 = (iMode >> ((2 - i) * 3)) 21804 var a uintptr = (bp /* &z */ + uintptr((1 + (i * 3)))) 21805 *(*int8)(unsafe.Pointer(a)) = func() int8 { 21806 if (m & 0x4) != 0 { 21807 return int8('r') 21808 } 21809 return int8('-') 21810 }() 21811 *(*int8)(unsafe.Pointer(a + 1)) = func() int8 { 21812 if (m & 0x2) != 0 { 21813 return int8('w') 21814 } 21815 return int8('-') 21816 }() 21817 *(*int8)(unsafe.Pointer(a + 2)) = func() int8 { 21818 if (m & 0x1) != 0 { 21819 return int8('x') 21820 } 21821 return int8('-') 21822 }() 21823 } 21824 *(*int8)(unsafe.Pointer(bp /* &z[0] */ + 10)) = int8(0) 21825 sqlite3.Xsqlite3_result_text(tls, context, bp /* &z[0] */, -1, libc.UintptrFromInt32(-1)) 21826 } 21827 21828 // Cursor type for recursively iterating through a directory structure. 21829 type fsdir_cursor1 = struct { 21830 Fbase sqlite3_vtab_cursor 21831 FnLvl int32 21832 FiLvl int32 21833 FaLvl uintptr 21834 FzBase uintptr 21835 FnBase int32 21836 _ [4]byte 21837 FsStat struct { 21838 Fst_dev uint64 21839 Fst_ino uint64 21840 Fst_nlink uint64 21841 Fst_mode uint32 21842 Fst_uid uint32 21843 Fst_gid uint32 21844 F__glibc_reserved0 int32 21845 Fst_rdev uint64 21846 Fst_size int64 21847 Fst_atim struct { 21848 Ftv_sec int64 21849 Ftv_nsec int64 21850 } 21851 Fst_mtim struct { 21852 Ftv_sec int64 21853 Ftv_nsec int64 21854 } 21855 Fst_ctim struct { 21856 Ftv_sec int64 21857 Ftv_nsec int64 21858 } 21859 Fst_blksize int64 21860 Fst_blocks int64 21861 F__glibc_reserved [3]int64 21862 } 21863 FzPath uintptr 21864 FiRowid sqlite3_int64 21865 } /* fileio.c:541:9 */ 21866 21867 // Cursor type for recursively iterating through a directory structure. 21868 type fsdir_cursor = fsdir_cursor1 /* fileio.c:541:29 */ 21869 type FsdirLevel1 = struct { 21870 FpDir uintptr 21871 FzDir uintptr 21872 } /* fileio.c:541:9 */ 21873 21874 type FsdirLevel = FsdirLevel1 /* fileio.c:542:27 */ 21875 21876 type fsdir_tab1 = struct{ Fbase sqlite3_vtab } /* fileio.c:564:9 */ 21877 21878 type fsdir_tab = fsdir_tab1 /* fileio.c:564:26 */ 21879 21880 // Construct a new fsdir virtual table object. 21881 func fsdirConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* fileio.c:572:12: */ 21882 var pNew uintptr = uintptr(0) 21883 var rc int32 21884 _ = pAux 21885 _ = argc 21886 _ = argv 21887 _ = pzErr 21888 rc = sqlite3.Xsqlite3_declare_vtab(tls, db, ts+4991 /* "CREATE TABLE x(n..." */) 21889 if rc == SQLITE_OK { 21890 pNew = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(fsdir_tab{}))) 21891 if pNew == uintptr(0) { 21892 return SQLITE_NOMEM 21893 } 21894 libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(fsdir_tab{}))) 21895 sqlite3.Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_DIRECTONLY, 0) 21896 } 21897 *(*uintptr)(unsafe.Pointer(ppVtab)) = pNew 21898 return rc 21899 } 21900 21901 // This method is the destructor for fsdir vtab objects. 21902 func fsdirDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* fileio.c:599:12: */ 21903 sqlite3.Xsqlite3_free(tls, pVtab) 21904 return SQLITE_OK 21905 } 21906 21907 // Constructor for a new fsdir_cursor object. 21908 func fsdirOpen(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* fileio.c:607:12: */ 21909 var pCur uintptr 21910 _ = p 21911 pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(fsdir_cursor{}))) 21912 if pCur == uintptr(0) { 21913 return SQLITE_NOMEM 21914 } 21915 libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(fsdir_cursor{}))) 21916 (*fsdir_cursor)(unsafe.Pointer(pCur)).FiLvl = -1 21917 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) 21918 return SQLITE_OK 21919 } 21920 21921 // Reset a cursor back to the state it was in when first returned 21922 // by fsdirOpen(). 21923 func fsdirResetCursor(tls *libc.TLS, pCur uintptr) { /* fileio.c:622:13: */ 21924 var i int32 21925 for i = 0; i <= (*fsdir_cursor)(unsafe.Pointer(pCur)).FiLvl; i++ { 21926 var pLvl uintptr = ((*fsdir_cursor)(unsafe.Pointer(pCur)).FaLvl + uintptr(i)*16) 21927 if (*FsdirLevel)(unsafe.Pointer(pLvl)).FpDir != 0 { 21928 libc.Xclosedir(tls, (*FsdirLevel)(unsafe.Pointer(pLvl)).FpDir) 21929 } 21930 sqlite3.Xsqlite3_free(tls, (*FsdirLevel)(unsafe.Pointer(pLvl)).FzDir) 21931 } 21932 sqlite3.Xsqlite3_free(tls, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath) 21933 sqlite3.Xsqlite3_free(tls, (*fsdir_cursor)(unsafe.Pointer(pCur)).FaLvl) 21934 (*fsdir_cursor)(unsafe.Pointer(pCur)).FaLvl = uintptr(0) 21935 (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath = uintptr(0) 21936 (*fsdir_cursor)(unsafe.Pointer(pCur)).FzBase = uintptr(0) 21937 (*fsdir_cursor)(unsafe.Pointer(pCur)).FnBase = 0 21938 (*fsdir_cursor)(unsafe.Pointer(pCur)).FnLvl = 0 21939 (*fsdir_cursor)(unsafe.Pointer(pCur)).FiLvl = -1 21940 (*fsdir_cursor)(unsafe.Pointer(pCur)).FiRowid = int64(1) 21941 } 21942 21943 // Destructor for an fsdir_cursor. 21944 func fsdirClose(tls *libc.TLS, cur uintptr) int32 { /* fileio.c:643:12: */ 21945 var pCur uintptr = cur 21946 21947 fsdirResetCursor(tls, pCur) 21948 sqlite3.Xsqlite3_free(tls, pCur) 21949 return SQLITE_OK 21950 } 21951 21952 // Set the error message for the virtual table associated with cursor 21953 // pCur to the results of vprintf(zFmt, ...). 21954 func fsdirSetErrmsg(tls *libc.TLS, pCur uintptr, zFmt uintptr, va uintptr) { /* fileio.c:655:13: */ 21955 var ap va_list 21956 _ = ap 21957 ap = va 21958 (*sqlite3_vtab)(unsafe.Pointer((*fsdir_cursor)(unsafe.Pointer(pCur)).Fbase.FpVtab)).FzErrMsg = sqlite3.Xsqlite3_vmprintf(tls, zFmt, ap) 21959 _ = ap 21960 } 21961 21962 // Advance an fsdir_cursor to its next row of output. 21963 func fsdirNext(tls *libc.TLS, cur uintptr) int32 { /* fileio.c:666:12: */ 21964 bp := tls.Alloc(32) 21965 defer tls.Free(32) 21966 21967 var pCur uintptr = cur 21968 var m mode_t = (*fsdir_cursor)(unsafe.Pointer(pCur)).FsStat.Fst_mode 21969 21970 (*fsdir_cursor)(unsafe.Pointer(pCur)).FiRowid++ 21971 if ((m) & mode_t(0170000)) == (mode_t(0040000)) { 21972 // Descend into this directory 21973 var iNew int32 = ((*fsdir_cursor)(unsafe.Pointer(pCur)).FiLvl + 1) 21974 var pLvl uintptr 21975 if iNew >= (*fsdir_cursor)(unsafe.Pointer(pCur)).FnLvl { 21976 var nNew int32 = (iNew + 1) 21977 var nByte sqlite3_int64 = (sqlite3_int64(uint64(nNew) * uint64(unsafe.Sizeof(FsdirLevel{})))) 21978 var aNew uintptr = sqlite3.Xsqlite3_realloc64(tls, (*fsdir_cursor)(unsafe.Pointer(pCur)).FaLvl, uint64(nByte)) 21979 if aNew == uintptr(0) { 21980 return SQLITE_NOMEM 21981 } 21982 libc.Xmemset(tls, (aNew + uintptr((*fsdir_cursor)(unsafe.Pointer(pCur)).FnLvl)*16), 0, (uint64(unsafe.Sizeof(FsdirLevel{})) * (uint64(nNew - (*fsdir_cursor)(unsafe.Pointer(pCur)).FnLvl)))) 21983 (*fsdir_cursor)(unsafe.Pointer(pCur)).FaLvl = aNew 21984 (*fsdir_cursor)(unsafe.Pointer(pCur)).FnLvl = nNew 21985 } 21986 (*fsdir_cursor)(unsafe.Pointer(pCur)).FiLvl = iNew 21987 pLvl = ((*fsdir_cursor)(unsafe.Pointer(pCur)).FaLvl + uintptr(iNew)*16) 21988 21989 (*FsdirLevel)(unsafe.Pointer(pLvl)).FzDir = (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath 21990 (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath = uintptr(0) 21991 (*FsdirLevel)(unsafe.Pointer(pLvl)).FpDir = libc.Xopendir(tls, (*FsdirLevel)(unsafe.Pointer(pLvl)).FzDir) 21992 if (*FsdirLevel)(unsafe.Pointer(pLvl)).FpDir == uintptr(0) { 21993 fsdirSetErrmsg(tls, pCur, ts+5051 /* "cannot read dire..." */, libc.VaList(bp, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath)) 21994 return SQLITE_ERROR 21995 } 21996 } 21997 21998 for (*fsdir_cursor)(unsafe.Pointer(pCur)).FiLvl >= 0 { 21999 var pLvl uintptr = ((*fsdir_cursor)(unsafe.Pointer(pCur)).FaLvl + uintptr((*fsdir_cursor)(unsafe.Pointer(pCur)).FiLvl)*16) 22000 var pEntry uintptr = libc.Xreaddir(tls, (*FsdirLevel)(unsafe.Pointer(pLvl)).FpDir) 22001 if pEntry != 0 { 22002 if int32(*(*int8)(unsafe.Pointer((pEntry + 19 /* &.d_name */)))) == '.' { 22003 if (int32(*(*int8)(unsafe.Pointer((pEntry + 19 /* &.d_name */) + 1))) == '.') && (int32(*(*int8)(unsafe.Pointer((pEntry + 19 /* &.d_name */) + 2))) == 0) { 22004 continue 22005 } 22006 if int32(*(*int8)(unsafe.Pointer((pEntry + 19 /* &.d_name */) + 1))) == 0 { 22007 continue 22008 } 22009 } 22010 sqlite3.Xsqlite3_free(tls, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath) 22011 (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath = sqlite3.Xsqlite3_mprintf(tls, ts+5077 /* "%s/%s" */, libc.VaList(bp+8, (*FsdirLevel)(unsafe.Pointer(pLvl)).FzDir, pEntry+19 /* &.d_name */)) 22012 if (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath == uintptr(0) { 22013 return SQLITE_NOMEM 22014 } 22015 if fileLinkStat(tls, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath, (pCur+40 /* &.sStat */)) != 0 { 22016 fsdirSetErrmsg(tls, pCur, ts+5083 /* "cannot stat file..." */, libc.VaList(bp+24, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath)) 22017 return SQLITE_ERROR 22018 } 22019 return SQLITE_OK 22020 } 22021 libc.Xclosedir(tls, (*FsdirLevel)(unsafe.Pointer(pLvl)).FpDir) 22022 sqlite3.Xsqlite3_free(tls, (*FsdirLevel)(unsafe.Pointer(pLvl)).FzDir) 22023 (*FsdirLevel)(unsafe.Pointer(pLvl)).FpDir = uintptr(0) 22024 (*FsdirLevel)(unsafe.Pointer(pLvl)).FzDir = uintptr(0) 22025 (*fsdir_cursor)(unsafe.Pointer(pCur)).FiLvl-- 22026 } 22027 22028 // EOF 22029 sqlite3.Xsqlite3_free(tls, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath) 22030 (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath = uintptr(0) 22031 return SQLITE_OK 22032 } 22033 22034 // Return values of columns for the row at which the series_cursor 22035 // is currently pointing. 22036 func fsdirColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* fileio.c:730:12: */ 22037 bp := tls.Alloc(64) 22038 defer tls.Free(64) 22039 22040 var pCur uintptr = cur 22041 switch i { 22042 case FSDIR_COLUMN_NAME: 22043 { 22044 sqlite3.Xsqlite3_result_text(tls, ctx, ((*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath + uintptr((*fsdir_cursor)(unsafe.Pointer(pCur)).FnBase)), -1, libc.UintptrFromInt32(-1)) 22045 break 22046 22047 } 22048 22049 case FSDIR_COLUMN_MODE: 22050 sqlite3.Xsqlite3_result_int64(tls, ctx, int64((*fsdir_cursor)(unsafe.Pointer(pCur)).FsStat.Fst_mode)) 22051 break 22052 22053 case FSDIR_COLUMN_MTIME: 22054 sqlite3.Xsqlite3_result_int64(tls, ctx, int64((*fsdir_cursor)(unsafe.Pointer(pCur)).FsStat.Fst_mtim.Ftv_sec)) 22055 break 22056 22057 case FSDIR_COLUMN_DATA: 22058 { 22059 var m mode_t = (*fsdir_cursor)(unsafe.Pointer(pCur)).FsStat.Fst_mode 22060 if ((m) & mode_t(0170000)) == (mode_t(0040000)) { 22061 sqlite3.Xsqlite3_result_null(tls, ctx) 22062 } else if ((m) & mode_t(0170000)) == (mode_t(0120000)) { 22063 // var aStatic [64]int8 at bp, 64 22064 22065 var aBuf uintptr = bp /* aStatic */ 22066 var nBuf sqlite3_int64 = int64(64) 22067 var n int32 22068 22069 for 1 != 0 { 22070 n = int32(libc.Xreadlink(tls, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath, aBuf, uint64(nBuf))) 22071 if sqlite3_int64(n) < nBuf { 22072 break 22073 } 22074 if aBuf != bp /* aStatic */ { 22075 sqlite3.Xsqlite3_free(tls, aBuf) 22076 } 22077 nBuf = (nBuf * int64(2)) 22078 aBuf = sqlite3.Xsqlite3_malloc64(tls, uint64(nBuf)) 22079 if aBuf == uintptr(0) { 22080 sqlite3.Xsqlite3_result_error_nomem(tls, ctx) 22081 return SQLITE_NOMEM 22082 } 22083 } 22084 22085 sqlite3.Xsqlite3_result_text(tls, ctx, aBuf, n, libc.UintptrFromInt32(-1)) 22086 if aBuf != bp /* aStatic */ { 22087 sqlite3.Xsqlite3_free(tls, aBuf) 22088 } 22089 } else { 22090 readFileContents(tls, ctx, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath) 22091 } 22092 22093 } 22094 fallthrough 22095 case FSDIR_COLUMN_PATH: 22096 fallthrough 22097 default: 22098 { 22099 // The FSDIR_COLUMN_PATH and FSDIR_COLUMN_DIR are input parameters. 22100 // always return their values as NULL 22101 break 22102 22103 } 22104 } 22105 return SQLITE_OK 22106 } 22107 22108 // Return the rowid for the current row. In this implementation, the 22109 // first row returned is assigned rowid value 1, and each subsequent 22110 // row a value 1 more than that of the previous. 22111 func fsdirRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* fileio.c:795:12: */ 22112 var pCur uintptr = cur 22113 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*fsdir_cursor)(unsafe.Pointer(pCur)).FiRowid 22114 return SQLITE_OK 22115 } 22116 22117 // Return TRUE if the cursor has been moved off of the last 22118 // row of output. 22119 func fsdirEof(tls *libc.TLS, cur uintptr) int32 { /* fileio.c:805:12: */ 22120 var pCur uintptr = cur 22121 return (libc.Bool32((*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath == uintptr(0))) 22122 } 22123 22124 // xFilter callback. 22125 // 22126 // idxNum==1 PATH parameter only 22127 // idxNum==2 Both PATH and DIR supplied 22128 func fsdirFilter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* fileio.c:816:12: */ 22129 bp := tls.Alloc(32) 22130 defer tls.Free(32) 22131 22132 var zDir uintptr = uintptr(0) 22133 var pCur uintptr = cur 22134 _ = idxStr 22135 fsdirResetCursor(tls, pCur) 22136 22137 if idxNum == 0 { 22138 fsdirSetErrmsg(tls, pCur, ts+5104 /* "table function f..." */, 0) 22139 return SQLITE_ERROR 22140 } 22141 22142 zDir = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 22143 if zDir == uintptr(0) { 22144 fsdirSetErrmsg(tls, pCur, ts+5146 /* "table function f..." */, 0) 22145 return SQLITE_ERROR 22146 } 22147 if argc == 2 { 22148 (*fsdir_cursor)(unsafe.Pointer(pCur)).FzBase = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 22149 } 22150 if (*fsdir_cursor)(unsafe.Pointer(pCur)).FzBase != 0 { 22151 (*fsdir_cursor)(unsafe.Pointer(pCur)).FnBase = (int32(libc.Xstrlen(tls, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzBase)) + 1) 22152 (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath = sqlite3.Xsqlite3_mprintf(tls, ts+5077 /* "%s/%s" */, libc.VaList(bp, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzBase, zDir)) 22153 } else { 22154 (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+16, zDir)) 22155 } 22156 22157 if (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath == uintptr(0) { 22158 return SQLITE_NOMEM 22159 } 22160 if fileLinkStat(tls, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath, (pCur+40 /* &.sStat */)) != 0 { 22161 fsdirSetErrmsg(tls, pCur, ts+5083 /* "cannot stat file..." */, libc.VaList(bp+24, (*fsdir_cursor)(unsafe.Pointer(pCur)).FzPath)) 22162 return SQLITE_ERROR 22163 } 22164 22165 return SQLITE_OK 22166 } 22167 22168 // SQLite will invoke this method one or more times while planning a query 22169 // that uses the generate_series virtual table. This routine needs to create 22170 // a query plan for each invocation and compute an estimated cost for that 22171 // plan. 22172 // 22173 // In this implementation idxNum is used to represent the 22174 // query plan. idxStr is unused. 22175 // 22176 // The query plan is represented by values of idxNum: 22177 // 22178 // (1) The path value is supplied by argv[0] 22179 // (2) Path is in argv[0] and dir is in argv[1] 22180 func fsdirBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* fileio.c:872:12: */ 22181 var i int32 // Loop over constraints 22182 var idxPath int32 = -1 // Index in pIdxInfo->aConstraint of PATH= 22183 var idxDir int32 = -1 // Index in pIdxInfo->aConstraint of DIR= 22184 var seenPath int32 = 0 // True if an unusable PATH= constraint is seen 22185 var seenDir int32 = 0 // True if an unusable DIR= constraint is seen 22186 var pConstraint uintptr 22187 22188 _ = tab 22189 pConstraint = (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint 22190 i = 0 22191 __1: 22192 if !(i < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { 22193 goto __3 22194 } 22195 { 22196 if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) != SQLITE_INDEX_CONSTRAINT_EQ { 22197 goto __2 22198 } 22199 switch (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn { 22200 case FSDIR_COLUMN_PATH: 22201 { 22202 if (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable != 0 { 22203 idxPath = i 22204 seenPath = 0 22205 } else if idxPath < 0 { 22206 seenPath = 1 22207 } 22208 break 22209 22210 } 22211 case FSDIR_COLUMN_DIR: 22212 { 22213 if (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable != 0 { 22214 idxDir = i 22215 seenDir = 0 22216 } else if idxDir < 0 { 22217 seenDir = 1 22218 } 22219 break 22220 22221 } 22222 } 22223 22224 } 22225 goto __2 22226 __2: 22227 i++ 22228 pConstraint += 12 22229 goto __1 22230 goto __3 22231 __3: 22232 ; 22233 if (seenPath != 0) || (seenDir != 0) { 22234 // If input parameters are unusable, disallow this plan 22235 return SQLITE_CONSTRAINT 22236 } 22237 22238 if idxPath < 0 { 22239 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 0 22240 // The pIdxInfo->estimatedCost should have been initialized to a huge 22241 // number. Leave it unchanged. 22242 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(0x7fffffff) 22243 } else { 22244 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(idxPath)*8)).Fomit = uint8(1) 22245 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(idxPath)*8)).FargvIndex = 1 22246 if idxDir >= 0 { 22247 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(idxDir)*8)).Fomit = uint8(1) 22248 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(idxDir)*8)).FargvIndex = 2 22249 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 2 22250 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 10.0 22251 } else { 22252 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 1 22253 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 100.0 22254 } 22255 } 22256 22257 return SQLITE_OK 22258 } 22259 22260 // Register the "fsdir" virtual table. 22261 func fsdirRegister(tls *libc.TLS, db uintptr) int32 { /* fileio.c:938:12: */ 22262 22263 var rc int32 = sqlite3.Xsqlite3_create_module(tls, db, ts+5196 /* "fsdir" */, uintptr(unsafe.Pointer(&fsdirModule1)), uintptr(0)) 22264 return rc 22265 } 22266 22267 var fsdirModule1 = sqlite3_module{ // xCreate 22268 FxConnect: 0, // xConnect 22269 FxBestIndex: 0, // xBestIndex 22270 FxDisconnect: 0, // xDestroy 22271 FxOpen: 0, // xOpen - open a cursor 22272 FxClose: 0, // xClose - close a cursor 22273 FxFilter: 0, // xFilter - configure scan constraints 22274 FxNext: 0, // xNext - advance a cursor 22275 FxEof: 0, // xEof - check for end of scan 22276 FxColumn: 0, // xColumn - read data 22277 FxRowid: 0, // xShadowName 22278 } /* fileio.c:939:25 */ 22279 22280 func sqlite3_fileio_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* fileio.c:976:5: */ 22281 var rc int32 = SQLITE_OK 22282 _ = pApi 22283 22284 _ = pzErrMsg // Unused parameter 22285 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+5202 /* "readfile" */, 1, 22286 (SQLITE_UTF8 | SQLITE_DIRECTONLY), uintptr(0), 22287 *(*uintptr)(unsafe.Pointer(&struct { 22288 f func(*libc.TLS, uintptr, int32, uintptr) 22289 }{readfileFunc})), uintptr(0), uintptr(0)) 22290 if rc == SQLITE_OK { 22291 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+5211 /* "writefile" */, -1, 22292 (SQLITE_UTF8 | SQLITE_DIRECTONLY), uintptr(0), 22293 *(*uintptr)(unsafe.Pointer(&struct { 22294 f func(*libc.TLS, uintptr, int32, uintptr) 22295 }{writefileFunc})), uintptr(0), uintptr(0)) 22296 } 22297 if rc == SQLITE_OK { 22298 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+5221 /* "lsmode" */, 1, SQLITE_UTF8, uintptr(0), 22299 *(*uintptr)(unsafe.Pointer(&struct { 22300 f func(*libc.TLS, uintptr, int32, uintptr) 22301 }{lsModeFunc})), uintptr(0), uintptr(0)) 22302 } 22303 if rc == SQLITE_OK { 22304 rc = fsdirRegister(tls, db) 22305 } 22306 return rc 22307 } 22308 22309 // If we are compiling with optimizing read this file. It contains 22310 // several optimizing inline functions and macros. 22311 22312 // Forward declaration of objects used by this implementation 22313 type fuzzer_vtab1 = struct { 22314 Fbase sqlite3_vtab 22315 FzClassName uintptr 22316 FpRule uintptr 22317 FnCursor int32 22318 _ [4]byte 22319 } /* fuzzer.c:162:9 */ 22320 22321 // If we are compiling with optimizing read this file. It contains 22322 // several optimizing inline functions and macros. 22323 22324 // Forward declaration of objects used by this implementation 22325 type fuzzer_vtab = fuzzer_vtab1 /* fuzzer.c:162:28 */ 22326 type fuzzer_cursor1 = struct { 22327 Fbase sqlite3_vtab_cursor 22328 FiRowid sqlite3_int64 22329 FpVtab uintptr 22330 FrLimit fuzzer_cost 22331 _ [4]byte 22332 FpStem uintptr 22333 FpDone uintptr 22334 FaQueue [20]uintptr 22335 FmxQueue int32 22336 _ [4]byte 22337 FzBuf uintptr 22338 FnBuf int32 22339 FnStem int32 22340 FiRuleset int32 22341 _ [4]byte 22342 FnullRule fuzzer_rule 22343 FapHash [4001]uintptr 22344 } /* fuzzer.c:163:9 */ 22345 22346 type fuzzer_cursor = fuzzer_cursor1 /* fuzzer.c:163:30 */ 22347 type fuzzer_rule1 = struct { 22348 FpNext uintptr 22349 FzFrom uintptr 22350 FrCost fuzzer_cost 22351 FnFrom fuzzer_len 22352 FnTo fuzzer_len 22353 _ [2]byte 22354 FiRuleset fuzzer_ruleid 22355 FzTo [4]int8 22356 } /* fuzzer.c:162:9 */ 22357 22358 type fuzzer_rule = fuzzer_rule1 /* fuzzer.c:164:28 */ 22359 type fuzzer_stem1 = struct { 22360 FzBasis uintptr 22361 FpRule uintptr 22362 FpNext uintptr 22363 FpHash uintptr 22364 FrBaseCost fuzzer_cost 22365 FrCostX fuzzer_cost 22366 FnBasis fuzzer_len 22367 Fn fuzzer_len 22368 _ [6]byte 22369 } /* fuzzer.c:163:9 */ 22370 22371 type fuzzer_stem = fuzzer_stem1 /* fuzzer.c:166:28 */ 22372 22373 // Various types. 22374 // 22375 // fuzzer_cost is the "cost" of an edit operation. 22376 // 22377 // fuzzer_len is the length of a matching string. 22378 // 22379 // fuzzer_ruleid is an ruleset identifier. 22380 type fuzzer_cost = int32 /* fuzzer.c:177:13 */ 22381 type fuzzer_len = int8 /* fuzzer.c:178:21 */ 22382 type fuzzer_ruleid = int32 /* fuzzer.c:179:13 */ 22383 22384 // The two input rule lists are both sorted in order of increasing 22385 // cost. Merge them together into a single list, sorted by cost, and 22386 // return a pointer to the head of that list. 22387 func fuzzerMergeRules(tls *libc.TLS, pA uintptr, pB uintptr) uintptr { /* fuzzer.c:261:20: */ 22388 bp := tls.Alloc(32) 22389 defer tls.Free(32) 22390 22391 // var head fuzzer_rule at bp, 32 22392 22393 var pTail uintptr 22394 22395 pTail = bp /* &head */ 22396 for (pA != 0) && (pB != 0) { 22397 if (*fuzzer_rule)(unsafe.Pointer(pA)).FrCost <= (*fuzzer_rule)(unsafe.Pointer(pB)).FrCost { 22398 (*fuzzer_rule)(unsafe.Pointer(pTail)).FpNext = pA 22399 pTail = pA 22400 pA = (*fuzzer_rule)(unsafe.Pointer(pA)).FpNext 22401 } else { 22402 (*fuzzer_rule)(unsafe.Pointer(pTail)).FpNext = pB 22403 pTail = pB 22404 pB = (*fuzzer_rule)(unsafe.Pointer(pB)).FpNext 22405 } 22406 } 22407 if pA == uintptr(0) { 22408 (*fuzzer_rule)(unsafe.Pointer(pTail)).FpNext = pB 22409 } else { 22410 (*fuzzer_rule)(unsafe.Pointer(pTail)).FpNext = pA 22411 } 22412 return (*fuzzer_rule)(unsafe.Pointer(bp /* &head */)).FpNext 22413 } 22414 22415 // Statement pStmt currently points to a row in the fuzzer data table. This 22416 // function allocates and populates a fuzzer_rule structure according to 22417 // the content of the row. 22418 // 22419 // If successful, *ppRule is set to point to the new object and SQLITE_OK 22420 // is returned. Otherwise, *ppRule is zeroed, *pzErr may be set to point 22421 // to an error message and an SQLite error code returned. 22422 func fuzzerLoadOneRule(tls *libc.TLS, p uintptr, pStmt uintptr, ppRule uintptr, pzErr uintptr) int32 { /* fuzzer.c:294:12: */ 22423 bp := tls.Alloc(48) 22424 defer tls.Free(48) 22425 22426 var iRuleset sqlite3_int64 = sqlite3.Xsqlite3_column_int64(tls, pStmt, 0) 22427 var zFrom uintptr = sqlite3.Xsqlite3_column_text(tls, pStmt, 1) 22428 var zTo uintptr = sqlite3.Xsqlite3_column_text(tls, pStmt, 2) 22429 var nCost int32 = sqlite3.Xsqlite3_column_int(tls, pStmt, 3) 22430 22431 var rc int32 = SQLITE_OK // Return code 22432 var nFrom int32 // Size of string zFrom, in bytes 22433 var nTo int32 // Size of string zTo, in bytes 22434 var pRule uintptr = uintptr(0) // New rule object to return 22435 22436 if zFrom == uintptr(0) { 22437 zFrom = ts + 489 /* "" */ 22438 } 22439 if zTo == uintptr(0) { 22440 zTo = ts + 489 /* "" */ 22441 } 22442 nFrom = int32(libc.Xstrlen(tls, zFrom)) 22443 nTo = int32(libc.Xstrlen(tls, zTo)) 22444 22445 // Silently ignore null transformations 22446 if libc.Xstrcmp(tls, zFrom, zTo) == 0 { 22447 *(*uintptr)(unsafe.Pointer(ppRule)) = uintptr(0) 22448 return SQLITE_OK 22449 } 22450 22451 if (nCost <= 0) || (nCost > FUZZER_MX_COST) { 22452 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3175, /* "%s: cost must be..." */ 22453 libc.VaList(bp, (*fuzzer_vtab)(unsafe.Pointer(p)).FzClassName, FUZZER_MX_COST)) 22454 rc = SQLITE_ERROR 22455 } else if (nFrom > FUZZER_MX_LENGTH) || (nTo > FUZZER_MX_LENGTH) { 22456 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3209, /* "%s: maximum stri..." */ 22457 libc.VaList(bp+16, (*fuzzer_vtab)(unsafe.Pointer(p)).FzClassName, FUZZER_MX_LENGTH)) 22458 rc = SQLITE_ERROR 22459 } else if (iRuleset < int64(0)) || (iRuleset > int64(FUZZER_MX_RULEID)) { 22460 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+5228, /* "%s: ruleset must..." */ 22461 libc.VaList(bp+32, (*fuzzer_vtab)(unsafe.Pointer(p)).FzClassName, FUZZER_MX_RULEID)) 22462 rc = SQLITE_ERROR 22463 } else { 22464 22465 pRule = sqlite3.Xsqlite3_malloc64(tls, (uint64((uint64(unsafe.Sizeof(fuzzer_rule{})) + uint64(nFrom)) + uint64(nTo)))) 22466 if pRule == uintptr(0) { 22467 rc = SQLITE_NOMEM 22468 } else { 22469 libc.Xmemset(tls, pRule, 0, uint64(unsafe.Sizeof(fuzzer_rule{}))) 22470 (*fuzzer_rule)(unsafe.Pointer(pRule)).FzFrom = pRule + 28 /* &.zTo */ 22471 *(*uintptr)(unsafe.Pointer(pRule + 8 /* &.zFrom */)) += (uintptr(nTo + 1)) 22472 (*fuzzer_rule)(unsafe.Pointer(pRule)).FnFrom = fuzzer_len(nFrom) 22473 libc.Xmemcpy(tls, (*fuzzer_rule)(unsafe.Pointer(pRule)).FzFrom, zFrom, (uint64(nFrom + 1))) 22474 libc.Xmemcpy(tls, pRule+28 /* &.zTo */, zTo, (uint64(nTo + 1))) 22475 (*fuzzer_rule)(unsafe.Pointer(pRule)).FnTo = fuzzer_len(nTo) 22476 (*fuzzer_rule)(unsafe.Pointer(pRule)).FrCost = nCost 22477 (*fuzzer_rule)(unsafe.Pointer(pRule)).FiRuleset = int32(iRuleset) 22478 } 22479 } 22480 22481 *(*uintptr)(unsafe.Pointer(ppRule)) = pRule 22482 return rc 22483 } 22484 22485 // Load the content of the fuzzer data table into memory. 22486 func fuzzerLoadRules(tls *libc.TLS, db uintptr, p uintptr, zDb uintptr, zData uintptr, pzErr uintptr) int32 { /* fuzzer.c:363:12: */ 22487 bp := tls.Alloc(192) 22488 defer tls.Free(192) 22489 22490 var rc int32 = SQLITE_OK // Return code 22491 var zSql uintptr // SELECT used to read from rules table 22492 var pHead uintptr = uintptr(0) 22493 22494 zSql = sqlite3.Xsqlite3_mprintf(tls, ts+3278 /* "SELECT * FROM %Q..." */, libc.VaList(bp, zDb, zData)) 22495 if zSql == uintptr(0) { 22496 rc = SQLITE_NOMEM 22497 } else { 22498 var rc2 int32 // finalize() return code 22499 *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)) = uintptr(0) 22500 rc = sqlite3.Xsqlite3_prepare_v2(tls, db, zSql, -1, bp+56 /* &pStmt */, uintptr(0)) 22501 if rc != SQLITE_OK { 22502 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3298 /* "%s: %s" */, libc.VaList(bp+16, (*fuzzer_vtab)(unsafe.Pointer(p)).FzClassName, sqlite3.Xsqlite3_errmsg(tls, db))) 22503 } else if sqlite3.Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) != 4 { 22504 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+3305, /* "%s: %s has %d co..." */ 22505 libc.VaList(bp+32, (*fuzzer_vtab)(unsafe.Pointer(p)).FzClassName, zData, sqlite3.Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))))) 22506 rc = SQLITE_ERROR 22507 } else { 22508 for (rc == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)))) { 22509 *(*uintptr)(unsafe.Pointer(bp + 64 /* pRule */)) = uintptr(0) 22510 rc = fuzzerLoadOneRule(tls, p, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)), bp+64 /* &pRule */, pzErr) 22511 if *(*uintptr)(unsafe.Pointer(bp + 64 /* pRule */)) != 0 { 22512 (*fuzzer_rule)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 64 /* pRule */)))).FpNext = pHead 22513 pHead = *(*uintptr)(unsafe.Pointer(bp + 64 /* pRule */)) 22514 } 22515 } 22516 } 22517 rc2 = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) 22518 if rc == SQLITE_OK { 22519 rc = rc2 22520 } 22521 } 22522 sqlite3.Xsqlite3_free(tls, zSql) 22523 22524 // All rules are now in a singly linked list starting at pHead. This 22525 // block sorts them by cost and then sets fuzzer_vtab.pRule to point to 22526 // point to the head of the sorted list. 22527 if rc == SQLITE_OK { 22528 var i uint32 22529 var pX uintptr 22530 // var a [15]uintptr at bp+72, 120 22531 22532 for i = uint32(0); uint64(i) < (uint64(unsafe.Sizeof([15]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0)))); i++ { 22533 *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)) = uintptr(0) 22534 } 22535 for (libc.AssignUintptr(&pX, pHead)) != uintptr(0) { 22536 pHead = (*fuzzer_rule)(unsafe.Pointer(pX)).FpNext 22537 (*fuzzer_rule)(unsafe.Pointer(pX)).FpNext = uintptr(0) 22538 for i = uint32(0); (*(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)) != 0) && (uint64(i) < ((uint64(unsafe.Sizeof([15]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0)))) - uint64(1))); i++ { 22539 pX = fuzzerMergeRules(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)), pX) 22540 *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)) = uintptr(0) 22541 } 22542 *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)) = fuzzerMergeRules(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)), pX) 22543 } 22544 pX = *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */)) 22545 i = uint32(1) 22546 for ; uint64(i) < (uint64(unsafe.Sizeof([15]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0)))); i++ { 22547 pX = fuzzerMergeRules(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* &a[0] */ + uintptr(i)*8)), pX) 22548 } 22549 (*fuzzer_vtab)(unsafe.Pointer(p)).FpRule = fuzzerMergeRules(tls, (*fuzzer_vtab)(unsafe.Pointer(p)).FpRule, pX) 22550 } else { 22551 // An error has occurred. Setting p->pRule to point to the head of the 22552 // allocated list ensures that the list will be cleaned up in this case. 22553 22554 (*fuzzer_vtab)(unsafe.Pointer(p)).FpRule = pHead 22555 } 22556 22557 return rc 22558 } 22559 22560 // This function converts an SQL quoted string into an unquoted string 22561 // and returns a pointer to a buffer allocated using sqlite3_malloc() 22562 // containing the result. The caller should eventually free this buffer 22563 // using sqlite3_free. 22564 // 22565 // Examples: 22566 // 22567 // "abc" becomes abc 22568 // 'xyz' becomes xyz 22569 // [pqr] becomes pqr 22570 // `mno` becomes mno 22571 func fuzzerDequote(tls *libc.TLS, zIn uintptr) uintptr { /* fuzzer.c:449:13: */ 22572 var nIn sqlite3_int64 // Size of input string, in bytes 22573 var zOut uintptr // Output (dequoted) string 22574 22575 nIn = sqlite3_int64(libc.Xstrlen(tls, zIn)) 22576 zOut = sqlite3.Xsqlite3_malloc64(tls, (uint64(nIn + int64(1)))) 22577 if zOut != 0 { 22578 var q int8 = *(*int8)(unsafe.Pointer(zIn)) // Quote character (if any ) 22579 22580 if (((int32(q) != '[') && (int32(q) != '\'')) && (int32(q) != '"')) && (int32(q) != '`') { 22581 libc.Xmemcpy(tls, zOut, zIn, (size_t(nIn + int64(1)))) 22582 } else { 22583 var iOut int32 = 0 // Index of next byte to write to output 22584 var iIn int32 // Index of next byte to read from input 22585 22586 if int32(q) == '[' { 22587 q = int8(']') 22588 } 22589 for iIn = 1; sqlite3_int64(iIn) < nIn; iIn++ { 22590 if int32(*(*int8)(unsafe.Pointer(zIn + uintptr(iIn)))) == int32(q) { 22591 iIn++ 22592 } 22593 *(*int8)(unsafe.Pointer(zOut + uintptr(libc.PostIncInt32(&iOut, 1)))) = *(*int8)(unsafe.Pointer(zIn + uintptr(iIn))) 22594 } 22595 } 22596 22597 } 22598 return zOut 22599 } 22600 22601 // xDisconnect/xDestroy method for the fuzzer module. 22602 func fuzzerDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* fuzzer.c:478:12: */ 22603 var p uintptr = pVtab 22604 22605 for (*fuzzer_vtab)(unsafe.Pointer(p)).FpRule != 0 { 22606 var pRule uintptr = (*fuzzer_vtab)(unsafe.Pointer(p)).FpRule 22607 (*fuzzer_vtab)(unsafe.Pointer(p)).FpRule = (*fuzzer_rule)(unsafe.Pointer(pRule)).FpNext 22608 sqlite3.Xsqlite3_free(tls, pRule) 22609 } 22610 sqlite3.Xsqlite3_free(tls, p) 22611 return SQLITE_OK 22612 } 22613 22614 // xConnect/xCreate method for the fuzzer module. Arguments are: 22615 // 22616 // argv[0] -> module name ("fuzzer") 22617 // argv[1] -> database name 22618 // argv[2] -> table name 22619 // argv[3] -> fuzzer rule table name 22620 func fuzzerConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* fuzzer.c:498:12: */ 22621 bp := tls.Alloc(8) 22622 defer tls.Free(8) 22623 22624 var rc int32 = SQLITE_OK // Return code 22625 var pNew uintptr = uintptr(0) // New virtual table 22626 var zModule uintptr = *(*uintptr)(unsafe.Pointer(argv)) 22627 var zDb uintptr = *(*uintptr)(unsafe.Pointer(argv + 1*8)) 22628 22629 if argc != 4 { 22630 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, 22631 ts+5265 /* "%s: wrong number..." */, libc.VaList(bp, zModule)) 22632 rc = SQLITE_ERROR 22633 } else { 22634 var nModule sqlite3_int64 // Length of zModule, in bytes 22635 22636 nModule = sqlite3_int64(libc.Xstrlen(tls, zModule)) 22637 pNew = sqlite3.Xsqlite3_malloc64(tls, ((uint64(unsafe.Sizeof(fuzzer_vtab{})) + uint64(nModule)) + uint64(1))) 22638 if pNew == uintptr(0) { 22639 rc = SQLITE_NOMEM 22640 } else { 22641 var zTab uintptr // Dequoted name of fuzzer data table 22642 22643 libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(fuzzer_vtab{}))) 22644 (*fuzzer_vtab)(unsafe.Pointer(pNew)).FzClassName = (pNew + 1*48) 22645 libc.Xmemcpy(tls, (*fuzzer_vtab)(unsafe.Pointer(pNew)).FzClassName, zModule, (size_t(nModule + int64(1)))) 22646 22647 zTab = fuzzerDequote(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) 22648 if zTab == uintptr(0) { 22649 rc = SQLITE_NOMEM 22650 } else { 22651 rc = fuzzerLoadRules(tls, db, pNew, zDb, zTab, pzErr) 22652 sqlite3.Xsqlite3_free(tls, zTab) 22653 } 22654 22655 if rc == SQLITE_OK { 22656 rc = sqlite3.Xsqlite3_declare_vtab(tls, db, ts+5316 /* "CREATE TABLE x(w..." */) 22657 } 22658 if rc != SQLITE_OK { 22659 fuzzerDisconnect(tls, pNew) 22660 pNew = uintptr(0) 22661 } else { 22662 sqlite3.Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_INNOCUOUS, 0) 22663 } 22664 } 22665 } 22666 22667 *(*uintptr)(unsafe.Pointer(ppVtab)) = pNew 22668 return rc 22669 } 22670 22671 // Open a new fuzzer cursor. 22672 func fuzzerOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* fuzzer.c:556:12: */ 22673 var p uintptr = pVTab 22674 var pCur uintptr 22675 pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(fuzzer_cursor{}))) 22676 if pCur == uintptr(0) { 22677 return SQLITE_NOMEM 22678 } 22679 libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(fuzzer_cursor{}))) 22680 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpVtab = p 22681 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) 22682 (*fuzzer_vtab)(unsafe.Pointer(p)).FnCursor++ 22683 return SQLITE_OK 22684 } 22685 22686 // Free all stems in a list. 22687 func fuzzerClearStemList(tls *libc.TLS, pStem uintptr) { /* fuzzer.c:571:13: */ 22688 for pStem != 0 { 22689 var pNext uintptr = (*fuzzer_stem)(unsafe.Pointer(pStem)).FpNext 22690 sqlite3.Xsqlite3_free(tls, pStem) 22691 pStem = pNext 22692 } 22693 } 22694 22695 // Free up all the memory allocated by a cursor. Set it rLimit to 0 22696 // to indicate that it is at EOF. 22697 func fuzzerClearCursor(tls *libc.TLS, pCur uintptr, clearHash int32) { /* fuzzer.c:583:13: */ 22698 var i int32 22699 fuzzerClearStemList(tls, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem) 22700 fuzzerClearStemList(tls, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpDone) 22701 for i = 0; i < FUZZER_NQUEUE; i++ { 22702 fuzzerClearStemList(tls, *(*uintptr)(unsafe.Pointer((pCur + 48 /* &.aQueue */) + uintptr(i)*8))) 22703 } 22704 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FrLimit = 0 22705 if (clearHash != 0) && ((*fuzzer_cursor)(unsafe.Pointer(pCur)).FnStem != 0) { 22706 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FmxQueue = 0 22707 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem = uintptr(0) 22708 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpDone = uintptr(0) 22709 libc.Xmemset(tls, pCur+48 /* &.aQueue */, 0, uint64(unsafe.Sizeof([20]uintptr{}))) 22710 libc.Xmemset(tls, pCur+272 /* &.apHash */, 0, uint64(unsafe.Sizeof([4001]uintptr{}))) 22711 } 22712 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FnStem = 0 22713 } 22714 22715 // Close a fuzzer cursor. 22716 func fuzzerClose(tls *libc.TLS, cur uintptr) int32 { /* fuzzer.c:602:12: */ 22717 var pCur uintptr = cur 22718 fuzzerClearCursor(tls, pCur, 0) 22719 sqlite3.Xsqlite3_free(tls, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FzBuf) 22720 (*fuzzer_vtab)(unsafe.Pointer((*fuzzer_cursor)(unsafe.Pointer(pCur)).FpVtab)).FnCursor-- 22721 sqlite3.Xsqlite3_free(tls, pCur) 22722 return SQLITE_OK 22723 } 22724 22725 // Compute the current output term for a fuzzer_stem. 22726 func fuzzerRender(tls *libc.TLS, pStem uintptr, pzBuf uintptr, pnBuf uintptr) int32 { /* fuzzer.c:614:12: */ 22727 var pRule uintptr = (*fuzzer_stem)(unsafe.Pointer(pStem)).FpRule 22728 var n int32 // Size of output term without nul-term 22729 var z uintptr // Buffer to assemble output term in 22730 22731 n = ((int32((*fuzzer_stem)(unsafe.Pointer(pStem)).FnBasis) + int32((*fuzzer_rule)(unsafe.Pointer(pRule)).FnTo)) - int32((*fuzzer_rule)(unsafe.Pointer(pRule)).FnFrom)) 22732 if (*(*int32)(unsafe.Pointer(pnBuf))) < (n + 1) { 22733 (*(*uintptr)(unsafe.Pointer(pzBuf))) = sqlite3.Xsqlite3_realloc(tls, *(*uintptr)(unsafe.Pointer(pzBuf)), (n + 100)) 22734 if (*(*uintptr)(unsafe.Pointer(pzBuf))) == uintptr(0) { 22735 return SQLITE_NOMEM 22736 } 22737 (*(*int32)(unsafe.Pointer(pnBuf))) = (n + 100) 22738 } 22739 n = int32((*fuzzer_stem)(unsafe.Pointer(pStem)).Fn) 22740 z = *(*uintptr)(unsafe.Pointer(pzBuf)) 22741 if n < 0 { 22742 libc.Xmemcpy(tls, z, (*fuzzer_stem)(unsafe.Pointer(pStem)).FzBasis, (uint64(int32((*fuzzer_stem)(unsafe.Pointer(pStem)).FnBasis) + 1))) 22743 } else { 22744 libc.Xmemcpy(tls, z, (*fuzzer_stem)(unsafe.Pointer(pStem)).FzBasis, uint64(n)) 22745 libc.Xmemcpy(tls, (z + uintptr(n)), pRule+28 /* &.zTo */, uint64((*fuzzer_rule)(unsafe.Pointer(pRule)).FnTo)) 22746 libc.Xmemcpy(tls, (z + uintptr((n + int32((*fuzzer_rule)(unsafe.Pointer(pRule)).FnTo)))), ((*fuzzer_stem)(unsafe.Pointer(pStem)).FzBasis + uintptr((n + int32((*fuzzer_rule)(unsafe.Pointer(pRule)).FnFrom)))), 22747 (uint64(((int32((*fuzzer_stem)(unsafe.Pointer(pStem)).FnBasis) - n) - int32((*fuzzer_rule)(unsafe.Pointer(pRule)).FnFrom)) + 1))) 22748 } 22749 22750 return SQLITE_OK 22751 } 22752 22753 // Compute a hash on zBasis. 22754 func fuzzerHash(tls *libc.TLS, z uintptr) uint32 { /* fuzzer.c:647:21: */ 22755 var h uint32 = uint32(0) 22756 for *(*int8)(unsafe.Pointer(z)) != 0 { 22757 h = (((h << 3) ^ (h >> 29)) ^ uint32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))))) 22758 } 22759 return (h % uint32(FUZZER_HASH)) 22760 } 22761 22762 // Current cost of a stem 22763 func fuzzerCost(tls *libc.TLS, pStem uintptr) fuzzer_cost { /* fuzzer.c:656:20: */ 22764 return libc.AssignPtrInt32(pStem+36 /* &.rCostX */, ((*fuzzer_stem)(unsafe.Pointer(pStem)).FrBaseCost + (*fuzzer_rule)(unsafe.Pointer((*fuzzer_stem)(unsafe.Pointer(pStem)).FpRule)).FrCost)) 22765 } 22766 22767 // Return 1 if the string to which the cursor is point has already 22768 // been emitted. Return 0 if not. Return -1 on a memory allocation 22769 // failures. 22770 func fuzzerSeen(tls *libc.TLS, pCur uintptr, pStem uintptr) int32 { /* fuzzer.c:694:12: */ 22771 var h uint32 22772 var pLookup uintptr 22773 22774 if fuzzerRender(tls, pStem, (pCur+216 /* &.zBuf */), (pCur+224 /* &.nBuf */)) == SQLITE_NOMEM { 22775 return -1 22776 } 22777 h = fuzzerHash(tls, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FzBuf) 22778 pLookup = *(*uintptr)(unsafe.Pointer((pCur + 272 /* &.apHash */) + uintptr(h)*8)) 22779 for (pLookup != 0) && (libc.Xstrcmp(tls, (*fuzzer_stem)(unsafe.Pointer(pLookup)).FzBasis, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FzBuf) != 0) { 22780 pLookup = (*fuzzer_stem)(unsafe.Pointer(pLookup)).FpHash 22781 } 22782 return (libc.Bool32(pLookup != uintptr(0))) 22783 } 22784 22785 // If argument pRule is NULL, this function returns false. 22786 // 22787 // Otherwise, it returns true if rule pRule should be skipped. A rule 22788 // should be skipped if it does not belong to rule-set iRuleset, or if 22789 // applying it to stem pStem would create a string longer than 22790 // FUZZER_MX_OUTPUT_LENGTH bytes. 22791 func fuzzerSkipRule(tls *libc.TLS, pRule uintptr, pStem uintptr, iRuleset int32) int32 { /* fuzzer.c:717:12: */ 22792 return (libc.Bool32((pRule != 0) && (((*fuzzer_rule)(unsafe.Pointer(pRule)).FiRuleset != iRuleset) || 22793 (((int32((*fuzzer_stem)(unsafe.Pointer(pStem)).FnBasis) + int32((*fuzzer_rule)(unsafe.Pointer(pRule)).FnTo)) - int32((*fuzzer_rule)(unsafe.Pointer(pRule)).FnFrom)) > FUZZER_MX_OUTPUT_LENGTH)))) 22794 } 22795 22796 // Advance a fuzzer_stem to its next value. Return 0 if there are 22797 // no more values that can be generated by this fuzzer_stem. Return 22798 // -1 on a memory allocation failure. 22799 func fuzzerAdvance(tls *libc.TLS, pCur uintptr, pStem uintptr) int32 { /* fuzzer.c:733:12: */ 22800 var pRule uintptr 22801 for (libc.AssignUintptr(&pRule, (*fuzzer_stem)(unsafe.Pointer(pStem)).FpRule)) != uintptr(0) { 22802 22803 for int32((*fuzzer_stem)(unsafe.Pointer(pStem)).Fn) < (int32((*fuzzer_stem)(unsafe.Pointer(pStem)).FnBasis) - int32((*fuzzer_rule)(unsafe.Pointer(pRule)).FnFrom)) { 22804 (*fuzzer_stem)(unsafe.Pointer(pStem)).Fn++ 22805 if (int32((*fuzzer_rule)(unsafe.Pointer(pRule)).FnFrom) == 0) || 22806 (libc.Xmemcmp(tls, ((*fuzzer_stem)(unsafe.Pointer(pStem)).FzBasis+uintptr((*fuzzer_stem)(unsafe.Pointer(pStem)).Fn)), (*fuzzer_rule)(unsafe.Pointer(pRule)).FzFrom, uint64((*fuzzer_rule)(unsafe.Pointer(pRule)).FnFrom)) == 0) { 22807 // Found a rewrite case. Make sure it is not a duplicate 22808 var rc int32 = fuzzerSeen(tls, pCur, pStem) 22809 if rc < 0 { 22810 return -1 22811 } 22812 if rc == 0 { 22813 fuzzerCost(tls, pStem) 22814 return 1 22815 } 22816 } 22817 } 22818 (*fuzzer_stem)(unsafe.Pointer(pStem)).Fn = int8(-1) 22819 for ok := true; ok; ok = fuzzerSkipRule(tls, pRule, pStem, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FiRuleset) != 0 { 22820 pRule = (*fuzzer_rule)(unsafe.Pointer(pRule)).FpNext 22821 } 22822 (*fuzzer_stem)(unsafe.Pointer(pStem)).FpRule = pRule 22823 if (pRule != 0) && (fuzzerCost(tls, pStem) > (*fuzzer_cursor)(unsafe.Pointer(pCur)).FrLimit) { 22824 (*fuzzer_stem)(unsafe.Pointer(pStem)).FpRule = uintptr(0) 22825 } 22826 } 22827 return 0 22828 } 22829 22830 // The two input stem lists are both sorted in order of increasing 22831 // rCostX. Merge them together into a single list, sorted by rCostX, and 22832 // return a pointer to the head of that new list. 22833 func fuzzerMergeStems(tls *libc.TLS, pA uintptr, pB uintptr) uintptr { /* fuzzer.c:766:20: */ 22834 bp := tls.Alloc(48) 22835 defer tls.Free(48) 22836 22837 // var head fuzzer_stem at bp, 48 22838 22839 var pTail uintptr 22840 22841 pTail = bp /* &head */ 22842 for (pA != 0) && (pB != 0) { 22843 if (*fuzzer_stem)(unsafe.Pointer(pA)).FrCostX <= (*fuzzer_stem)(unsafe.Pointer(pB)).FrCostX { 22844 (*fuzzer_stem)(unsafe.Pointer(pTail)).FpNext = pA 22845 pTail = pA 22846 pA = (*fuzzer_stem)(unsafe.Pointer(pA)).FpNext 22847 } else { 22848 (*fuzzer_stem)(unsafe.Pointer(pTail)).FpNext = pB 22849 pTail = pB 22850 pB = (*fuzzer_stem)(unsafe.Pointer(pB)).FpNext 22851 } 22852 } 22853 if pA == uintptr(0) { 22854 (*fuzzer_stem)(unsafe.Pointer(pTail)).FpNext = pB 22855 } else { 22856 (*fuzzer_stem)(unsafe.Pointer(pTail)).FpNext = pA 22857 } 22858 return (*fuzzer_stem)(unsafe.Pointer(bp /* &head */)).FpNext 22859 } 22860 22861 // Load pCur->pStem with the lowest-cost stem. Return a pointer 22862 // to the lowest-cost stem. 22863 func fuzzerLowestCostStem(tls *libc.TLS, pCur uintptr) uintptr { /* fuzzer.c:794:20: */ 22864 var pBest uintptr 22865 var pX uintptr 22866 var iBest int32 22867 var i int32 22868 22869 if (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem == uintptr(0) { 22870 iBest = -1 22871 pBest = uintptr(0) 22872 for i = 0; i <= (*fuzzer_cursor)(unsafe.Pointer(pCur)).FmxQueue; i++ { 22873 pX = *(*uintptr)(unsafe.Pointer((pCur + 48 /* &.aQueue */) + uintptr(i)*8)) 22874 if pX == uintptr(0) { 22875 continue 22876 } 22877 if (pBest == uintptr(0)) || ((*fuzzer_stem)(unsafe.Pointer(pBest)).FrCostX > (*fuzzer_stem)(unsafe.Pointer(pX)).FrCostX) { 22878 pBest = pX 22879 iBest = i 22880 } 22881 } 22882 if pBest != 0 { 22883 *(*uintptr)(unsafe.Pointer((pCur + 48 /* &.aQueue */) + uintptr(iBest)*8)) = (*fuzzer_stem)(unsafe.Pointer(pBest)).FpNext 22884 (*fuzzer_stem)(unsafe.Pointer(pBest)).FpNext = uintptr(0) 22885 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem = pBest 22886 } 22887 } 22888 return (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem 22889 } 22890 22891 // Insert pNew into queue of pending stems. Then find the stem 22892 // with the lowest rCostX and move it into pCur->pStem. 22893 // list. The insert is done such the pNew is in the correct order 22894 // according to fuzzer_stem.zBaseCost+fuzzer_stem.pRule->rCost. 22895 func fuzzerInsert(tls *libc.TLS, pCur uintptr, pNew uintptr) uintptr { /* fuzzer.c:825:20: */ 22896 var pX uintptr 22897 var i int32 22898 22899 // If pCur->pStem exists and is greater than pNew, then make pNew 22900 // the new pCur->pStem and insert the old pCur->pStem instead. 22901 if ((libc.AssignUintptr(&pX, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem)) != uintptr(0)) && ((*fuzzer_stem)(unsafe.Pointer(pX)).FrCostX > (*fuzzer_stem)(unsafe.Pointer(pNew)).FrCostX) { 22902 (*fuzzer_stem)(unsafe.Pointer(pNew)).FpNext = uintptr(0) 22903 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem = pNew 22904 pNew = pX 22905 } 22906 22907 // Insert the new value 22908 (*fuzzer_stem)(unsafe.Pointer(pNew)).FpNext = uintptr(0) 22909 pX = pNew 22910 for i = 0; i <= (*fuzzer_cursor)(unsafe.Pointer(pCur)).FmxQueue; i++ { 22911 if *(*uintptr)(unsafe.Pointer((pCur + 48 /* &.aQueue */) + uintptr(i)*8)) != 0 { 22912 pX = fuzzerMergeStems(tls, pX, *(*uintptr)(unsafe.Pointer((pCur + 48 /* &.aQueue */) + uintptr(i)*8))) 22913 *(*uintptr)(unsafe.Pointer((pCur + 48 /* &.aQueue */) + uintptr(i)*8)) = uintptr(0) 22914 } else { 22915 *(*uintptr)(unsafe.Pointer((pCur + 48 /* &.aQueue */) + uintptr(i)*8)) = pX 22916 break 22917 } 22918 } 22919 if i > (*fuzzer_cursor)(unsafe.Pointer(pCur)).FmxQueue { 22920 if i < FUZZER_NQUEUE { 22921 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FmxQueue = i 22922 *(*uintptr)(unsafe.Pointer((pCur + 48 /* &.aQueue */) + uintptr(i)*8)) = pX 22923 } else { 22924 22925 pX = fuzzerMergeStems(tls, pX, *(*uintptr)(unsafe.Pointer((pCur + 48 /* &.aQueue */) + 19*8))) 22926 *(*uintptr)(unsafe.Pointer((pCur + 48 /* &.aQueue */) + 19*8)) = pX 22927 } 22928 } 22929 22930 return fuzzerLowestCostStem(tls, pCur) 22931 } 22932 22933 // Allocate a new fuzzer_stem. Add it to the hash table but do not 22934 // link it into either the pCur->pStem or pCur->pDone lists. 22935 func fuzzerNewStem(tls *libc.TLS, pCur uintptr, zWord uintptr, rBaseCost fuzzer_cost) uintptr { /* fuzzer.c:868:20: */ 22936 var pNew uintptr 22937 var pRule uintptr 22938 var h uint32 22939 22940 pNew = sqlite3.Xsqlite3_malloc64(tls, (uint64((uint64(unsafe.Sizeof(fuzzer_stem{})) + libc.Xstrlen(tls, zWord)) + uint64(1)))) 22941 if pNew == uintptr(0) { 22942 return uintptr(0) 22943 } 22944 libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(fuzzer_stem{}))) 22945 (*fuzzer_stem)(unsafe.Pointer(pNew)).FzBasis = (pNew + 1*48) 22946 (*fuzzer_stem)(unsafe.Pointer(pNew)).FnBasis = fuzzer_len(libc.Xstrlen(tls, zWord)) 22947 libc.Xmemcpy(tls, (*fuzzer_stem)(unsafe.Pointer(pNew)).FzBasis, zWord, (uint64(int32((*fuzzer_stem)(unsafe.Pointer(pNew)).FnBasis) + 1))) 22948 pRule = (*fuzzer_vtab)(unsafe.Pointer((*fuzzer_cursor)(unsafe.Pointer(pCur)).FpVtab)).FpRule 22949 for fuzzerSkipRule(tls, pRule, pNew, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FiRuleset) != 0 { 22950 pRule = (*fuzzer_rule)(unsafe.Pointer(pRule)).FpNext 22951 } 22952 (*fuzzer_stem)(unsafe.Pointer(pNew)).FpRule = pRule 22953 (*fuzzer_stem)(unsafe.Pointer(pNew)).Fn = int8(-1) 22954 (*fuzzer_stem)(unsafe.Pointer(pNew)).FrBaseCost = libc.AssignPtrInt32(pNew+36 /* &.rCostX */, rBaseCost) 22955 h = fuzzerHash(tls, (*fuzzer_stem)(unsafe.Pointer(pNew)).FzBasis) 22956 (*fuzzer_stem)(unsafe.Pointer(pNew)).FpHash = *(*uintptr)(unsafe.Pointer((pCur + 272 /* &.apHash */) + uintptr(h)*8)) 22957 *(*uintptr)(unsafe.Pointer((pCur + 272 /* &.apHash */) + uintptr(h)*8)) = pNew 22958 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FnStem++ 22959 return pNew 22960 } 22961 22962 // Advance a cursor to its next row of output 22963 func fuzzerNext(tls *libc.TLS, cur uintptr) int32 { /* fuzzer.c:901:12: */ 22964 var pCur uintptr = cur 22965 var rc int32 22966 var pStem uintptr 22967 var pNew uintptr 22968 22969 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FiRowid++ 22970 22971 // Use the element the cursor is currently point to to create 22972 // a new stem and insert the new stem into the priority queue. 22973 pStem = (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem 22974 if (*fuzzer_stem)(unsafe.Pointer(pStem)).FrCostX > 0 { 22975 rc = fuzzerRender(tls, pStem, (pCur + 216 /* &.zBuf */), (pCur + 224 /* &.nBuf */)) 22976 if rc == SQLITE_NOMEM { 22977 return SQLITE_NOMEM 22978 } 22979 pNew = fuzzerNewStem(tls, pCur, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FzBuf, (*fuzzer_stem)(unsafe.Pointer(pStem)).FrCostX) 22980 if pNew != 0 { 22981 if fuzzerAdvance(tls, pCur, pNew) == 0 { 22982 (*fuzzer_stem)(unsafe.Pointer(pNew)).FpNext = (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpDone 22983 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpDone = pNew 22984 } else { 22985 if fuzzerInsert(tls, pCur, pNew) == pNew { 22986 return SQLITE_OK 22987 } 22988 } 22989 } else { 22990 return SQLITE_NOMEM 22991 } 22992 } 22993 22994 // Adjust the priority queue so that the first element of the 22995 // stem list is the next lowest cost word. 22996 for (libc.AssignUintptr(&pStem, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem)) != uintptr(0) { 22997 var res int32 = fuzzerAdvance(tls, pCur, pStem) 22998 if res < 0 { 22999 return SQLITE_NOMEM 23000 } else if res > 0 { 23001 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem = uintptr(0) 23002 pStem = fuzzerInsert(tls, pCur, pStem) 23003 if (libc.AssignInt32(&rc, fuzzerSeen(tls, pCur, pStem))) != 0 { 23004 if rc < 0 { 23005 return SQLITE_NOMEM 23006 } 23007 continue 23008 } 23009 return SQLITE_OK // New word found 23010 } 23011 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem = uintptr(0) 23012 (*fuzzer_stem)(unsafe.Pointer(pStem)).FpNext = (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpDone 23013 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpDone = pStem 23014 if fuzzerLowestCostStem(tls, pCur) != 0 { 23015 rc = fuzzerSeen(tls, pCur, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem) 23016 if rc < 0 { 23017 return SQLITE_NOMEM 23018 } 23019 if rc == 0 { 23020 return SQLITE_OK 23021 } 23022 } 23023 } 23024 23025 // Reach this point only if queue has been exhausted and there is 23026 // nothing left to be output. 23027 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FrLimit = 0 23028 return SQLITE_OK 23029 } 23030 23031 // Called to "rewind" a cursor back to the beginning so that 23032 // it starts its output over again. Always called at least once 23033 // prior to any fuzzerColumn, fuzzerRowid, or fuzzerEof call. 23034 func fuzzerFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* fuzzer.c:969:12: */ 23035 var pCur uintptr = pVtabCursor 23036 var zWord uintptr = ts + 489 /* "" */ 23037 var pStem uintptr 23038 var idx int32 23039 23040 fuzzerClearCursor(tls, pCur, 1) 23041 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FrLimit = 2147483647 23042 idx = 0 23043 if (idxNum & 1) != 0 { 23044 zWord = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 23045 idx++ 23046 } 23047 if (idxNum & 2) != 0 { 23048 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FrLimit = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(idx)*8))) 23049 idx++ 23050 } 23051 if (idxNum & 4) != 0 { 23052 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FiRuleset = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(idx)*8))) 23053 idx++ 23054 } 23055 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FnullRule.FpNext = (*fuzzer_vtab)(unsafe.Pointer((*fuzzer_cursor)(unsafe.Pointer(pCur)).FpVtab)).FpRule 23056 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FnullRule.FrCost = 0 23057 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FnullRule.FnFrom = int8(0) 23058 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FnullRule.FnTo = int8(0) 23059 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FnullRule.FzFrom = ts + 489 /* "" */ 23060 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FiRowid = int64(1) 23061 23062 // If the query term is longer than FUZZER_MX_OUTPUT_LENGTH bytes, this 23063 // query will return zero rows. 23064 if int32(libc.Xstrlen(tls, zWord)) < FUZZER_MX_OUTPUT_LENGTH { 23065 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem = libc.AssignUintptr(&pStem, fuzzerNewStem(tls, pCur, zWord, 0)) 23066 if pStem == uintptr(0) { 23067 return SQLITE_NOMEM 23068 } 23069 (*fuzzer_stem)(unsafe.Pointer(pStem)).FpRule = (pCur + 240 /* &.nullRule */) 23070 (*fuzzer_stem)(unsafe.Pointer(pStem)).Fn = (*fuzzer_stem)(unsafe.Pointer(pStem)).FnBasis 23071 } else { 23072 (*fuzzer_cursor)(unsafe.Pointer(pCur)).FrLimit = 0 23073 } 23074 23075 return SQLITE_OK 23076 } 23077 23078 // Only the word and distance columns have values. All other columns 23079 // return NULL 23080 func fuzzerColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* fuzzer.c:1020:12: */ 23081 var pCur uintptr = cur 23082 if i == 0 { 23083 // the "word" column 23084 if fuzzerRender(tls, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem, (pCur+216 /* &.zBuf */), (pCur+224 /* &.nBuf */)) == SQLITE_NOMEM { 23085 return SQLITE_NOMEM 23086 } 23087 sqlite3.Xsqlite3_result_text(tls, ctx, (*fuzzer_cursor)(unsafe.Pointer(pCur)).FzBuf, -1, libc.UintptrFromInt32(-1)) 23088 } else if i == 1 { 23089 // the "distance" column 23090 sqlite3.Xsqlite3_result_int(tls, ctx, (*fuzzer_stem)(unsafe.Pointer((*fuzzer_cursor)(unsafe.Pointer(pCur)).FpStem)).FrCostX) 23091 } else { 23092 // All other columns are NULL 23093 sqlite3.Xsqlite3_result_null(tls, ctx) 23094 } 23095 return SQLITE_OK 23096 } 23097 23098 // The rowid. 23099 func fuzzerRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* fuzzer.c:1041:12: */ 23100 var pCur uintptr = cur 23101 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*fuzzer_cursor)(unsafe.Pointer(pCur)).FiRowid 23102 return SQLITE_OK 23103 } 23104 23105 // When the fuzzer_cursor.rLimit value is 0 or less, that is a signal 23106 // that the cursor has nothing more to output. 23107 func fuzzerEof(tls *libc.TLS, cur uintptr) int32 { /* fuzzer.c:1051:12: */ 23108 var pCur uintptr = cur 23109 return (libc.Bool32((*fuzzer_cursor)(unsafe.Pointer(pCur)).FrLimit <= 0)) 23110 } 23111 23112 // Search for terms of these forms: 23113 // 23114 // (A) word MATCH $str 23115 // (B1) distance < $value 23116 // (B2) distance <= $value 23117 // (C) ruleid == $ruleid 23118 // 23119 // The distance< and distance<= are both treated as distance<=. 23120 // The query plan number is a bit vector: 23121 // 23122 // bit 1: Term of the form (A) found 23123 // bit 2: Term like (B1) or (B2) found 23124 // bit 3: Term like (C) found 23125 // 23126 // If bit-1 is set, $str is always in filter.argv[0]. If bit-2 is set 23127 // then $value is in filter.argv[0] if bit-1 is clear and is in 23128 // filter.argv[1] if bit-1 is set. If bit-3 is set, then $ruleid is 23129 // in filter.argv[0] if bit-1 and bit-2 are both zero, is in 23130 // filter.argv[1] if exactly one of bit-1 and bit-2 are set, and is in 23131 // filter.argv[2] if both bit-1 and bit-2 are set. 23132 func fuzzerBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* fuzzer.c:1078:12: */ 23133 var iPlan int32 = 0 23134 var iDistTerm int32 = -1 23135 var iRulesetTerm int32 = -1 23136 var i int32 23137 var seenMatch int32 = 0 23138 var pConstraint uintptr 23139 var rCost float64 = 1e12 23140 23141 pConstraint = (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint 23142 i = 0 23143 __1: 23144 if !(i < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { 23145 goto __3 23146 } 23147 { 23148 if ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 0) && 23149 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH) { 23150 seenMatch = 1 23151 } 23152 if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 { 23153 goto __2 23154 } 23155 if (((iPlan & 1) == 0) && 23156 ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 0)) && 23157 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH) { 23158 iPlan = iPlan | (1) 23159 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 1 23160 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) 23161 rCost = rCost / (1e6) 23162 } 23163 if (((iPlan & 2) == 0) && 23164 ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 1)) && 23165 ((int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LT) || 23166 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LE)) { 23167 iPlan = iPlan | (2) 23168 iDistTerm = i 23169 rCost = rCost / (10.0) 23170 } 23171 if (((iPlan & 4) == 0) && 23172 ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == 2)) && 23173 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { 23174 iPlan = iPlan | (4) 23175 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) 23176 iRulesetTerm = i 23177 rCost = rCost / (10.0) 23178 } 23179 23180 } 23181 goto __2 23182 __2: 23183 i++ 23184 pConstraint += 12 23185 goto __1 23186 goto __3 23187 __3: 23188 ; 23189 if (iPlan & 2) != 0 { 23190 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iDistTerm)*8)).FargvIndex = (1 + (libc.Bool32((iPlan & 1) != 0))) 23191 } 23192 if (iPlan & 4) != 0 { 23193 var idx int32 = 1 23194 if (iPlan & 1) != 0 { 23195 idx++ 23196 } 23197 if (iPlan & 2) != 0 { 23198 idx++ 23199 } 23200 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iRulesetTerm)*8)).FargvIndex = idx 23201 } 23202 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = iPlan 23203 if (((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy == 1) && 23204 ((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).FiColumn == 1)) && 23205 (int32((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).Fdesc) == 0) { 23206 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 1 23207 } 23208 if (seenMatch != 0) && ((iPlan & 1) == 0) { 23209 rCost = 1e99 23210 } 23211 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = rCost 23212 23213 return SQLITE_OK 23214 } 23215 23216 // A virtual table module that implements the "fuzzer". 23217 var fuzzerModule = sqlite3_module{ // iVersion 23218 FxCreate: 0, 23219 FxConnect: 0, 23220 FxBestIndex: 0, 23221 FxDisconnect: 0, 23222 FxDestroy: 0, 23223 FxOpen: 0, // xOpen - open a cursor 23224 FxClose: 0, // xClose - close a cursor 23225 FxFilter: 0, // xFilter - configure scan constraints 23226 FxNext: 0, // xNext - advance a cursor 23227 FxEof: 0, // xEof - check for end of scan 23228 FxColumn: 0, // xColumn - read data 23229 FxRowid: 0, // xRename 23230 } /* fuzzer.c:1147:23 */ 23231 23232 func sqlite3_fuzzer_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* fuzzer.c:1176:5: */ 23233 var rc int32 = SQLITE_OK 23234 _ = pApi 23235 23236 rc = sqlite3.Xsqlite3_create_module(tls, db, ts+5354 /* "fuzzer" */, uintptr(unsafe.Pointer(&fuzzerModule)), uintptr(0)) 23237 return rc 23238 } 23239 23240 // Mark a function parameter as unused, to suppress nuisance compiler 23241 // warnings. 23242 23243 // Implementation of the ieee754() function 23244 func ieee754func(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* ieee754.c:102:13: */ 23245 bp := tls.Alloc(160) 23246 defer tls.Free(160) 23247 23248 if argc == 1 { 23249 var m sqlite3_int64 23250 // var a sqlite3_int64 at bp+32, 8 23251 23252 // var r float64 at bp+16, 8 23253 23254 var e int32 23255 var isNeg int32 23256 // var zResult [100]int8 at bp+40, 100 23257 23258 if (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_BLOB) && 23259 (uint64(sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))) == uint64(unsafe.Sizeof(float64(0)))) { 23260 var x uintptr = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) 23261 var i uint32 23262 *(*sqlite3_uint64)(unsafe.Pointer(bp + 24 /* v */)) = uint64(0) 23263 for i = uint32(0); uint64(i) < uint64(unsafe.Sizeof(float64(0))); i++ { 23264 *(*sqlite3_uint64)(unsafe.Pointer(bp + 24 /* v */)) = ((*(*sqlite3_uint64)(unsafe.Pointer(bp + 24 /* v */)) << 8) | sqlite3_uint64(*(*uint8)(unsafe.Pointer(x + uintptr(i))))) 23265 } 23266 libc.Xmemcpy(tls, bp+16 /* &r */, bp+24 /* &v */, uint64(unsafe.Sizeof(float64(0)))) 23267 } else { 23268 *(*float64)(unsafe.Pointer(bp + 16 /* r */)) = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) 23269 } 23270 if *(*float64)(unsafe.Pointer(bp + 16 /* r */)) < 0.0 { 23271 isNeg = 1 23272 *(*float64)(unsafe.Pointer(bp + 16 /* r */)) = -*(*float64)(unsafe.Pointer(bp + 16 /* r */)) 23273 } else { 23274 isNeg = 0 23275 } 23276 libc.Xmemcpy(tls, bp+32 /* &a */, bp+16 /* &r */, uint64(unsafe.Sizeof(sqlite3_int64(0)))) 23277 if *(*sqlite3_int64)(unsafe.Pointer(bp + 32 /* a */)) == int64(0) { 23278 e = 0 23279 m = int64(0) 23280 } else { 23281 e = (int32(*(*sqlite3_int64)(unsafe.Pointer(bp + 32 /* a */)) >> 52)) 23282 m = (*(*sqlite3_int64)(unsafe.Pointer(bp + 32 /* a */)) & ((sqlite3_int64((int64(1))) << 52) - int64(1))) 23283 if e == 0 { 23284 m <<= 1 23285 } else { 23286 m = m | (sqlite3_int64((int64(1))) << 52) 23287 } 23288 for ((e < 1075) && (m > int64(0))) && ((m & int64(1)) == int64(0)) { 23289 m >>= 1 23290 e++ 23291 } 23292 if isNeg != 0 { 23293 m = -m 23294 } 23295 } 23296 switch *(*int32)(unsafe.Pointer(sqlite3.Xsqlite3_user_data(tls, context))) { 23297 case 0: 23298 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+40 /* &zResult[0] */, ts+5361, /* "ieee754(%lld,%d)" */ 23299 libc.VaList(bp, m, (e-1075))) 23300 sqlite3.Xsqlite3_result_text(tls, context, bp+40 /* &zResult[0] */, -1, libc.UintptrFromInt32(-1)) 23301 break 23302 fallthrough 23303 case 1: 23304 sqlite3.Xsqlite3_result_int64(tls, context, m) 23305 break 23306 fallthrough 23307 case 2: 23308 sqlite3.Xsqlite3_result_int(tls, context, (e - 1075)) 23309 break 23310 } 23311 } else { 23312 var m sqlite3_int64 23313 var e sqlite3_int64 23314 // var a sqlite3_int64 at bp+152, 8 23315 23316 // var r float64 at bp+144, 8 23317 23318 var isNeg int32 = 0 23319 m = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) 23320 e = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 23321 23322 // Limit the range of e. Ticket 22dea1cfdb9151e4 2021-03-02 23323 if e > int64(10000) { 23324 e = int64(10000) 23325 } else if e < int64(-10000) { 23326 e = int64(-10000) 23327 } 23328 23329 if m < int64(0) { 23330 isNeg = 1 23331 m = -m 23332 if m < int64(0) { 23333 return 23334 } 23335 } else if ((m == int64(0)) && (e > int64(-1000))) && (e < int64(1000)) { 23336 sqlite3.Xsqlite3_result_double(tls, context, 0.0) 23337 return 23338 } 23339 for ((m >> 32) & int64(0xffe00000)) != 0 { 23340 m >>= 1 23341 e++ 23342 } 23343 for (m != int64(0)) && (((m >> 32) & int64(0xfff00000)) == int64(0)) { 23344 m <<= 1 23345 e-- 23346 } 23347 e = e + (int64(1075)) 23348 if e <= int64(0) { 23349 // Subnormal 23350 m >>= (int64(1) - e) 23351 e = int64(0) 23352 } else if e > int64(0x7ff) { 23353 e = int64(0x7ff) 23354 } 23355 *(*sqlite3_int64)(unsafe.Pointer(bp + 152 /* a */)) = (m & ((sqlite3_int64((int64(1))) << 52) - int64(1))) 23356 *(*sqlite3_int64)(unsafe.Pointer(bp + 152 /* a */)) |= (e << 52) 23357 if isNeg != 0 { 23358 *(*sqlite3_int64)(unsafe.Pointer(bp + 152 /* a */)) |= libc.Int64FromUint64((sqlite3_uint64((uint64(1))) << 63)) 23359 } 23360 libc.Xmemcpy(tls, bp+144 /* &r */, bp+152 /* &a */, uint64(unsafe.Sizeof(float64(0)))) 23361 sqlite3.Xsqlite3_result_double(tls, context, *(*float64)(unsafe.Pointer(bp + 144 /* r */))) 23362 } 23363 } 23364 23365 // Functions to convert between blobs and floats. 23366 func ieee754func_from_blob(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* ieee754.c:213:13: */ 23367 bp := tls.Alloc(16) 23368 defer tls.Free(16) 23369 23370 _ = argc 23371 if (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_BLOB) && 23372 (uint64(sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))) == uint64(unsafe.Sizeof(float64(0)))) { 23373 // var r float64 at bp, 8 23374 23375 var x uintptr = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) 23376 var i uint32 23377 *(*sqlite3_uint64)(unsafe.Pointer(bp + 8 /* v */)) = uint64(0) 23378 for i = uint32(0); uint64(i) < uint64(unsafe.Sizeof(float64(0))); i++ { 23379 *(*sqlite3_uint64)(unsafe.Pointer(bp + 8 /* v */)) = ((*(*sqlite3_uint64)(unsafe.Pointer(bp + 8 /* v */)) << 8) | sqlite3_uint64(*(*uint8)(unsafe.Pointer(x + uintptr(i))))) 23380 } 23381 libc.Xmemcpy(tls, bp /* &r */, bp+8 /* &v */, uint64(unsafe.Sizeof(float64(0)))) 23382 sqlite3.Xsqlite3_result_double(tls, context, *(*float64)(unsafe.Pointer(bp /* r */))) 23383 } 23384 } 23385 23386 func ieee754func_to_blob(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* ieee754.c:233:13: */ 23387 bp := tls.Alloc(24) 23388 defer tls.Free(24) 23389 23390 _ = argc 23391 if (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_FLOAT) || 23392 (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_INTEGER) { 23393 *(*float64)(unsafe.Pointer(bp + 8 /* r */)) = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) 23394 // var v sqlite3_uint64 at bp, 8 23395 23396 // var a [8]uint8 at bp+16, 8 23397 23398 var i uint32 23399 libc.Xmemcpy(tls, bp /* &v */, bp+8 /* &r */, uint64(unsafe.Sizeof(float64(0)))) 23400 for i = uint32(1); uint64(i) <= uint64(unsafe.Sizeof(float64(0))); i++ { 23401 *(*uint8)(unsafe.Pointer(bp + 16 /* &a[0] */ + uintptr((uint64(unsafe.Sizeof(float64(0))) - uint64(i))))) = (uint8(*(*sqlite3_uint64)(unsafe.Pointer(bp /* v */)) & uint64(0xff))) 23402 *(*sqlite3_uint64)(unsafe.Pointer(bp /* v */)) >>= 8 23403 } 23404 sqlite3.Xsqlite3_result_blob(tls, context, bp+16 /* &a[0] */, int32(unsafe.Sizeof(float64(0))), libc.UintptrFromInt32(-1)) 23405 } 23406 } 23407 23408 func sqlite3_ieee_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* ieee754.c:259:5: */ 23409 var i uint32 23410 var rc int32 = SQLITE_OK 23411 _ = pApi 23412 23413 _ = pzErrMsg // Unused parameter 23414 for i = uint32(0); (uint64(i) < (uint64(unsafe.Sizeof(aFunc1)) / uint64(unsafe.Sizeof(struct { 23415 FzFName uintptr 23416 FnArg int32 23417 FiAux int32 23418 FxFunc uintptr 23419 }{})))) && (rc == SQLITE_OK); i++ { 23420 rc = sqlite3.Xsqlite3_create_function(tls, db, aFunc1[i].FzFName, aFunc1[i].FnArg, 23421 (SQLITE_UTF8 | SQLITE_INNOCUOUS), 23422 (uintptr(unsafe.Pointer(&aFunc1)) + uintptr(i)*24 + 12 /* &.iAux */), 23423 aFunc1[i].FxFunc, uintptr(0), uintptr(0)) 23424 } 23425 return rc 23426 } 23427 23428 var aFunc1 = [6]struct { 23429 FzFName uintptr 23430 FnArg int32 23431 FiAux int32 23432 FxFunc uintptr 23433 }{ 23434 {FzFName: ts + 5378 /* "ieee754" */, FnArg: 1, FxFunc: 0}, 23435 {FzFName: ts + 5378 /* "ieee754" */, FnArg: 2, FxFunc: 0}, 23436 {FzFName: ts + 5386 /* "ieee754_mantissa" */, FnArg: 1, FiAux: 1, FxFunc: 0}, 23437 {FzFName: ts + 5403 /* "ieee754_exponent" */, FnArg: 1, FiAux: 2, FxFunc: 0}, 23438 {FzFName: ts + 5420 /* "ieee754_to_blob" */, FnArg: 1, FxFunc: 0}, 23439 {FzFName: ts + 5436 /* "ieee754_from_blo..." */, FnArg: 1, FxFunc: 0}, 23440 } /* ieee754.c:269:5 */ 23441 23442 // 23443 // END OF REGISTRATION API 23444 // 23445 23446 //******* End of fts5.h ******** 23447 23448 // This function is used to touch each page of a mapping of a memory 23449 // mapped SQLite database. Assuming that the system has sufficient free 23450 // memory and supports sufficiently large mappings, this causes the OS 23451 // to cache the entire database in main memory, making subsequent 23452 // database accesses faster. 23453 // 23454 // If the second parameter to this function is not NULL, it is the name of 23455 // the specific database to operate on (i.e. "main" or the name of an 23456 // attached database). 23457 // 23458 // SQLITE_OK is returned if successful, or an SQLite error code otherwise. 23459 // It is not considered an error if the file is not memory-mapped, or if 23460 // the mapping does not span the entire file. If an error does occur, a 23461 // transaction may be left open on the database file. 23462 // 23463 // It is illegal to call this function when the database handle has an 23464 // open transaction. SQLITE_MISUSE is returned in this case. 23465 func sqlite3_mmap_warm(tls *libc.TLS, db uintptr, zDb uintptr) int32 { /* mmapwarm.c:37:5: */ 23466 bp := tls.Alloc(88) 23467 defer tls.Free(88) 23468 23469 var rc int32 = SQLITE_OK 23470 var zSql uintptr = uintptr(0) 23471 var pgsz int32 = 0 23472 var nTotal int32 = 0 23473 23474 if 0 == sqlite3.Xsqlite3_get_autocommit(tls, db) { 23475 return SQLITE_MISUSE 23476 } 23477 23478 // Open a read-only transaction on the file in question 23479 zSql = sqlite3.Xsqlite3_mprintf(tls, ts+5454, /* "BEGIN; SELECT * ..." */ 23480 libc.VaList(bp, func() uintptr { 23481 if zDb != 0 { 23482 return ts + 5495 /* "'" */ 23483 } 23484 return ts + 489 /* "" */ 23485 }(), func() uintptr { 23486 if zDb != 0 { 23487 return zDb 23488 } 23489 return ts + 489 /* "" */ 23490 }(), func() uintptr { 23491 if zDb != 0 { 23492 return ts + 5497 /* "'." */ 23493 } 23494 return ts + 489 /* "" */ 23495 }())) 23496 if zSql == uintptr(0) { 23497 return SQLITE_NOMEM 23498 } 23499 rc = sqlite3.Xsqlite3_exec(tls, db, zSql, uintptr(0), uintptr(0), uintptr(0)) 23500 sqlite3.Xsqlite3_free(tls, zSql) 23501 23502 // Find the SQLite page size of the file 23503 if rc == SQLITE_OK { 23504 zSql = sqlite3.Xsqlite3_mprintf(tls, ts+5500, /* "PRAGMA %s%q%spag..." */ 23505 libc.VaList(bp+24, func() uintptr { 23506 if zDb != 0 { 23507 return ts + 5495 /* "'" */ 23508 } 23509 return ts + 489 /* "" */ 23510 }(), func() uintptr { 23511 if zDb != 0 { 23512 return zDb 23513 } 23514 return ts + 489 /* "" */ 23515 }(), func() uintptr { 23516 if zDb != 0 { 23517 return ts + 5497 /* "'." */ 23518 } 23519 return ts + 489 /* "" */ 23520 }())) 23521 if zSql == uintptr(0) { 23522 rc = SQLITE_NOMEM 23523 } else { 23524 *(*uintptr)(unsafe.Pointer(bp + 64 /* pPgsz */)) = uintptr(0) 23525 rc = sqlite3.Xsqlite3_prepare_v2(tls, db, zSql, -1, bp+64 /* &pPgsz */, uintptr(0)) 23526 sqlite3.Xsqlite3_free(tls, zSql) 23527 if rc == SQLITE_OK { 23528 if sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pPgsz */))) == SQLITE_ROW { 23529 pgsz = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pPgsz */)), 0) 23530 } 23531 rc = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pPgsz */))) 23532 } 23533 if (rc == SQLITE_OK) && (pgsz == 0) { 23534 rc = SQLITE_ERROR 23535 } 23536 } 23537 } 23538 23539 // Touch each mmap'd page of the file 23540 if rc == SQLITE_OK { 23541 var rc2 int32 23542 *(*uintptr)(unsafe.Pointer(bp + 72 /* pFd */)) = uintptr(0) 23543 rc = sqlite3.Xsqlite3_file_control(tls, db, zDb, SQLITE_FCNTL_FILE_POINTER, bp+72 /* &pFd */) 23544 if (rc == SQLITE_OK) && ((*sqlite3_io_methods1)(unsafe.Pointer((*sqlite3_file)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 72 /* pFd */)))).FpMethods)).FiVersion >= 3) { 23545 var iPg sqlite3_int64 = int64(1) 23546 var p uintptr = (*sqlite3_file)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 72 /* pFd */)))).FpMethods 23547 for 1 != 0 { 23548 // var pMap uintptr at bp+80, 8 23549 23550 rc = (*(*func(*libc.TLS, uintptr, sqlite3_int64, int32, uintptr) int32)(unsafe.Pointer((p + 136 /* &.xFetch */))))(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pFd */)), (sqlite3_int64(pgsz) * iPg), pgsz, bp+80 /* &pMap */) 23551 if (rc != SQLITE_OK) || (*(*uintptr)(unsafe.Pointer(bp + 80 /* pMap */)) == uintptr(0)) { 23552 break 23553 } 23554 23555 nTotal = nTotal + (int32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 80 /* pMap */)))))) 23556 nTotal = nTotal + (int32(*(*uint8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 80 /* pMap */)) + uintptr((pgsz - 1)))))) 23557 23558 rc = (*(*func(*libc.TLS, uintptr, sqlite3_int64, uintptr) int32)(unsafe.Pointer((p + 144 /* &.xUnfetch */))))(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pFd */)), (sqlite3_int64(pgsz) * iPg), *(*uintptr)(unsafe.Pointer(bp + 80 /* pMap */))) 23559 if rc != SQLITE_OK { 23560 break 23561 } 23562 iPg++ 23563 } 23564 sqlite3.Xsqlite3_log(tls, SQLITE_OK, 23565 ts+5523 /* "sqlite3_mmap_war..." */, libc.VaList(bp+48, func() int64 { 23566 if iPg == int64(1) { 23567 return int64(0) 23568 } 23569 return iPg 23570 }(), 23571 sqlite3.Xsqlite3_db_filename(tls, db, zDb))) 23572 } 23573 23574 rc2 = sqlite3.Xsqlite3_exec(tls, db, ts+5573 /* "END" */, uintptr(0), uintptr(0), uintptr(0)) 23575 if rc == SQLITE_OK { 23576 rc = rc2 23577 } 23578 } 23579 23580 return rc 23581 } 23582 23583 // A structure to hold context of the next_char() computation across 23584 // nested function calls. 23585 type nextCharContext1 = struct { 23586 Fdb uintptr 23587 FpStmt uintptr 23588 FzPrefix uintptr 23589 FnPrefix int32 23590 FnAlloc int32 23591 FnUsed int32 23592 _ [4]byte 23593 FaResult uintptr 23594 FmallocFailed int32 23595 FotherError int32 23596 } /* nextchar.c:63:9 */ 23597 23598 // A structure to hold context of the next_char() computation across 23599 // nested function calls. 23600 type nextCharContext = nextCharContext1 /* nextchar.c:63:32 */ 23601 23602 // Append a result character if the character is not already in the 23603 // result. 23604 func nextCharAppend(tls *libc.TLS, p uintptr, c uint32) { /* nextchar.c:80:13: */ 23605 var i int32 23606 for i = 0; i < (*nextCharContext)(unsafe.Pointer(p)).FnUsed; i++ { 23607 if *(*uint32)(unsafe.Pointer((*nextCharContext)(unsafe.Pointer(p)).FaResult + uintptr(i)*4)) == c { 23608 return 23609 } 23610 } 23611 if ((*nextCharContext)(unsafe.Pointer(p)).FnUsed + 1) > (*nextCharContext)(unsafe.Pointer(p)).FnAlloc { 23612 var aNew uintptr 23613 var n int32 = (((*nextCharContext)(unsafe.Pointer(p)).FnAlloc * 2) + 30) 23614 aNew = sqlite3.Xsqlite3_realloc64(tls, (*nextCharContext)(unsafe.Pointer(p)).FaResult, (uint64(uint64(n) * uint64(unsafe.Sizeof(uint32(0)))))) 23615 if aNew == uintptr(0) { 23616 (*nextCharContext)(unsafe.Pointer(p)).FmallocFailed = 1 23617 return 23618 } else { 23619 (*nextCharContext)(unsafe.Pointer(p)).FaResult = aNew 23620 (*nextCharContext)(unsafe.Pointer(p)).FnAlloc = n 23621 } 23622 } 23623 *(*uint32)(unsafe.Pointer((*nextCharContext)(unsafe.Pointer(p)).FaResult + uintptr(libc.PostIncInt32(&(*nextCharContext)(unsafe.Pointer(p)).FnUsed, 1))*4)) = c 23624 } 23625 23626 // Write a character into z[] as UTF8. Return the number of bytes needed 23627 // to hold the character 23628 func writeUtf8(tls *libc.TLS, z uintptr, c uint32) int32 { /* nextchar.c:104:12: */ 23629 if c < uint32(0x00080) { 23630 *(*uint8)(unsafe.Pointer(z)) = (uint8(c & uint32(0xff))) 23631 return 1 23632 } 23633 if c < uint32(0x00800) { 23634 *(*uint8)(unsafe.Pointer(z)) = (uint8(0xC0 + int32((uint8((c >> 6) & uint32(0x1F)))))) 23635 *(*uint8)(unsafe.Pointer(z + 1)) = (uint8(0x80 + int32((uint8(c & uint32(0x3F)))))) 23636 return 2 23637 } 23638 if c < uint32(0x10000) { 23639 *(*uint8)(unsafe.Pointer(z)) = (uint8(0xE0 + int32((uint8((c >> 12) & uint32(0x0F)))))) 23640 *(*uint8)(unsafe.Pointer(z + 1)) = (uint8(0x80 + int32((uint8((c >> 6) & uint32(0x3F)))))) 23641 *(*uint8)(unsafe.Pointer(z + 2)) = (uint8(0x80 + int32((uint8(c & uint32(0x3F)))))) 23642 return 3 23643 } 23644 *(*uint8)(unsafe.Pointer(z)) = (uint8(0xF0 + int32((uint8((c >> 18) & uint32(0x07)))))) 23645 *(*uint8)(unsafe.Pointer(z + 1)) = (uint8(0x80 + int32((uint8((c >> 12) & uint32(0x3F)))))) 23646 *(*uint8)(unsafe.Pointer(z + 2)) = (uint8(0x80 + int32((uint8((c >> 6) & uint32(0x3F)))))) 23647 *(*uint8)(unsafe.Pointer(z + 3)) = (uint8(0x80 + int32((uint8(c & uint32(0x3F)))))) 23648 return 4 23649 } 23650 23651 // Read a UTF8 character out of z[] and write it into *pOut. Return 23652 // the number of bytes in z[] that were used to construct the character. 23653 func readUtf8(tls *libc.TLS, z uintptr, pOut uintptr) int32 { /* nextchar.c:131:12: */ 23654 var c uint32 = uint32(*(*uint8)(unsafe.Pointer(z))) 23655 if c < uint32(0xc0) { 23656 *(*uint32)(unsafe.Pointer(pOut)) = c 23657 return 1 23658 } else { 23659 var n int32 = 1 23660 c = uint32(validBits[(c - uint32(0xc0))]) 23661 for (int32(*(*uint8)(unsafe.Pointer(z + uintptr(n)))) & 0xc0) == 0x80 { 23662 c = ((c << 6) + (uint32(0x3f & int32(*(*uint8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&n, 1)))))))) 23663 } 23664 if ((c < uint32(0x80)) || ((c & 0xFFFFF800) == uint32(0xD800))) || ((c & 0xFFFFFFFE) == uint32(0xFFFE)) { 23665 c = uint32(0xFFFD) 23666 } 23667 *(*uint32)(unsafe.Pointer(pOut)) = c 23668 return n 23669 } 23670 return int32(0) 23671 } 23672 23673 var validBits = [64]uint8{ 23674 uint8(0x00), uint8(0x01), uint8(0x02), uint8(0x03), uint8(0x04), uint8(0x05), uint8(0x06), uint8(0x07), 23675 uint8(0x08), uint8(0x09), uint8(0x0a), uint8(0x0b), uint8(0x0c), uint8(0x0d), uint8(0x0e), uint8(0x0f), 23676 uint8(0x10), uint8(0x11), uint8(0x12), uint8(0x13), uint8(0x14), uint8(0x15), uint8(0x16), uint8(0x17), 23677 uint8(0x18), uint8(0x19), uint8(0x1a), uint8(0x1b), uint8(0x1c), uint8(0x1d), uint8(0x1e), uint8(0x1f), 23678 uint8(0x00), uint8(0x01), uint8(0x02), uint8(0x03), uint8(0x04), uint8(0x05), uint8(0x06), uint8(0x07), 23679 uint8(0x08), uint8(0x09), uint8(0x0a), uint8(0x0b), uint8(0x0c), uint8(0x0d), uint8(0x0e), uint8(0x0f), 23680 uint8(0x00), uint8(0x01), uint8(0x02), uint8(0x03), uint8(0x04), uint8(0x05), uint8(0x06), uint8(0x07), 23681 uint8(0x00), uint8(0x01), uint8(0x02), uint8(0x03), uint8(0x00), uint8(0x01), uint8(0x00), uint8(0x00), 23682 } /* nextchar.c:132:30 */ 23683 23684 // The nextCharContext structure has been set up. Add all "next" characters 23685 // to the result set. 23686 func findNextChars(tls *libc.TLS, p uintptr) { /* nextchar.c:164:13: */ 23687 bp := tls.Alloc(12) 23688 defer tls.Free(12) 23689 23690 var cPrev uint32 = uint32(0) 23691 // var zPrev [8]uint8 at bp, 8 23692 23693 var n int32 23694 var rc int32 23695 23696 for { 23697 sqlite3.Xsqlite3_bind_text(tls, (*nextCharContext)(unsafe.Pointer(p)).FpStmt, 1, (*nextCharContext)(unsafe.Pointer(p)).FzPrefix, (*nextCharContext)(unsafe.Pointer(p)).FnPrefix, 23698 uintptr(0)) 23699 n = writeUtf8(tls, bp /* &zPrev[0] */, (cPrev + uint32(1))) 23700 sqlite3.Xsqlite3_bind_text(tls, (*nextCharContext)(unsafe.Pointer(p)).FpStmt, 2, bp /* zPrev */, n, uintptr(0)) 23701 rc = sqlite3.Xsqlite3_step(tls, (*nextCharContext)(unsafe.Pointer(p)).FpStmt) 23702 if rc == SQLITE_DONE { 23703 sqlite3.Xsqlite3_reset(tls, (*nextCharContext)(unsafe.Pointer(p)).FpStmt) 23704 return 23705 } else if rc != SQLITE_ROW { 23706 (*nextCharContext)(unsafe.Pointer(p)).FotherError = rc 23707 return 23708 } else { 23709 var zOut uintptr = sqlite3.Xsqlite3_column_text(tls, (*nextCharContext)(unsafe.Pointer(p)).FpStmt, 0) 23710 // var cNext uint32 at bp+8, 4 23711 23712 n = readUtf8(tls, (zOut + uintptr((*nextCharContext)(unsafe.Pointer(p)).FnPrefix)), bp+8 /* &cNext */) 23713 sqlite3.Xsqlite3_reset(tls, (*nextCharContext)(unsafe.Pointer(p)).FpStmt) 23714 nextCharAppend(tls, p, *(*uint32)(unsafe.Pointer(bp + 8 /* cNext */))) 23715 cPrev = *(*uint32)(unsafe.Pointer(bp + 8 /* cNext */)) 23716 if (*nextCharContext)(unsafe.Pointer(p)).FmallocFailed != 0 { 23717 return 23718 } 23719 } 23720 } 23721 } 23722 23723 // next_character(A,T,F,W) 23724 // 23725 // Return a string composted of all next possible characters after 23726 // A for elements of T.F. If W is supplied, then it is an SQL expression 23727 // that limits the elements in T.F that are considered. 23728 func nextCharFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* nextchar.c:201:13: */ 23729 bp := tls.Alloc(136) 23730 defer tls.Free(136) 23731 23732 // var c nextCharContext at bp+80, 56 23733 23734 var zTable uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 23735 var zField uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) 23736 var zWhere uintptr 23737 var zCollName uintptr 23738 var zWhereClause uintptr = uintptr(0) 23739 var zColl uintptr = uintptr(0) 23740 var zSql uintptr 23741 var rc int32 23742 23743 libc.Xmemset(tls, bp+80 /* &c */, 0, uint64(unsafe.Sizeof(nextCharContext{}))) 23744 (*nextCharContext)(unsafe.Pointer(bp + 80 /* &c */)).Fdb = sqlite3.Xsqlite3_context_db_handle(tls, context) 23745 (*nextCharContext)(unsafe.Pointer(bp + 80 /* &c */)).FzPrefix = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 23746 (*nextCharContext)(unsafe.Pointer(bp + 80 /* &c */)).FnPrefix = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) 23747 if ((zTable == uintptr(0)) || (zField == uintptr(0))) || ((*nextCharContext)(unsafe.Pointer(bp+80 /* &c */)).FzPrefix == uintptr(0)) { 23748 return 23749 } 23750 if ((argc >= 4) && 23751 ((libc.AssignUintptr(&zWhere, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))))) != uintptr(0))) && 23752 (int32(*(*uint8)(unsafe.Pointer(zWhere))) != 0) { 23753 zWhereClause = sqlite3.Xsqlite3_mprintf(tls, ts+5577 /* "AND (%s)" */, libc.VaList(bp, zWhere)) 23754 if zWhereClause == uintptr(0) { 23755 sqlite3.Xsqlite3_result_error_nomem(tls, context) 23756 return 23757 } 23758 } else { 23759 zWhereClause = ts + 489 /* "" */ 23760 } 23761 if ((argc >= 5) && 23762 ((libc.AssignUintptr(&zCollName, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8))))) != uintptr(0))) && 23763 (int32(*(*uint8)(unsafe.Pointer(zCollName))) != 0) { 23764 zColl = sqlite3.Xsqlite3_mprintf(tls, ts+5586 /* "collate \"%w\"" */, libc.VaList(bp+8, zCollName)) 23765 if zColl == uintptr(0) { 23766 sqlite3.Xsqlite3_result_error_nomem(tls, context) 23767 if *(*int8)(unsafe.Pointer(zWhereClause)) != 0 { 23768 sqlite3.Xsqlite3_free(tls, zWhereClause) 23769 } 23770 return 23771 } 23772 } else { 23773 zColl = ts + 489 /* "" */ 23774 } 23775 zSql = sqlite3.Xsqlite3_mprintf(tls, 23776 23777 // 1114111 == 0x10ffff 23778 23779 ts+5599, /* "SELECT %s FROM %..." */ 23780 libc.VaList(bp+16, zField, zTable, zField, zColl, zField, zColl, zWhereClause, zColl)) 23781 if *(*int8)(unsafe.Pointer(zWhereClause)) != 0 { 23782 sqlite3.Xsqlite3_free(tls, zWhereClause) 23783 } 23784 if *(*int8)(unsafe.Pointer(zColl)) != 0 { 23785 sqlite3.Xsqlite3_free(tls, zColl) 23786 } 23787 if zSql == uintptr(0) { 23788 sqlite3.Xsqlite3_result_error_nomem(tls, context) 23789 return 23790 } 23791 23792 rc = sqlite3.Xsqlite3_prepare_v2(tls, (*nextCharContext)(unsafe.Pointer(bp+80 /* &c */)).Fdb, zSql, -1, (bp + 80 /* &c */ + 8 /* &.pStmt */), uintptr(0)) 23793 sqlite3.Xsqlite3_free(tls, zSql) 23794 if rc != 0 { 23795 sqlite3.Xsqlite3_result_error(tls, context, sqlite3.Xsqlite3_errmsg(tls, (*nextCharContext)(unsafe.Pointer(bp+80 /* &c */)).Fdb), -1) 23796 return 23797 } 23798 findNextChars(tls, bp+80 /* &c */) 23799 if (*nextCharContext)(unsafe.Pointer(bp+80 /* &c */)).FmallocFailed != 0 { 23800 sqlite3.Xsqlite3_result_error_nomem(tls, context) 23801 } else { 23802 var pRes uintptr 23803 pRes = sqlite3.Xsqlite3_malloc64(tls, (uint64(((*nextCharContext)(unsafe.Pointer(bp+80 /* &c */)).FnUsed * 4) + 1))) 23804 if pRes == uintptr(0) { 23805 sqlite3.Xsqlite3_result_error_nomem(tls, context) 23806 } else { 23807 var i int32 23808 var n int32 = 0 23809 for i = 0; i < (*nextCharContext)(unsafe.Pointer(bp+80 /* &c */)).FnUsed; i++ { 23810 n = n + (writeUtf8(tls, (pRes + uintptr(n)), *(*uint32)(unsafe.Pointer((*nextCharContext)(unsafe.Pointer(bp+80 /* &c */)).FaResult + uintptr(i)*4)))) 23811 } 23812 *(*uint8)(unsafe.Pointer(pRes + uintptr(n))) = uint8(0) 23813 sqlite3.Xsqlite3_result_text(tls, context, pRes, n, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) 23814 } 23815 } 23816 sqlite3.Xsqlite3_finalize(tls, (*nextCharContext)(unsafe.Pointer(bp+80 /* &c */)).FpStmt) 23817 sqlite3.Xsqlite3_free(tls, (*nextCharContext)(unsafe.Pointer(bp+80 /* &c */)).FaResult) 23818 } 23819 23820 func sqlite3_nextchar_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* nextchar.c:292:5: */ 23821 var rc int32 = SQLITE_OK 23822 _ = pApi 23823 23824 _ = pzErrMsg // Unused parameter 23825 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+5707 /* "next_char" */, 3, 23826 (SQLITE_UTF8 | SQLITE_INNOCUOUS), uintptr(0), 23827 *(*uintptr)(unsafe.Pointer(&struct { 23828 f func(*libc.TLS, uintptr, int32, uintptr) 23829 }{nextCharFunc})), uintptr(0), uintptr(0)) 23830 if rc == SQLITE_OK { 23831 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+5707 /* "next_char" */, 4, 23832 (SQLITE_UTF8 | SQLITE_INNOCUOUS), uintptr(0), 23833 *(*uintptr)(unsafe.Pointer(&struct { 23834 f func(*libc.TLS, uintptr, int32, uintptr) 23835 }{nextCharFunc})), uintptr(0), uintptr(0)) 23836 } 23837 if rc == SQLITE_OK { 23838 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+5707 /* "next_char" */, 5, 23839 (SQLITE_UTF8 | SQLITE_INNOCUOUS), uintptr(0), 23840 *(*uintptr)(unsafe.Pointer(&struct { 23841 f func(*libc.TLS, uintptr, int32, uintptr) 23842 }{nextCharFunc})), uintptr(0), uintptr(0)) 23843 } 23844 return rc 23845 } 23846 23847 // Implementation note: 23848 // 23849 // Much of the tokenizer logic is copied out of the tokenize.c source file 23850 // of SQLite. That logic could be simplified for this particular application, 23851 // but that would impose a risk of introducing subtle errors. It is best to 23852 // keep the code as close to the original as possible. 23853 // 23854 // The tokenize code is in sync with the SQLite core as of 2018-01-08. 23855 // Any future changes to the core tokenizer might require corresponding 23856 // adjustments to the tokenizer logic in this module. 23857 23858 // Character classes for tokenizing 23859 // 23860 // In the sqlite3GetToken() function, a switch() on aiClass[c] is implemented 23861 // using a lookup table, whereas a switch() directly on c uses a binary search. 23862 // The lookup table is much faster. To maximize speed, and to ensure that 23863 // a lookup table is used, all of the classes need to be small integers and 23864 // all of them need to be used within the switch. 23865 23866 var aiClass = [256]uint8{ 23867 // x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf 23868 /* 0x */ uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(27), uint8(7), uint8(7), uint8(27), uint8(7), uint8(7), uint8(27), uint8(27), 23869 /* 1x */ 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), 23870 /* 2x */ 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), 23871 /* 3x */ 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), 23872 /* 4x */ 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), 23873 /* 5x */ uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(0), uint8(1), uint8(1), uint8(9), uint8(27), uint8(27), uint8(27), uint8(1), 23874 /* 6x */ 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), 23875 /* 7x */ uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(1), uint8(0), uint8(1), uint8(1), uint8(27), uint8(10), uint8(27), uint8(25), uint8(27), 23876 /* 8x */ uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), 23877 /* 9x */ uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), 23878 /* Ax */ uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), 23879 /* Bx */ uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), 23880 /* Cx */ uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), 23881 /* Dx */ uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), 23882 /* Ex */ uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), 23883 /* Fx */ uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), uint8(2), 23884 } /* normalize.c:106:28 */ 23885 23886 // An array to map all upper-case characters into their corresponding 23887 // lower-case character. 23888 // 23889 // SQLite only considers US-ASCII (or EBCDIC) characters. We do not 23890 // handle case conversions for the UTF character set since the tables 23891 // involved are nearly as big or bigger than SQLite itself. 23892 var sqlite3UpperToLower = [256]uint8{ 23893 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), 23894 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), 23895 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), 23896 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), 23897 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), 23898 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), 23899 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), 23900 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), 23901 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), 23902 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), 23903 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), 23904 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), 23905 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), 23906 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), 23907 uint8(252), uint8(253), uint8(254), uint8(255), 23908 } /* normalize.c:133:28 */ 23909 23910 // The following 256 byte lookup table is used to support SQLites built-in 23911 // equivalents to the following standard library functions: 23912 // 23913 // isspace() 0x01 23914 // isalpha() 0x02 23915 // isdigit() 0x04 23916 // isalnum() 0x06 23917 // isxdigit() 0x08 23918 // toupper() 0x20 23919 // SQLite identifier character 0x40 23920 // Quote character 0x80 23921 // 23922 // Bit 0x20 is set if the mapped character requires translation to upper 23923 // case. i.e. if the character is a lower-case ASCII character. 23924 // If x is a lower-case ASCII character, then its upper-case equivalent 23925 // is (x - 0x20). Therefore toupper() can be implemented as: 23926 // 23927 // (x & ~(map[x]&0x20)) 23928 // 23929 // The equivalent of tolower() is implemented using the sqlite3UpperToLower[] 23930 // array. tolower() is used more often than toupper() by SQLite. 23931 // 23932 // Bit 0x40 is set if the character is non-alphanumeric and can be used in an 23933 // SQLite identifier. Identifiers are alphanumerics, "_", "$", and any 23934 // non-ASCII UTF character. Hence the test for whether or not a character is 23935 // part of an identifier is 0x46. 23936 var sqlite3CtypeMap = [256]uint8{ 23937 uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), // 00..07 ........ 23938 uint8(0x00), uint8(0x01), uint8(0x01), uint8(0x01), uint8(0x01), uint8(0x01), uint8(0x00), uint8(0x00), // 08..0f ........ 23939 uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), // 10..17 ........ 23940 uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), // 18..1f ........ 23941 uint8(0x01), uint8(0x00), uint8(0x80), uint8(0x00), uint8(0x40), uint8(0x00), uint8(0x00), uint8(0x80), // 20..27 !"#$%&' 23942 uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), // 28..2f ()*+,-./ 23943 uint8(0x0c), uint8(0x0c), uint8(0x0c), uint8(0x0c), uint8(0x0c), uint8(0x0c), uint8(0x0c), uint8(0x0c), // 30..37 01234567 23944 uint8(0x0c), uint8(0x0c), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), // 38..3f 89:;<=>? 23945 23946 uint8(0x00), uint8(0x0a), uint8(0x0a), uint8(0x0a), uint8(0x0a), uint8(0x0a), uint8(0x0a), uint8(0x02), // 40..47 @ABCDEFG 23947 uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02), // 48..4f HIJKLMNO 23948 uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x02), // 50..57 PQRSTUVW 23949 uint8(0x02), uint8(0x02), uint8(0x02), uint8(0x80), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x40), // 58..5f XYZ[\]^_ 23950 uint8(0x80), uint8(0x2a), uint8(0x2a), uint8(0x2a), uint8(0x2a), uint8(0x2a), uint8(0x2a), uint8(0x22), // 60..67 `abcdefg 23951 uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22), // 68..6f hijklmno 23952 uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x22), // 70..77 pqrstuvw 23953 uint8(0x22), uint8(0x22), uint8(0x22), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), uint8(0x00), // 78..7f xyz{|}~. 23954 23955 uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), // 80..87 ........ 23956 uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), // 88..8f ........ 23957 uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), // 90..97 ........ 23958 uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), // 98..9f ........ 23959 uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), // a0..a7 ........ 23960 uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), // a8..af ........ 23961 uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), // b0..b7 ........ 23962 uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), // b8..bf ........ 23963 23964 uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), // c0..c7 ........ 23965 uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), // c8..cf ........ 23966 uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), // d0..d7 ........ 23967 uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), // d8..df ........ 23968 uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), // e0..e7 ........ 23969 uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), // e8..ef ........ 23970 uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), // f0..f7 ........ 23971 uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), uint8(0x40), // f8..ff ........ 23972 } /* normalize.c:179:28 */ 23973 23974 // If X is a character that can be used in an identifier then 23975 // IdChar(X) will be true. Otherwise it is false. 23976 // 23977 // For ASCII, any character with the high-order bit set is 23978 // allowed in an identifier. For 7-bit characters, 23979 // sqlite3IsIdChar[X] must be 1. 23980 // 23981 // For EBCDIC, the rules are more complex but have the same 23982 // end result. 23983 // 23984 // Ticket #1066. the SQL standard does not allow '$' in the 23985 // middle of identifiers. But many SQL implementations do. 23986 // SQLite will allow '$' in identifiers for compatibility. 23987 // But the feature is undocumented. 23988 23989 // Ignore testcase() macros 23990 23991 // Token values 23992 23993 // Disable nuisence warnings about case fall-through 23994 23995 // Return the length (in bytes) of the token that begins at z[0]. 23996 // Store the token type in *tokenType before returning. 23997 func sqlite3GetToken(tls *libc.TLS, z uintptr, tokenType uintptr) int32 { /* normalize.c:300:12: */ 23998 var i int32 23999 var c int32 24000 switch int32(aiClass[*(*uint8)(unsafe.Pointer(z))]) { // Switch on the character-class of the first byte 24001 // of the token. See the comment on the CC_ defines 24002 // above. 24003 case CC_SPACE: 24004 { 24005 for i = 1; (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x01) != 0; i++ { 24006 } 24007 *(*int32)(unsafe.Pointer(tokenType)) = TK_SPACE 24008 return i 24009 24010 } 24011 case CC_MINUS: 24012 { 24013 if int32(*(*uint8)(unsafe.Pointer(z + 1))) == '-' { 24014 for i = 2; ((libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0) && (c != '\n'); i++ { 24015 } 24016 *(*int32)(unsafe.Pointer(tokenType)) = TK_SPACE 24017 return i 24018 } 24019 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24020 return 1 24021 24022 } 24023 case CC_LP: 24024 { 24025 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24026 return 1 24027 24028 } 24029 case CC_RP: 24030 { 24031 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24032 return 1 24033 24034 } 24035 case CC_SEMI: 24036 { 24037 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24038 return 1 24039 24040 } 24041 case CC_PLUS: 24042 { 24043 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24044 return 1 24045 24046 } 24047 case CC_STAR: 24048 { 24049 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24050 return 1 24051 24052 } 24053 case CC_SLASH: 24054 { 24055 if (int32(*(*uint8)(unsafe.Pointer(z + 1))) != '*') || (int32(*(*uint8)(unsafe.Pointer(z + 2))) == 0) { 24056 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24057 return 1 24058 } 24059 i = 3 24060 c = int32(*(*uint8)(unsafe.Pointer(z + 2))) 24061 for ; ((c != '*') || (int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) != '/')) && ((libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0); i++ { 24062 } 24063 if c != 0 { 24064 i++ 24065 } 24066 *(*int32)(unsafe.Pointer(tokenType)) = TK_SPACE 24067 return i 24068 24069 } 24070 case CC_PERCENT: 24071 { 24072 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24073 return 1 24074 24075 } 24076 case CC_EQ: 24077 { 24078 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24079 return (1 + (libc.Bool32(int32(*(*uint8)(unsafe.Pointer(z + 1))) == '='))) 24080 24081 } 24082 case CC_LT: 24083 { 24084 if (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + 1))))) == '=' { 24085 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24086 return 2 24087 } else if c == '>' { 24088 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24089 return 2 24090 } else if c == '<' { 24091 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24092 return 2 24093 } else { 24094 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24095 return 1 24096 } 24097 24098 } 24099 fallthrough 24100 case CC_GT: 24101 { 24102 if (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + 1))))) == '=' { 24103 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24104 return 2 24105 } else if c == '>' { 24106 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24107 return 2 24108 } else { 24109 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24110 return 1 24111 } 24112 24113 } 24114 fallthrough 24115 case CC_BANG: 24116 { 24117 if int32(*(*uint8)(unsafe.Pointer(z + 1))) != '=' { 24118 *(*int32)(unsafe.Pointer(tokenType)) = TK_ERROR 24119 return 1 24120 } else { 24121 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24122 return 2 24123 } 24124 24125 } 24126 fallthrough 24127 case CC_PIPE: 24128 { 24129 if int32(*(*uint8)(unsafe.Pointer(z + 1))) != '|' { 24130 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24131 return 1 24132 } else { 24133 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24134 return 2 24135 } 24136 24137 } 24138 fallthrough 24139 case CC_COMMA: 24140 { 24141 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24142 return 1 24143 24144 } 24145 case CC_AND: 24146 { 24147 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24148 return 1 24149 24150 } 24151 case CC_TILDA: 24152 { 24153 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24154 return 1 24155 24156 } 24157 case CC_QUOTE: 24158 { 24159 var delim int32 = int32(*(*uint8)(unsafe.Pointer(z))) 24160 24161 for i = 1; (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0; i++ { 24162 if c == delim { 24163 if int32(*(*uint8)(unsafe.Pointer(z + uintptr((i + 1))))) == delim { 24164 i++ 24165 } else { 24166 break 24167 } 24168 } 24169 } 24170 if c == '\'' { 24171 *(*int32)(unsafe.Pointer(tokenType)) = TK_LITERAL 24172 return (i + 1) 24173 } else if c != 0 { 24174 *(*int32)(unsafe.Pointer(tokenType)) = TK_NAME 24175 return (i + 1) 24176 } else { 24177 *(*int32)(unsafe.Pointer(tokenType)) = TK_ERROR 24178 return i 24179 } 24180 24181 } 24182 fallthrough 24183 case CC_DOT: 24184 { 24185 if !((int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + 1))]) & 0x04) != 0) { 24186 *(*int32)(unsafe.Pointer(tokenType)) = TK_PUNCT 24187 return 1 24188 } 24189 // If the next character is a digit, this is a floating point 24190 // number that begins with ".". Fall thru into the next case 24191 /* no break */ 24192 24193 } 24194 fallthrough 24195 case CC_DIGIT: 24196 { 24197 *(*int32)(unsafe.Pointer(tokenType)) = TK_LITERAL 24198 if ((int32(*(*uint8)(unsafe.Pointer(z))) == '0') && ((int32(*(*uint8)(unsafe.Pointer(z + 1))) == 'x') || (int32(*(*uint8)(unsafe.Pointer(z + 1))) == 'X'))) && ((int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + 2))]) & 0x08) != 0) { 24199 for i = 3; (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x08) != 0; i++ { 24200 } 24201 return i 24202 } 24203 for i = 0; (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x04) != 0; i++ { 24204 } 24205 if int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) == '.' { 24206 i++ 24207 for (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x04) != 0 { 24208 i++ 24209 } 24210 *(*int32)(unsafe.Pointer(tokenType)) = TK_LITERAL 24211 } 24212 if ((int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) == 'e') || (int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) == 'E')) && (((int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr((i + 1))))]) & 0x04) != 0) || 24213 (((int32(*(*uint8)(unsafe.Pointer(z + uintptr((i + 1))))) == '+') || (int32(*(*uint8)(unsafe.Pointer(z + uintptr((i + 1))))) == '-')) && ((int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr((i + 2))))]) & 0x04) != 0))) { 24214 i = i + (2) 24215 for (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x04) != 0 { 24216 i++ 24217 } 24218 *(*int32)(unsafe.Pointer(tokenType)) = TK_LITERAL 24219 } 24220 for (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x46) != 0 { 24221 *(*int32)(unsafe.Pointer(tokenType)) = TK_ERROR 24222 i++ 24223 } 24224 return i 24225 24226 } 24227 case CC_QUOTE2: 24228 { 24229 i = 1 24230 c = int32(*(*uint8)(unsafe.Pointer(z))) 24231 for ; (c != ']') && ((libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0); i++ { 24232 } 24233 *(*int32)(unsafe.Pointer(tokenType)) = func() int32 { 24234 if c == ']' { 24235 return TK_NAME 24236 } 24237 return TK_ERROR 24238 }() 24239 return i 24240 24241 } 24242 case CC_VARNUM: 24243 { 24244 *(*int32)(unsafe.Pointer(tokenType)) = TK_LITERAL 24245 for i = 1; (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x04) != 0; i++ { 24246 } 24247 return i 24248 24249 } 24250 case CC_DOLLAR: 24251 fallthrough 24252 case CC_VARALPHA: 24253 { 24254 var n int32 = 0 24255 24256 *(*int32)(unsafe.Pointer(tokenType)) = TK_LITERAL 24257 for i = 1; (libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0; i++ { 24258 if (int32(sqlite3CtypeMap[uint8(c)]) & 0x46) != 0 { 24259 n++ 24260 } else if (c == '(') && (n > 0) { 24261 for ok := true; ok; ok = ((((libc.AssignInt32(&c, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) != 0) && !((int32(sqlite3CtypeMap[uint8(c)]) & 0x01) != 0)) && (c != ')')) { 24262 i++ 24263 } 24264 if c == ')' { 24265 i++ 24266 } else { 24267 *(*int32)(unsafe.Pointer(tokenType)) = TK_ERROR 24268 } 24269 break 24270 } else if (c == ':') && (int32(*(*uint8)(unsafe.Pointer(z + uintptr((i + 1))))) == ':') { 24271 i++ 24272 } else { 24273 break 24274 } 24275 } 24276 if n == 0 { 24277 *(*int32)(unsafe.Pointer(tokenType)) = TK_ERROR 24278 } 24279 return i 24280 24281 } 24282 case CC_KYWD: 24283 { 24284 for i = 1; int32(aiClass[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) <= CC_KYWD; i++ { 24285 } 24286 if (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x46) != 0 { 24287 // This token started out using characters that can appear in keywords, 24288 // but z[i] is a character not allowed within keywords, so this must 24289 // be an identifier instead 24290 i++ 24291 break 24292 } 24293 *(*int32)(unsafe.Pointer(tokenType)) = TK_NAME 24294 return i 24295 24296 } 24297 case CC_X: 24298 { 24299 24300 if int32(*(*uint8)(unsafe.Pointer(z + 1))) == '\'' { 24301 *(*int32)(unsafe.Pointer(tokenType)) = TK_LITERAL 24302 for i = 2; (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x08) != 0; i++ { 24303 } 24304 if (int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) != '\'') || ((i % 2) != 0) { 24305 *(*int32)(unsafe.Pointer(tokenType)) = TK_ERROR 24306 for (*(*uint8)(unsafe.Pointer(z + uintptr(i))) != 0) && (int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) != '\'') { 24307 i++ 24308 } 24309 } 24310 if *(*uint8)(unsafe.Pointer(z + uintptr(i))) != 0 { 24311 i++ 24312 } 24313 return i 24314 } 24315 // If it is not a BLOB literal, then it must be an ID, since no 24316 // SQL keywords start with the letter 'x'. Fall through 24317 /* no break */ 24318 24319 } 24320 fallthrough 24321 case CC_ID: 24322 { 24323 i = 1 24324 break 24325 24326 } 24327 default: 24328 { 24329 *(*int32)(unsafe.Pointer(tokenType)) = TK_ERROR 24330 return 1 24331 24332 } 24333 } 24334 for (int32(sqlite3CtypeMap[*(*uint8)(unsafe.Pointer(z + uintptr(i)))]) & 0x46) != 0 { 24335 i++ 24336 } 24337 *(*int32)(unsafe.Pointer(tokenType)) = TK_NAME 24338 return i 24339 } 24340 24341 func sqlite3_normalize(tls *libc.TLS, zSql uintptr) uintptr { /* normalize.c:555:6: */ 24342 bp := tls.Alloc(4) 24343 defer tls.Free(4) 24344 24345 var z uintptr // The output string 24346 var nZ sqlite3_int64 // Size of the output string in bytes 24347 var nSql sqlite3_int64 // Size of the input string in bytes 24348 var i int32 // Next character to read from zSql[] 24349 var j int32 // Next slot to fill in on z[] 24350 // var tokenType int32 at bp, 4 24351 // Type of the next token 24352 var n int32 // Size of the next token 24353 var k int32 // Loop counter 24354 24355 nSql = sqlite3_int64(libc.Xstrlen(tls, zSql)) 24356 nZ = nSql 24357 z = sqlite3.Xsqlite3_malloc64(tls, (uint64(nZ + int64(2)))) 24358 if z == uintptr(0) { 24359 return uintptr(0) 24360 } 24361 for i = libc.AssignInt32(&j, 0); *(*int8)(unsafe.Pointer(zSql + uintptr(i))) != 0; i = i + (n) { 24362 n = sqlite3GetToken(tls, (zSql + uintptr(i)), bp /* &tokenType */) 24363 switch *(*int32)(unsafe.Pointer(bp /* tokenType */)) { 24364 case TK_SPACE: 24365 { 24366 break 24367 24368 } 24369 case TK_ERROR: 24370 { 24371 sqlite3.Xsqlite3_free(tls, z) 24372 return uintptr(0) 24373 24374 } 24375 case TK_LITERAL: 24376 { 24377 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&j, 1)))) = int8('?') 24378 break 24379 24380 } 24381 case TK_PUNCT: 24382 fallthrough 24383 case TK_NAME: 24384 { 24385 if (n == 4) && (sqlite3.Xsqlite3_strnicmp(tls, (zSql+uintptr(i)), ts+5717 /* "NULL" */, 4) == 0) { 24386 if (((j >= 3) && (libc.Xstrncmp(tls, ((z+uintptr(j))-uintptr(2)), ts+5722 /* "is" */, uint64(2)) == 0)) && !((int32(sqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z + uintptr((j - 3)))))]) & 0x46) != 0)) || 24387 (((j >= 4) && (libc.Xstrncmp(tls, ((z+uintptr(j))-uintptr(3)), ts+5725 /* "not" */, uint64(3)) == 0)) && !((int32(sqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z + uintptr((j - 4)))))]) & 0x46) != 0)) { 24388 // NULL is a keyword in this case, not a literal value 24389 } else { 24390 // Here the NULL is a literal value 24391 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&j, 1)))) = int8('?') 24392 break 24393 } 24394 } 24395 if ((j > 0) && ((int32(sqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z + uintptr((j - 1)))))]) & 0x46) != 0)) && ((int32(sqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zSql + uintptr(i))))]) & 0x46) != 0) { 24396 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&j, 1)))) = int8(' ') 24397 } 24398 for k = 0; k < n; k++ { 24399 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&j, 1)))) = int8(sqlite3UpperToLower[uint8(*(*int8)(unsafe.Pointer(zSql + uintptr((i + k)))))]) 24400 } 24401 break 24402 24403 } 24404 } 24405 } 24406 for (j > 0) && (int32(*(*int8)(unsafe.Pointer(z + uintptr((j - 1))))) == ' ') { 24407 j-- 24408 } 24409 if (j > 0) && (int32(*(*int8)(unsafe.Pointer(z + uintptr((j - 1))))) != ';') { 24410 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&j, 1)))) = int8(';') 24411 } 24412 *(*int8)(unsafe.Pointer(z + uintptr(j))) = int8(0) 24413 24414 // Make a second pass converting "in(...)" where the "..." is not a 24415 // SELECT statement into "in(?,?,?)" 24416 for i = 0; i < j; i = n { 24417 var zIn uintptr = libc.Xstrstr(tls, (z + uintptr(i)), ts+5729 /* "in(" */) 24418 var nParen int32 24419 if zIn == uintptr(0) { 24420 break 24421 } 24422 n = ((int32((int64(zIn) - int64(z)) / 1)) + 3) // Index of first char past "in(" 24423 if (n != 0) && ((int32(sqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zIn + libc.UintptrFromInt32(-1))))]) & 0x46) != 0) { 24424 continue 24425 } 24426 if (libc.Xstrncmp(tls, zIn, ts+5733 /* "in(select" */, uint64(9)) == 0) && !((int32(sqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zIn + 9)))]) & 0x46) != 0) { 24427 continue 24428 } 24429 if (libc.Xstrncmp(tls, zIn, ts+5743 /* "in(with" */, uint64(7)) == 0) && !((int32(sqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(zIn + 7)))]) & 0x46) != 0) { 24430 continue 24431 } 24432 nParen = 1 24433 k = 0 24434 for ; *(*int8)(unsafe.Pointer(z + uintptr((n + k)))) != 0; k++ { 24435 if int32(*(*int8)(unsafe.Pointer(z + uintptr((n + k))))) == '(' { 24436 nParen++ 24437 } 24438 if int32(*(*int8)(unsafe.Pointer(z + uintptr((n + k))))) == ')' { 24439 nParen-- 24440 if nParen == 0 { 24441 break 24442 } 24443 } 24444 } 24445 // k is the number of bytes in the "..." within "in(...)" 24446 if k < 5 { 24447 z = sqlite3.Xsqlite3_realloc64(tls, z, (uint64((j + (5 - k)) + 1))) 24448 if z == uintptr(0) { 24449 return uintptr(0) 24450 } 24451 libc.Xmemmove(tls, ((z + uintptr(n)) + uintptr(5)), ((z + uintptr(n)) + uintptr(k)), (uint64(j - (n + k)))) 24452 } else if k > 5 { 24453 libc.Xmemmove(tls, ((z + uintptr(n)) + uintptr(5)), ((z + uintptr(n)) + uintptr(k)), (uint64(j - (n + k)))) 24454 } 24455 j = ((j - k) + 5) 24456 *(*int8)(unsafe.Pointer(z + uintptr(j))) = int8(0) 24457 libc.Xmemcpy(tls, (z + uintptr(n)), ts+5751 /* "?,?,?" */, uint64(5)) 24458 } 24459 return z 24460 } 24461 24462 // For testing purposes, or to build a stand-alone SQL normalizer program, 24463 // compile this one source file with the -DSQLITE_NORMALIZE_CLI and link 24464 // it against any SQLite library. The resulting command-line program will 24465 // run sqlite3_normalize() over the text of all files named on the command- 24466 // line and show the result on standard output. 24467 24468 // Floating-point inline functions for stdlib.h. 24469 // Copyright (C) 2012-2018 Free Software Foundation, Inc. 24470 // This file is part of the GNU C Library. 24471 // 24472 // The GNU C Library is free software; you can redistribute it and/or 24473 // modify it under the terms of the GNU Lesser General Public 24474 // License as published by the Free Software Foundation; either 24475 // version 2.1 of the License, or (at your option) any later version. 24476 // 24477 // The GNU C Library is distributed in the hope that it will be useful, 24478 // but WITHOUT ANY WARRANTY; without even the implied warranty of 24479 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24480 // Lesser General Public License for more details. 24481 // 24482 // You should have received a copy of the GNU Lesser General Public 24483 // License along with the GNU C Library; if not, see 24484 // <http://www.gnu.org/licenses/>. 24485 24486 // Define some macros helping to catch buffer overflows. 24487 24488 // The following object is the session context for a single percentile() 24489 // function. We have to remember all input Y values until the very end. 24490 // Those values are accumulated in the Percentile.a[] array. 24491 type Percentile1 = struct { 24492 FnAlloc uint32 24493 FnUsed uint32 24494 FrPct float64 24495 Fa uintptr 24496 } /* percentile.c:71:9 */ 24497 24498 // Floating-point inline functions for stdlib.h. 24499 // Copyright (C) 2012-2018 Free Software Foundation, Inc. 24500 // This file is part of the GNU C Library. 24501 // 24502 // The GNU C Library is free software; you can redistribute it and/or 24503 // modify it under the terms of the GNU Lesser General Public 24504 // License as published by the Free Software Foundation; either 24505 // version 2.1 of the License, or (at your option) any later version. 24506 // 24507 // The GNU C Library is distributed in the hope that it will be useful, 24508 // but WITHOUT ANY WARRANTY; without even the implied warranty of 24509 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24510 // Lesser General Public License for more details. 24511 // 24512 // You should have received a copy of the GNU Lesser General Public 24513 // License along with the GNU C Library; if not, see 24514 // <http://www.gnu.org/licenses/>. 24515 24516 // Define some macros helping to catch buffer overflows. 24517 24518 // The following object is the session context for a single percentile() 24519 // function. We have to remember all input Y values until the very end. 24520 // Those values are accumulated in the Percentile.a[] array. 24521 type Percentile = Percentile1 /* percentile.c:71:27 */ 24522 24523 // Return TRUE if the input floating-point number is an infinity. 24524 func isInfinity(tls *libc.TLS, r float64) int32 { /* percentile.c:82:12: */ 24525 bp := tls.Alloc(16) 24526 defer tls.Free(16) 24527 *(*float64)(unsafe.Pointer(bp + 8)) = r 24528 24529 // var u sqlite3_uint64 at bp, 8 24530 24531 libc.Xmemcpy(tls, bp /* &u */, bp+8 /* &r */, uint64(unsafe.Sizeof(sqlite3_uint64(0)))) 24532 return (libc.Bool32(((*(*sqlite3_uint64)(unsafe.Pointer(bp /* u */)) >> 52) & uint64(0x7ff)) == uint64(0x7ff))) 24533 } 24534 24535 // Return TRUE if two doubles differ by 0.001 or less 24536 func sameValue(tls *libc.TLS, a float64, b float64) int32 { /* percentile.c:92:12: */ 24537 a = a - (b) 24538 return (libc.Bool32((a >= -0.001) && (a <= 0.001))) 24539 } 24540 24541 // The "step" function for percentile(Y,P) is called once for each 24542 // input row. 24543 func percentStep(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) { /* percentile.c:101:13: */ 24544 var p uintptr 24545 var rPct float64 24546 var eType int32 24547 var y float64 24548 24549 // Requirement 3: P must be a number between 0 and 100 24550 eType = sqlite3.Xsqlite3_value_numeric_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 24551 rPct = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 24552 if (((eType != SQLITE_INTEGER) && (eType != SQLITE_FLOAT)) || 24553 (rPct < 0.0)) || (rPct > 100.0) { 24554 sqlite3.Xsqlite3_result_error(tls, pCtx, 24555 ts+5757 /* "2nd argument to ..." */, -1) 24556 return 24557 } 24558 24559 // Allocate the session context. 24560 p = sqlite3.Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(Percentile{}))) 24561 if p == uintptr(0) { 24562 return 24563 } 24564 24565 // Remember the P value. Throw an error if the P value is different 24566 // from any prior row, per Requirement (2). 24567 if (*Percentile)(unsafe.Pointer(p)).FrPct == 0.0 { 24568 (*Percentile)(unsafe.Pointer(p)).FrPct = (rPct + 1.0) 24569 } else if !(sameValue(tls, (*Percentile)(unsafe.Pointer(p)).FrPct, (rPct+1.0)) != 0) { 24570 sqlite3.Xsqlite3_result_error(tls, pCtx, 24571 ts+5824 /* "2nd argument to ..." */, -1) 24572 return 24573 } 24574 24575 // Ignore rows for which Y is NULL 24576 eType = sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) 24577 if eType == SQLITE_NULL { 24578 return 24579 } 24580 24581 // If not NULL, then Y must be numeric. Otherwise throw an error. 24582 // Requirement 4 24583 if (eType != SQLITE_INTEGER) && (eType != SQLITE_FLOAT) { 24584 sqlite3.Xsqlite3_result_error(tls, pCtx, 24585 ts+5888 /* "1st argument to ..." */, -1) 24586 return 24587 } 24588 24589 // Throw an error if the Y value is infinity or NaN 24590 y = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) 24591 if isInfinity(tls, y) != 0 { 24592 sqlite3.Xsqlite3_result_error(tls, pCtx, ts+5932 /* "Inf input to per..." */, -1) 24593 return 24594 } 24595 24596 // Allocate and store the Y 24597 if (*Percentile)(unsafe.Pointer(p)).FnUsed >= (*Percentile)(unsafe.Pointer(p)).FnAlloc { 24598 var n uint32 = (((*Percentile)(unsafe.Pointer(p)).FnAlloc * uint32(2)) + uint32(250)) 24599 var a uintptr = sqlite3.Xsqlite3_realloc64(tls, (*Percentile)(unsafe.Pointer(p)).Fa, (uint64(uint64(unsafe.Sizeof(float64(0))) * uint64(n)))) 24600 if a == uintptr(0) { 24601 sqlite3.Xsqlite3_free(tls, (*Percentile)(unsafe.Pointer(p)).Fa) 24602 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(Percentile{}))) 24603 sqlite3.Xsqlite3_result_error_nomem(tls, pCtx) 24604 return 24605 } 24606 (*Percentile)(unsafe.Pointer(p)).FnAlloc = n 24607 (*Percentile)(unsafe.Pointer(p)).Fa = a 24608 } 24609 *(*float64)(unsafe.Pointer((*Percentile)(unsafe.Pointer(p)).Fa + uintptr(libc.PostIncUint32(&(*Percentile)(unsafe.Pointer(p)).FnUsed, 1))*8)) = y 24610 } 24611 24612 // Compare to doubles for sorting using qsort() 24613 func doubleCmp(tls *libc.TLS, pA uintptr, pB uintptr) int32 { /* percentile.c:170:25: */ 24614 var a float64 = *(*float64)(unsafe.Pointer(pA)) 24615 var b float64 = *(*float64)(unsafe.Pointer(pB)) 24616 if a == b { 24617 return 0 24618 } 24619 if a < b { 24620 return -1 24621 } 24622 return +1 24623 } 24624 24625 // Called to compute the final output of percentile() and to clean 24626 // up all allocated memory. 24627 func percentFinal(tls *libc.TLS, pCtx uintptr) { /* percentile.c:182:13: */ 24628 var p uintptr 24629 var i1 uint32 24630 var i2 uint32 24631 var v1 float64 24632 var v2 float64 24633 var ix float64 24634 var vx float64 24635 p = sqlite3.Xsqlite3_aggregate_context(tls, pCtx, 0) 24636 if p == uintptr(0) { 24637 return 24638 } 24639 if (*Percentile)(unsafe.Pointer(p)).Fa == uintptr(0) { 24640 return 24641 } 24642 if (*Percentile)(unsafe.Pointer(p)).FnUsed != 0 { 24643 libc.Xqsort(tls, (*Percentile)(unsafe.Pointer(p)).Fa, uint64((*Percentile)(unsafe.Pointer(p)).FnUsed), uint64(unsafe.Sizeof(float64(0))), *(*uintptr)(unsafe.Pointer(&struct { 24644 f func(*libc.TLS, uintptr, uintptr) int32 24645 }{doubleCmp}))) 24646 ix = ((((*Percentile)(unsafe.Pointer(p)).FrPct - 1.0) * (float64((*Percentile)(unsafe.Pointer(p)).FnUsed - uint32(1)))) * 0.01) 24647 i1 = uint32(ix) 24648 if (ix == float64(i1)) || (i1 == ((*Percentile)(unsafe.Pointer(p)).FnUsed - uint32(1))) { 24649 i2 = i1 24650 } else { 24651 i2 = (i1 + uint32(1)) 24652 } 24653 v1 = *(*float64)(unsafe.Pointer((*Percentile)(unsafe.Pointer(p)).Fa + uintptr(i1)*8)) 24654 v2 = *(*float64)(unsafe.Pointer((*Percentile)(unsafe.Pointer(p)).Fa + uintptr(i2)*8)) 24655 vx = (v1 + ((v2 - v1) * (ix - float64(i1)))) 24656 sqlite3.Xsqlite3_result_double(tls, pCtx, vx) 24657 } 24658 sqlite3.Xsqlite3_free(tls, (*Percentile)(unsafe.Pointer(p)).Fa) 24659 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(Percentile{}))) 24660 } 24661 24662 func sqlite3_percentile_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* percentile.c:208:5: */ 24663 var rc int32 = SQLITE_OK 24664 _ = pApi 24665 24666 _ = pzErrMsg // Unused parameter 24667 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+5958 /* "percentile" */, 2, 24668 (SQLITE_UTF8 | SQLITE_INNOCUOUS), uintptr(0), 24669 uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 24670 f func(*libc.TLS, uintptr, int32, uintptr) 24671 }{percentStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{percentFinal}))) 24672 return rc 24673 } 24674 24675 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 24676 // This file is part of the GNU C Library. 24677 // 24678 // The GNU C Library is free software; you can redistribute it and/or 24679 // modify it under the terms of the GNU Lesser General Public 24680 // License as published by the Free Software Foundation; either 24681 // version 2.1 of the License, or (at your option) any later version. 24682 // 24683 // The GNU C Library is distributed in the hope that it will be useful, 24684 // but WITHOUT ANY WARRANTY; without even the implied warranty of 24685 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24686 // Lesser General Public License for more details. 24687 // 24688 // You should have received a copy of the GNU Lesser General Public 24689 // License along with the GNU C Library; if not, see 24690 // <http://www.gnu.org/licenses/>. 24691 24692 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 24693 24694 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 24695 // This file is part of the GNU C Library. 24696 // 24697 // The GNU C Library is free software; you can redistribute it and/or 24698 // modify it under the terms of the GNU Lesser General Public 24699 // License as published by the Free Software Foundation; either 24700 // version 2.1 of the License, or (at your option) any later version. 24701 // 24702 // The GNU C Library is distributed in the hope that it will be useful, 24703 // but WITHOUT ANY WARRANTY; without even the implied warranty of 24704 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24705 // Lesser General Public License for more details. 24706 // 24707 // You should have received a copy of the GNU Lesser General Public 24708 // License along with the GNU C Library; if not, see 24709 // <http://www.gnu.org/licenses/>. 24710 24711 // void assert (int expression); 24712 // 24713 // If NDEBUG is defined, do nothing. 24714 // If not, and EXPRESSION is zero, print an error message and abort. 24715 24716 // void assert_perror (int errnum); 24717 // 24718 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 24719 // error message with the error text for ERRNUM and abort. 24720 // (This is a GNU extension.) 24721 24722 // prefixes_vtab is a subclass of sqlite3_vtab which is 24723 // underlying representation of the virtual table 24724 type prefixes_vtab1 = struct{ Fbase sqlite3_vtab } /* prefixes.c:33:9 */ 24725 24726 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 24727 // This file is part of the GNU C Library. 24728 // 24729 // The GNU C Library is free software; you can redistribute it and/or 24730 // modify it under the terms of the GNU Lesser General Public 24731 // License as published by the Free Software Foundation; either 24732 // version 2.1 of the License, or (at your option) any later version. 24733 // 24734 // The GNU C Library is distributed in the hope that it will be useful, 24735 // but WITHOUT ANY WARRANTY; without even the implied warranty of 24736 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24737 // Lesser General Public License for more details. 24738 // 24739 // You should have received a copy of the GNU Lesser General Public 24740 // License along with the GNU C Library; if not, see 24741 // <http://www.gnu.org/licenses/>. 24742 24743 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 24744 24745 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 24746 // This file is part of the GNU C Library. 24747 // 24748 // The GNU C Library is free software; you can redistribute it and/or 24749 // modify it under the terms of the GNU Lesser General Public 24750 // License as published by the Free Software Foundation; either 24751 // version 2.1 of the License, or (at your option) any later version. 24752 // 24753 // The GNU C Library is distributed in the hope that it will be useful, 24754 // but WITHOUT ANY WARRANTY; without even the implied warranty of 24755 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24756 // Lesser General Public License for more details. 24757 // 24758 // You should have received a copy of the GNU Lesser General Public 24759 // License along with the GNU C Library; if not, see 24760 // <http://www.gnu.org/licenses/>. 24761 24762 // void assert (int expression); 24763 // 24764 // If NDEBUG is defined, do nothing. 24765 // If not, and EXPRESSION is zero, print an error message and abort. 24766 24767 // void assert_perror (int errnum); 24768 // 24769 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 24770 // error message with the error text for ERRNUM and abort. 24771 // (This is a GNU extension.) 24772 24773 // prefixes_vtab is a subclass of sqlite3_vtab which is 24774 // underlying representation of the virtual table 24775 type prefixes_vtab = prefixes_vtab1 /* prefixes.c:33:30 */ 24776 24777 // prefixes_cursor is a subclass of sqlite3_vtab_cursor which will 24778 // serve as the underlying representation of a cursor that scans 24779 // over rows of the result 24780 type prefixes_cursor1 = struct { 24781 Fbase sqlite3_vtab_cursor 24782 FiRowid sqlite3_int64 24783 FzStr uintptr 24784 FnStr int32 24785 _ [4]byte 24786 } /* prefixes.c:43:9 */ 24787 24788 // prefixes_cursor is a subclass of sqlite3_vtab_cursor which will 24789 // serve as the underlying representation of a cursor that scans 24790 // over rows of the result 24791 type prefixes_cursor = prefixes_cursor1 /* prefixes.c:43:32 */ 24792 24793 // The prefixesConnect() method is invoked to create a new 24794 // template virtual table. 24795 // 24796 // Think of this routine as the constructor for prefixes_vtab objects. 24797 // 24798 // All this routine needs to do is: 24799 // 24800 // (1) Allocate the prefixes_vtab object and initialize all fields. 24801 // 24802 // (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the 24803 // result set of queries against the virtual table will look like. 24804 func prefixesConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* prefixes.c:64:12: */ 24805 var pNew uintptr 24806 var rc int32 24807 24808 rc = sqlite3.Xsqlite3_declare_vtab(tls, db, 24809 ts+5969 /* "CREATE TABLE pre..." */) 24810 if rc == SQLITE_OK { 24811 pNew = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(prefixes_vtab{}))) 24812 *(*uintptr)(unsafe.Pointer(ppVtab)) = pNew 24813 if pNew == uintptr(0) { 24814 return SQLITE_NOMEM 24815 } 24816 libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(prefixes_vtab{}))) 24817 sqlite3.Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_INNOCUOUS, 0) 24818 } 24819 return rc 24820 } 24821 24822 // This method is the destructor for prefixes_vtab objects. 24823 func prefixesDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* prefixes.c:90:12: */ 24824 var p uintptr = pVtab 24825 sqlite3.Xsqlite3_free(tls, p) 24826 return SQLITE_OK 24827 } 24828 24829 // Constructor for a new prefixes_cursor object. 24830 func prefixesOpen(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* prefixes.c:99:12: */ 24831 var pCur uintptr 24832 pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(prefixes_cursor{}))) 24833 if pCur == uintptr(0) { 24834 return SQLITE_NOMEM 24835 } 24836 libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(prefixes_cursor{}))) 24837 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) 24838 return SQLITE_OK 24839 } 24840 24841 // Destructor for a prefixes_cursor. 24842 func prefixesClose(tls *libc.TLS, cur uintptr) int32 { /* prefixes.c:111:12: */ 24843 var pCur uintptr = cur 24844 sqlite3.Xsqlite3_free(tls, (*prefixes_cursor)(unsafe.Pointer(pCur)).FzStr) 24845 sqlite3.Xsqlite3_free(tls, pCur) 24846 return SQLITE_OK 24847 } 24848 24849 // Advance a prefixes_cursor to its next row of output. 24850 func prefixesNext(tls *libc.TLS, cur uintptr) int32 { /* prefixes.c:122:12: */ 24851 var pCur uintptr = cur 24852 (*prefixes_cursor)(unsafe.Pointer(pCur)).FiRowid++ 24853 return SQLITE_OK 24854 } 24855 24856 // Return values of columns for the row at which the prefixes_cursor 24857 // is currently pointing. 24858 func prefixesColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* prefixes.c:132:12: */ 24859 var pCur uintptr = cur 24860 switch i { 24861 case 0: 24862 sqlite3.Xsqlite3_result_text(tls, ctx, (*prefixes_cursor)(unsafe.Pointer(pCur)).FzStr, ((*prefixes_cursor)(unsafe.Pointer(pCur)).FnStr - int32((*prefixes_cursor)(unsafe.Pointer(pCur)).FiRowid)), 24863 uintptr(0)) 24864 break 24865 default: 24866 sqlite3.Xsqlite3_result_text(tls, ctx, (*prefixes_cursor)(unsafe.Pointer(pCur)).FzStr, (*prefixes_cursor)(unsafe.Pointer(pCur)).FnStr, uintptr(0)) 24867 break 24868 } 24869 return SQLITE_OK 24870 } 24871 24872 // Return the rowid for the current row. In this implementation, the 24873 // rowid is the same as the output value. 24874 func prefixesRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* prefixes.c:154:12: */ 24875 var pCur uintptr = cur 24876 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*prefixes_cursor)(unsafe.Pointer(pCur)).FiRowid 24877 return SQLITE_OK 24878 } 24879 24880 // Return TRUE if the cursor has been moved off of the last 24881 // row of output. 24882 func prefixesEof(tls *libc.TLS, cur uintptr) int32 { /* prefixes.c:164:12: */ 24883 var pCur uintptr = cur 24884 return (libc.Bool32((*prefixes_cursor)(unsafe.Pointer(pCur)).FiRowid > sqlite3_int64((*prefixes_cursor)(unsafe.Pointer(pCur)).FnStr))) 24885 } 24886 24887 // This method is called to "rewind" the prefixes_cursor object back 24888 // to the first row of output. This method is always called at least 24889 // once prior to any call to prefixesColumn() or prefixesRowid() or 24890 // prefixesEof(). 24891 func prefixesFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* prefixes.c:175:12: */ 24892 bp := tls.Alloc(8) 24893 defer tls.Free(8) 24894 24895 var pCur uintptr = pVtabCursor 24896 sqlite3.Xsqlite3_free(tls, (*prefixes_cursor)(unsafe.Pointer(pCur)).FzStr) 24897 if argc > 0 { 24898 (*prefixes_cursor)(unsafe.Pointer(pCur)).FzStr = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))))) 24899 (*prefixes_cursor)(unsafe.Pointer(pCur)).FnStr = func() int32 { 24900 if (*prefixes_cursor)(unsafe.Pointer(pCur)).FzStr != 0 { 24901 return int32(libc.Xstrlen(tls, (*prefixes_cursor)(unsafe.Pointer(pCur)).FzStr)) 24902 } 24903 return 0 24904 }() 24905 } else { 24906 (*prefixes_cursor)(unsafe.Pointer(pCur)).FzStr = uintptr(0) 24907 (*prefixes_cursor)(unsafe.Pointer(pCur)).FnStr = 0 24908 } 24909 (*prefixes_cursor)(unsafe.Pointer(pCur)).FiRowid = int64(0) 24910 return SQLITE_OK 24911 } 24912 24913 // SQLite will invoke this method one or more times while planning a query 24914 // that uses the virtual table. This routine needs to create 24915 // a query plan for each invocation and compute an estimated cost for that 24916 // plan. 24917 func prefixesBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* prefixes.c:199:12: */ 24918 // Search for a usable equality constraint against column 1 24919 // (original_string) and use it if at all possible 24920 var i int32 24921 var p uintptr 24922 24923 i = 0 24924 p = (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint 24925 __1: 24926 if !(i < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { 24927 goto __3 24928 } 24929 { 24930 if (*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn != 1 { 24931 goto __2 24932 } 24933 if int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) != SQLITE_INDEX_CONSTRAINT_EQ { 24934 goto __2 24935 } 24936 if !(int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable) != 0) { 24937 goto __2 24938 } 24939 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 1 24940 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) 24941 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(10) 24942 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(10) 24943 return SQLITE_OK 24944 24945 } 24946 goto __2 24947 __2: 24948 i++ 24949 p += 12 24950 goto __1 24951 goto __3 24952 __3: 24953 ; 24954 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(1000000000) 24955 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1000000000) 24956 return SQLITE_OK 24957 } 24958 24959 // This following structure defines all the methods for the 24960 // virtual table. 24961 var prefixesModule = sqlite3_module{ 24962 /* xConnect */ FxConnect: 0, 24963 /* xBestIndex */ FxBestIndex: 0, 24964 /* xDisconnect */ FxDisconnect: 0, 24965 /* xOpen */ FxOpen: 0, 24966 /* xClose */ FxClose: 0, 24967 /* xFilter */ FxFilter: 0, 24968 /* xNext */ FxNext: 0, 24969 /* xEof */ FxEof: 0, 24970 /* xColumn */ FxColumn: 0, 24971 /* xRowid */ FxRowid: 0, 24972 } /* prefixes.c:227:23 */ 24973 24974 // This is a copy of the SQLITE_SKIP_UTF8(zIn) macro in sqliteInt.h. 24975 // 24976 // Assuming zIn points to the first byte of a UTF-8 character, 24977 // advance zIn to point to the first byte of the next UTF-8 character. 24978 24979 // Implementation of function prefix_length(). This function accepts two 24980 // strings as arguments and returns the length in characters (not bytes), 24981 // of the longest prefix shared by the two strings. For example: 24982 // 24983 // prefix_length('abcdxxx', 'abcyy') == 3 24984 // prefix_length('abcdxxx', 'bcyyy') == 0 24985 // prefix_length('abcdxxx', 'ab') == 2 24986 // prefix_length('ab', 'abcd') == 2 24987 // 24988 // This function assumes the input is well-formed utf-8. If it is not, 24989 // it is possible for this function to return -1. 24990 func prefixLengthFunc(tls *libc.TLS, ctx uintptr, nVal int32, apVal uintptr) { /* prefixes.c:279:13: */ 24991 var nByte int32 // Number of bytes to compare 24992 var nRet int32 = 0 // Return value 24993 var zL uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal))) 24994 var zR uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) 24995 var nL int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal))) 24996 var nR int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) 24997 var i int32 24998 24999 nByte = func() int32 { 25000 if nL > nR { 25001 return nL 25002 } 25003 return nR 25004 }() 25005 for i = 0; i < nByte; i++ { 25006 if int32(*(*uint8)(unsafe.Pointer(zL + uintptr(i)))) != int32(*(*uint8)(unsafe.Pointer(zR + uintptr(i)))) { 25007 break 25008 } 25009 if (int32(*(*uint8)(unsafe.Pointer(zL + uintptr(i)))) & 0xC0) != 0x80 { 25010 nRet++ 25011 } 25012 } 25013 25014 if (int32(*(*uint8)(unsafe.Pointer(zL + uintptr(i)))) & 0xC0) == 0x80 { 25015 nRet-- 25016 } 25017 sqlite3.Xsqlite3_result_int(tls, ctx, nRet) 25018 } 25019 25020 func sqlite3_prefixes_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* prefixes.c:305:5: */ 25021 var rc int32 = SQLITE_OK 25022 _ = pApi 25023 25024 rc = sqlite3.Xsqlite3_create_module(tls, db, ts+6033 /* "prefixes" */, uintptr(unsafe.Pointer(&prefixesModule)), uintptr(0)) 25025 if rc == SQLITE_OK { 25026 rc = sqlite3.Xsqlite3_create_function(tls, 25027 db, ts+6042 /* "prefix_length" */, 2, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 25028 f func(*libc.TLS, uintptr, int32, uintptr) 25029 }{prefixLengthFunc})), uintptr(0), uintptr(0)) 25030 } 25031 return rc 25032 } 25033 25034 // The following macros redefine the API routines so that they are 25035 // redirected through the global sqlite3_api structure. 25036 // 25037 // This header file is also used by the loadext.c source file 25038 // (part of the main SQLite library - not an extension) so that 25039 // it can get access to the sqlite3_api_routines structure 25040 // definition. But the main library does not want to redefine 25041 // the API. So the redefinition macros are only valid if the 25042 // SQLITE_CORE macros is undefined. 25043 25044 // This case when the file is being statically linked into the 25045 // application 25046 25047 // The following #defines change the names of some functions implemented in 25048 // this file to prevent name collisions with C-library functions of the 25049 // same name. 25050 25051 // The end-of-input character 25052 25053 // The NFA is implemented as sequence of opcodes taken from the following 25054 // set. Each opcode has a single integer argument. 25055 25056 // Each opcode is a "state" in the NFA 25057 type ReStateNumber = uint16 /* regexp.c:98:24 */ 25058 25059 // Because this is an NFA and not a DFA, multiple states can be active at 25060 // once. An instance of the following object records all active states in 25061 // the NFA. The implementation is optimized for the common case where the 25062 // number of actives states is small. 25063 type ReStateSet1 = struct { 25064 FnState uint32 25065 _ [4]byte 25066 FaState uintptr 25067 } /* regexp.c:105:9 */ 25068 25069 // Because this is an NFA and not a DFA, multiple states can be active at 25070 // once. An instance of the following object records all active states in 25071 // the NFA. The implementation is optimized for the common case where the 25072 // number of actives states is small. 25073 type ReStateSet = ReStateSet1 /* regexp.c:108:3 */ 25074 25075 // An input string read one character at a time. 25076 type ReInput1 = struct { 25077 Fz uintptr 25078 Fi int32 25079 Fmx int32 25080 } /* regexp.c:112:9 */ 25081 25082 // An input string read one character at a time. 25083 type ReInput = ReInput1 /* regexp.c:112:24 */ 25084 25085 // A compiled NFA (or an NFA that is in the process of being compiled) is 25086 // an instance of the following object. 25087 type ReCompiled1 = struct { 25088 FsIn ReInput 25089 FzErr uintptr 25090 FaOp uintptr 25091 FaArg uintptr 25092 FxNextChar uintptr 25093 FzInit [12]uint8 25094 FnInit int32 25095 FnState uint32 25096 FnAlloc uint32 25097 } /* regexp.c:122:9 */ 25098 25099 // A compiled NFA (or an NFA that is in the process of being compiled) is 25100 // an instance of the following object. 25101 type ReCompiled = ReCompiled1 /* regexp.c:122:27 */ 25102 25103 // Add a state to the given state set if it is not already there 25104 func re_add_state(tls *libc.TLS, pSet uintptr, newState int32) { /* regexp.c:136:13: */ 25105 var i uint32 25106 for i = uint32(0); i < (*ReStateSet)(unsafe.Pointer(pSet)).FnState; i++ { 25107 if int32(*(*ReStateNumber)(unsafe.Pointer((*ReStateSet)(unsafe.Pointer(pSet)).FaState + uintptr(i)*2))) == newState { 25108 return 25109 } 25110 } 25111 *(*ReStateNumber)(unsafe.Pointer((*ReStateSet)(unsafe.Pointer(pSet)).FaState + uintptr(libc.PostIncUint32(&(*ReStateSet)(unsafe.Pointer(pSet)).FnState, 1))*2)) = ReStateNumber(newState) 25112 } 25113 25114 // Extract the next unicode character from *pzIn and return it. Advance 25115 // *pzIn to the first byte past the end of the character returned. To 25116 // be clear: this routine converts utf8 to unicode. This routine is 25117 // optimized for the common case where the next character is a single byte. 25118 func re_next_char(tls *libc.TLS, p uintptr) uint32 { /* regexp.c:147:17: */ 25119 var c uint32 25120 if (*ReInput)(unsafe.Pointer(p)).Fi >= (*ReInput)(unsafe.Pointer(p)).Fmx { 25121 return uint32(0) 25122 } 25123 c = uint32(*(*uint8)(unsafe.Pointer((*ReInput)(unsafe.Pointer(p)).Fz + uintptr(libc.PostIncInt32(&(*ReInput)(unsafe.Pointer(p)).Fi, 1))))) 25124 if c >= uint32(0x80) { 25125 if (((c & uint32(0xe0)) == uint32(0xc0)) && ((*ReInput)(unsafe.Pointer(p)).Fi < (*ReInput)(unsafe.Pointer(p)).Fmx)) && ((int32(*(*uint8)(unsafe.Pointer((*ReInput)(unsafe.Pointer(p)).Fz + uintptr((*ReInput)(unsafe.Pointer(p)).Fi)))) & 0xc0) == 0x80) { 25126 c = (((c & uint32(0x1f)) << 6) | (uint32(int32(*(*uint8)(unsafe.Pointer((*ReInput)(unsafe.Pointer(p)).Fz + uintptr(libc.PostIncInt32(&(*ReInput)(unsafe.Pointer(p)).Fi, 1))))) & 0x3f))) 25127 if c < uint32(0x80) { 25128 c = uint32(0xfffd) 25129 } 25130 } else if ((((c & uint32(0xf0)) == uint32(0xe0)) && (((*ReInput)(unsafe.Pointer(p)).Fi + 1) < (*ReInput)(unsafe.Pointer(p)).Fmx)) && ((int32(*(*uint8)(unsafe.Pointer((*ReInput)(unsafe.Pointer(p)).Fz + uintptr((*ReInput)(unsafe.Pointer(p)).Fi)))) & 0xc0) == 0x80)) && 25131 ((int32(*(*uint8)(unsafe.Pointer((*ReInput)(unsafe.Pointer(p)).Fz + uintptr(((*ReInput)(unsafe.Pointer(p)).Fi + 1))))) & 0xc0) == 0x80) { 25132 c = ((((c & uint32(0x0f)) << 12) | (uint32((int32(*(*uint8)(unsafe.Pointer((*ReInput)(unsafe.Pointer(p)).Fz + uintptr((*ReInput)(unsafe.Pointer(p)).Fi)))) & 0x3f) << 6))) | (uint32(int32(*(*uint8)(unsafe.Pointer((*ReInput)(unsafe.Pointer(p)).Fz + uintptr(((*ReInput)(unsafe.Pointer(p)).Fi + 1))))) & 0x3f))) 25133 *(*int32)(unsafe.Pointer(p + 8 /* &.i */)) += (2) 25134 if (c <= uint32(0x7ff)) || ((c >= uint32(0xd800)) && (c <= uint32(0xdfff))) { 25135 c = uint32(0xfffd) 25136 } 25137 } else if (((((c & uint32(0xf8)) == uint32(0xf0)) && (((*ReInput)(unsafe.Pointer(p)).Fi + 3) < (*ReInput)(unsafe.Pointer(p)).Fmx)) && ((int32(*(*uint8)(unsafe.Pointer((*ReInput)(unsafe.Pointer(p)).Fz + uintptr((*ReInput)(unsafe.Pointer(p)).Fi)))) & 0xc0) == 0x80)) && 25138 ((int32(*(*uint8)(unsafe.Pointer((*ReInput)(unsafe.Pointer(p)).Fz + uintptr(((*ReInput)(unsafe.Pointer(p)).Fi + 1))))) & 0xc0) == 0x80)) && ((int32(*(*uint8)(unsafe.Pointer((*ReInput)(unsafe.Pointer(p)).Fz + uintptr(((*ReInput)(unsafe.Pointer(p)).Fi + 2))))) & 0xc0) == 0x80) { 25139 c = (((((c & uint32(0x07)) << 18) | (uint32((int32(*(*uint8)(unsafe.Pointer((*ReInput)(unsafe.Pointer(p)).Fz + uintptr((*ReInput)(unsafe.Pointer(p)).Fi)))) & 0x3f) << 12))) | (uint32((int32(*(*uint8)(unsafe.Pointer((*ReInput)(unsafe.Pointer(p)).Fz + uintptr(((*ReInput)(unsafe.Pointer(p)).Fi + 1))))) & 0x3f) << 6))) | 25140 (uint32(int32(*(*uint8)(unsafe.Pointer((*ReInput)(unsafe.Pointer(p)).Fz + uintptr(((*ReInput)(unsafe.Pointer(p)).Fi + 2))))) & 0x3f))) 25141 *(*int32)(unsafe.Pointer(p + 8 /* &.i */)) += (3) 25142 if (c <= uint32(0xffff)) || (c > uint32(0x10ffff)) { 25143 c = uint32(0xfffd) 25144 } 25145 } else { 25146 c = uint32(0xfffd) 25147 } 25148 } 25149 return c 25150 } 25151 25152 func re_next_char_nocase(tls *libc.TLS, p uintptr) uint32 { /* regexp.c:172:17: */ 25153 var c uint32 = re_next_char(tls, p) 25154 if (c >= uint32('A')) && (c <= uint32('Z')) { 25155 c = c + (uint32('a' - 'A')) 25156 } 25157 return c 25158 } 25159 25160 // Return true if c is a perl "word" character: [A-Za-z0-9_] 25161 func re_word_char(tls *libc.TLS, c int32) int32 { /* regexp.c:179:12: */ 25162 return (libc.Bool32(((((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'z'))) || 25163 ((c >= 'A') && (c <= 'Z'))) || (c == '_'))) 25164 } 25165 25166 // Return true if c is a "digit" character: [0-9] 25167 func re_digit_char(tls *libc.TLS, c int32) int32 { /* regexp.c:185:12: */ 25168 return (libc.Bool32((c >= '0') && (c <= '9'))) 25169 } 25170 25171 // Return true if c is a perl "space" character: [ \t\r\n\v\f] 25172 func re_space_char(tls *libc.TLS, c int32) int32 { /* regexp.c:190:12: */ 25173 return (libc.Bool32((((((c == ' ') || (c == '\t')) || (c == '\n')) || (c == '\r')) || (c == '\v')) || (c == '\f'))) 25174 } 25175 25176 // Run a compiled regular expression on the zero-terminated input 25177 // string zIn[]. Return true on a match and false if there is no match. 25178 func sqlite3re_match(tls *libc.TLS, pRe uintptr, zIn uintptr, nIn int32) int32 { /* regexp.c:197:12: */ 25179 bp := tls.Alloc(248) 25180 defer tls.Free(248) 25181 25182 // var aStateSet [2]ReStateSet at bp, 32 25183 25184 var pThis uintptr 25185 var pNext uintptr 25186 // var aSpace [100]ReStateNumber at bp+32, 200 25187 25188 var pToFree uintptr 25189 var i uint32 25190 var iSwap uint32 25191 var c int32 25192 var cPrev int32 25193 var rc int32 25194 // var in ReInput at bp+232, 16 25195 25196 var x uint8 25197 var j int32 25198 var n int32 25199 var hit int32 25200 var x1 int32 25201 i = uint32(0) 25202 iSwap = uint32(0) 25203 c = (RE_EOF + 1) 25204 cPrev = 0 25205 rc = 0 25206 25207 (*ReInput)(unsafe.Pointer(bp + 232 /* &in */)).Fz = zIn 25208 (*ReInput)(unsafe.Pointer(bp + 232 /* &in */)).Fi = 0 25209 (*ReInput)(unsafe.Pointer(bp + 232 /* &in */)).Fmx = func() int32 { 25210 if nIn >= 0 { 25211 return nIn 25212 } 25213 return int32(libc.Xstrlen(tls, zIn)) 25214 }() 25215 25216 // Look for the initial prefix match, if there is one. 25217 if !((*ReCompiled)(unsafe.Pointer(pRe)).FnInit != 0) { 25218 goto __1 25219 } 25220 x = *(*uint8)(unsafe.Pointer((pRe + 48 /* &.zInit */))) 25221 __2: 25222 if !((((*ReInput)(unsafe.Pointer(bp+232 /* &in */)).Fi + (*ReCompiled)(unsafe.Pointer(pRe)).FnInit) <= (*ReInput)(unsafe.Pointer(bp+232 /* &in */)).Fmx) && 25223 ((int32(*(*uint8)(unsafe.Pointer(zIn + uintptr((*ReInput)(unsafe.Pointer(bp+232 /* &in */)).Fi)))) != int32(x)) || (libc.Xstrncmp(tls, (zIn+uintptr((*ReInput)(unsafe.Pointer(bp+232 /* &in */)).Fi)), pRe+48 /* &.zInit */, uint64((*ReCompiled)(unsafe.Pointer(pRe)).FnInit)) != 0))) { 25224 goto __3 25225 } 25226 (*ReInput)(unsafe.Pointer(bp+232 /* &in */)).Fi++ 25227 goto __2 25228 __3: 25229 ; 25230 if !(((*ReInput)(unsafe.Pointer(bp+232 /* &in */)).Fi + (*ReCompiled)(unsafe.Pointer(pRe)).FnInit) > (*ReInput)(unsafe.Pointer(bp+232 /* &in */)).Fmx) { 25231 goto __4 25232 } 25233 return 0 25234 __4: 25235 ; 25236 __1: 25237 ; 25238 25239 if !(uint64((*ReCompiled)(unsafe.Pointer(pRe)).FnState) <= (uint64(unsafe.Sizeof([100]ReStateNumber{})) / (uint64(unsafe.Sizeof(ReStateNumber(0))) * uint64(2)))) { 25240 goto __5 25241 } 25242 pToFree = uintptr(0) 25243 (*ReStateSet)(unsafe.Pointer(bp /* &aStateSet */)).FaState = bp + 32 /* &aSpace[0] */ 25244 goto __6 25245 __5: 25246 pToFree = sqlite3.Xsqlite3_malloc64(tls, (uint64((uint64(unsafe.Sizeof(ReStateNumber(0))) * uint64(2)) * uint64((*ReCompiled)(unsafe.Pointer(pRe)).FnState)))) 25247 if !(pToFree == uintptr(0)) { 25248 goto __7 25249 } 25250 return -1 25251 __7: 25252 ; 25253 (*ReStateSet)(unsafe.Pointer(bp /* &aStateSet */)).FaState = pToFree 25254 __6: 25255 ; 25256 (*ReStateSet)(unsafe.Pointer(bp /* &aStateSet */ + 1*16)).FaState = ((*ReStateSet)(unsafe.Pointer(bp /* &aStateSet */)).FaState + uintptr((*ReCompiled)(unsafe.Pointer(pRe)).FnState)*2) 25257 pNext = (bp /* &aStateSet */ + 1*16) 25258 (*ReStateSet)(unsafe.Pointer(pNext)).FnState = uint32(0) 25259 re_add_state(tls, pNext, 0) 25260 __8: 25261 if !((c != RE_EOF) && ((*ReStateSet)(unsafe.Pointer(pNext)).FnState > uint32(0))) { 25262 goto __9 25263 } 25264 cPrev = c 25265 c = int32((*(*func(*libc.TLS, uintptr) uint32)(unsafe.Pointer((pRe + 40 /* &.xNextChar */))))(tls, bp+232 /* &in */)) 25266 pThis = pNext 25267 pNext = (bp /* &aStateSet */ + uintptr(iSwap)*16) 25268 iSwap = (uint32(1) - iSwap) 25269 (*ReStateSet)(unsafe.Pointer(pNext)).FnState = uint32(0) 25270 i = uint32(0) 25271 __10: 25272 if !(i < (*ReStateSet)(unsafe.Pointer(pThis)).FnState) { 25273 goto __12 25274 } 25275 x1 = int32(*(*ReStateNumber)(unsafe.Pointer((*ReStateSet)(unsafe.Pointer(pThis)).FaState + uintptr(i)*2))) 25276 switch int32(*(*int8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaOp + uintptr(x1)))) { 25277 case RE_OP_MATCH: 25278 goto __14 25279 case RE_OP_ANY: 25280 goto __15 25281 case RE_OP_WORD: 25282 goto __16 25283 case RE_OP_NOTWORD: 25284 goto __17 25285 case RE_OP_DIGIT: 25286 goto __18 25287 case RE_OP_NOTDIGIT: 25288 goto __19 25289 case RE_OP_SPACE: 25290 goto __20 25291 case RE_OP_NOTSPACE: 25292 goto __21 25293 case RE_OP_BOUNDARY: 25294 goto __22 25295 case RE_OP_ANYSTAR: 25296 goto __23 25297 case RE_OP_FORK: 25298 goto __24 25299 case RE_OP_GOTO: 25300 goto __25 25301 case RE_OP_ACCEPT: 25302 goto __26 25303 case RE_OP_CC_INC: 25304 goto __27 25305 case RE_OP_CC_EXC: 25306 goto __28 25307 } 25308 goto __13 25309 __14: 25310 if !(*(*int32)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaArg + uintptr(x1)*4)) == c) { 25311 goto __29 25312 } 25313 re_add_state(tls, pNext, (x1 + 1)) 25314 __29: 25315 ; 25316 goto __13 25317 25318 __15: 25319 re_add_state(tls, pNext, (x1 + 1)) 25320 goto __13 25321 25322 __16: 25323 if !(re_word_char(tls, c) != 0) { 25324 goto __30 25325 } 25326 re_add_state(tls, pNext, (x1 + 1)) 25327 __30: 25328 ; 25329 goto __13 25330 25331 __17: 25332 if !(!(re_word_char(tls, c) != 0)) { 25333 goto __31 25334 } 25335 re_add_state(tls, pNext, (x1 + 1)) 25336 __31: 25337 ; 25338 goto __13 25339 25340 __18: 25341 if !(re_digit_char(tls, c) != 0) { 25342 goto __32 25343 } 25344 re_add_state(tls, pNext, (x1 + 1)) 25345 __32: 25346 ; 25347 goto __13 25348 25349 __19: 25350 if !(!(re_digit_char(tls, c) != 0)) { 25351 goto __33 25352 } 25353 re_add_state(tls, pNext, (x1 + 1)) 25354 __33: 25355 ; 25356 goto __13 25357 25358 __20: 25359 if !(re_space_char(tls, c) != 0) { 25360 goto __34 25361 } 25362 re_add_state(tls, pNext, (x1 + 1)) 25363 __34: 25364 ; 25365 goto __13 25366 25367 __21: 25368 if !(!(re_space_char(tls, c) != 0)) { 25369 goto __35 25370 } 25371 re_add_state(tls, pNext, (x1 + 1)) 25372 __35: 25373 ; 25374 goto __13 25375 25376 __22: 25377 if !(re_word_char(tls, c) != re_word_char(tls, cPrev)) { 25378 goto __36 25379 } 25380 re_add_state(tls, pThis, (x1 + 1)) 25381 __36: 25382 ; 25383 goto __13 25384 25385 __23: 25386 re_add_state(tls, pNext, x1) 25387 re_add_state(tls, pThis, (x1 + 1)) 25388 goto __13 25389 25390 __24: 25391 re_add_state(tls, pThis, (x1 + *(*int32)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaArg + uintptr(x1)*4)))) 25392 re_add_state(tls, pThis, (x1 + 1)) 25393 goto __13 25394 25395 __25: 25396 re_add_state(tls, pThis, (x1 + *(*int32)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaArg + uintptr(x1)*4)))) 25397 goto __13 25398 25399 __26: 25400 rc = 1 25401 goto re_match_end 25402 25403 __27: 25404 __28: 25405 j = 1 25406 n = *(*int32)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaArg + uintptr(x1)*4)) 25407 hit = 0 25408 j = 1 25409 __37: 25410 if !((j > 0) && (j < n)) { 25411 goto __39 25412 } 25413 if !(int32(*(*int8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaOp + uintptr((x1 + j))))) == RE_OP_CC_VALUE) { 25414 goto __40 25415 } 25416 if !(*(*int32)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaArg + uintptr((x1+j))*4)) == c) { 25417 goto __42 25418 } 25419 hit = 1 25420 j = -1 25421 __42: 25422 ; 25423 goto __41 25424 __40: 25425 if !((*(*int32)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaArg + uintptr((x1+j))*4)) <= c) && (*(*int32)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaArg + uintptr(((x1+j)+1))*4)) >= c)) { 25426 goto __43 25427 } 25428 hit = 1 25429 j = -1 25430 goto __44 25431 __43: 25432 j++ 25433 __44: 25434 ; 25435 __41: 25436 ; 25437 goto __38 25438 __38: 25439 j++ 25440 goto __37 25441 goto __39 25442 __39: 25443 ; 25444 if !(int32(*(*int8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaOp + uintptr(x1)))) == RE_OP_CC_EXC) { 25445 goto __45 25446 } 25447 hit = libc.BoolInt32(!(hit != 0)) 25448 __45: 25449 ; 25450 if !(hit != 0) { 25451 goto __46 25452 } 25453 re_add_state(tls, pNext, (x1 + n)) 25454 __46: 25455 ; 25456 goto __13 25457 25458 __13: 25459 ; 25460 goto __11 25461 __11: 25462 i++ 25463 goto __10 25464 goto __12 25465 __12: 25466 ; 25467 goto __8 25468 __9: 25469 ; 25470 i = uint32(0) 25471 __47: 25472 if !(i < (*ReStateSet)(unsafe.Pointer(pNext)).FnState) { 25473 goto __49 25474 } 25475 if !(int32(*(*int8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaOp + uintptr(*(*ReStateNumber)(unsafe.Pointer((*ReStateSet)(unsafe.Pointer(pNext)).FaState + uintptr(i)*2)))))) == RE_OP_ACCEPT) { 25476 goto __50 25477 } 25478 rc = 1 25479 goto __49 25480 __50: 25481 ; 25482 goto __48 25483 __48: 25484 i++ 25485 goto __47 25486 goto __49 25487 __49: 25488 ; 25489 re_match_end: 25490 sqlite3.Xsqlite3_free(tls, pToFree) 25491 return rc 25492 } 25493 25494 // Resize the opcode and argument arrays for an RE under construction. 25495 func re_resize(tls *libc.TLS, p uintptr, N int32) int32 { /* regexp.c:337:12: */ 25496 var aOp uintptr 25497 var aArg uintptr 25498 aOp = sqlite3.Xsqlite3_realloc64(tls, (*ReCompiled)(unsafe.Pointer(p)).FaOp, (uint64(uint64(N) * uint64(unsafe.Sizeof(int8(0)))))) 25499 if aOp == uintptr(0) { 25500 return 1 25501 } 25502 (*ReCompiled)(unsafe.Pointer(p)).FaOp = aOp 25503 aArg = sqlite3.Xsqlite3_realloc64(tls, (*ReCompiled)(unsafe.Pointer(p)).FaArg, (uint64(uint64(N) * uint64(unsafe.Sizeof(int32(0)))))) 25504 if aArg == uintptr(0) { 25505 return 1 25506 } 25507 (*ReCompiled)(unsafe.Pointer(p)).FaArg = aArg 25508 (*ReCompiled)(unsafe.Pointer(p)).FnAlloc = uint32(N) 25509 return 0 25510 } 25511 25512 // Insert a new opcode and argument into an RE under construction. The 25513 // insertion point is just prior to existing opcode iBefore. 25514 func re_insert(tls *libc.TLS, p uintptr, iBefore int32, op int32, arg int32) int32 { /* regexp.c:353:12: */ 25515 var i int32 25516 if ((*ReCompiled)(unsafe.Pointer(p)).FnAlloc <= (*ReCompiled)(unsafe.Pointer(p)).FnState) && (re_resize(tls, p, (int32((*ReCompiled)(unsafe.Pointer(p)).FnAlloc*uint32(2)))) != 0) { 25517 return 0 25518 } 25519 for i = int32((*ReCompiled)(unsafe.Pointer(p)).FnState); i > iBefore; i-- { 25520 *(*int8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(p)).FaOp + uintptr(i))) = *(*int8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(p)).FaOp + uintptr((i - 1)))) 25521 *(*int32)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(p)).FaArg + uintptr(i)*4)) = *(*int32)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(p)).FaArg + uintptr((i-1))*4)) 25522 } 25523 (*ReCompiled)(unsafe.Pointer(p)).FnState++ 25524 *(*int8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(p)).FaOp + uintptr(iBefore))) = int8(op) 25525 *(*int32)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(p)).FaArg + uintptr(iBefore)*4)) = arg 25526 return iBefore 25527 } 25528 25529 // Append a new opcode and argument to the end of the RE under construction. 25530 func re_append(tls *libc.TLS, p uintptr, op int32, arg int32) int32 { /* regexp.c:368:12: */ 25531 return re_insert(tls, p, int32((*ReCompiled)(unsafe.Pointer(p)).FnState), op, arg) 25532 } 25533 25534 // Make a copy of N opcodes starting at iStart onto the end of the RE 25535 // under construction. 25536 func re_copy(tls *libc.TLS, p uintptr, iStart int32, N int32) { /* regexp.c:375:13: */ 25537 if (((*ReCompiled)(unsafe.Pointer(p)).FnState + uint32(N)) >= (*ReCompiled)(unsafe.Pointer(p)).FnAlloc) && (re_resize(tls, p, (int32(((*ReCompiled)(unsafe.Pointer(p)).FnAlloc*uint32(2))+uint32(N)))) != 0) { 25538 return 25539 } 25540 libc.Xmemcpy(tls, ((*ReCompiled)(unsafe.Pointer(p)).FaOp + uintptr((*ReCompiled)(unsafe.Pointer(p)).FnState)), ((*ReCompiled)(unsafe.Pointer(p)).FaOp + uintptr(iStart)), (uint64(N) * uint64(unsafe.Sizeof(int8(0))))) 25541 libc.Xmemcpy(tls, ((*ReCompiled)(unsafe.Pointer(p)).FaArg + uintptr((*ReCompiled)(unsafe.Pointer(p)).FnState)*4), ((*ReCompiled)(unsafe.Pointer(p)).FaArg + uintptr(iStart)*4), (uint64(N) * uint64(unsafe.Sizeof(int32(0))))) 25542 *(*uint32)(unsafe.Pointer(p + 64 /* &.nState */)) += (uint32(N)) 25543 } 25544 25545 // Return true if c is a hexadecimal digit character: [0-9a-fA-F] 25546 // If c is a hex digit, also set *pV = (*pV)*16 + valueof(c). If 25547 // c is not a hex digit *pV is unchanged. 25548 func re_hex(tls *libc.TLS, c int32, pV uintptr) int32 { /* regexp.c:386:12: */ 25549 if (c >= '0') && (c <= '9') { 25550 c = c - ('0') 25551 } else if (c >= 'a') && (c <= 'f') { 25552 c = c - ('a' - 10) 25553 } else if (c >= 'A') && (c <= 'F') { 25554 c = c - ('A' - 10) 25555 } else { 25556 return 0 25557 } 25558 *(*int32)(unsafe.Pointer(pV)) = (((*(*int32)(unsafe.Pointer(pV))) * 16) + (c & 0xff)) 25559 return 1 25560 } 25561 25562 // A backslash character has been seen, read the next character and 25563 // return its interpretation. 25564 func re_esc_char(tls *libc.TLS, p uintptr) uint32 { /* regexp.c:403:17: */ 25565 bp := tls.Alloc(4) 25566 defer tls.Free(4) 25567 25568 var i int32 25569 *(*int32)(unsafe.Pointer(bp /* v */)) = 0 25570 var c int8 25571 if (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi >= (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fmx { 25572 return uint32(0) 25573 } 25574 c = int8(*(*uint8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(p)).FsIn.Fz + uintptr((*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi)))) 25575 if (int32(c) == 'u') && (((*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi + 4) < (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fmx) { 25576 var zIn uintptr = ((*ReCompiled)(unsafe.Pointer(p)).FsIn.Fz + uintptr((*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi)) 25577 if (((re_hex(tls, int32(*(*uint8)(unsafe.Pointer(zIn + 1))), bp /* &v */) != 0) && 25578 (re_hex(tls, int32(*(*uint8)(unsafe.Pointer(zIn + 2))), bp /* &v */) != 0)) && 25579 (re_hex(tls, int32(*(*uint8)(unsafe.Pointer(zIn + 3))), bp /* &v */) != 0)) && 25580 (re_hex(tls, int32(*(*uint8)(unsafe.Pointer(zIn + 4))), bp /* &v */) != 0) { 25581 *(*int32)(unsafe.Pointer(p /* &.sIn */ + 8 /* &.i */)) += (5) 25582 return uint32(*(*int32)(unsafe.Pointer(bp /* v */))) 25583 } 25584 } 25585 if (int32(c) == 'x') && (((*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi + 2) < (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fmx) { 25586 var zIn uintptr = ((*ReCompiled)(unsafe.Pointer(p)).FsIn.Fz + uintptr((*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi)) 25587 if (re_hex(tls, int32(*(*uint8)(unsafe.Pointer(zIn + 1))), bp /* &v */) != 0) && 25588 (re_hex(tls, int32(*(*uint8)(unsafe.Pointer(zIn + 2))), bp /* &v */) != 0) { 25589 *(*int32)(unsafe.Pointer(p /* &.sIn */ + 8 /* &.i */)) += (3) 25590 return uint32(*(*int32)(unsafe.Pointer(bp /* v */))) 25591 } 25592 } 25593 for i = 0; (zEsc[i] != 0) && (int32(zEsc[i]) != int32(c)); i++ { 25594 } 25595 if zEsc[i] != 0 { 25596 if i < 6 { 25597 c = zTrans[i] 25598 } 25599 (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi++ 25600 } else { 25601 (*ReCompiled)(unsafe.Pointer(p)).FzErr = ts + 6056 /* "unknown \\ escape" */ 25602 } 25603 return uint32(c) 25604 } 25605 25606 var zEsc = *(*[21]int8)(unsafe.Pointer(ts + 6073 /* "afnrtv\\()*.+?[$^..." */)) /* regexp.c:404:21 */ 25607 var zTrans = *(*[7]int8)(unsafe.Pointer(ts + 6094 /* "\a\f\n\r\t\v" */)) /* regexp.c:405:21 */ 25608 25609 // Peek at the next byte of input 25610 func rePeek(tls *libc.TLS, p uintptr) uint8 { /* regexp.c:444:22: */ 25611 if (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi < (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fmx { 25612 return *(*uint8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(p)).FsIn.Fz + uintptr((*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi))) 25613 } 25614 return uint8(0) 25615 } 25616 25617 // Compile RE text into a sequence of opcodes. Continue up to the 25618 // first unmatched ")" character, then return. If an error is found, 25619 // return a pointer to the error message string. 25620 func re_subcompile_re(tls *libc.TLS, p uintptr) uintptr { /* regexp.c:452:19: */ 25621 var zErr uintptr 25622 var iStart int32 25623 var iEnd int32 25624 var iGoto int32 25625 iStart = int32((*ReCompiled)(unsafe.Pointer(p)).FnState) 25626 zErr = re_subcompile_string(tls, p) 25627 if zErr != 0 { 25628 return zErr 25629 } 25630 for int32(rePeek(tls, p)) == '|' { 25631 iEnd = int32((*ReCompiled)(unsafe.Pointer(p)).FnState) 25632 re_insert(tls, p, iStart, RE_OP_FORK, ((iEnd + 2) - iStart)) 25633 iGoto = re_append(tls, p, RE_OP_GOTO, 0) 25634 (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi++ 25635 zErr = re_subcompile_string(tls, p) 25636 if zErr != 0 { 25637 return zErr 25638 } 25639 *(*int32)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(p)).FaArg + uintptr(iGoto)*4)) = (int32((*ReCompiled)(unsafe.Pointer(p)).FnState - uint32(iGoto))) 25640 } 25641 return uintptr(0) 25642 } 25643 25644 // Compile an element of regular expression text (anything that can be 25645 // an operand to the "|" operator). Return NULL on success or a pointer 25646 // to the error message if there is a problem. 25647 func re_subcompile_string(tls *libc.TLS, p uintptr) uintptr { /* regexp.c:474:19: */ 25648 var iPrev int32 = -1 25649 var iStart int32 25650 var c uint32 25651 var zErr uintptr 25652 for (libc.AssignUint32(&c, (*(*func(*libc.TLS, uintptr) uint32)(unsafe.Pointer((p + 40 /* &.xNextChar */))))(tls, (p /* &.sIn */)))) != uint32(0) { 25653 iStart = int32((*ReCompiled)(unsafe.Pointer(p)).FnState) 25654 switch c { 25655 case uint32('|'): 25656 fallthrough 25657 case uint32('$'): 25658 fallthrough 25659 case uint32(')'): 25660 { 25661 (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi-- 25662 return uintptr(0) 25663 25664 } 25665 case uint32('('): 25666 { 25667 zErr = re_subcompile_re(tls, p) 25668 if zErr != 0 { 25669 return zErr 25670 } 25671 if int32(rePeek(tls, p)) != ')' { 25672 return ts + 6101 /* "unmatched '('" */ 25673 } 25674 (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi++ 25675 break 25676 25677 } 25678 case uint32('.'): 25679 { 25680 if int32(rePeek(tls, p)) == '*' { 25681 re_append(tls, p, RE_OP_ANYSTAR, 0) 25682 (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi++ 25683 } else { 25684 re_append(tls, p, RE_OP_ANY, 0) 25685 } 25686 break 25687 25688 } 25689 case uint32('*'): 25690 { 25691 if iPrev < 0 { 25692 return ts + 6115 /* "'*' without oper..." */ 25693 } 25694 re_insert(tls, p, iPrev, RE_OP_GOTO, (int32(((*ReCompiled)(unsafe.Pointer(p)).FnState - uint32(iPrev)) + uint32(1)))) 25695 re_append(tls, p, RE_OP_FORK, (int32((uint32(iPrev) - (*ReCompiled)(unsafe.Pointer(p)).FnState) + uint32(1)))) 25696 break 25697 25698 } 25699 case uint32('+'): 25700 { 25701 if iPrev < 0 { 25702 return ts + 6135 /* "'+' without oper..." */ 25703 } 25704 re_append(tls, p, RE_OP_FORK, (int32(uint32(iPrev) - (*ReCompiled)(unsafe.Pointer(p)).FnState))) 25705 break 25706 25707 } 25708 case uint32('?'): 25709 { 25710 if iPrev < 0 { 25711 return ts + 6155 /* "'?' without oper..." */ 25712 } 25713 re_insert(tls, p, iPrev, RE_OP_FORK, (int32(((*ReCompiled)(unsafe.Pointer(p)).FnState - uint32(iPrev)) + uint32(1)))) 25714 break 25715 25716 } 25717 case uint32('{'): 25718 { 25719 var m int32 = 0 25720 var n int32 = 0 25721 var sz int32 25722 var j int32 25723 if iPrev < 0 { 25724 return ts + 6175 /* "'{m,n}' without ..." */ 25725 } 25726 for ((libc.AssignUint32(&c, uint32(rePeek(tls, p)))) >= uint32('0')) && (c <= uint32('9')) { 25727 m = (int32(((uint32(m * 10)) + c) - uint32('0'))) 25728 (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi++ 25729 } 25730 n = m 25731 if c == uint32(',') { 25732 (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi++ 25733 n = 0 25734 for ((libc.AssignUint32(&c, uint32(rePeek(tls, p)))) >= uint32('0')) && (c <= uint32('9')) { 25735 n = (int32(((uint32(n * 10)) + c) - uint32('0'))) 25736 (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi++ 25737 } 25738 } 25739 if c != uint32('}') { 25740 return ts + 6199 /* "unmatched '{'" */ 25741 } 25742 if (n > 0) && (n < m) { 25743 return ts + 6213 /* "n less than m in..." */ 25744 } 25745 (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi++ 25746 sz = (int32((*ReCompiled)(unsafe.Pointer(p)).FnState - uint32(iPrev))) 25747 if m == 0 { 25748 if n == 0 { 25749 return ts + 6238 /* "both m and n are..." */ 25750 } 25751 re_insert(tls, p, iPrev, RE_OP_FORK, (sz + 1)) 25752 n-- 25753 } else { 25754 for j = 1; j < m; j++ { 25755 re_copy(tls, p, iPrev, sz) 25756 } 25757 } 25758 for j = m; j < n; j++ { 25759 re_append(tls, p, RE_OP_FORK, (sz + 1)) 25760 re_copy(tls, p, iPrev, sz) 25761 } 25762 if (n == 0) && (m > 0) { 25763 re_append(tls, p, RE_OP_FORK, -sz) 25764 } 25765 break 25766 25767 } 25768 case uint32('['): 25769 { 25770 var iFirst int32 = int32((*ReCompiled)(unsafe.Pointer(p)).FnState) 25771 if int32(rePeek(tls, p)) == '^' { 25772 re_append(tls, p, RE_OP_CC_EXC, 0) 25773 (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi++ 25774 } else { 25775 re_append(tls, p, RE_OP_CC_INC, 0) 25776 } 25777 for (libc.AssignUint32(&c, (*(*func(*libc.TLS, uintptr) uint32)(unsafe.Pointer((p + 40 /* &.xNextChar */))))(tls, (p /* &.sIn */)))) != uint32(0) { 25778 if (c == uint32('[')) && (int32(rePeek(tls, p)) == ':') { 25779 return ts + 6271 /* "POSIX character ..." */ 25780 } 25781 if c == uint32('\\') { 25782 c = re_esc_char(tls, p) 25783 } 25784 if int32(rePeek(tls, p)) == '-' { 25785 re_append(tls, p, RE_OP_CC_RANGE, int32(c)) 25786 (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi++ 25787 c = (*(*func(*libc.TLS, uintptr) uint32)(unsafe.Pointer((p + 40 /* &.xNextChar */))))(tls, (p /* &.sIn */)) 25788 if c == uint32('\\') { 25789 c = re_esc_char(tls, p) 25790 } 25791 re_append(tls, p, RE_OP_CC_RANGE, int32(c)) 25792 } else { 25793 re_append(tls, p, RE_OP_CC_VALUE, int32(c)) 25794 } 25795 if int32(rePeek(tls, p)) == ']' { 25796 (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi++ 25797 break 25798 } 25799 } 25800 if c == uint32(0) { 25801 return ts + 6309 /* "unclosed '['" */ 25802 } 25803 *(*int32)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(p)).FaArg + uintptr(iFirst)*4)) = (int32((*ReCompiled)(unsafe.Pointer(p)).FnState - uint32(iFirst))) 25804 break 25805 25806 } 25807 case uint32('\\'): 25808 { 25809 var specialOp int32 = 0 25810 switch int32(rePeek(tls, p)) { 25811 case 'b': 25812 specialOp = RE_OP_BOUNDARY 25813 break 25814 case 'd': 25815 specialOp = RE_OP_DIGIT 25816 break 25817 case 'D': 25818 specialOp = RE_OP_NOTDIGIT 25819 break 25820 case 's': 25821 specialOp = RE_OP_SPACE 25822 break 25823 case 'S': 25824 specialOp = RE_OP_NOTSPACE 25825 break 25826 case 'w': 25827 specialOp = RE_OP_WORD 25828 break 25829 case 'W': 25830 specialOp = RE_OP_NOTWORD 25831 break 25832 } 25833 if specialOp != 0 { 25834 (*ReCompiled)(unsafe.Pointer(p)).FsIn.Fi++ 25835 re_append(tls, p, specialOp, 0) 25836 } else { 25837 c = re_esc_char(tls, p) 25838 re_append(tls, p, RE_OP_MATCH, int32(c)) 25839 } 25840 break 25841 25842 } 25843 default: 25844 { 25845 re_append(tls, p, RE_OP_MATCH, int32(c)) 25846 break 25847 25848 } 25849 } 25850 iPrev = iStart 25851 } 25852 return uintptr(0) 25853 } 25854 25855 // Free and reclaim all the memory used by a previously compiled 25856 // regular expression. Applications should invoke this routine once 25857 // for every call to re_compile() to avoid memory leaks. 25858 func sqlite3re_free(tls *libc.TLS, pRe uintptr) { /* regexp.c:613:13: */ 25859 if pRe != 0 { 25860 sqlite3.Xsqlite3_free(tls, (*ReCompiled)(unsafe.Pointer(pRe)).FaOp) 25861 sqlite3.Xsqlite3_free(tls, (*ReCompiled)(unsafe.Pointer(pRe)).FaArg) 25862 sqlite3.Xsqlite3_free(tls, pRe) 25863 } 25864 } 25865 25866 // Compile a textual regular expression in zIn[] into a compiled regular 25867 // expression suitable for us by re_match() and return a pointer to the 25868 // compiled regular expression in *ppRe. Return NULL on success or an 25869 // error message if something goes wrong. 25870 func sqlite3re_compile(tls *libc.TLS, ppRe uintptr, zIn uintptr, noCase int32) uintptr { /* regexp.c:627:19: */ 25871 var pRe uintptr 25872 var zErr uintptr 25873 var i int32 25874 var j int32 25875 25876 *(*uintptr)(unsafe.Pointer(ppRe)) = uintptr(0) 25877 pRe = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(ReCompiled{}))) 25878 if pRe == uintptr(0) { 25879 return ts + 1930 /* "out of memory" */ 25880 } 25881 libc.Xmemset(tls, pRe, 0, uint64(unsafe.Sizeof(ReCompiled{}))) 25882 (*ReCompiled)(unsafe.Pointer(pRe)).FxNextChar = func() uintptr { 25883 if noCase != 0 { 25884 return *(*uintptr)(unsafe.Pointer(&struct { 25885 f func(*libc.TLS, uintptr) uint32 25886 }{re_next_char_nocase})) 25887 } 25888 return *(*uintptr)(unsafe.Pointer(&struct { 25889 f func(*libc.TLS, uintptr) uint32 25890 }{re_next_char})) 25891 }() 25892 if re_resize(tls, pRe, 30) != 0 { 25893 sqlite3re_free(tls, pRe) 25894 return ts + 1930 /* "out of memory" */ 25895 } 25896 if int32(*(*int8)(unsafe.Pointer(zIn))) == '^' { 25897 zIn++ 25898 } else { 25899 re_append(tls, pRe, RE_OP_ANYSTAR, 0) 25900 } 25901 (*ReCompiled)(unsafe.Pointer(pRe)).FsIn.Fz = zIn 25902 (*ReCompiled)(unsafe.Pointer(pRe)).FsIn.Fi = 0 25903 (*ReCompiled)(unsafe.Pointer(pRe)).FsIn.Fmx = int32(libc.Xstrlen(tls, zIn)) 25904 zErr = re_subcompile_re(tls, pRe) 25905 if zErr != 0 { 25906 sqlite3re_free(tls, pRe) 25907 return zErr 25908 } 25909 if (int32(rePeek(tls, pRe)) == '$') && (((*ReCompiled)(unsafe.Pointer(pRe)).FsIn.Fi + 1) >= (*ReCompiled)(unsafe.Pointer(pRe)).FsIn.Fmx) { 25910 re_append(tls, pRe, RE_OP_MATCH, RE_EOF) 25911 re_append(tls, pRe, RE_OP_ACCEPT, 0) 25912 *(*uintptr)(unsafe.Pointer(ppRe)) = pRe 25913 } else if (*ReCompiled)(unsafe.Pointer(pRe)).FsIn.Fi >= (*ReCompiled)(unsafe.Pointer(pRe)).FsIn.Fmx { 25914 re_append(tls, pRe, RE_OP_ACCEPT, 0) 25915 *(*uintptr)(unsafe.Pointer(ppRe)) = pRe 25916 } else { 25917 sqlite3re_free(tls, pRe) 25918 return ts + 6322 /* "unrecognized cha..." */ 25919 } 25920 25921 // The following is a performance optimization. If the regex begins with 25922 // ".*" (if the input regex lacks an initial "^") and afterwards there are 25923 // one or more matching characters, enter those matching characters into 25924 // zInit[]. The re_match() routine can then search ahead in the input 25925 // string looking for the initial match without having to run the whole 25926 // regex engine over the string. Do not worry able trying to match 25927 // unicode characters beyond plane 0 - those are very rare and this is 25928 // just an optimization. 25929 if int32(*(*int8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaOp))) == RE_OP_ANYSTAR { 25930 j = 0 25931 i = 1 25932 for ; (uint64(j) < (uint64(unsafe.Sizeof([12]uint8{})) - uint64(2))) && (int32(*(*int8)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaOp + uintptr(i)))) == RE_OP_MATCH); i++ { 25933 var x uint32 = uint32(*(*int32)(unsafe.Pointer((*ReCompiled)(unsafe.Pointer(pRe)).FaArg + uintptr(i)*4))) 25934 if x <= uint32(127) { 25935 *(*uint8)(unsafe.Pointer((pRe + 48 /* &.zInit */) + uintptr(libc.PostIncInt32(&j, 1)))) = uint8(x) 25936 } else if x <= uint32(0xfff) { 25937 *(*uint8)(unsafe.Pointer((pRe + 48 /* &.zInit */) + uintptr(libc.PostIncInt32(&j, 1)))) = (uint8(uint32(0xc0) | (x >> 6))) 25938 *(*uint8)(unsafe.Pointer((pRe + 48 /* &.zInit */) + uintptr(libc.PostIncInt32(&j, 1)))) = (uint8(uint32(0x80) | (x & uint32(0x3f)))) 25939 } else if x <= uint32(0xffff) { 25940 *(*uint8)(unsafe.Pointer((pRe + 48 /* &.zInit */) + uintptr(libc.PostIncInt32(&j, 1)))) = (uint8(uint32(0xd0) | (x >> 12))) 25941 *(*uint8)(unsafe.Pointer((pRe + 48 /* &.zInit */) + uintptr(libc.PostIncInt32(&j, 1)))) = (uint8(uint32(0x80) | ((x >> 6) & uint32(0x3f)))) 25942 *(*uint8)(unsafe.Pointer((pRe + 48 /* &.zInit */) + uintptr(libc.PostIncInt32(&j, 1)))) = (uint8(uint32(0x80) | (x & uint32(0x3f)))) 25943 } else { 25944 break 25945 } 25946 } 25947 if (j > 0) && (int32(*(*uint8)(unsafe.Pointer((pRe + 48 /* &.zInit */) + uintptr((j - 1))))) == 0) { 25948 j-- 25949 } 25950 (*ReCompiled)(unsafe.Pointer(pRe)).FnInit = j 25951 } 25952 return (*ReCompiled)(unsafe.Pointer(pRe)).FzErr 25953 } 25954 25955 // Implementation of the regexp() SQL function. This function implements 25956 // the build-in REGEXP operator. The first argument to the function is the 25957 // pattern and the second argument is the string. So, the SQL statements: 25958 // 25959 // A REGEXP B 25960 // 25961 // is implemented as regexp(B,A). 25962 func re_sql_func(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* regexp.c:707:13: */ 25963 bp := tls.Alloc(8) 25964 defer tls.Free(8) 25965 25966 // var pRe uintptr at bp, 8 25967 // Compiled regular expression 25968 var zPattern uintptr // The regular expression 25969 var zStr uintptr // String being searched 25970 var zErr uintptr // Compile error message 25971 var setAux int32 = 0 // True to invoke sqlite3_set_auxdata() 25972 25973 *(*uintptr)(unsafe.Pointer(bp /* pRe */)) = sqlite3.Xsqlite3_get_auxdata(tls, context, 0) 25974 if *(*uintptr)(unsafe.Pointer(bp /* pRe */)) == uintptr(0) { 25975 zPattern = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 25976 if zPattern == uintptr(0) { 25977 return 25978 } 25979 zErr = sqlite3re_compile(tls, bp /* &pRe */, zPattern, 0) 25980 if zErr != 0 { 25981 sqlite3re_free(tls, *(*uintptr)(unsafe.Pointer(bp /* pRe */))) 25982 sqlite3.Xsqlite3_result_error(tls, context, zErr, -1) 25983 return 25984 } 25985 if *(*uintptr)(unsafe.Pointer(bp /* pRe */)) == uintptr(0) { 25986 sqlite3.Xsqlite3_result_error_nomem(tls, context) 25987 return 25988 } 25989 setAux = 1 25990 } 25991 zStr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 25992 if zStr != uintptr(0) { 25993 sqlite3.Xsqlite3_result_int(tls, context, sqlite3re_match(tls, *(*uintptr)(unsafe.Pointer(bp /* pRe */)), zStr, -1)) 25994 } 25995 if setAux != 0 { 25996 sqlite3.Xsqlite3_set_auxdata(tls, context, 0, *(*uintptr)(unsafe.Pointer(bp /* pRe */)), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3re_free}))) 25997 } 25998 } 25999 26000 // Invoke this routine to register the regexp() function with the 26001 // SQLite database connection. 26002 func sqlite3_regexp_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* regexp.c:750:5: */ 26003 var rc int32 = SQLITE_OK 26004 _ = pApi 26005 26006 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+6345 /* "regexp" */, 2, (SQLITE_UTF8 | SQLITE_INNOCUOUS), 26007 uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 26008 f func(*libc.TLS, uintptr, int32, uintptr) 26009 }{re_sql_func})), uintptr(0), uintptr(0)) 26010 return rc 26011 } 26012 26013 // The following macros redefine the API routines so that they are 26014 // redirected through the global sqlite3_api structure. 26015 // 26016 // This header file is also used by the loadext.c source file 26017 // (part of the main SQLite library - not an extension) so that 26018 // it can get access to the sqlite3_api_routines structure 26019 // definition. But the main library does not want to redefine 26020 // the API. So the redefinition macros are only valid if the 26021 // SQLITE_CORE macros is undefined. 26022 26023 // This case when the file is being statically linked into the 26024 // application 26025 26026 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 26027 // This file is part of the GNU C Library. 26028 // 26029 // The GNU C Library is free software; you can redistribute it and/or 26030 // modify it under the terms of the GNU Lesser General Public 26031 // License as published by the Free Software Foundation; either 26032 // version 2.1 of the License, or (at your option) any later version. 26033 // 26034 // The GNU C Library is distributed in the hope that it will be useful, 26035 // but WITHOUT ANY WARRANTY; without even the implied warranty of 26036 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26037 // Lesser General Public License for more details. 26038 // 26039 // You should have received a copy of the GNU Lesser General Public 26040 // License along with the GNU C Library; if not, see 26041 // <http://www.gnu.org/licenses/>. 26042 26043 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 26044 26045 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 26046 // This file is part of the GNU C Library. 26047 // 26048 // The GNU C Library is free software; you can redistribute it and/or 26049 // modify it under the terms of the GNU Lesser General Public 26050 // License as published by the Free Software Foundation; either 26051 // version 2.1 of the License, or (at your option) any later version. 26052 // 26053 // The GNU C Library is distributed in the hope that it will be useful, 26054 // but WITHOUT ANY WARRANTY; without even the implied warranty of 26055 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26056 // Lesser General Public License for more details. 26057 // 26058 // You should have received a copy of the GNU Lesser General Public 26059 // License along with the GNU C Library; if not, see 26060 // <http://www.gnu.org/licenses/>. 26061 26062 // These are defined by the user (or the compiler) 26063 // to specify the desired environment: 26064 // 26065 // __STRICT_ANSI__ ISO Standard C. 26066 // _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. 26067 // _ISOC11_SOURCE Extensions to ISO C99 from ISO C11. 26068 // __STDC_WANT_LIB_EXT2__ 26069 // Extensions to ISO C99 from TR 27431-2:2010. 26070 // __STDC_WANT_IEC_60559_BFP_EXT__ 26071 // Extensions to ISO C11 from TS 18661-1:2014. 26072 // __STDC_WANT_IEC_60559_FUNCS_EXT__ 26073 // Extensions to ISO C11 from TS 18661-4:2015. 26074 // __STDC_WANT_IEC_60559_TYPES_EXT__ 26075 // Extensions to ISO C11 from TS 18661-3:2015. 26076 // 26077 // _POSIX_SOURCE IEEE Std 1003.1. 26078 // _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; 26079 // if >=199309L, add IEEE Std 1003.1b-1993; 26080 // if >=199506L, add IEEE Std 1003.1c-1995; 26081 // if >=200112L, all of IEEE 1003.1-2004 26082 // if >=200809L, all of IEEE 1003.1-2008 26083 // _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if 26084 // Single Unix conformance is wanted, to 600 for the 26085 // sixth revision, to 700 for the seventh revision. 26086 // _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. 26087 // _LARGEFILE_SOURCE Some more functions for correct standard I/O. 26088 // _LARGEFILE64_SOURCE Additional functionality from LFS for large files. 26089 // _FILE_OFFSET_BITS=N Select default filesystem interface. 26090 // _ATFILE_SOURCE Additional *at interfaces. 26091 // _GNU_SOURCE All of the above, plus GNU extensions. 26092 // _DEFAULT_SOURCE The default set of features (taking precedence over 26093 // __STRICT_ANSI__). 26094 // 26095 // _FORTIFY_SOURCE Add security hardening to many library functions. 26096 // Set to 1 or 2; 2 performs stricter checks than 1. 26097 // 26098 // _REENTRANT, _THREAD_SAFE 26099 // Obsolete; equivalent to _POSIX_C_SOURCE=199506L. 26100 // 26101 // The `-ansi' switch to the GNU C compiler, and standards conformance 26102 // options such as `-std=c99', define __STRICT_ANSI__. If none of 26103 // these are defined, or if _DEFAULT_SOURCE is defined, the default is 26104 // to have _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to 26105 // 200809L, as well as enabling miscellaneous functions from BSD and 26106 // SVID. If more than one of these are defined, they accumulate. For 26107 // example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE together 26108 // give you ISO C, 1003.1, and 1003.2, but nothing else. 26109 // 26110 // These are defined by this file and are used by the 26111 // header files to decide what to declare or define: 26112 // 26113 // __GLIBC_USE (F) Define things from feature set F. This is defined 26114 // to 1 or 0; the subsequent macros are either defined 26115 // or undefined, and those tests should be moved to 26116 // __GLIBC_USE. 26117 // __USE_ISOC11 Define ISO C11 things. 26118 // __USE_ISOC99 Define ISO C99 things. 26119 // __USE_ISOC95 Define ISO C90 AMD1 (C95) things. 26120 // __USE_ISOCXX11 Define ISO C++11 things. 26121 // __USE_POSIX Define IEEE Std 1003.1 things. 26122 // __USE_POSIX2 Define IEEE Std 1003.2 things. 26123 // __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. 26124 // __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. 26125 // __USE_XOPEN Define XPG things. 26126 // __USE_XOPEN_EXTENDED Define X/Open Unix things. 26127 // __USE_UNIX98 Define Single Unix V2 things. 26128 // __USE_XOPEN2K Define XPG6 things. 26129 // __USE_XOPEN2KXSI Define XPG6 XSI things. 26130 // __USE_XOPEN2K8 Define XPG7 things. 26131 // __USE_XOPEN2K8XSI Define XPG7 XSI things. 26132 // __USE_LARGEFILE Define correct standard I/O things. 26133 // __USE_LARGEFILE64 Define LFS things with separate names. 26134 // __USE_FILE_OFFSET64 Define 64bit interface as default. 26135 // __USE_MISC Define things from 4.3BSD or System V Unix. 26136 // __USE_ATFILE Define *at interfaces and AT_* constants for them. 26137 // __USE_GNU Define GNU extensions. 26138 // __USE_FORTIFY_LEVEL Additional security measures used, according to level. 26139 // 26140 // The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are 26141 // defined by this file unconditionally. `__GNU_LIBRARY__' is provided 26142 // only for compatibility. All new code should use the other symbols 26143 // to test for features. 26144 // 26145 // All macros listed above as possibly being defined by this file are 26146 // explicitly undefined if they are not explicitly defined. 26147 // Feature-test macros that are not defined by the user or compiler 26148 // but are implied by the other feature-test macros defined (or by the 26149 // lack of any definitions) are defined by the file. 26150 // 26151 // ISO C feature test macros depend on the definition of the macro 26152 // when an affected header is included, not when the first system 26153 // header is included, and so they are handled in 26154 // <bits/libc-header-start.h>, which does not have a multiple include 26155 // guard. Feature test macros that can be handled from the first 26156 // system header included are handled here. 26157 26158 // Undefine everything, so we get a clean slate. 26159 26160 // Suppress kernel-name space pollution unless user expressedly asks 26161 // for it. 26162 26163 // Convenience macro to test the version of gcc. 26164 // Use like this: 26165 // #if __GNUC_PREREQ (2,8) 26166 // ... code requiring gcc 2.8 or later ... 26167 // #endif 26168 // Note: only works for GCC 2.0 and later, because __GNUC_MINOR__ was 26169 // added in 2.0. 26170 26171 // Similarly for clang. Features added to GCC after version 4.2 may 26172 // or may not also be available in clang, and clang's definitions of 26173 // __GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such 26174 // features can be queried via __has_extension/__has_feature. 26175 26176 // Whether to use feature set F. 26177 26178 // _BSD_SOURCE and _SVID_SOURCE are deprecated aliases for 26179 // _DEFAULT_SOURCE. If _DEFAULT_SOURCE is present we do not 26180 // issue a warning; the expectation is that the source is being 26181 // transitioned to use the new macro. 26182 26183 // If _GNU_SOURCE was defined by the user, turn on all the other features. 26184 26185 // If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined, 26186 // define _DEFAULT_SOURCE. 26187 26188 // This is to enable the ISO C11 extension. 26189 26190 // This is to enable the ISO C99 extension. 26191 26192 // This is to enable the ISO C90 Amendment 1:1995 extension. 26193 26194 // If none of the ANSI/POSIX macros are defined, or if _DEFAULT_SOURCE 26195 // is defined, use POSIX.1-2008 (or another version depending on 26196 // _XOPEN_SOURCE). 26197 26198 // Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be 26199 // defined in all multithreaded code. GNU libc has not required this 26200 // for many years. We now treat them as compatibility synonyms for 26201 // _POSIX_C_SOURCE=199506L, which is the earliest level of POSIX with 26202 // comprehensive support for multithreaded code. Using them never 26203 // lowers the selected level of POSIX conformance, only raises it. 26204 26205 // The function 'gets' existed in C89, but is impossible to use 26206 // safely. It has been removed from ISO C11 and ISO C++14. Note: for 26207 // compatibility with various implementations of <cstdio>, this test 26208 // must consider only the value of __cplusplus when compiling C++. 26209 26210 // Get definitions of __STDC_* predefined macros, if the compiler has 26211 // not preincluded this header automatically. 26212 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 26213 // This file is part of the GNU C Library. 26214 // 26215 // The GNU C Library is free software; you can redistribute it and/or 26216 // modify it under the terms of the GNU Lesser General Public 26217 // License as published by the Free Software Foundation; either 26218 // version 2.1 of the License, or (at your option) any later version. 26219 // 26220 // The GNU C Library is distributed in the hope that it will be useful, 26221 // but WITHOUT ANY WARRANTY; without even the implied warranty of 26222 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26223 // Lesser General Public License for more details. 26224 // 26225 // You should have received a copy of the GNU Lesser General Public 26226 // License along with the GNU C Library; if not, see 26227 // <http://www.gnu.org/licenses/>. 26228 26229 // This macro indicates that the installed library is the GNU C Library. 26230 // For historic reasons the value now is 6 and this will stay from now 26231 // on. The use of this variable is deprecated. Use __GLIBC__ and 26232 // __GLIBC_MINOR__ now (see below) when you want to test for a specific 26233 // GNU C library version and use the values in <gnu/lib-names.h> to get 26234 // the sonames of the shared libraries. 26235 26236 // Major and minor version number of the GNU C library package. Use 26237 // these macros to test for features in specific releases. 26238 26239 // This is here only because every header file already includes this one. 26240 // Copyright (C) 1992-2018 Free Software Foundation, Inc. 26241 // This file is part of the GNU C Library. 26242 // 26243 // The GNU C Library is free software; you can redistribute it and/or 26244 // modify it under the terms of the GNU Lesser General Public 26245 // License as published by the Free Software Foundation; either 26246 // version 2.1 of the License, or (at your option) any later version. 26247 // 26248 // The GNU C Library is distributed in the hope that it will be useful, 26249 // but WITHOUT ANY WARRANTY; without even the implied warranty of 26250 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26251 // Lesser General Public License for more details. 26252 // 26253 // You should have received a copy of the GNU Lesser General Public 26254 // License along with the GNU C Library; if not, see 26255 // <http://www.gnu.org/licenses/>. 26256 26257 // We are almost always included from features.h. 26258 26259 // The GNU libc does not support any K&R compilers or the traditional mode 26260 // of ISO C compilers anymore. Check for some of the combinations not 26261 // anymore supported. 26262 26263 // Some user header file might have defined this before. 26264 26265 // All functions, except those with callbacks or those that 26266 // synchronize memory, are leaf functions. 26267 26268 // GCC can always grok prototypes. For C++ programs we add throw() 26269 // to help it optimize the function calls. But this works only with 26270 // gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions 26271 // as non-throwing using a function attribute since programs can use 26272 // the -fexceptions options for C code as well. 26273 26274 // Compilers that are not clang may object to 26275 // #if defined __clang__ && __has_extension(...) 26276 // even though they do not need to evaluate the right-hand side of the &&. 26277 26278 // These two macros are not used in glibc anymore. They are kept here 26279 // only because some other projects expect the macros to be defined. 26280 26281 // For these things, GCC behaves the ANSI way normally, 26282 // and the non-ANSI way under -traditional. 26283 26284 // This is not a typedef so `const __ptr_t' does the right thing. 26285 26286 // C++ needs to know that types and declarations are C, not C++. 26287 26288 // Fortify support. 26289 26290 // Support for flexible arrays. 26291 // Headers that should use flexible arrays only if they're "real" 26292 // (e.g. only if they won't affect sizeof()) should test 26293 // #if __glibc_c99_flexarr_available. 26294 26295 // __asm__ ("xyz") is used throughout the headers to rename functions 26296 // at the assembly language level. This is wrapped by the __REDIRECT 26297 // macro, in order to support compilers that can do this some other 26298 // way. When compilers don't support asm-names at all, we have to do 26299 // preprocessor tricks instead (which don't have exactly the right 26300 // semantics, but it's the best we can do). 26301 // 26302 // Example: 26303 // int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); 26304 26305 // 26306 // #elif __SOME_OTHER_COMPILER__ 26307 // 26308 // # define __REDIRECT(name, proto, alias) name proto; _Pragma("let " #name " = " #alias) 26309 26310 // GCC has various useful declarations that can be made with the 26311 // `__attribute__' syntax. All of the ways we use this do fine if 26312 // they are omitted for compilers that don't understand it. 26313 26314 // At some point during the gcc 2.96 development the `malloc' attribute 26315 // for functions was introduced. We don't want to use it unconditionally 26316 // (although this would be possible) since it generates warnings. 26317 26318 // Tell the compiler which arguments to an allocation function 26319 // indicate the size of the allocation. 26320 26321 // At some point during the gcc 2.96 development the `pure' attribute 26322 // for functions was introduced. We don't want to use it unconditionally 26323 // (although this would be possible) since it generates warnings. 26324 26325 // This declaration tells the compiler that the value is constant. 26326 26327 // At some point during the gcc 3.1 development the `used' attribute 26328 // for functions was introduced. We don't want to use it unconditionally 26329 // (although this would be possible) since it generates warnings. 26330 26331 // Since version 3.2, gcc allows marking deprecated functions. 26332 26333 // Since version 4.5, gcc also allows one to specify the message printed 26334 // when a deprecated function is used. clang claims to be gcc 4.2, but 26335 // may also support this feature. 26336 26337 // At some point during the gcc 2.8 development the `format_arg' attribute 26338 // for functions was introduced. We don't want to use it unconditionally 26339 // (although this would be possible) since it generates warnings. 26340 // If several `format_arg' attributes are given for the same function, in 26341 // gcc-3.0 and older, all but the last one are ignored. In newer gccs, 26342 // all designated arguments are considered. 26343 26344 // At some point during the gcc 2.97 development the `strfmon' format 26345 // attribute for functions was introduced. We don't want to use it 26346 // unconditionally (although this would be possible) since it 26347 // generates warnings. 26348 26349 // The nonull function attribute allows to mark pointer parameters which 26350 // must not be NULL. 26351 26352 // If fortification mode, we warn about unused results of certain 26353 // function calls which can lead to problems. 26354 26355 // Forces a function to be always inlined. 26356 // The Linux kernel defines __always_inline in stddef.h (283d7573), and 26357 // it conflicts with this definition. Therefore undefine it first to 26358 // allow either header to be included first. 26359 26360 // Associate error messages with the source location of the call site rather 26361 // than with the source location inside the function. 26362 26363 // GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 26364 // inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ 26365 // or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions 26366 // older than 4.3 may define these macros and still not guarantee GNU inlining 26367 // semantics. 26368 // 26369 // clang++ identifies itself as gcc-4.2, but has support for GNU inlining 26370 // semantics, that can be checked fot by using the __GNUC_STDC_INLINE_ and 26371 // __GNUC_GNU_INLINE__ macro definitions. 26372 26373 // GCC 4.3 and above allow passing all anonymous arguments of an 26374 // __extern_always_inline function to some other vararg function. 26375 26376 // It is possible to compile containing GCC extensions even if GCC is 26377 // run in pedantic mode if the uses are carefully marked using the 26378 // `__extension__' keyword. But this is not generally available before 26379 // version 2.8. 26380 26381 // __restrict is known in EGCS 1.2 and above. 26382 26383 // ISO C99 also allows to declare arrays as non-overlapping. The syntax is 26384 // array_name[restrict] 26385 // GCC 3.1 supports this. 26386 26387 // Describes a char array whose address can safely be passed as the first 26388 // argument to strncpy and strncat, as the char array is not necessarily 26389 // a NUL-terminated string. 26390 26391 // Determine the wordsize from the preprocessor defines. 26392 26393 // Properties of long double type. ldbl-opt version. 26394 // Copyright (C) 2016-2018 Free Software Foundation, Inc. 26395 // This file is part of the GNU C Library. 26396 // 26397 // The GNU C Library is free software; you can redistribute it and/or 26398 // modify it under the terms of the GNU Lesser General Public 26399 // License published by the Free Software Foundation; either 26400 // version 2.1 of the License, or (at your option) any later version. 26401 // 26402 // The GNU C Library is distributed in the hope that it will be useful, 26403 // but WITHOUT ANY WARRANTY; without even the implied warranty of 26404 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26405 // Lesser General Public License for more details. 26406 // 26407 // You should have received a copy of the GNU Lesser General Public 26408 // License along with the GNU C Library; if not, see 26409 // <http://www.gnu.org/licenses/>. 26410 26411 // __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is 26412 // intended for use in preprocessor macros. 26413 // 26414 // Note: MESSAGE must be a _single_ string; concatenation of string 26415 // literals is not supported. 26416 26417 // Generic selection (ISO C11) is a C-only feature, available in GCC 26418 // since version 4.9. Previous versions do not provide generic 26419 // selection, even though they might set __STDC_VERSION__ to 201112L, 26420 // when in -std=c11 mode. Thus, we must check for !defined __GNUC__ 26421 // when testing __STDC_VERSION__ for generic selection support. 26422 // On the other hand, Clang also defines __GNUC__, so a clang-specific 26423 // check is required to enable the use of generic selection. 26424 26425 // If we don't have __REDIRECT, prototypes will be missing if 26426 // __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. 26427 26428 // Decide whether we can define 'extern inline' functions in headers. 26429 26430 // This is here only because every header file already includes this one. 26431 // Get the definitions of all the appropriate `__stub_FUNCTION' symbols. 26432 // <gnu/stubs.h> contains `#define __stub_FUNCTION' when FUNCTION is a stub 26433 // that will always return failure (and set errno to ENOSYS). 26434 // This file is automatically generated. 26435 // This file selects the right generated file of `__stub_FUNCTION' macros 26436 // based on the architecture being compiled for. 26437 26438 // Determine the wordsize from the preprocessor defines. 26439 26440 // This file is automatically generated. 26441 // It defines a symbol `__stub_FUNCTION' for each function 26442 // in the C library which is a stub, meaning it will fail 26443 // every time called, usually setting errno to ENOSYS. 26444 26445 // void assert (int expression); 26446 // 26447 // If NDEBUG is defined, do nothing. 26448 // If not, and EXPRESSION is zero, print an error message and abort. 26449 26450 // void assert_perror (int errnum); 26451 // 26452 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 26453 // error message with the error text for ERRNUM and abort. 26454 // (This is a GNU extension.) 26455 26456 // remember(V,PTR) 26457 // 26458 // Return the integer value V. Also save the value of V in a 26459 // C-language variable whose address is PTR. 26460 func rememberFunc(tls *libc.TLS, pCtx uintptr, argc int32, argv uintptr) { /* remember.c:45:13: */ 26461 var v sqlite3_int64 26462 var ptr uintptr 26463 26464 v = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) 26465 ptr = sqlite3.Xsqlite3_value_pointer(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+3931 /* "carray" */) 26466 if ptr != 0 { 26467 *(*sqlite3_int64)(unsafe.Pointer(ptr)) = v 26468 } 26469 sqlite3.Xsqlite3_result_int64(tls, pCtx, v) 26470 } 26471 26472 func sqlite3_remember_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* remember.c:62:5: */ 26473 var rc int32 = SQLITE_OK 26474 _ = pApi 26475 26476 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+6352 /* "remember" */, 2, SQLITE_UTF8, uintptr(0), 26477 *(*uintptr)(unsafe.Pointer(&struct { 26478 f func(*libc.TLS, uintptr, int32, uintptr) 26479 }{rememberFunc})), uintptr(0), uintptr(0)) 26480 return rc 26481 } 26482 26483 // series_cursor is a subclass of sqlite3_vtab_cursor which will 26484 // serve as the underlying representation of a cursor that scans 26485 // over rows of the result 26486 type series_cursor1 = struct { 26487 Fbase sqlite3_vtab_cursor 26488 FisDesc int32 26489 _ [4]byte 26490 FiRowid sqlite3_int64 26491 FiValue sqlite3_int64 26492 FmnValue sqlite3_int64 26493 FmxValue sqlite3_int64 26494 FiStep sqlite3_int64 26495 } /* series.c:83:9 */ 26496 26497 // series_cursor is a subclass of sqlite3_vtab_cursor which will 26498 // serve as the underlying representation of a cursor that scans 26499 // over rows of the result 26500 type series_cursor = series_cursor1 /* series.c:83:30 */ 26501 26502 // The seriesConnect() method is invoked to create a new 26503 // series_vtab that describes the generate_series virtual table. 26504 // 26505 // Think of this routine as the constructor for series_vtab objects. 26506 // 26507 // All this routine needs to do is: 26508 // 26509 // (1) Allocate the series_vtab object and initialize all fields. 26510 // 26511 // (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the 26512 // result set of queries against generate_series will look like. 26513 func seriesConnect(tls *libc.TLS, db uintptr, pUnused uintptr, argcUnused int32, argvUnused uintptr, ppVtab uintptr, pzErrUnused uintptr) int32 { /* series.c:107:12: */ 26514 var pNew uintptr 26515 var rc int32 26516 26517 // Column numbers 26518 26519 _ = pUnused 26520 _ = argcUnused 26521 _ = argvUnused 26522 _ = pzErrUnused 26523 rc = sqlite3.Xsqlite3_declare_vtab(tls, db, 26524 ts+6361 /* "CREATE TABLE x(v..." */) 26525 if rc == SQLITE_OK { 26526 pNew = libc.AssignPtrUintptr(ppVtab, sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(sqlite3_vtab{})))) 26527 if pNew == uintptr(0) { 26528 return SQLITE_NOMEM 26529 } 26530 libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(sqlite3_vtab{}))) 26531 sqlite3.Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_INNOCUOUS, 0) 26532 } 26533 return rc 26534 } 26535 26536 // This method is the destructor for series_cursor objects. 26537 func seriesDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* series.c:141:12: */ 26538 sqlite3.Xsqlite3_free(tls, pVtab) 26539 return SQLITE_OK 26540 } 26541 26542 // Constructor for a new series_cursor object. 26543 func seriesOpen(tls *libc.TLS, pUnused uintptr, ppCursor uintptr) int32 { /* series.c:149:12: */ 26544 var pCur uintptr 26545 _ = pUnused 26546 pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(series_cursor{}))) 26547 if pCur == uintptr(0) { 26548 return SQLITE_NOMEM 26549 } 26550 libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(series_cursor{}))) 26551 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) 26552 return SQLITE_OK 26553 } 26554 26555 // Destructor for a series_cursor. 26556 func seriesClose(tls *libc.TLS, cur uintptr) int32 { /* series.c:162:12: */ 26557 sqlite3.Xsqlite3_free(tls, cur) 26558 return SQLITE_OK 26559 } 26560 26561 // Advance a series_cursor to its next row of output. 26562 func seriesNext(tls *libc.TLS, cur uintptr) int32 { /* series.c:171:12: */ 26563 var pCur uintptr = cur 26564 if (*series_cursor)(unsafe.Pointer(pCur)).FisDesc != 0 { 26565 *(*sqlite3_int64)(unsafe.Pointer(pCur + 24 /* &.iValue */)) -= ((*series_cursor)(unsafe.Pointer(pCur)).FiStep) 26566 } else { 26567 *(*sqlite3_int64)(unsafe.Pointer(pCur + 24 /* &.iValue */)) += ((*series_cursor)(unsafe.Pointer(pCur)).FiStep) 26568 } 26569 (*series_cursor)(unsafe.Pointer(pCur)).FiRowid++ 26570 return SQLITE_OK 26571 } 26572 26573 // Return values of columns for the row at which the series_cursor 26574 // is currently pointing. 26575 func seriesColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* series.c:186:12: */ 26576 var pCur uintptr = cur 26577 var x sqlite3_int64 = int64(0) 26578 switch i { 26579 case SERIES_COLUMN_START: 26580 x = (*series_cursor)(unsafe.Pointer(pCur)).FmnValue 26581 break 26582 case SERIES_COLUMN_STOP: 26583 x = (*series_cursor)(unsafe.Pointer(pCur)).FmxValue 26584 break 26585 case SERIES_COLUMN_STEP: 26586 x = (*series_cursor)(unsafe.Pointer(pCur)).FiStep 26587 break 26588 default: 26589 x = (*series_cursor)(unsafe.Pointer(pCur)).FiValue 26590 break 26591 } 26592 sqlite3.Xsqlite3_result_int64(tls, ctx, x) 26593 return SQLITE_OK 26594 } 26595 26596 // Return the rowid for the current row. In this implementation, the 26597 // first row returned is assigned rowid value 1, and each subsequent 26598 // row a value 1 more than that of the previous. 26599 func seriesRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* series.c:208:12: */ 26600 var pCur uintptr = cur 26601 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*series_cursor)(unsafe.Pointer(pCur)).FiRowid 26602 return SQLITE_OK 26603 } 26604 26605 // Return TRUE if the cursor has been moved off of the last 26606 // row of output. 26607 func seriesEof(tls *libc.TLS, cur uintptr) int32 { /* series.c:218:12: */ 26608 var pCur uintptr = cur 26609 if (*series_cursor)(unsafe.Pointer(pCur)).FisDesc != 0 { 26610 return (libc.Bool32((*series_cursor)(unsafe.Pointer(pCur)).FiValue < (*series_cursor)(unsafe.Pointer(pCur)).FmnValue)) 26611 } else { 26612 return (libc.Bool32((*series_cursor)(unsafe.Pointer(pCur)).FiValue > (*series_cursor)(unsafe.Pointer(pCur)).FmxValue)) 26613 } 26614 return int32(0) 26615 } 26616 26617 // True to cause run-time checking of the start=, stop=, and/or step= 26618 // parameters. The only reason to do this is for testing the 26619 // constraint checking logic for virtual tables in the SQLite core. 26620 26621 // This method is called to "rewind" the series_cursor object back 26622 // to the first row of output. This method is always called at least 26623 // once prior to any call to seriesColumn() or seriesRowid() or 26624 // seriesEof(). 26625 // 26626 // The query plan selected by seriesBestIndex is passed in the idxNum 26627 // parameter. (idxStr is not used in this implementation.) idxNum 26628 // is a bitmask showing which constraints are available: 26629 // 26630 // 1: start=VALUE 26631 // 2: stop=VALUE 26632 // 4: step=VALUE 26633 // 26634 // Also, if bit 8 is set, that means that the series should be output 26635 // in descending order rather than in ascending order. If bit 16 is 26636 // set, then output must appear in ascending order. 26637 // 26638 // This routine should initialize the cursor and position it so that it 26639 // is pointing at the first row, or pointing off the end of the table 26640 // (so that seriesEof() will return true) if the table is empty. 26641 func seriesFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStrUnused uintptr, argc int32, argv uintptr) int32 { /* series.c:257:12: */ 26642 var pCur uintptr = pVtabCursor 26643 var i int32 = 0 26644 _ = idxStrUnused 26645 if (idxNum & 1) != 0 { 26646 (*series_cursor)(unsafe.Pointer(pCur)).FmnValue = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(libc.PostIncInt32(&i, 1))*8))) 26647 } else { 26648 (*series_cursor)(unsafe.Pointer(pCur)).FmnValue = int64(0) 26649 } 26650 if (idxNum & 2) != 0 { 26651 (*series_cursor)(unsafe.Pointer(pCur)).FmxValue = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(libc.PostIncInt32(&i, 1))*8))) 26652 } else { 26653 (*series_cursor)(unsafe.Pointer(pCur)).FmxValue = int64(0xffffffff) 26654 } 26655 if (idxNum & 4) != 0 { 26656 (*series_cursor)(unsafe.Pointer(pCur)).FiStep = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(libc.PostIncInt32(&i, 1))*8))) 26657 if (*series_cursor)(unsafe.Pointer(pCur)).FiStep == int64(0) { 26658 (*series_cursor)(unsafe.Pointer(pCur)).FiStep = int64(1) 26659 } else if (*series_cursor)(unsafe.Pointer(pCur)).FiStep < int64(0) { 26660 (*series_cursor)(unsafe.Pointer(pCur)).FiStep = -(*series_cursor)(unsafe.Pointer(pCur)).FiStep 26661 if (idxNum & 16) == 0 { 26662 idxNum = idxNum | (8) 26663 } 26664 } 26665 } else { 26666 (*series_cursor)(unsafe.Pointer(pCur)).FiStep = int64(1) 26667 } 26668 for i = 0; i < argc; i++ { 26669 if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) == SQLITE_NULL { 26670 // If any of the constraints have a NULL value, then return no rows. 26671 // See ticket https://www.sqlite.org/src/info/fac496b61722daf2 26672 (*series_cursor)(unsafe.Pointer(pCur)).FmnValue = int64(1) 26673 (*series_cursor)(unsafe.Pointer(pCur)).FmxValue = int64(0) 26674 break 26675 } 26676 } 26677 if (idxNum & 8) != 0 { 26678 (*series_cursor)(unsafe.Pointer(pCur)).FisDesc = 1 26679 (*series_cursor)(unsafe.Pointer(pCur)).FiValue = (*series_cursor)(unsafe.Pointer(pCur)).FmxValue 26680 if (*series_cursor)(unsafe.Pointer(pCur)).FiStep > int64(0) { 26681 *(*sqlite3_int64)(unsafe.Pointer(pCur + 24 /* &.iValue */)) -= (((*series_cursor)(unsafe.Pointer(pCur)).FmxValue - (*series_cursor)(unsafe.Pointer(pCur)).FmnValue) % (*series_cursor)(unsafe.Pointer(pCur)).FiStep) 26682 } 26683 } else { 26684 (*series_cursor)(unsafe.Pointer(pCur)).FisDesc = 0 26685 (*series_cursor)(unsafe.Pointer(pCur)).FiValue = (*series_cursor)(unsafe.Pointer(pCur)).FmnValue 26686 } 26687 (*series_cursor)(unsafe.Pointer(pCur)).FiRowid = int64(1) 26688 return SQLITE_OK 26689 } 26690 26691 // SQLite will invoke this method one or more times while planning a query 26692 // that uses the generate_series virtual table. This routine needs to create 26693 // a query plan for each invocation and compute an estimated cost for that 26694 // plan. 26695 // 26696 // In this implementation idxNum is used to represent the 26697 // query plan. idxStr is unused. 26698 // 26699 // The query plan is represented by bits in idxNum: 26700 // 26701 // (1) start = $value -- constraint exists 26702 // (2) stop = $value -- constraint exists 26703 // (4) step = $value -- constraint exists 26704 // (8) output in descending order 26705 func seriesBestIndex(tls *libc.TLS, tabUnused uintptr, pIdxInfo uintptr) int32 { /* series.c:325:12: */ 26706 bp := tls.Alloc(12) 26707 defer tls.Free(12) 26708 26709 var i int32 26710 var j int32 // Loop over constraints 26711 var idxNum int32 = 0 // The query plan bitmask 26712 var unusableMask int32 = 0 // Mask of unusable constraints 26713 var nArg int32 = 0 // Number of arguments that seriesFilter() expects 26714 // var aIdx [3]int32 at bp, 12 26715 // Constraints on start, stop, and step 26716 var pConstraint uintptr 26717 26718 // This implementation assumes that the start, stop, and step columns 26719 // are the last three columns in the virtual table. 26720 26721 _ = tabUnused 26722 *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */)) = libc.AssignPtrInt32(bp /* &aIdx */ +1*4, libc.AssignPtrInt32(bp /* &aIdx */ +2*4, -1)) 26723 pConstraint = (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint 26724 i = 0 26725 __1: 26726 if !(i < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { 26727 goto __3 26728 } 26729 { 26730 var iCol int32 // 0 for start, 1 for stop, 2 for step 26731 var iMask int32 // bitmask for those column 26732 if (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn < SERIES_COLUMN_START { 26733 goto __2 26734 } 26735 iCol = ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn - SERIES_COLUMN_START) 26736 26737 iMask = (int32(1) << iCol) 26738 if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 { 26739 unusableMask = unusableMask | (iMask) 26740 goto __2 26741 } else if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ { 26742 idxNum = idxNum | (iMask) 26743 *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + uintptr(iCol)*4)) = i 26744 } 26745 26746 } 26747 goto __2 26748 __2: 26749 i++ 26750 pConstraint += 12 26751 goto __1 26752 goto __3 26753 __3: 26754 ; 26755 for i = 0; i < 3; i++ { 26756 if (libc.AssignInt32(&j, *(*int32)(unsafe.Pointer(bp /* &aIdx[0] */ + uintptr(i)*4)))) >= 0 { 26757 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(j)*8)).FargvIndex = libc.PreIncInt32(&nArg, 1) 26758 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(j)*8)).Fomit = libc.BoolUint8(!(1 != 0)) 26759 } 26760 } 26761 if (unusableMask & ^idxNum) != 0 { 26762 // The start, stop, and step columns are inputs. Therefore if there 26763 // are unusable constraints on any of start, stop, or step then 26764 // this plan is unusable 26765 return SQLITE_CONSTRAINT 26766 } 26767 if (idxNum & 3) == 3 { 26768 // Both start= and stop= boundaries are available. This is the 26769 // the preferred case 26770 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = (float64(2 - (libc.Bool32((idxNum & 4) != 0)))) 26771 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1000) 26772 if (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy == 1 { 26773 if (*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).Fdesc != 0 { 26774 idxNum = idxNum | (8) 26775 } else { 26776 idxNum = idxNum | (16) 26777 } 26778 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 1 26779 } 26780 } else { 26781 // If either boundary is missing, we have to generate a huge span 26782 // of numbers. Make this case very expensive so that the query 26783 // planner will work hard to avoid it. 26784 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(2147483647) 26785 } 26786 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = idxNum 26787 return SQLITE_OK 26788 } 26789 26790 // This following structure defines all the methods for the 26791 // generate_series virtual table. 26792 var seriesModule = sqlite3_module{ // xCreate 26793 FxConnect: 0, // xConnect 26794 FxBestIndex: 0, // xBestIndex 26795 FxDisconnect: 0, // xDestroy 26796 FxOpen: 0, // xOpen - open a cursor 26797 FxClose: 0, // xClose - close a cursor 26798 FxFilter: 0, // xFilter - configure scan constraints 26799 FxNext: 0, // xNext - advance a cursor 26800 FxEof: 0, // xEof - check for end of scan 26801 FxColumn: 0, // xColumn - read data 26802 FxRowid: 0, // xShadowName 26803 } /* series.c:397:23 */ 26804 26805 func sqlite3_series_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* series.c:429:5: */ 26806 var rc int32 = SQLITE_OK 26807 _ = pApi 26808 26809 if sqlite3.Xsqlite3_libversion_number(tls) < 3008012 { 26810 *(*uintptr)(unsafe.Pointer(pzErrMsg)) = sqlite3.Xsqlite3_mprintf(tls, 26811 ts+6420 /* "generate_series(..." */, 0) 26812 return SQLITE_ERROR 26813 } 26814 rc = sqlite3.Xsqlite3_create_module(tls, db, ts+6470 /* "generate_series" */, uintptr(unsafe.Pointer(&seriesModule)), uintptr(0)) 26815 return rc 26816 } 26817 26818 type u16 = uint16 /* spellfix.c:34:26 */ 26819 26820 // Character classes for ASCII characters: 26821 // 26822 // 0 '' Silent letters: H W 26823 // 1 'A' Any vowel: A E I O U (Y) 26824 // 2 'B' A bilabeal stop or fricative: B F P V W 26825 // 3 'C' Other fricatives or back stops: C G J K Q S X Z 26826 // 4 'D' Alveolar stops: D T 26827 // 5 'H' Letter H at the beginning of a word 26828 // 6 'L' Glide: L 26829 // 7 'R' Semivowel: R 26830 // 8 'M' Nasals: M N 26831 // 9 'Y' Letter Y at the beginning of a word. 26832 // 10 '9' Digits: 0 1 2 3 4 5 6 7 8 9 26833 // 11 ' ' White space 26834 // 12 '?' Other. 26835 26836 // The following table gives the character class for non-initial ASCII 26837 // characters. 26838 var midClass = [128]uint8{ 26839 /* */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26840 /* */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26841 /* */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26842 /* */ uint8(CCLASS_SPACE) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26843 /* */ uint8(CCLASS_SPACE) /* */, uint8(CCLASS_SPACE) /* */, uint8(CCLASS_OTHER), 26844 /* */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26845 /* */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26846 /* */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26847 /* */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26848 /* */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26849 /* */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_SPACE), 26850 /* ! */ uint8(CCLASS_OTHER) /* " */, uint8(CCLASS_OTHER) /* # */, uint8(CCLASS_OTHER), 26851 /* $ */ uint8(CCLASS_OTHER) /* % */, uint8(CCLASS_OTHER) /* & */, uint8(CCLASS_OTHER), 26852 /* ' */ uint8(CCLASS_SILENT) /* ( */, uint8(CCLASS_OTHER) /* ) */, uint8(CCLASS_OTHER), 26853 /* * */ uint8(CCLASS_OTHER) /* + */, uint8(CCLASS_OTHER) /* , */, uint8(CCLASS_OTHER), 26854 /* - */ uint8(CCLASS_OTHER) /* . */, uint8(CCLASS_OTHER) /* / */, uint8(CCLASS_OTHER), 26855 /* 0 */ uint8(CCLASS_DIGIT) /* 1 */, uint8(CCLASS_DIGIT) /* 2 */, uint8(CCLASS_DIGIT), 26856 /* 3 */ uint8(CCLASS_DIGIT) /* 4 */, uint8(CCLASS_DIGIT) /* 5 */, uint8(CCLASS_DIGIT), 26857 /* 6 */ uint8(CCLASS_DIGIT) /* 7 */, uint8(CCLASS_DIGIT) /* 8 */, uint8(CCLASS_DIGIT), 26858 /* 9 */ uint8(CCLASS_DIGIT) /* : */, uint8(CCLASS_OTHER) /* ; */, uint8(CCLASS_OTHER), 26859 /* < */ uint8(CCLASS_OTHER) /* = */, uint8(CCLASS_OTHER) /* > */, uint8(CCLASS_OTHER), 26860 /* ? */ uint8(CCLASS_OTHER) /* @ */, uint8(CCLASS_OTHER) /* A */, uint8(CCLASS_VOWEL), 26861 /* B */ uint8(CCLASS_B) /* C */, uint8(CCLASS_C) /* D */, uint8(CCLASS_D), 26862 /* E */ uint8(CCLASS_VOWEL) /* F */, uint8(CCLASS_B) /* G */, uint8(CCLASS_C), 26863 /* H */ uint8(CCLASS_SILENT) /* I */, uint8(CCLASS_VOWEL) /* J */, uint8(CCLASS_C), 26864 /* K */ uint8(CCLASS_C) /* L */, uint8(CCLASS_L) /* M */, uint8(CCLASS_M), 26865 /* N */ uint8(CCLASS_M) /* O */, uint8(CCLASS_VOWEL) /* P */, uint8(CCLASS_B), 26866 /* Q */ uint8(CCLASS_C) /* R */, uint8(CCLASS_R) /* S */, uint8(CCLASS_C), 26867 /* T */ uint8(CCLASS_D) /* U */, uint8(CCLASS_VOWEL) /* V */, uint8(CCLASS_B), 26868 /* W */ uint8(CCLASS_B) /* X */, uint8(CCLASS_C) /* Y */, uint8(CCLASS_VOWEL), 26869 /* Z */ uint8(CCLASS_C) /* [ */, uint8(CCLASS_OTHER) /* \ */, uint8(CCLASS_OTHER), 26870 /* ] */ uint8(CCLASS_OTHER) /* ^ */, uint8(CCLASS_OTHER) /* _ */, uint8(CCLASS_OTHER), 26871 /* ` */ uint8(CCLASS_OTHER) /* a */, uint8(CCLASS_VOWEL) /* b */, uint8(CCLASS_B), 26872 /* c */ uint8(CCLASS_C) /* d */, uint8(CCLASS_D) /* e */, uint8(CCLASS_VOWEL), 26873 /* f */ uint8(CCLASS_B) /* g */, uint8(CCLASS_C) /* h */, uint8(CCLASS_SILENT), 26874 /* i */ uint8(CCLASS_VOWEL) /* j */, uint8(CCLASS_C) /* k */, uint8(CCLASS_C), 26875 /* l */ uint8(CCLASS_L) /* m */, uint8(CCLASS_M) /* n */, uint8(CCLASS_M), 26876 /* o */ uint8(CCLASS_VOWEL) /* p */, uint8(CCLASS_B) /* q */, uint8(CCLASS_C), 26877 /* r */ uint8(CCLASS_R) /* s */, uint8(CCLASS_C) /* t */, uint8(CCLASS_D), 26878 /* u */ uint8(CCLASS_VOWEL) /* v */, uint8(CCLASS_B) /* w */, uint8(CCLASS_B), 26879 /* x */ uint8(CCLASS_C) /* y */, uint8(CCLASS_VOWEL) /* z */, uint8(CCLASS_C), 26880 /* { */ uint8(CCLASS_OTHER) /* | */, uint8(CCLASS_OTHER) /* } */, uint8(CCLASS_OTHER), 26881 /* ~ */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26882 } /* spellfix.c:75:28 */ 26883 // This tables gives the character class for ASCII characters that form the 26884 // initial character of a word. The only difference from midClass is with 26885 // the letters H, W, and Y. 26886 var initClass = [128]uint8{ 26887 /* */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26888 /* */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26889 /* */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26890 /* */ uint8(CCLASS_SPACE) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26891 /* */ uint8(CCLASS_SPACE) /* */, uint8(CCLASS_SPACE) /* */, uint8(CCLASS_OTHER), 26892 /* */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26893 /* */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26894 /* */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26895 /* */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26896 /* */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26897 /* */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER) /* */, uint8(CCLASS_SPACE), 26898 /* ! */ uint8(CCLASS_OTHER) /* " */, uint8(CCLASS_OTHER) /* # */, uint8(CCLASS_OTHER), 26899 /* $ */ uint8(CCLASS_OTHER) /* % */, uint8(CCLASS_OTHER) /* & */, uint8(CCLASS_OTHER), 26900 /* ' */ uint8(CCLASS_OTHER) /* ( */, uint8(CCLASS_OTHER) /* ) */, uint8(CCLASS_OTHER), 26901 /* * */ uint8(CCLASS_OTHER) /* + */, uint8(CCLASS_OTHER) /* , */, uint8(CCLASS_OTHER), 26902 /* - */ uint8(CCLASS_OTHER) /* . */, uint8(CCLASS_OTHER) /* / */, uint8(CCLASS_OTHER), 26903 /* 0 */ uint8(CCLASS_DIGIT) /* 1 */, uint8(CCLASS_DIGIT) /* 2 */, uint8(CCLASS_DIGIT), 26904 /* 3 */ uint8(CCLASS_DIGIT) /* 4 */, uint8(CCLASS_DIGIT) /* 5 */, uint8(CCLASS_DIGIT), 26905 /* 6 */ uint8(CCLASS_DIGIT) /* 7 */, uint8(CCLASS_DIGIT) /* 8 */, uint8(CCLASS_DIGIT), 26906 /* 9 */ uint8(CCLASS_DIGIT) /* : */, uint8(CCLASS_OTHER) /* ; */, uint8(CCLASS_OTHER), 26907 /* < */ uint8(CCLASS_OTHER) /* = */, uint8(CCLASS_OTHER) /* > */, uint8(CCLASS_OTHER), 26908 /* ? */ uint8(CCLASS_OTHER) /* @ */, uint8(CCLASS_OTHER) /* A */, uint8(CCLASS_VOWEL), 26909 /* B */ uint8(CCLASS_B) /* C */, uint8(CCLASS_C) /* D */, uint8(CCLASS_D), 26910 /* E */ uint8(CCLASS_VOWEL) /* F */, uint8(CCLASS_B) /* G */, uint8(CCLASS_C), 26911 /* H */ uint8(CCLASS_SILENT) /* I */, uint8(CCLASS_VOWEL) /* J */, uint8(CCLASS_C), 26912 /* K */ uint8(CCLASS_C) /* L */, uint8(CCLASS_L) /* M */, uint8(CCLASS_M), 26913 /* N */ uint8(CCLASS_M) /* O */, uint8(CCLASS_VOWEL) /* P */, uint8(CCLASS_B), 26914 /* Q */ uint8(CCLASS_C) /* R */, uint8(CCLASS_R) /* S */, uint8(CCLASS_C), 26915 /* T */ uint8(CCLASS_D) /* U */, uint8(CCLASS_VOWEL) /* V */, uint8(CCLASS_B), 26916 /* W */ uint8(CCLASS_B) /* X */, uint8(CCLASS_C) /* Y */, uint8(CCLASS_Y), 26917 /* Z */ uint8(CCLASS_C) /* [ */, uint8(CCLASS_OTHER) /* \ */, uint8(CCLASS_OTHER), 26918 /* ] */ uint8(CCLASS_OTHER) /* ^ */, uint8(CCLASS_OTHER) /* _ */, uint8(CCLASS_OTHER), 26919 /* ` */ uint8(CCLASS_OTHER) /* a */, uint8(CCLASS_VOWEL) /* b */, uint8(CCLASS_B), 26920 /* c */ uint8(CCLASS_C) /* d */, uint8(CCLASS_D) /* e */, uint8(CCLASS_VOWEL), 26921 /* f */ uint8(CCLASS_B) /* g */, uint8(CCLASS_C) /* h */, uint8(CCLASS_SILENT), 26922 /* i */ uint8(CCLASS_VOWEL) /* j */, uint8(CCLASS_C) /* k */, uint8(CCLASS_C), 26923 /* l */ uint8(CCLASS_L) /* m */, uint8(CCLASS_M) /* n */, uint8(CCLASS_M), 26924 /* o */ uint8(CCLASS_VOWEL) /* p */, uint8(CCLASS_B) /* q */, uint8(CCLASS_C), 26925 /* r */ uint8(CCLASS_R) /* s */, uint8(CCLASS_C) /* t */, uint8(CCLASS_D), 26926 /* u */ uint8(CCLASS_VOWEL) /* v */, uint8(CCLASS_B) /* w */, uint8(CCLASS_B), 26927 /* x */ uint8(CCLASS_C) /* y */, uint8(CCLASS_Y) /* z */, uint8(CCLASS_C), 26928 /* { */ uint8(CCLASS_OTHER) /* | */, uint8(CCLASS_OTHER) /* } */, uint8(CCLASS_OTHER), 26929 /* ~ */ uint8(CCLASS_OTHER) /* */, uint8(CCLASS_OTHER), 26930 } /* spellfix.c:125:28 */ 26931 26932 // Mapping from the character class number (0-13) to a symbol for each 26933 // character class. Note that initClass[] can be used to map the class 26934 // symbol back into the class number. 26935 var className = *(*[14]uint8)(unsafe.Pointer(ts + 6486 /* ".ABCDHLRMY9 ?" */)) /* spellfix.c:176:28 */ 26936 26937 // Generate a "phonetic hash" from a string of ASCII characters 26938 // in zIn[0..nIn-1]. 26939 // 26940 // * Map characters by character class as defined above. 26941 // * Omit double-letters 26942 // * Omit vowels beside R and L 26943 // * Omit T when followed by CH 26944 // * Omit W when followed by R 26945 // * Omit D when followed by J or G 26946 // * Omit K in KN or G in GN at the beginning of a word 26947 // 26948 // Space to hold the result is obtained from sqlite3_malloc() 26949 // 26950 // Return NULL if memory allocation fails. 26951 func phoneticHash(tls *libc.TLS, zIn uintptr, nIn int32) uintptr { /* spellfix.c:194:22: */ 26952 var zOut uintptr = sqlite3.Xsqlite3_malloc64(tls, (uint64(nIn + 1))) 26953 var i int32 26954 var nOut int32 = 0 26955 var cPrev int8 = int8(0x77) 26956 var cPrevX int8 = int8(0x77) 26957 var aClass uintptr = uintptr(unsafe.Pointer(&initClass)) 26958 26959 if zOut == uintptr(0) { 26960 return uintptr(0) 26961 } 26962 if nIn > 2 { 26963 switch int32(*(*uint8)(unsafe.Pointer(zIn))) { 26964 case 'g': 26965 fallthrough 26966 case 'k': 26967 { 26968 if int32(*(*uint8)(unsafe.Pointer(zIn + 1))) == 'n' { 26969 zIn++ 26970 nIn-- 26971 } 26972 break 26973 26974 } 26975 } 26976 } 26977 for i = 0; i < nIn; i++ { 26978 var c uint8 = *(*uint8)(unsafe.Pointer(zIn + uintptr(i))) 26979 if (i + 1) < nIn { 26980 if (int32(c) == 'w') && (int32(*(*uint8)(unsafe.Pointer(zIn + uintptr((i + 1))))) == 'r') { 26981 continue 26982 } 26983 if (int32(c) == 'd') && ((int32(*(*uint8)(unsafe.Pointer(zIn + uintptr((i + 1))))) == 'j') || (int32(*(*uint8)(unsafe.Pointer(zIn + uintptr((i + 1))))) == 'g')) { 26984 continue 26985 } 26986 if (i + 2) < nIn { 26987 if ((int32(c) == 't') && (int32(*(*uint8)(unsafe.Pointer(zIn + uintptr((i + 1))))) == 'c')) && (int32(*(*uint8)(unsafe.Pointer(zIn + uintptr((i + 2))))) == 'h') { 26988 continue 26989 } 26990 } 26991 } 26992 c = *(*uint8)(unsafe.Pointer(aClass + uintptr((int32(c) & 0x7f)))) 26993 if int32(c) == CCLASS_SPACE { 26994 continue 26995 } 26996 if (int32(c) == CCLASS_OTHER) && (int32(cPrev) != CCLASS_DIGIT) { 26997 continue 26998 } 26999 aClass = uintptr(unsafe.Pointer(&midClass)) 27000 if (int32(c) == CCLASS_VOWEL) && ((int32(cPrevX) == CCLASS_R) || (int32(cPrevX) == CCLASS_L)) { 27001 continue /* No vowels beside L or R */ 27002 } 27003 if ((int32(c) == CCLASS_R) || (int32(c) == CCLASS_L)) && (int32(cPrevX) == CCLASS_VOWEL) { 27004 nOut-- // No vowels beside L or R 27005 } 27006 cPrev = int8(c) 27007 if int32(c) == CCLASS_SILENT { 27008 continue 27009 } 27010 cPrevX = int8(c) 27011 c = className[c] 27012 27013 if (nOut == 0) || (int32(c) != int32(*(*uint8)(unsafe.Pointer(zOut + uintptr((nOut - 1)))))) { 27014 *(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncInt32(&nOut, 1)))) = c 27015 } 27016 } 27017 *(*uint8)(unsafe.Pointer(zOut + uintptr(nOut))) = uint8(0) 27018 return zOut 27019 } 27020 27021 // This is an SQL function wrapper around phoneticHash(). See 27022 // the description of phoneticHash() for additional information. 27023 func phoneticHashSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* spellfix.c:246:13: */ 27024 var zIn uintptr 27025 var zOut uintptr 27026 27027 zIn = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 27028 if zIn == uintptr(0) { 27029 return 27030 } 27031 zOut = phoneticHash(tls, zIn, sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))) 27032 if zOut == uintptr(0) { 27033 sqlite3.Xsqlite3_result_error_nomem(tls, context) 27034 } else { 27035 sqlite3.Xsqlite3_result_text(tls, context, zOut, -1, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) 27036 } 27037 } 27038 27039 // Return the character class number for a character given its 27040 // context. 27041 func characterClass(tls *libc.TLS, cPrev int8, c int8) int8 { /* spellfix.c:268:13: */ 27042 if int32(cPrev) == 0 { 27043 return int8(initClass[(int32(c) & 0x7f)]) 27044 } 27045 return int8(midClass[(int32(c) & 0x7f)]) 27046 } 27047 27048 // Return the cost of inserting or deleting character c immediately 27049 // following character cPrev. If cPrev==0, that means c is the first 27050 // character of the word. 27051 func insertOrDeleteCost(tls *libc.TLS, cPrev int8, c int8, cNext int8) int32 { /* spellfix.c:277:12: */ 27052 var classC int8 = characterClass(tls, cPrev, c) 27053 var classCprev int8 27054 27055 if int32(classC) == CCLASS_SILENT { 27056 // Insert or delete "silent" characters such as H or W 27057 return 1 27058 } 27059 if int32(cPrev) == int32(c) { 27060 // Repeated characters, or miss a repeat 27061 return 10 27062 } 27063 if (int32(classC) == CCLASS_VOWEL) && ((int32(cPrev) == 'r') || (int32(cNext) == 'r')) { 27064 return 20 // Insert a vowel before or after 'r' 27065 } 27066 classCprev = characterClass(tls, cPrev, cPrev) 27067 if int32(classC) == int32(classCprev) { 27068 if int32(classC) == CCLASS_VOWEL { 27069 // Remove or add a new vowel to a vowel cluster 27070 return 15 27071 } else { 27072 // Remove or add a consonant not in the same class 27073 return 50 27074 } 27075 } 27076 27077 // any other character insertion or deletion 27078 return 100 27079 } 27080 27081 // Divide the insertion cost by this factor when appending to the 27082 // end of the word. 27083 27084 // Return the cost of substituting cTo in place of cFrom assuming 27085 // the previous character is cPrev. If cPrev==0 then cTo is the first 27086 // character of the word. 27087 func substituteCost(tls *libc.TLS, cPrev int8, cFrom int8, cTo int8) int32 { /* spellfix.c:318:12: */ 27088 var classFrom int8 27089 var classTo int8 27090 if int32(cFrom) == int32(cTo) { 27091 // Exact match 27092 return 0 27093 } 27094 if (int32(cFrom) == (int32(cTo) ^ 0x20)) && (((int32(cTo) >= 'A') && (int32(cTo) <= 'Z')) || ((int32(cTo) >= 'a') && (int32(cTo) <= 'z'))) { 27095 // differ only in case 27096 return 0 27097 } 27098 classFrom = characterClass(tls, cPrev, cFrom) 27099 classTo = characterClass(tls, cPrev, cTo) 27100 if int32(classFrom) == int32(classTo) { 27101 // Same character class 27102 return 40 27103 } 27104 if (((int32(classFrom) >= CCLASS_B) && (int32(classFrom) <= CCLASS_Y)) && 27105 (int32(classTo) >= CCLASS_B)) && (int32(classTo) <= CCLASS_Y) { 27106 // Convert from one consonant to another, but in a different class 27107 return 75 27108 } 27109 // Any other subsitution 27110 return 100 27111 } 27112 27113 // Given two strings zA and zB which are pure ASCII, return the cost 27114 // of transforming zA into zB. If zA ends with '*' assume that it is 27115 // a prefix of zB and give only minimal penalty for extra characters 27116 // on the end of zB. 27117 // 27118 // Smaller numbers mean a closer match. 27119 // 27120 // Negative values indicate an error: 27121 // -1 One of the inputs is NULL 27122 // -2 Non-ASCII characters on input 27123 // -3 Unable to allocate memory 27124 // 27125 // If pnMatch is not NULL, then *pnMatch is set to the number of bytes 27126 // of zB that matched the pattern in zA. If zA does not end with a '*', 27127 // then this value is always the number of bytes in zB (i.e. strlen(zB)). 27128 // If zA does end in a '*', then it is the number of bytes in the prefix 27129 // of zB that was deemed to match zA. 27130 func editdist1(tls *libc.TLS, zA uintptr, zB uintptr, pnMatch uintptr) int32 { /* spellfix.c:362:12: */ 27131 bp := tls.Alloc(300) 27132 defer tls.Free(300) 27133 27134 var nA int32 27135 var nB int32 // Number of characters in zA[] and zB[] 27136 var xA int32 27137 var xB int32 // Loop counters for zA[] and zB[] 27138 var cA int8 = int8(0) 27139 var cB int8 // Current character of zA and zB 27140 var cAprev int8 27141 var cBprev int8 // Previous character of zA and zB 27142 var cAnext int8 27143 var cBnext int8 // Next character in zA and zB 27144 var d int32 // North-west cost value 27145 var dc int32 = 0 // North-west character value 27146 var res int32 // Final result 27147 var m uintptr // The cost matrix 27148 var cx uintptr // Corresponding character values 27149 var toFree uintptr = uintptr(0) // Malloced space 27150 var nMatch int32 = 0 27151 // var mStack [75]int32 at bp, 300 27152 // Stack space to use if not too much is needed 27153 27154 // Early out if either input is NULL 27155 if (zA == uintptr(0)) || (zB == uintptr(0)) { 27156 return -1 27157 } 27158 27159 // Skip any common prefix 27160 for (*(*int8)(unsafe.Pointer(zA)) != 0) && (int32(*(*int8)(unsafe.Pointer(zA))) == int32(*(*int8)(unsafe.Pointer(zB)))) { 27161 dc = int32(*(*int8)(unsafe.Pointer(zA))) 27162 zA++ 27163 zB++ 27164 nMatch++ 27165 } 27166 if pnMatch != 0 { 27167 *(*int32)(unsafe.Pointer(pnMatch)) = nMatch 27168 } 27169 if (int32(*(*int8)(unsafe.Pointer(zA))) == 0) && (int32(*(*int8)(unsafe.Pointer(zB))) == 0) { 27170 return 0 27171 } 27172 27173 // Verify input strings and measure their lengths 27174 for nA = 0; *(*int8)(unsafe.Pointer(zA + uintptr(nA))) != 0; nA++ { 27175 if (int32(*(*int8)(unsafe.Pointer(zA + uintptr(nA)))) & 0x80) != 0 { 27176 return -2 27177 } 27178 } 27179 for nB = 0; *(*int8)(unsafe.Pointer(zB + uintptr(nB))) != 0; nB++ { 27180 if (int32(*(*int8)(unsafe.Pointer(zB + uintptr(nB)))) & 0x80) != 0 { 27181 return -2 27182 } 27183 } 27184 27185 // Special processing if either string is empty 27186 if nA == 0 { 27187 cBprev = int8(dc) 27188 for xB = libc.AssignInt32(&res, 0); (int32(libc.AssignInt8(&cB, *(*int8)(unsafe.Pointer(zB + uintptr(xB)))))) != 0; xB++ { 27189 res = res + (insertOrDeleteCost(tls, cBprev, cB, *(*int8)(unsafe.Pointer(zB + uintptr((xB + 1))))) / FINAL_INS_COST_DIV) 27190 cBprev = cB 27191 } 27192 return res 27193 } 27194 if nB == 0 { 27195 cAprev = int8(dc) 27196 for xA = libc.AssignInt32(&res, 0); (int32(libc.AssignInt8(&cA, *(*int8)(unsafe.Pointer(zA + uintptr(xA)))))) != 0; xA++ { 27197 res = res + (insertOrDeleteCost(tls, cAprev, cA, *(*int8)(unsafe.Pointer(zA + uintptr((xA + 1)))))) 27198 cAprev = cA 27199 } 27200 return res 27201 } 27202 27203 // A is a prefix of B 27204 if (int32(*(*int8)(unsafe.Pointer(zA))) == '*') && (int32(*(*int8)(unsafe.Pointer(zA + 1))) == 0) { 27205 return 0 27206 } 27207 27208 // Allocate and initialize the Wagner matrix 27209 if uint64(nB) < ((uint64(unsafe.Sizeof([75]int32{})) * uint64(4)) / (uint64(unsafe.Sizeof(int32(0))) * uint64(5))) { 27210 m = bp /* &mStack[0] */ 27211 } else { 27212 m = libc.AssignUintptr(&toFree, sqlite3.Xsqlite3_malloc64(tls, (uint64(((uint64((nB+1)*5))*uint64(unsafe.Sizeof(int32(0))))/uint64(4))))) 27213 if m == uintptr(0) { 27214 return -3 27215 } 27216 } 27217 cx = (m + uintptr((nB+1))*4) 27218 27219 // Compute the Wagner edit distance 27220 *(*int32)(unsafe.Pointer(m)) = 0 27221 *(*int8)(unsafe.Pointer(cx)) = int8(dc) 27222 cBprev = int8(dc) 27223 for xB = 1; xB <= nB; xB++ { 27224 cBnext = *(*int8)(unsafe.Pointer(zB + uintptr(xB))) 27225 cB = *(*int8)(unsafe.Pointer(zB + uintptr((xB - 1)))) 27226 *(*int8)(unsafe.Pointer(cx + uintptr(xB))) = cB 27227 *(*int32)(unsafe.Pointer(m + uintptr(xB)*4)) = (*(*int32)(unsafe.Pointer(m + uintptr((xB-1))*4)) + insertOrDeleteCost(tls, cBprev, cB, cBnext)) 27228 cBprev = cB 27229 } 27230 cAprev = int8(dc) 27231 for xA = 1; xA <= nA; xA++ { 27232 var lastA int32 = (libc.Bool32(xA == nA)) 27233 cA = *(*int8)(unsafe.Pointer(zA + uintptr((xA - 1)))) 27234 cAnext = *(*int8)(unsafe.Pointer(zA + uintptr(xA))) 27235 if (int32(cA) == '*') && (lastA != 0) { 27236 break 27237 } 27238 d = *(*int32)(unsafe.Pointer(m)) 27239 dc = int32(*(*int8)(unsafe.Pointer(cx))) 27240 *(*int32)(unsafe.Pointer(m)) = (d + insertOrDeleteCost(tls, cAprev, cA, cAnext)) 27241 cBprev = int8(0) 27242 for xB = 1; xB <= nB; xB++ { 27243 var totalCost int32 27244 var insCost int32 27245 var delCost int32 27246 var subCost int32 27247 var ncx int32 27248 cB = *(*int8)(unsafe.Pointer(zB + uintptr((xB - 1)))) 27249 cBnext = *(*int8)(unsafe.Pointer(zB + uintptr(xB))) 27250 27251 // Cost to insert cB 27252 insCost = insertOrDeleteCost(tls, *(*int8)(unsafe.Pointer(cx + uintptr((xB - 1)))), cB, cBnext) 27253 if lastA != 0 { 27254 insCost = insCost / (FINAL_INS_COST_DIV) 27255 } 27256 27257 // Cost to delete cA 27258 delCost = insertOrDeleteCost(tls, *(*int8)(unsafe.Pointer(cx + uintptr(xB))), cA, cBnext) 27259 27260 // Cost to substitute cA->cB 27261 subCost = substituteCost(tls, *(*int8)(unsafe.Pointer(cx + uintptr((xB - 1)))), cA, cB) 27262 27263 // Best cost 27264 totalCost = (insCost + *(*int32)(unsafe.Pointer(m + uintptr((xB-1))*4))) 27265 ncx = int32(cB) 27266 if (delCost + *(*int32)(unsafe.Pointer(m + uintptr(xB)*4))) < totalCost { 27267 totalCost = (delCost + *(*int32)(unsafe.Pointer(m + uintptr(xB)*4))) 27268 ncx = int32(cA) 27269 } 27270 if (subCost + d) < totalCost { 27271 totalCost = (subCost + d) 27272 } 27273 27274 // Update the matrix 27275 d = *(*int32)(unsafe.Pointer(m + uintptr(xB)*4)) 27276 dc = int32(*(*int8)(unsafe.Pointer(cx + uintptr(xB)))) 27277 *(*int32)(unsafe.Pointer(m + uintptr(xB)*4)) = totalCost 27278 *(*int8)(unsafe.Pointer(cx + uintptr(xB))) = int8(ncx) 27279 cBprev = cB 27280 } 27281 cAprev = cA 27282 } 27283 27284 // Free the wagner matrix and return the result 27285 if int32(cA) == '*' { 27286 res = *(*int32)(unsafe.Pointer(m + 1*4)) 27287 for xB = 1; xB <= nB; xB++ { 27288 if *(*int32)(unsafe.Pointer(m + uintptr(xB)*4)) < res { 27289 res = *(*int32)(unsafe.Pointer(m + uintptr(xB)*4)) 27290 if pnMatch != 0 { 27291 *(*int32)(unsafe.Pointer(pnMatch)) = (xB + nMatch) 27292 } 27293 } 27294 } 27295 } else { 27296 res = *(*int32)(unsafe.Pointer(m + uintptr(nB)*4)) 27297 // In the current implementation, pnMatch is always NULL if zA does 27298 // not end in "*" 27299 27300 } 27301 sqlite3.Xsqlite3_free(tls, toFree) 27302 return res 27303 } 27304 27305 // Function: editdist(A,B) 27306 // 27307 // Return the cost of transforming string A into string B. Both strings 27308 // must be pure ASCII text. If A ends with '*' then it is assumed to be 27309 // a prefix of B and extra characters on the end of B have minimal additional 27310 // cost. 27311 func editdistSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* spellfix.c:518:13: */ 27312 var res int32 = editdist1(tls, 27313 sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))), 27314 sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))), 27315 uintptr(0)) 27316 if res < 0 { 27317 if res == (-3) { 27318 sqlite3.Xsqlite3_result_error_nomem(tls, context) 27319 } else if res == (-2) { 27320 sqlite3.Xsqlite3_result_error(tls, context, ts+6500 /* "non-ASCII input ..." */, -1) 27321 } else { 27322 sqlite3.Xsqlite3_result_error(tls, context, ts+6530 /* "NULL input to ed..." */, -1) 27323 } 27324 } else { 27325 sqlite3.Xsqlite3_result_int(tls, context, res) 27326 } 27327 } 27328 27329 // End of the fixed-cost edit distance implementation 27330 // 27331 // 27332 // Begin: Configurable cost unicode edit distance routines 27333 // Forward declaration of structures 27334 type EditDist3Cost1 = struct { 27335 FpNext uintptr 27336 FnFrom u8 27337 FnTo u8 27338 FiCost u16 27339 Fa [4]int8 27340 } /* spellfix.c:546:9 */ 27341 27342 // End of the fixed-cost edit distance implementation 27343 // 27344 // 27345 // Begin: Configurable cost unicode edit distance routines 27346 // Forward declaration of structures 27347 type EditDist3Cost = EditDist3Cost1 /* spellfix.c:546:30 */ 27348 type EditDist3Config1 = struct { 27349 FnLang int32 27350 _ [4]byte 27351 Fa uintptr 27352 } /* spellfix.c:547:9 */ 27353 27354 type EditDist3Config = EditDist3Config1 /* spellfix.c:547:32 */ 27355 type EditDist3From1 = struct { 27356 FnSubst int32 27357 FnDel int32 27358 FnByte int32 27359 _ [4]byte 27360 FapSubst uintptr 27361 FapDel uintptr 27362 } /* spellfix.c:549:9 */ 27363 27364 type EditDist3From = EditDist3From1 /* spellfix.c:549:30 */ 27365 type EditDist3FromString1 = struct { 27366 Fz uintptr 27367 Fn int32 27368 FisPrefix int32 27369 Fa uintptr 27370 } /* spellfix.c:550:9 */ 27371 27372 type EditDist3FromString = EditDist3FromString1 /* spellfix.c:550:36 */ 27373 type EditDist3To1 = struct { 27374 FnIns int32 27375 FnByte int32 27376 FapIns uintptr 27377 } /* spellfix.c:551:9 */ 27378 27379 type EditDist3To = EditDist3To1 /* spellfix.c:551:28 */ 27380 type EditDist3ToString1 = struct { 27381 Fz uintptr 27382 Fn int32 27383 _ [4]byte 27384 Fa uintptr 27385 } /* spellfix.c:552:9 */ 27386 27387 type EditDist3ToString = EditDist3ToString1 /* spellfix.c:552:34 */ 27388 type EditDist3Lang1 = struct { 27389 FiLang int32 27390 FiInsCost int32 27391 FiDelCost int32 27392 FiSubCost int32 27393 FpCost uintptr 27394 } /* spellfix.c:547:9 */ 27395 27396 type EditDist3Lang = EditDist3Lang1 /* spellfix.c:553:30 */ 27397 27398 // The default EditDist3Lang object, with default costs. 27399 var editDist3Lang = EditDist3Lang{FiInsCost: 100, FiDelCost: 100, FiSubCost: 150} /* spellfix.c:583:28 */ 27400 27401 // Clear or delete an instance of the object that records all edit-distance 27402 // weights. 27403 func editDist3ConfigClear(tls *libc.TLS, p uintptr) { /* spellfix.c:640:13: */ 27404 var i int32 27405 if p == uintptr(0) { 27406 return 27407 } 27408 for i = 0; i < (*EditDist3Config)(unsafe.Pointer(p)).FnLang; i++ { 27409 var pCost uintptr 27410 var pNext uintptr 27411 pCost = (*EditDist3Lang)(unsafe.Pointer((*EditDist3Config)(unsafe.Pointer(p)).Fa + uintptr(i)*24)).FpCost 27412 for pCost != 0 { 27413 pNext = (*EditDist3Cost)(unsafe.Pointer(pCost)).FpNext 27414 sqlite3.Xsqlite3_free(tls, pCost) 27415 pCost = pNext 27416 } 27417 } 27418 sqlite3.Xsqlite3_free(tls, (*EditDist3Config)(unsafe.Pointer(p)).Fa) 27419 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(EditDist3Config{}))) 27420 } 27421 27422 func editDist3ConfigDelete(tls *libc.TLS, pIn uintptr) { /* spellfix.c:655:13: */ 27423 var p uintptr = pIn 27424 editDist3ConfigClear(tls, p) 27425 sqlite3.Xsqlite3_free(tls, p) 27426 } 27427 27428 // Compare the FROM values of two EditDist3Cost objects, for sorting. 27429 // Return negative, zero, or positive if the A is less than, equal to, 27430 // or greater than B. 27431 func editDist3CostCompare(tls *libc.TLS, pA uintptr, pB uintptr) int32 { /* spellfix.c:665:12: */ 27432 var n int32 = int32((*EditDist3Cost)(unsafe.Pointer(pA)).FnFrom) 27433 var rc int32 27434 if n > int32((*EditDist3Cost)(unsafe.Pointer(pB)).FnFrom) { 27435 n = int32((*EditDist3Cost)(unsafe.Pointer(pB)).FnFrom) 27436 } 27437 rc = libc.Xstrncmp(tls, pA+12 /* &.a */, pB+12 /* &.a */, uint64(n)) 27438 if rc == 0 { 27439 rc = (int32((*EditDist3Cost)(unsafe.Pointer(pA)).FnFrom) - int32((*EditDist3Cost)(unsafe.Pointer(pB)).FnFrom)) 27440 } 27441 return rc 27442 } 27443 27444 // Merge together two sorted lists of EditDist3Cost objects, in order 27445 // of increasing FROM. 27446 func editDist3CostMerge(tls *libc.TLS, pA uintptr, pB uintptr) uintptr { /* spellfix.c:678:22: */ 27447 bp := tls.Alloc(8) 27448 defer tls.Free(8) 27449 27450 *(*uintptr)(unsafe.Pointer(bp /* pHead */)) = uintptr(0) 27451 var ppTail uintptr = bp /* &pHead */ 27452 var p uintptr 27453 for (pA != 0) && (pB != 0) { 27454 if editDist3CostCompare(tls, pA, pB) <= 0 { 27455 p = pA 27456 pA = (*EditDist3Cost)(unsafe.Pointer(pA)).FpNext 27457 } else { 27458 p = pB 27459 pB = (*EditDist3Cost)(unsafe.Pointer(pB)).FpNext 27460 } 27461 *(*uintptr)(unsafe.Pointer(ppTail)) = p 27462 ppTail = (p /* &.pNext */) 27463 } 27464 if pA != 0 { 27465 *(*uintptr)(unsafe.Pointer(ppTail)) = pA 27466 } else { 27467 *(*uintptr)(unsafe.Pointer(ppTail)) = pB 27468 } 27469 return *(*uintptr)(unsafe.Pointer(bp /* pHead */)) 27470 } 27471 27472 // Sort a list of EditDist3Cost objects into order of increasing FROM 27473 func editDist3CostSort(tls *libc.TLS, pList uintptr) uintptr { /* spellfix.c:707:22: */ 27474 bp := tls.Alloc(480) 27475 defer tls.Free(480) 27476 27477 // var ap [60]uintptr at bp, 480 27478 27479 var p uintptr 27480 var i int32 27481 var mx int32 = 0 27482 *(*uintptr)(unsafe.Pointer(bp /* &ap[0] */)) = uintptr(0) 27483 *(*uintptr)(unsafe.Pointer(bp /* &ap[0] */ + 1*8)) = uintptr(0) 27484 for pList != 0 { 27485 p = pList 27486 pList = (*EditDist3Cost)(unsafe.Pointer(p)).FpNext 27487 (*EditDist3Cost)(unsafe.Pointer(p)).FpNext = uintptr(0) 27488 for i = 0; *(*uintptr)(unsafe.Pointer(bp /* &ap[0] */ + uintptr(i)*8)) != 0; i++ { 27489 p = editDist3CostMerge(tls, *(*uintptr)(unsafe.Pointer(bp /* &ap[0] */ + uintptr(i)*8)), p) 27490 *(*uintptr)(unsafe.Pointer(bp /* &ap[0] */ + uintptr(i)*8)) = uintptr(0) 27491 } 27492 *(*uintptr)(unsafe.Pointer(bp /* &ap[0] */ + uintptr(i)*8)) = p 27493 if i > mx { 27494 mx = i 27495 *(*uintptr)(unsafe.Pointer(bp /* &ap[0] */ + uintptr((i+1))*8)) = uintptr(0) 27496 } 27497 } 27498 p = uintptr(0) 27499 for i = 0; i <= mx; i++ { 27500 if *(*uintptr)(unsafe.Pointer(bp /* &ap[0] */ + uintptr(i)*8)) != 0 { 27501 p = editDist3CostMerge(tls, p, *(*uintptr)(unsafe.Pointer(bp /* &ap[0] */ + uintptr(i)*8))) 27502 } 27503 } 27504 return p 27505 } 27506 27507 // Load all edit-distance weights from a table. 27508 func editDist3ConfigLoad(tls *libc.TLS, p uintptr, db uintptr, zTable uintptr) int32 { /* spellfix.c:737:12: */ 27509 bp := tls.Alloc(16) 27510 defer tls.Free(16) 27511 27512 // var pStmt uintptr at bp+8, 8 27513 27514 var rc int32 27515 var rc2 int32 27516 var zSql uintptr 27517 var iLangPrev int32 = -9999 27518 var pLang uintptr = uintptr(0) 27519 27520 zSql = sqlite3.Xsqlite3_mprintf(tls, 27521 ts+6555 /* "SELECT iLang, cF..." */, libc.VaList(bp, zTable)) 27522 if zSql == uintptr(0) { 27523 return SQLITE_NOMEM 27524 } 27525 rc = sqlite3.Xsqlite3_prepare(tls, db, zSql, -1, bp+8 /* &pStmt */, uintptr(0)) 27526 sqlite3.Xsqlite3_free(tls, zSql) 27527 if rc != 0 { 27528 return rc 27529 } 27530 editDist3ConfigClear(tls, p) 27531 for sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) == SQLITE_ROW { 27532 var iLang int32 = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 0) 27533 var zFrom uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1) 27534 var nFrom int32 27535 if zFrom != 0 { 27536 nFrom = sqlite3.Xsqlite3_column_bytes(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 1) 27537 } else { 27538 nFrom = 0 27539 } 27540 var zTo uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 2) 27541 var nTo int32 27542 if zTo != 0 { 27543 nTo = sqlite3.Xsqlite3_column_bytes(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 2) 27544 } else { 27545 nTo = 0 27546 } 27547 var iCost int32 = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 3) 27548 27549 if (nFrom > 100) || (nTo > 100) { 27550 continue 27551 } 27552 if iCost < 0 { 27553 continue 27554 } 27555 if iCost >= 10000 { 27556 continue 27557 } // Costs above 10K are considered infinite 27558 if (pLang == uintptr(0)) || (iLang != iLangPrev) { 27559 var pNew uintptr 27560 pNew = sqlite3.Xsqlite3_realloc64(tls, (*EditDist3Config)(unsafe.Pointer(p)).Fa, (uint64((uint64((*EditDist3Config)(unsafe.Pointer(p)).FnLang + 1)) * uint64(unsafe.Sizeof(EditDist3Lang{}))))) 27561 if pNew == uintptr(0) { 27562 rc = SQLITE_NOMEM 27563 break 27564 } 27565 (*EditDist3Config)(unsafe.Pointer(p)).Fa = pNew 27566 pLang = ((*EditDist3Config)(unsafe.Pointer(p)).Fa + uintptr((*EditDist3Config)(unsafe.Pointer(p)).FnLang)*24) 27567 (*EditDist3Config)(unsafe.Pointer(p)).FnLang++ 27568 (*EditDist3Lang)(unsafe.Pointer(pLang)).FiLang = iLang 27569 (*EditDist3Lang)(unsafe.Pointer(pLang)).FiInsCost = 100 27570 (*EditDist3Lang)(unsafe.Pointer(pLang)).FiDelCost = 100 27571 (*EditDist3Lang)(unsafe.Pointer(pLang)).FiSubCost = 150 27572 (*EditDist3Lang)(unsafe.Pointer(pLang)).FpCost = uintptr(0) 27573 iLangPrev = iLang 27574 } 27575 if ((nFrom == 1) && (int32(*(*int8)(unsafe.Pointer(zFrom))) == '?')) && (nTo == 0) { 27576 (*EditDist3Lang)(unsafe.Pointer(pLang)).FiDelCost = iCost 27577 } else if ((nFrom == 0) && (nTo == 1)) && (int32(*(*int8)(unsafe.Pointer(zTo))) == '?') { 27578 (*EditDist3Lang)(unsafe.Pointer(pLang)).FiInsCost = iCost 27579 } else if (((nFrom == 1) && (nTo == 1)) && (int32(*(*int8)(unsafe.Pointer(zFrom))) == '?')) && (int32(*(*int8)(unsafe.Pointer(zTo))) == '?') { 27580 (*EditDist3Lang)(unsafe.Pointer(pLang)).FiSubCost = iCost 27581 } else { 27582 var pCost uintptr 27583 var nExtra int32 = ((nFrom + nTo) - 4) 27584 if nExtra < 0 { 27585 nExtra = 0 27586 } 27587 pCost = sqlite3.Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(EditDist3Cost{})) + uint64(nExtra)))) 27588 if pCost == uintptr(0) { 27589 rc = SQLITE_NOMEM 27590 break 27591 } 27592 (*EditDist3Cost)(unsafe.Pointer(pCost)).FnFrom = u8(nFrom) 27593 (*EditDist3Cost)(unsafe.Pointer(pCost)).FnTo = u8(nTo) 27594 (*EditDist3Cost)(unsafe.Pointer(pCost)).FiCost = u16(iCost) 27595 libc.Xmemcpy(tls, pCost+12 /* &.a */, zFrom, uint64(nFrom)) 27596 libc.Xmemcpy(tls, ((pCost + 12 /* &.a */) + uintptr(nFrom)), zTo, uint64(nTo)) 27597 (*EditDist3Cost)(unsafe.Pointer(pCost)).FpNext = (*EditDist3Lang)(unsafe.Pointer(pLang)).FpCost 27598 (*EditDist3Lang)(unsafe.Pointer(pLang)).FpCost = pCost 27599 } 27600 } 27601 rc2 = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) 27602 if rc == SQLITE_OK { 27603 rc = rc2 27604 } 27605 if rc == SQLITE_OK { 27606 var iLang int32 27607 for iLang = 0; iLang < (*EditDist3Config)(unsafe.Pointer(p)).FnLang; iLang++ { 27608 (*EditDist3Lang)(unsafe.Pointer((*EditDist3Config)(unsafe.Pointer(p)).Fa + uintptr(iLang)*24)).FpCost = editDist3CostSort(tls, (*EditDist3Lang)(unsafe.Pointer((*EditDist3Config)(unsafe.Pointer(p)).Fa+uintptr(iLang)*24)).FpCost) 27609 } 27610 } 27611 return rc 27612 } 27613 27614 // Return the length (in bytes) of a utf-8 character. Or return a maximum 27615 // of N. 27616 func utf8Len(tls *libc.TLS, c uint8, N int32) int32 { /* spellfix.c:818:12: */ 27617 var len int32 = 1 27618 if int32(c) > 0x7f { 27619 if (int32(c) & 0xe0) == 0xc0 { 27620 len = 2 27621 } else if (int32(c) & 0xf0) == 0xe0 { 27622 len = 3 27623 } else { 27624 len = 4 27625 } 27626 } 27627 if len > N { 27628 len = N 27629 } 27630 return len 27631 } 27632 27633 // Return TRUE (non-zero) if the To side of the given cost matches 27634 // the given string. 27635 func matchTo(tls *libc.TLS, p uintptr, z uintptr, n int32) int32 { /* spellfix.c:837:12: */ 27636 27637 if int32(*(*int8)(unsafe.Pointer((p + 12 /* &.a */) + uintptr((*EditDist3Cost)(unsafe.Pointer(p)).FnFrom)))) != int32(*(*int8)(unsafe.Pointer(z))) { 27638 return 0 27639 } 27640 if int32((*EditDist3Cost)(unsafe.Pointer(p)).FnTo) > n { 27641 return 0 27642 } 27643 if libc.Xstrncmp(tls, ((p+12 /* &.a */)+uintptr((*EditDist3Cost)(unsafe.Pointer(p)).FnFrom)), z, uint64((*EditDist3Cost)(unsafe.Pointer(p)).FnTo)) != 0 { 27644 return 0 27645 } 27646 return 1 27647 } 27648 27649 // Return TRUE (non-zero) if the From side of the given cost matches 27650 // the given string. 27651 func matchFrom(tls *libc.TLS, p uintptr, z uintptr, n int32) int32 { /* spellfix.c:849:12: */ 27652 27653 if (*EditDist3Cost)(unsafe.Pointer(p)).FnFrom != 0 { 27654 if int32(*(*int8)(unsafe.Pointer((p + 12 /* &.a */)))) != int32(*(*int8)(unsafe.Pointer(z))) { 27655 return 0 27656 } 27657 if libc.Xstrncmp(tls, p+12 /* &.a */, z, uint64((*EditDist3Cost)(unsafe.Pointer(p)).FnFrom)) != 0 { 27658 return 0 27659 } 27660 } 27661 return 1 27662 } 27663 27664 // Return TRUE (non-zero) of the next FROM character and the next TO 27665 // character are the same. 27666 func matchFromTo(tls *libc.TLS, pStr uintptr, n1 int32, z2 uintptr, n2 int32) int32 { /* spellfix.c:862:12: */ 27667 var b1 int32 = (*EditDist3From)(unsafe.Pointer((*EditDist3FromString)(unsafe.Pointer(pStr)).Fa + uintptr(n1)*32)).FnByte 27668 if b1 > n2 { 27669 return 0 27670 } 27671 27672 if int32(*(*int8)(unsafe.Pointer((*EditDist3FromString)(unsafe.Pointer(pStr)).Fz + uintptr(n1)))) != int32(*(*int8)(unsafe.Pointer(z2))) { 27673 return 0 27674 } 27675 if libc.Xstrncmp(tls, ((*EditDist3FromString)(unsafe.Pointer(pStr)).Fz+uintptr(n1)), z2, uint64(b1)) != 0 { 27676 return 0 27677 } 27678 return 1 27679 } 27680 27681 // Delete an EditDist3FromString objecct 27682 func editDist3FromStringDelete(tls *libc.TLS, p uintptr) { /* spellfix.c:879:13: */ 27683 var i int32 27684 if p != 0 { 27685 for i = 0; i < (*EditDist3FromString)(unsafe.Pointer(p)).Fn; i++ { 27686 sqlite3.Xsqlite3_free(tls, (*EditDist3From)(unsafe.Pointer((*EditDist3FromString)(unsafe.Pointer(p)).Fa+uintptr(i)*32)).FapDel) 27687 sqlite3.Xsqlite3_free(tls, (*EditDist3From)(unsafe.Pointer((*EditDist3FromString)(unsafe.Pointer(p)).Fa+uintptr(i)*32)).FapSubst) 27688 } 27689 sqlite3.Xsqlite3_free(tls, p) 27690 } 27691 } 27692 27693 // Create a EditDist3FromString object. 27694 func editDist3FromStringNew(tls *libc.TLS, pLang uintptr, z uintptr, n int32) uintptr { /* spellfix.c:893:28: */ 27695 var pStr uintptr 27696 var p uintptr 27697 var i int32 27698 27699 if z == uintptr(0) { 27700 return uintptr(0) 27701 } 27702 if n < 0 { 27703 n = int32(libc.Xstrlen(tls, z)) 27704 } 27705 pStr = sqlite3.Xsqlite3_malloc64(tls, (uint64(((uint64(unsafe.Sizeof(EditDist3FromString{})) + (uint64(unsafe.Sizeof(EditDist3From{})) * uint64(n))) + uint64(n)) + uint64(1)))) 27706 if pStr == uintptr(0) { 27707 return uintptr(0) 27708 } 27709 (*EditDist3FromString)(unsafe.Pointer(pStr)).Fa = (pStr + 1*24) 27710 libc.Xmemset(tls, (*EditDist3FromString)(unsafe.Pointer(pStr)).Fa, 0, (uint64(unsafe.Sizeof(EditDist3From{})) * uint64(n))) 27711 (*EditDist3FromString)(unsafe.Pointer(pStr)).Fn = n 27712 (*EditDist3FromString)(unsafe.Pointer(pStr)).Fz = ((*EditDist3FromString)(unsafe.Pointer(pStr)).Fa + uintptr(n)*32) 27713 libc.Xmemcpy(tls, (*EditDist3FromString)(unsafe.Pointer(pStr)).Fz, z, (uint64(n + 1))) 27714 if (n != 0) && (int32(*(*int8)(unsafe.Pointer(z + uintptr((n - 1))))) == '*') { 27715 (*EditDist3FromString)(unsafe.Pointer(pStr)).FisPrefix = 1 27716 n-- 27717 (*EditDist3FromString)(unsafe.Pointer(pStr)).Fn-- 27718 *(*int8)(unsafe.Pointer((*EditDist3FromString)(unsafe.Pointer(pStr)).Fz + uintptr(n))) = int8(0) 27719 } else { 27720 (*EditDist3FromString)(unsafe.Pointer(pStr)).FisPrefix = 0 27721 } 27722 27723 for i = 0; i < n; i++ { 27724 var pFrom uintptr = ((*EditDist3FromString)(unsafe.Pointer(pStr)).Fa + uintptr(i)*32) 27725 libc.Xmemset(tls, pFrom, 0, uint64(unsafe.Sizeof(EditDist3From{}))) 27726 (*EditDist3From)(unsafe.Pointer(pFrom)).FnByte = utf8Len(tls, uint8(*(*int8)(unsafe.Pointer(z + uintptr(i)))), (n - i)) 27727 for p = (*EditDist3Lang)(unsafe.Pointer(pLang)).FpCost; p != 0; p = (*EditDist3Cost)(unsafe.Pointer(p)).FpNext { 27728 var apNew uintptr 27729 if (i + int32((*EditDist3Cost)(unsafe.Pointer(p)).FnFrom)) > n { 27730 continue 27731 } 27732 if matchFrom(tls, p, (z+uintptr(i)), (n-i)) == 0 { 27733 continue 27734 } 27735 if int32((*EditDist3Cost)(unsafe.Pointer(p)).FnTo) == 0 { 27736 apNew = sqlite3.Xsqlite3_realloc64(tls, (*EditDist3From)(unsafe.Pointer(pFrom)).FapDel, 27737 (uint64(uint64(unsafe.Sizeof(uintptr(0))) * (uint64((*EditDist3From)(unsafe.Pointer(pFrom)).FnDel + 1))))) 27738 if apNew == uintptr(0) { 27739 break 27740 } 27741 (*EditDist3From)(unsafe.Pointer(pFrom)).FapDel = apNew 27742 *(*uintptr)(unsafe.Pointer(apNew + uintptr(libc.PostIncInt32(&(*EditDist3From)(unsafe.Pointer(pFrom)).FnDel, 1))*8)) = p 27743 } else { 27744 apNew = sqlite3.Xsqlite3_realloc64(tls, (*EditDist3From)(unsafe.Pointer(pFrom)).FapSubst, 27745 (uint64(uint64(unsafe.Sizeof(uintptr(0))) * (uint64((*EditDist3From)(unsafe.Pointer(pFrom)).FnSubst + 1))))) 27746 if apNew == uintptr(0) { 27747 break 27748 } 27749 (*EditDist3From)(unsafe.Pointer(pFrom)).FapSubst = apNew 27750 *(*uintptr)(unsafe.Pointer(apNew + uintptr(libc.PostIncInt32(&(*EditDist3From)(unsafe.Pointer(pFrom)).FnSubst, 1))*8)) = p 27751 } 27752 } 27753 if p != 0 { 27754 editDist3FromStringDelete(tls, pStr) 27755 pStr = uintptr(0) 27756 break 27757 } 27758 } 27759 return pStr 27760 } 27761 27762 // Update entry m[i] such that it is the minimum of its current value 27763 // and m[j]+iCost. 27764 func updateCost(tls *libc.TLS, m uintptr, i int32, j int32, iCost int32) { /* spellfix.c:955:13: */ 27765 var b uint32 27766 27767 b = (*(*uint32)(unsafe.Pointer(m + uintptr(j)*4)) + uint32(iCost)) 27768 if b < *(*uint32)(unsafe.Pointer(m + uintptr(i)*4)) { 27769 *(*uint32)(unsafe.Pointer(m + uintptr(i)*4)) = b 27770 } 27771 } 27772 27773 // How much stack space (int bytes) to use for Wagner matrix in 27774 // editDist3Core(). If more space than this is required, the entire 27775 // matrix is taken from the heap. To reduce the load on the memory 27776 // allocator, make this value as large as practical for the 27777 // architecture in use. 27778 27779 // Compute the edit distance between two strings. 27780 // 27781 // If an error occurs, return a negative number which is the error code. 27782 // 27783 // If pnMatch is not NULL, then *pnMatch is set to the number of characters 27784 // (not bytes) in z2 that matched the search pattern in *pFrom. If pFrom does 27785 // not contain the pattern for a prefix-search, then this is always the number 27786 // of characters in z2. If pFrom does contain a prefix search pattern, then 27787 // it is the number of characters in the prefix of z2 that was deemed to 27788 // match pFrom. 27789 func editDist3Core(tls *libc.TLS, pFrom uintptr, z2 uintptr, n2 int32, pLang uintptr, pnMatch uintptr) int32 { /* spellfix.c:990:12: */ 27790 bp := tls.Alloc(1048) 27791 defer tls.Free(1048) 27792 27793 var k int32 27794 var n int32 27795 var i1 int32 27796 var b1 int32 27797 var i2 int32 27798 var b2 int32 27799 // var f EditDist3FromString at bp+1024, 24 27800 27801 var a2 uintptr 27802 var m uintptr 27803 var pToFree uintptr 27804 var szRow int32 27805 var p uintptr 27806 var res int32 27807 var nByte sqlite3_uint64 27808 // var stackSpace [256]uint32 at bp, 1024 27809 27810 var apNew uintptr 27811 var cx int32 // Index of current cell 27812 var cxp int32 // Index of cell immediately to the left 27813 var cxd int32 // Index of cell to the left and one row above 27814 var cxu int32 27815 var rx int32 // Starting index for current row 27816 var rxp int32 27817 var b int32 27818 var nExtra int32 27819 *(*EditDist3FromString)(unsafe.Pointer(bp + 1024 /* f */)) = *(*EditDist3FromString)(unsafe.Pointer(pFrom)) 27820 27821 // allocate the Wagner matrix and the aTo[] array for the TO string 27822 n = (((*EditDist3FromString)(unsafe.Pointer(bp+1024 /* &f */)).Fn + 1) * (n2 + 1)) 27823 n = ((n + 1) & libc.CplInt32(1)) 27824 nByte = (sqlite3_uint64((uint64(n) * uint64(unsafe.Sizeof(uint32(0)))) + (uint64(unsafe.Sizeof(EditDist3To{})) * uint64(n2)))) 27825 if !(nByte <= sqlite3_uint64(unsafe.Sizeof([256]uint32{}))) { 27826 goto __1 27827 } 27828 m = bp /* &stackSpace[0] */ 27829 pToFree = uintptr(0) 27830 goto __2 27831 __1: 27832 m = libc.AssignUintptr(&pToFree, sqlite3.Xsqlite3_malloc64(tls, nByte)) 27833 if !(m == uintptr(0)) { 27834 goto __3 27835 } 27836 return -1 27837 __3: 27838 ; // Out of memory 27839 __2: 27840 ; 27841 a2 = (m + uintptr(n)*4) 27842 libc.Xmemset(tls, a2, 0, (uint64(unsafe.Sizeof(EditDist3To{})) * uint64(n2))) 27843 27844 // Fill in the a1[] matrix for all characters of the TO string 27845 i2 = 0 27846 __4: 27847 if !(i2 < n2) { 27848 goto __6 27849 } 27850 (*EditDist3To)(unsafe.Pointer(a2 + uintptr(i2)*16)).FnByte = utf8Len(tls, uint8(*(*int8)(unsafe.Pointer(z2 + uintptr(i2)))), (n2 - i2)) 27851 p = (*EditDist3Lang)(unsafe.Pointer(pLang)).FpCost 27852 __7: 27853 if !(p != 0) { 27854 goto __9 27855 } 27856 if !(int32((*EditDist3Cost)(unsafe.Pointer(p)).FnFrom) > 0) { 27857 goto __10 27858 } 27859 goto __9 27860 __10: 27861 ; 27862 if !((i2 + int32((*EditDist3Cost)(unsafe.Pointer(p)).FnTo)) > n2) { 27863 goto __11 27864 } 27865 goto __8 27866 __11: 27867 ; 27868 if !(int32(*(*int8)(unsafe.Pointer((p + 12 /* &.a */)))) > int32(*(*int8)(unsafe.Pointer(z2 + uintptr(i2))))) { 27869 goto __12 27870 } 27871 goto __9 27872 __12: 27873 ; 27874 if !(matchTo(tls, p, (z2+uintptr(i2)), (n2-i2)) == 0) { 27875 goto __13 27876 } 27877 goto __8 27878 __13: 27879 ; 27880 (*EditDist3To)(unsafe.Pointer(a2+uintptr(i2)*16)).FnIns++ 27881 apNew = sqlite3.Xsqlite3_realloc64(tls, (*EditDist3To)(unsafe.Pointer(a2+uintptr(i2)*16)).FapIns, (uint64(uint64(unsafe.Sizeof(uintptr(0))) * uint64((*EditDist3To)(unsafe.Pointer(a2+uintptr(i2)*16)).FnIns)))) 27882 if !(apNew == uintptr(0)) { 27883 goto __14 27884 } 27885 res = -1 // Out of memory 27886 goto editDist3Abort 27887 __14: 27888 ; 27889 (*EditDist3To)(unsafe.Pointer(a2 + uintptr(i2)*16)).FapIns = apNew 27890 *(*uintptr)(unsafe.Pointer((*EditDist3To)(unsafe.Pointer(a2+uintptr(i2)*16)).FapIns + uintptr(((*EditDist3To)(unsafe.Pointer(a2+uintptr(i2)*16)).FnIns-1))*8)) = p 27891 goto __8 27892 __8: 27893 p = (*EditDist3Cost)(unsafe.Pointer(p)).FpNext 27894 goto __7 27895 goto __9 27896 __9: 27897 ; 27898 goto __5 27899 __5: 27900 i2++ 27901 goto __4 27902 goto __6 27903 __6: 27904 ; 27905 27906 // Prepare to compute the minimum edit distance 27907 szRow = ((*EditDist3FromString)(unsafe.Pointer(bp+1024 /* &f */)).Fn + 1) 27908 libc.Xmemset(tls, m, 0x01, ((uint64((n2 + 1) * szRow)) * uint64(unsafe.Sizeof(uint32(0))))) 27909 *(*uint32)(unsafe.Pointer(m)) = uint32(0) 27910 27911 // First fill in the top-row of the matrix with FROM deletion costs 27912 i1 = 0 27913 __15: 27914 if !(i1 < (*EditDist3FromString)(unsafe.Pointer(bp+1024 /* &f */)).Fn) { 27915 goto __17 27916 } 27917 b1 = (*EditDist3From)(unsafe.Pointer((*EditDist3FromString)(unsafe.Pointer(bp+1024 /* &f */)).Fa + uintptr(i1)*32)).FnByte 27918 updateCost(tls, m, (i1 + b1), i1, (*EditDist3Lang)(unsafe.Pointer(pLang)).FiDelCost) 27919 k = 0 27920 __18: 27921 if !(k < (*EditDist3From)(unsafe.Pointer((*EditDist3FromString)(unsafe.Pointer(bp+1024 /* &f */)).Fa+uintptr(i1)*32)).FnDel) { 27922 goto __20 27923 } 27924 p = *(*uintptr)(unsafe.Pointer((*EditDist3From)(unsafe.Pointer((*EditDist3FromString)(unsafe.Pointer(bp+1024 /* &f */)).Fa+uintptr(i1)*32)).FapDel + uintptr(k)*8)) 27925 updateCost(tls, m, (i1 + int32((*EditDist3Cost)(unsafe.Pointer(p)).FnFrom)), i1, int32((*EditDist3Cost)(unsafe.Pointer(p)).FiCost)) 27926 goto __19 27927 __19: 27928 k++ 27929 goto __18 27930 goto __20 27931 __20: 27932 ; 27933 goto __16 27934 __16: 27935 i1 = i1 + (b1) 27936 goto __15 27937 goto __17 27938 __17: 27939 ; 27940 27941 // Fill in all subsequent rows, top-to-bottom, left-to-right 27942 i2 = 0 27943 __21: 27944 if !(i2 < n2) { 27945 goto __23 27946 } // Starting index for previous row 27947 b2 = (*EditDist3To)(unsafe.Pointer(a2 + uintptr(i2)*16)).FnByte 27948 rx = (szRow * (i2 + b2)) 27949 rxp = (szRow * i2) 27950 updateCost(tls, m, rx, rxp, (*EditDist3Lang)(unsafe.Pointer(pLang)).FiInsCost) 27951 k = 0 27952 __24: 27953 if !(k < (*EditDist3To)(unsafe.Pointer(a2+uintptr(i2)*16)).FnIns) { 27954 goto __26 27955 } 27956 p = *(*uintptr)(unsafe.Pointer((*EditDist3To)(unsafe.Pointer(a2+uintptr(i2)*16)).FapIns + uintptr(k)*8)) 27957 updateCost(tls, m, (szRow * (i2 + int32((*EditDist3Cost)(unsafe.Pointer(p)).FnTo))), rxp, int32((*EditDist3Cost)(unsafe.Pointer(p)).FiCost)) 27958 goto __25 27959 __25: 27960 k++ 27961 goto __24 27962 goto __26 27963 __26: 27964 ; 27965 i1 = 0 27966 __27: 27967 if !(i1 < (*EditDist3FromString)(unsafe.Pointer(bp+1024 /* &f */)).Fn) { 27968 goto __29 27969 } // Index of cell immediately above 27970 b1 = (*EditDist3From)(unsafe.Pointer((*EditDist3FromString)(unsafe.Pointer(bp+1024 /* &f */)).Fa + uintptr(i1)*32)).FnByte 27971 cxp = (rx + i1) 27972 cx = (cxp + b1) 27973 cxd = (rxp + i1) 27974 cxu = (cxd + b1) 27975 updateCost(tls, m, cx, cxp, (*EditDist3Lang)(unsafe.Pointer(pLang)).FiDelCost) 27976 k = 0 27977 __30: 27978 if !(k < (*EditDist3From)(unsafe.Pointer((*EditDist3FromString)(unsafe.Pointer(bp+1024 /* &f */)).Fa+uintptr(i1)*32)).FnDel) { 27979 goto __32 27980 } 27981 p = *(*uintptr)(unsafe.Pointer((*EditDist3From)(unsafe.Pointer((*EditDist3FromString)(unsafe.Pointer(bp+1024 /* &f */)).Fa+uintptr(i1)*32)).FapDel + uintptr(k)*8)) 27982 updateCost(tls, m, (cxp + int32((*EditDist3Cost)(unsafe.Pointer(p)).FnFrom)), cxp, int32((*EditDist3Cost)(unsafe.Pointer(p)).FiCost)) 27983 goto __31 27984 __31: 27985 k++ 27986 goto __30 27987 goto __32 27988 __32: 27989 ; 27990 updateCost(tls, m, cx, cxu, (*EditDist3Lang)(unsafe.Pointer(pLang)).FiInsCost) 27991 if !(matchFromTo(tls, bp+1024 /* &f */, i1, (z2+uintptr(i2)), (n2-i2)) != 0) { 27992 goto __33 27993 } 27994 updateCost(tls, m, cx, cxd, 0) 27995 __33: 27996 ; 27997 updateCost(tls, m, cx, cxd, (*EditDist3Lang)(unsafe.Pointer(pLang)).FiSubCost) 27998 k = 0 27999 __34: 28000 if !(k < (*EditDist3From)(unsafe.Pointer((*EditDist3FromString)(unsafe.Pointer(bp+1024 /* &f */)).Fa+uintptr(i1)*32)).FnSubst) { 28001 goto __36 28002 } 28003 p = *(*uintptr)(unsafe.Pointer((*EditDist3From)(unsafe.Pointer((*EditDist3FromString)(unsafe.Pointer(bp+1024 /* &f */)).Fa+uintptr(i1)*32)).FapSubst + uintptr(k)*8)) 28004 if !(matchTo(tls, p, (z2+uintptr(i2)), (n2-i2)) != 0) { 28005 goto __37 28006 } 28007 updateCost(tls, m, ((cxd + int32((*EditDist3Cost)(unsafe.Pointer(p)).FnFrom)) + (szRow * int32((*EditDist3Cost)(unsafe.Pointer(p)).FnTo))), cxd, int32((*EditDist3Cost)(unsafe.Pointer(p)).FiCost)) 28008 __37: 28009 ; 28010 goto __35 28011 __35: 28012 k++ 28013 goto __34 28014 goto __36 28015 __36: 28016 ; 28017 goto __28 28018 __28: 28019 i1 = i1 + (b1) 28020 goto __27 28021 goto __29 28022 __29: 28023 ; 28024 goto __22 28025 __22: 28026 i2 = i2 + (b2) 28027 goto __21 28028 goto __23 28029 __23: 28030 ; 28031 28032 // Free memory allocations and return the result 28033 res = int32(*(*uint32)(unsafe.Pointer(m + uintptr(((szRow*(n2+1))-1))*4))) 28034 n = n2 28035 if !((*EditDist3FromString)(unsafe.Pointer(bp+1024 /* &f */)).FisPrefix != 0) { 28036 goto __38 28037 } 28038 i2 = 1 28039 __39: 28040 if !(i2 <= n2) { 28041 goto __41 28042 } 28043 b = int32(*(*uint32)(unsafe.Pointer(m + uintptr(((szRow*i2)-1))*4))) 28044 if !(b <= res) { 28045 goto __42 28046 } 28047 res = b 28048 n = (i2 - 1) 28049 __42: 28050 ; 28051 goto __40 28052 __40: 28053 i2++ 28054 goto __39 28055 goto __41 28056 __41: 28057 ; 28058 __38: 28059 ; 28060 if !(pnMatch != 0) { 28061 goto __43 28062 } 28063 nExtra = 0 28064 k = 0 28065 __44: 28066 if !(k < n) { 28067 goto __46 28068 } 28069 if !((int32(*(*int8)(unsafe.Pointer(z2 + uintptr(k)))) & 0xc0) == 0x80) { 28070 goto __47 28071 } 28072 nExtra++ 28073 __47: 28074 ; 28075 goto __45 28076 __45: 28077 k++ 28078 goto __44 28079 goto __46 28080 __46: 28081 ; 28082 *(*int32)(unsafe.Pointer(pnMatch)) = (n - nExtra) 28083 __43: 28084 ; 28085 28086 editDist3Abort: 28087 i2 = 0 28088 __48: 28089 if !(i2 < n2) { 28090 goto __50 28091 } 28092 sqlite3.Xsqlite3_free(tls, (*EditDist3To)(unsafe.Pointer(a2+uintptr(i2)*16)).FapIns) 28093 goto __49 28094 __49: 28095 i2++ 28096 goto __48 28097 goto __50 28098 __50: 28099 ; 28100 sqlite3.Xsqlite3_free(tls, pToFree) 28101 return res 28102 } 28103 28104 // Get an appropriate EditDist3Lang object. 28105 func editDist3FindLang(tls *libc.TLS, pConfig uintptr, iLang int32) uintptr { /* spellfix.c:1150:28: */ 28106 var i int32 28107 for i = 0; i < (*EditDist3Config)(unsafe.Pointer(pConfig)).FnLang; i++ { 28108 if (*EditDist3Lang)(unsafe.Pointer((*EditDist3Config)(unsafe.Pointer(pConfig)).Fa+uintptr(i)*24)).FiLang == iLang { 28109 return ((*EditDist3Config)(unsafe.Pointer(pConfig)).Fa + uintptr(i)*24) 28110 } 28111 } 28112 return uintptr(unsafe.Pointer(&editDist3Lang)) 28113 } 28114 28115 // Function: editdist3(A,B,iLang) 28116 // editdist3(tablename) 28117 // 28118 // Return the cost of transforming string A into string B using edit 28119 // weights for iLang. 28120 // 28121 // The second form loads edit weights into memory from a table. 28122 func editDist3SqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* spellfix.c:1170:13: */ 28123 var pConfig uintptr = sqlite3.Xsqlite3_user_data(tls, context) 28124 var db uintptr = sqlite3.Xsqlite3_context_db_handle(tls, context) 28125 var rc int32 28126 if argc == 1 { 28127 var zTable uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 28128 rc = editDist3ConfigLoad(tls, pConfig, db, zTable) 28129 if rc != 0 { 28130 sqlite3.Xsqlite3_result_error_code(tls, context, rc) 28131 } 28132 } else { 28133 var zA uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 28134 var zB uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 28135 var nA int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) 28136 var nB int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 28137 var iLang int32 28138 if argc == 3 { 28139 iLang = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) 28140 } else { 28141 iLang = 0 28142 } 28143 var pLang uintptr = editDist3FindLang(tls, pConfig, iLang) 28144 var pFrom uintptr 28145 var dist int32 28146 28147 pFrom = editDist3FromStringNew(tls, pLang, zA, nA) 28148 if pFrom == uintptr(0) { 28149 sqlite3.Xsqlite3_result_error_nomem(tls, context) 28150 return 28151 } 28152 dist = editDist3Core(tls, pFrom, zB, nB, pLang, uintptr(0)) 28153 editDist3FromStringDelete(tls, pFrom) 28154 if dist == (-1) { 28155 sqlite3.Xsqlite3_result_error_nomem(tls, context) 28156 } else { 28157 sqlite3.Xsqlite3_result_int(tls, context, dist) 28158 } 28159 } 28160 } 28161 28162 // Register the editDist3 function with SQLite 28163 func editDist3Install(tls *libc.TLS, db uintptr) int32 { /* spellfix.c:1210:12: */ 28164 var rc int32 28165 var pConfig uintptr = sqlite3.Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(EditDist3Config{}))) 28166 if pConfig == uintptr(0) { 28167 return SQLITE_NOMEM 28168 } 28169 libc.Xmemset(tls, pConfig, 0, uint64(unsafe.Sizeof(EditDist3Config{}))) 28170 rc = sqlite3.Xsqlite3_create_function_v2(tls, db, ts+6627, /* "editdist3" */ 28171 2, (SQLITE_UTF8 | SQLITE_DETERMINISTIC), pConfig, 28172 *(*uintptr)(unsafe.Pointer(&struct { 28173 f func(*libc.TLS, uintptr, int32, uintptr) 28174 }{editDist3SqlFunc})), uintptr(0), uintptr(0), uintptr(0)) 28175 if rc == SQLITE_OK { 28176 rc = sqlite3.Xsqlite3_create_function_v2(tls, db, ts+6627, /* "editdist3" */ 28177 3, (SQLITE_UTF8 | SQLITE_DETERMINISTIC), pConfig, 28178 *(*uintptr)(unsafe.Pointer(&struct { 28179 f func(*libc.TLS, uintptr, int32, uintptr) 28180 }{editDist3SqlFunc})), uintptr(0), uintptr(0), uintptr(0)) 28181 } 28182 if rc == SQLITE_OK { 28183 rc = sqlite3.Xsqlite3_create_function_v2(tls, db, ts+6627, /* "editdist3" */ 28184 1, (SQLITE_UTF8 | SQLITE_DETERMINISTIC), pConfig, 28185 *(*uintptr)(unsafe.Pointer(&struct { 28186 f func(*libc.TLS, uintptr, int32, uintptr) 28187 }{editDist3SqlFunc})), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{editDist3ConfigDelete}))) 28188 } else { 28189 sqlite3.Xsqlite3_free(tls, pConfig) 28190 } 28191 return rc 28192 } 28193 28194 // End configurable cost unicode edit distance routines 28195 // 28196 // 28197 // Begin transliterate unicode-to-ascii implementation 28198 28199 // This lookup table is used to help decode the first byte of 28200 // a multi-byte UTF8 character. 28201 var sqlite3Utf8Trans1 = [64]uint8{ 28202 uint8(0x00), uint8(0x01), uint8(0x02), uint8(0x03), uint8(0x04), uint8(0x05), uint8(0x06), uint8(0x07), 28203 uint8(0x08), uint8(0x09), uint8(0x0a), uint8(0x0b), uint8(0x0c), uint8(0x0d), uint8(0x0e), uint8(0x0f), 28204 uint8(0x10), uint8(0x11), uint8(0x12), uint8(0x13), uint8(0x14), uint8(0x15), uint8(0x16), uint8(0x17), 28205 uint8(0x18), uint8(0x19), uint8(0x1a), uint8(0x1b), uint8(0x1c), uint8(0x1d), uint8(0x1e), uint8(0x1f), 28206 uint8(0x00), uint8(0x01), uint8(0x02), uint8(0x03), uint8(0x04), uint8(0x05), uint8(0x06), uint8(0x07), 28207 uint8(0x08), uint8(0x09), uint8(0x0a), uint8(0x0b), uint8(0x0c), uint8(0x0d), uint8(0x0e), uint8(0x0f), 28208 uint8(0x00), uint8(0x01), uint8(0x02), uint8(0x03), uint8(0x04), uint8(0x05), uint8(0x06), uint8(0x07), 28209 uint8(0x00), uint8(0x01), uint8(0x02), uint8(0x03), uint8(0x00), uint8(0x01), uint8(0x00), uint8(0x00), 28210 } /* spellfix.c:1243:28 */ 28211 28212 // Return the value of the first UTF-8 character in the string. 28213 func utf8Read(tls *libc.TLS, z uintptr, n int32, pSize uintptr) int32 { /* spellfix.c:1258:12: */ 28214 var c int32 28215 var i int32 28216 28217 // All callers to this routine (in the current implementation) 28218 // always have n>0. 28219 if 0 != 0 { 28220 c = libc.AssignInt32(&i, 0) 28221 } else { 28222 c = int32(*(*uint8)(unsafe.Pointer(z))) 28223 i = 1 28224 if c >= 0xc0 { 28225 c = int32(sqlite3Utf8Trans1[(c - 0xc0)]) 28226 for (i < n) && ((int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))) & 0xc0) == 0x80) { 28227 c = ((c << 6) + (0x3f & int32(*(*uint8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&i, 1))))))) 28228 } 28229 } 28230 } 28231 *(*int32)(unsafe.Pointer(pSize)) = i 28232 return c 28233 } 28234 28235 // Return the number of characters in the utf-8 string in the nIn byte 28236 // buffer pointed to by zIn. 28237 func utf8Charlen(tls *libc.TLS, zIn uintptr, nIn int32) int32 { /* spellfix.c:1283:12: */ 28238 bp := tls.Alloc(4) 28239 defer tls.Free(4) 28240 28241 var i int32 28242 var nChar int32 = 0 28243 for i = 0; i < nIn; nChar++ { 28244 // var sz int32 at bp, 4 28245 28246 utf8Read(tls, (zIn + uintptr(i)), (nIn - i), bp /* &sz */) 28247 i = i + (*(*int32)(unsafe.Pointer(bp /* sz */))) 28248 } 28249 return nChar 28250 } 28251 28252 type Transliteration1 = struct { 28253 FcFrom uint16 28254 FcTo0 uint8 28255 FcTo1 uint8 28256 FcTo2 uint8 28257 FcTo3 uint8 28258 } /* spellfix.c:1294:9 */ 28259 28260 type Transliteration = Transliteration1 /* spellfix.c:1294:32 */ 28261 28262 // Table of translations from unicode characters into ASCII. 28263 var translit = [389]Transliteration{ 28264 {FcFrom: uint16(0x00A0), FcTo0: uint8(0x20)}, // to 28265 {FcFrom: uint16(0x00B5), FcTo0: uint8(0x75)}, // µ to u 28266 {FcFrom: uint16(0x00C0), FcTo0: uint8(0x41)}, // À to A 28267 {FcFrom: uint16(0x00C1), FcTo0: uint8(0x41)}, // Á to A 28268 {FcFrom: uint16(0x00C2), FcTo0: uint8(0x41)}, //  to A 28269 {FcFrom: uint16(0x00C3), FcTo0: uint8(0x41)}, // à to A 28270 {FcFrom: uint16(0x00C4), FcTo0: uint8(0x41), FcTo1: uint8(0x65)}, // Ä to Ae 28271 {FcFrom: uint16(0x00C5), FcTo0: uint8(0x41), FcTo1: uint8(0x61)}, // Å to Aa 28272 {FcFrom: uint16(0x00C6), FcTo0: uint8(0x41), FcTo1: uint8(0x45)}, // Æ to AE 28273 {FcFrom: uint16(0x00C7), FcTo0: uint8(0x43)}, // Ç to C 28274 {FcFrom: uint16(0x00C8), FcTo0: uint8(0x45)}, // È to E 28275 {FcFrom: uint16(0x00C9), FcTo0: uint8(0x45)}, // É to E 28276 {FcFrom: uint16(0x00CA), FcTo0: uint8(0x45)}, // Ê to E 28277 {FcFrom: uint16(0x00CB), FcTo0: uint8(0x45)}, // Ë to E 28278 {FcFrom: uint16(0x00CC), FcTo0: uint8(0x49)}, // Ì to I 28279 {FcFrom: uint16(0x00CD), FcTo0: uint8(0x49)}, // Í to I 28280 {FcFrom: uint16(0x00CE), FcTo0: uint8(0x49)}, // Î to I 28281 {FcFrom: uint16(0x00CF), FcTo0: uint8(0x49)}, // Ï to I 28282 {FcFrom: uint16(0x00D0), FcTo0: uint8(0x44)}, // Ð to D 28283 {FcFrom: uint16(0x00D1), FcTo0: uint8(0x4E)}, // Ñ to N 28284 {FcFrom: uint16(0x00D2), FcTo0: uint8(0x4F)}, // Ò to O 28285 {FcFrom: uint16(0x00D3), FcTo0: uint8(0x4F)}, // Ó to O 28286 {FcFrom: uint16(0x00D4), FcTo0: uint8(0x4F)}, // Ô to O 28287 {FcFrom: uint16(0x00D5), FcTo0: uint8(0x4F)}, // Õ to O 28288 {FcFrom: uint16(0x00D6), FcTo0: uint8(0x4F), FcTo1: uint8(0x65)}, // Ö to Oe 28289 {FcFrom: uint16(0x00D7), FcTo0: uint8(0x78)}, // × to x 28290 {FcFrom: uint16(0x00D8), FcTo0: uint8(0x4F)}, // Ø to O 28291 {FcFrom: uint16(0x00D9), FcTo0: uint8(0x55)}, // Ù to U 28292 {FcFrom: uint16(0x00DA), FcTo0: uint8(0x55)}, // Ú to U 28293 {FcFrom: uint16(0x00DB), FcTo0: uint8(0x55)}, // Û to U 28294 {FcFrom: uint16(0x00DC), FcTo0: uint8(0x55), FcTo1: uint8(0x65)}, // Ü to Ue 28295 {FcFrom: uint16(0x00DD), FcTo0: uint8(0x59)}, // Ý to Y 28296 {FcFrom: uint16(0x00DE), FcTo0: uint8(0x54), FcTo1: uint8(0x68)}, // Þ to Th 28297 {FcFrom: uint16(0x00DF), FcTo0: uint8(0x73), FcTo1: uint8(0x73)}, // ß to ss 28298 {FcFrom: uint16(0x00E0), FcTo0: uint8(0x61)}, // à to a 28299 {FcFrom: uint16(0x00E1), FcTo0: uint8(0x61)}, // á to a 28300 {FcFrom: uint16(0x00E2), FcTo0: uint8(0x61)}, // â to a 28301 {FcFrom: uint16(0x00E3), FcTo0: uint8(0x61)}, // ã to a 28302 {FcFrom: uint16(0x00E4), FcTo0: uint8(0x61), FcTo1: uint8(0x65)}, // ä to ae 28303 {FcFrom: uint16(0x00E5), FcTo0: uint8(0x61), FcTo1: uint8(0x61)}, // å to aa 28304 {FcFrom: uint16(0x00E6), FcTo0: uint8(0x61), FcTo1: uint8(0x65)}, // æ to ae 28305 {FcFrom: uint16(0x00E7), FcTo0: uint8(0x63)}, // ç to c 28306 {FcFrom: uint16(0x00E8), FcTo0: uint8(0x65)}, // è to e 28307 {FcFrom: uint16(0x00E9), FcTo0: uint8(0x65)}, // é to e 28308 {FcFrom: uint16(0x00EA), FcTo0: uint8(0x65)}, // ê to e 28309 {FcFrom: uint16(0x00EB), FcTo0: uint8(0x65)}, // ë to e 28310 {FcFrom: uint16(0x00EC), FcTo0: uint8(0x69)}, // ì to i 28311 {FcFrom: uint16(0x00ED), FcTo0: uint8(0x69)}, // í to i 28312 {FcFrom: uint16(0x00EE), FcTo0: uint8(0x69)}, // î to i 28313 {FcFrom: uint16(0x00EF), FcTo0: uint8(0x69)}, // ï to i 28314 {FcFrom: uint16(0x00F0), FcTo0: uint8(0x64)}, // ð to d 28315 {FcFrom: uint16(0x00F1), FcTo0: uint8(0x6E)}, // ñ to n 28316 {FcFrom: uint16(0x00F2), FcTo0: uint8(0x6F)}, // ò to o 28317 {FcFrom: uint16(0x00F3), FcTo0: uint8(0x6F)}, // ó to o 28318 {FcFrom: uint16(0x00F4), FcTo0: uint8(0x6F)}, // ô to o 28319 {FcFrom: uint16(0x00F5), FcTo0: uint8(0x6F)}, // õ to o 28320 {FcFrom: uint16(0x00F6), FcTo0: uint8(0x6F), FcTo1: uint8(0x65)}, // ö to oe 28321 {FcFrom: uint16(0x00F7), FcTo0: uint8(0x3A)}, // ÷ to : 28322 {FcFrom: uint16(0x00F8), FcTo0: uint8(0x6F)}, // ø to o 28323 {FcFrom: uint16(0x00F9), FcTo0: uint8(0x75)}, // ù to u 28324 {FcFrom: uint16(0x00FA), FcTo0: uint8(0x75)}, // ú to u 28325 {FcFrom: uint16(0x00FB), FcTo0: uint8(0x75)}, // û to u 28326 {FcFrom: uint16(0x00FC), FcTo0: uint8(0x75), FcTo1: uint8(0x65)}, // ü to ue 28327 {FcFrom: uint16(0x00FD), FcTo0: uint8(0x79)}, // ý to y 28328 {FcFrom: uint16(0x00FE), FcTo0: uint8(0x74), FcTo1: uint8(0x68)}, // þ to th 28329 {FcFrom: uint16(0x00FF), FcTo0: uint8(0x79)}, // ÿ to y 28330 {FcFrom: uint16(0x0100), FcTo0: uint8(0x41)}, // Ā to A 28331 {FcFrom: uint16(0x0101), FcTo0: uint8(0x61)}, // ā to a 28332 {FcFrom: uint16(0x0102), FcTo0: uint8(0x41)}, // Ă to A 28333 {FcFrom: uint16(0x0103), FcTo0: uint8(0x61)}, // ă to a 28334 {FcFrom: uint16(0x0104), FcTo0: uint8(0x41)}, // Ą to A 28335 {FcFrom: uint16(0x0105), FcTo0: uint8(0x61)}, // ą to a 28336 {FcFrom: uint16(0x0106), FcTo0: uint8(0x43)}, // Ć to C 28337 {FcFrom: uint16(0x0107), FcTo0: uint8(0x63)}, // ć to c 28338 {FcFrom: uint16(0x0108), FcTo0: uint8(0x43), FcTo1: uint8(0x68)}, // Ĉ to Ch 28339 {FcFrom: uint16(0x0109), FcTo0: uint8(0x63), FcTo1: uint8(0x68)}, // ĉ to ch 28340 {FcFrom: uint16(0x010A), FcTo0: uint8(0x43)}, // Ċ to C 28341 {FcFrom: uint16(0x010B), FcTo0: uint8(0x63)}, // ċ to c 28342 {FcFrom: uint16(0x010C), FcTo0: uint8(0x43)}, // Č to C 28343 {FcFrom: uint16(0x010D), FcTo0: uint8(0x63)}, // č to c 28344 {FcFrom: uint16(0x010E), FcTo0: uint8(0x44)}, // Ď to D 28345 {FcFrom: uint16(0x010F), FcTo0: uint8(0x64)}, // ď to d 28346 {FcFrom: uint16(0x0110), FcTo0: uint8(0x44)}, // Đ to D 28347 {FcFrom: uint16(0x0111), FcTo0: uint8(0x64)}, // đ to d 28348 {FcFrom: uint16(0x0112), FcTo0: uint8(0x45)}, // Ē to E 28349 {FcFrom: uint16(0x0113), FcTo0: uint8(0x65)}, // ē to e 28350 {FcFrom: uint16(0x0114), FcTo0: uint8(0x45)}, // Ĕ to E 28351 {FcFrom: uint16(0x0115), FcTo0: uint8(0x65)}, // ĕ to e 28352 {FcFrom: uint16(0x0116), FcTo0: uint8(0x45)}, // Ė to E 28353 {FcFrom: uint16(0x0117), FcTo0: uint8(0x65)}, // ė to e 28354 {FcFrom: uint16(0x0118), FcTo0: uint8(0x45)}, // Ę to E 28355 {FcFrom: uint16(0x0119), FcTo0: uint8(0x65)}, // ę to e 28356 {FcFrom: uint16(0x011A), FcTo0: uint8(0x45)}, // Ě to E 28357 {FcFrom: uint16(0x011B), FcTo0: uint8(0x65)}, // ě to e 28358 {FcFrom: uint16(0x011C), FcTo0: uint8(0x47), FcTo1: uint8(0x68)}, // Ĝ to Gh 28359 {FcFrom: uint16(0x011D), FcTo0: uint8(0x67), FcTo1: uint8(0x68)}, // ĝ to gh 28360 {FcFrom: uint16(0x011E), FcTo0: uint8(0x47)}, // Ğ to G 28361 {FcFrom: uint16(0x011F), FcTo0: uint8(0x67)}, // ğ to g 28362 {FcFrom: uint16(0x0120), FcTo0: uint8(0x47)}, // Ġ to G 28363 {FcFrom: uint16(0x0121), FcTo0: uint8(0x67)}, // ġ to g 28364 {FcFrom: uint16(0x0122), FcTo0: uint8(0x47)}, // Ģ to G 28365 {FcFrom: uint16(0x0123), FcTo0: uint8(0x67)}, // ģ to g 28366 {FcFrom: uint16(0x0124), FcTo0: uint8(0x48), FcTo1: uint8(0x68)}, // Ĥ to Hh 28367 {FcFrom: uint16(0x0125), FcTo0: uint8(0x68), FcTo1: uint8(0x68)}, // ĥ to hh 28368 {FcFrom: uint16(0x0126), FcTo0: uint8(0x48)}, // Ħ to H 28369 {FcFrom: uint16(0x0127), FcTo0: uint8(0x68)}, // ħ to h 28370 {FcFrom: uint16(0x0128), FcTo0: uint8(0x49)}, // Ĩ to I 28371 {FcFrom: uint16(0x0129), FcTo0: uint8(0x69)}, // ĩ to i 28372 {FcFrom: uint16(0x012A), FcTo0: uint8(0x49)}, // Ī to I 28373 {FcFrom: uint16(0x012B), FcTo0: uint8(0x69)}, // ī to i 28374 {FcFrom: uint16(0x012C), FcTo0: uint8(0x49)}, // Ĭ to I 28375 {FcFrom: uint16(0x012D), FcTo0: uint8(0x69)}, // ĭ to i 28376 {FcFrom: uint16(0x012E), FcTo0: uint8(0x49)}, // Į to I 28377 {FcFrom: uint16(0x012F), FcTo0: uint8(0x69)}, // į to i 28378 {FcFrom: uint16(0x0130), FcTo0: uint8(0x49)}, // İ to I 28379 {FcFrom: uint16(0x0131), FcTo0: uint8(0x69)}, // ı to i 28380 {FcFrom: uint16(0x0132), FcTo0: uint8(0x49), FcTo1: uint8(0x4A)}, // IJ to IJ 28381 {FcFrom: uint16(0x0133), FcTo0: uint8(0x69), FcTo1: uint8(0x6A)}, // ij to ij 28382 {FcFrom: uint16(0x0134), FcTo0: uint8(0x4A), FcTo1: uint8(0x68)}, // Ĵ to Jh 28383 {FcFrom: uint16(0x0135), FcTo0: uint8(0x6A), FcTo1: uint8(0x68)}, // ĵ to jh 28384 {FcFrom: uint16(0x0136), FcTo0: uint8(0x4B)}, // Ķ to K 28385 {FcFrom: uint16(0x0137), FcTo0: uint8(0x6B)}, // ķ to k 28386 {FcFrom: uint16(0x0138), FcTo0: uint8(0x6B)}, // ĸ to k 28387 {FcFrom: uint16(0x0139), FcTo0: uint8(0x4C)}, // Ĺ to L 28388 {FcFrom: uint16(0x013A), FcTo0: uint8(0x6C)}, // ĺ to l 28389 {FcFrom: uint16(0x013B), FcTo0: uint8(0x4C)}, // Ļ to L 28390 {FcFrom: uint16(0x013C), FcTo0: uint8(0x6C)}, // ļ to l 28391 {FcFrom: uint16(0x013D), FcTo0: uint8(0x4C)}, // Ľ to L 28392 {FcFrom: uint16(0x013E), FcTo0: uint8(0x6C)}, // ľ to l 28393 {FcFrom: uint16(0x013F), FcTo0: uint8(0x4C), FcTo1: uint8(0x2E)}, // Ŀ to L. 28394 {FcFrom: uint16(0x0140), FcTo0: uint8(0x6C), FcTo1: uint8(0x2E)}, // ŀ to l. 28395 {FcFrom: uint16(0x0141), FcTo0: uint8(0x4C)}, // Ł to L 28396 {FcFrom: uint16(0x0142), FcTo0: uint8(0x6C)}, // ł to l 28397 {FcFrom: uint16(0x0143), FcTo0: uint8(0x4E)}, // Ń to N 28398 {FcFrom: uint16(0x0144), FcTo0: uint8(0x6E)}, // ń to n 28399 {FcFrom: uint16(0x0145), FcTo0: uint8(0x4E)}, // Ņ to N 28400 {FcFrom: uint16(0x0146), FcTo0: uint8(0x6E)}, // ņ to n 28401 {FcFrom: uint16(0x0147), FcTo0: uint8(0x4E)}, // Ň to N 28402 {FcFrom: uint16(0x0148), FcTo0: uint8(0x6E)}, // ň to n 28403 {FcFrom: uint16(0x0149), FcTo0: uint8(0x27), FcTo1: uint8(0x6E)}, // ʼn to 'n 28404 {FcFrom: uint16(0x014A), FcTo0: uint8(0x4E), FcTo1: uint8(0x47)}, // Ŋ to NG 28405 {FcFrom: uint16(0x014B), FcTo0: uint8(0x6E), FcTo1: uint8(0x67)}, // ŋ to ng 28406 {FcFrom: uint16(0x014C), FcTo0: uint8(0x4F)}, // Ō to O 28407 {FcFrom: uint16(0x014D), FcTo0: uint8(0x6F)}, // ō to o 28408 {FcFrom: uint16(0x014E), FcTo0: uint8(0x4F)}, // Ŏ to O 28409 {FcFrom: uint16(0x014F), FcTo0: uint8(0x6F)}, // ŏ to o 28410 {FcFrom: uint16(0x0150), FcTo0: uint8(0x4F)}, // Ő to O 28411 {FcFrom: uint16(0x0151), FcTo0: uint8(0x6F)}, // ő to o 28412 {FcFrom: uint16(0x0152), FcTo0: uint8(0x4F), FcTo1: uint8(0x45)}, // Œ to OE 28413 {FcFrom: uint16(0x0153), FcTo0: uint8(0x6F), FcTo1: uint8(0x65)}, // œ to oe 28414 {FcFrom: uint16(0x0154), FcTo0: uint8(0x52)}, // Ŕ to R 28415 {FcFrom: uint16(0x0155), FcTo0: uint8(0x72)}, // ŕ to r 28416 {FcFrom: uint16(0x0156), FcTo0: uint8(0x52)}, // Ŗ to R 28417 {FcFrom: uint16(0x0157), FcTo0: uint8(0x72)}, // ŗ to r 28418 {FcFrom: uint16(0x0158), FcTo0: uint8(0x52)}, // Ř to R 28419 {FcFrom: uint16(0x0159), FcTo0: uint8(0x72)}, // ř to r 28420 {FcFrom: uint16(0x015A), FcTo0: uint8(0x53)}, // Ś to S 28421 {FcFrom: uint16(0x015B), FcTo0: uint8(0x73)}, // ś to s 28422 {FcFrom: uint16(0x015C), FcTo0: uint8(0x53), FcTo1: uint8(0x68)}, // Ŝ to Sh 28423 {FcFrom: uint16(0x015D), FcTo0: uint8(0x73), FcTo1: uint8(0x68)}, // ŝ to sh 28424 {FcFrom: uint16(0x015E), FcTo0: uint8(0x53)}, // Ş to S 28425 {FcFrom: uint16(0x015F), FcTo0: uint8(0x73)}, // ş to s 28426 {FcFrom: uint16(0x0160), FcTo0: uint8(0x53)}, // Š to S 28427 {FcFrom: uint16(0x0161), FcTo0: uint8(0x73)}, // š to s 28428 {FcFrom: uint16(0x0162), FcTo0: uint8(0x54)}, // Ţ to T 28429 {FcFrom: uint16(0x0163), FcTo0: uint8(0x74)}, // ţ to t 28430 {FcFrom: uint16(0x0164), FcTo0: uint8(0x54)}, // Ť to T 28431 {FcFrom: uint16(0x0165), FcTo0: uint8(0x74)}, // ť to t 28432 {FcFrom: uint16(0x0166), FcTo0: uint8(0x54)}, // Ŧ to T 28433 {FcFrom: uint16(0x0167), FcTo0: uint8(0x74)}, // ŧ to t 28434 {FcFrom: uint16(0x0168), FcTo0: uint8(0x55)}, // Ũ to U 28435 {FcFrom: uint16(0x0169), FcTo0: uint8(0x75)}, // ũ to u 28436 {FcFrom: uint16(0x016A), FcTo0: uint8(0x55)}, // Ū to U 28437 {FcFrom: uint16(0x016B), FcTo0: uint8(0x75)}, // ū to u 28438 {FcFrom: uint16(0x016C), FcTo0: uint8(0x55)}, // Ŭ to U 28439 {FcFrom: uint16(0x016D), FcTo0: uint8(0x75)}, // ŭ to u 28440 {FcFrom: uint16(0x016E), FcTo0: uint8(0x55)}, // Ů to U 28441 {FcFrom: uint16(0x016F), FcTo0: uint8(0x75)}, // ů to u 28442 {FcFrom: uint16(0x0170), FcTo0: uint8(0x55)}, // Ű to U 28443 {FcFrom: uint16(0x0171), FcTo0: uint8(0x75)}, // ű to u 28444 {FcFrom: uint16(0x0172), FcTo0: uint8(0x55)}, // Ų to U 28445 {FcFrom: uint16(0x0173), FcTo0: uint8(0x75)}, // ų to u 28446 {FcFrom: uint16(0x0174), FcTo0: uint8(0x57)}, // Ŵ to W 28447 {FcFrom: uint16(0x0175), FcTo0: uint8(0x77)}, // ŵ to w 28448 {FcFrom: uint16(0x0176), FcTo0: uint8(0x59)}, // Ŷ to Y 28449 {FcFrom: uint16(0x0177), FcTo0: uint8(0x79)}, // ŷ to y 28450 {FcFrom: uint16(0x0178), FcTo0: uint8(0x59)}, // Ÿ to Y 28451 {FcFrom: uint16(0x0179), FcTo0: uint8(0x5A)}, // Ź to Z 28452 {FcFrom: uint16(0x017A), FcTo0: uint8(0x7A)}, // ź to z 28453 {FcFrom: uint16(0x017B), FcTo0: uint8(0x5A)}, // Ż to Z 28454 {FcFrom: uint16(0x017C), FcTo0: uint8(0x7A)}, // ż to z 28455 {FcFrom: uint16(0x017D), FcTo0: uint8(0x5A)}, // Ž to Z 28456 {FcFrom: uint16(0x017E), FcTo0: uint8(0x7A)}, // ž to z 28457 {FcFrom: uint16(0x017F), FcTo0: uint8(0x73)}, // ſ to s 28458 {FcFrom: uint16(0x0192), FcTo0: uint8(0x66)}, // ƒ to f 28459 {FcFrom: uint16(0x0218), FcTo0: uint8(0x53)}, // Ș to S 28460 {FcFrom: uint16(0x0219), FcTo0: uint8(0x73)}, // ș to s 28461 {FcFrom: uint16(0x021A), FcTo0: uint8(0x54)}, // Ț to T 28462 {FcFrom: uint16(0x021B), FcTo0: uint8(0x74)}, // ț to t 28463 {FcFrom: uint16(0x0386), FcTo0: uint8(0x41)}, // Ά to A 28464 {FcFrom: uint16(0x0388), FcTo0: uint8(0x45)}, // Έ to E 28465 {FcFrom: uint16(0x0389), FcTo0: uint8(0x49)}, // Ή to I 28466 {FcFrom: uint16(0x038A), FcTo0: uint8(0x49)}, // Ί to I 28467 {FcFrom: uint16(0x038C), FcTo0: uint8(0x4f)}, // Ό to O 28468 {FcFrom: uint16(0x038E), FcTo0: uint8(0x59)}, // Ύ to Y 28469 {FcFrom: uint16(0x038F), FcTo0: uint8(0x4f)}, // Ώ to O 28470 {FcFrom: uint16(0x0390), FcTo0: uint8(0x69)}, // ΐ to i 28471 {FcFrom: uint16(0x0391), FcTo0: uint8(0x41)}, // Α to A 28472 {FcFrom: uint16(0x0392), FcTo0: uint8(0x42)}, // Β to B 28473 {FcFrom: uint16(0x0393), FcTo0: uint8(0x47)}, // Γ to G 28474 {FcFrom: uint16(0x0394), FcTo0: uint8(0x44)}, // Δ to D 28475 {FcFrom: uint16(0x0395), FcTo0: uint8(0x45)}, // Ε to E 28476 {FcFrom: uint16(0x0396), FcTo0: uint8(0x5a)}, // Ζ to Z 28477 {FcFrom: uint16(0x0397), FcTo0: uint8(0x49)}, // Η to I 28478 {FcFrom: uint16(0x0398), FcTo0: uint8(0x54), FcTo1: uint8(0x68)}, // Θ to Th 28479 {FcFrom: uint16(0x0399), FcTo0: uint8(0x49)}, // Ι to I 28480 {FcFrom: uint16(0x039A), FcTo0: uint8(0x4b)}, // Κ to K 28481 {FcFrom: uint16(0x039B), FcTo0: uint8(0x4c)}, // Λ to L 28482 {FcFrom: uint16(0x039C), FcTo0: uint8(0x4d)}, // Μ to M 28483 {FcFrom: uint16(0x039D), FcTo0: uint8(0x4e)}, // Ν to N 28484 {FcFrom: uint16(0x039E), FcTo0: uint8(0x58)}, // Ξ to X 28485 {FcFrom: uint16(0x039F), FcTo0: uint8(0x4f)}, // Ο to O 28486 {FcFrom: uint16(0x03A0), FcTo0: uint8(0x50)}, // Π to P 28487 {FcFrom: uint16(0x03A1), FcTo0: uint8(0x52)}, // Ρ to R 28488 {FcFrom: uint16(0x03A3), FcTo0: uint8(0x53)}, // Σ to S 28489 {FcFrom: uint16(0x03A4), FcTo0: uint8(0x54)}, // Τ to T 28490 {FcFrom: uint16(0x03A5), FcTo0: uint8(0x59)}, // Υ to Y 28491 {FcFrom: uint16(0x03A6), FcTo0: uint8(0x46)}, // Φ to F 28492 {FcFrom: uint16(0x03A7), FcTo0: uint8(0x43), FcTo1: uint8(0x68)}, // Χ to Ch 28493 {FcFrom: uint16(0x03A8), FcTo0: uint8(0x50), FcTo1: uint8(0x73)}, // Ψ to Ps 28494 {FcFrom: uint16(0x03A9), FcTo0: uint8(0x4f)}, // Ω to O 28495 {FcFrom: uint16(0x03AA), FcTo0: uint8(0x49)}, // Ϊ to I 28496 {FcFrom: uint16(0x03AB), FcTo0: uint8(0x59)}, // Ϋ to Y 28497 {FcFrom: uint16(0x03AC), FcTo0: uint8(0x61)}, // ά to a 28498 {FcFrom: uint16(0x03AD), FcTo0: uint8(0x65)}, // έ to e 28499 {FcFrom: uint16(0x03AE), FcTo0: uint8(0x69)}, // ή to i 28500 {FcFrom: uint16(0x03AF), FcTo0: uint8(0x69)}, // ί to i 28501 {FcFrom: uint16(0x03B1), FcTo0: uint8(0x61)}, // α to a 28502 {FcFrom: uint16(0x03B2), FcTo0: uint8(0x62)}, // β to b 28503 {FcFrom: uint16(0x03B3), FcTo0: uint8(0x67)}, // γ to g 28504 {FcFrom: uint16(0x03B4), FcTo0: uint8(0x64)}, // δ to d 28505 {FcFrom: uint16(0x03B5), FcTo0: uint8(0x65)}, // ε to e 28506 {FcFrom: uint16(0x03B6), FcTo0: uint8(0x7a)}, // ζ to z 28507 {FcFrom: uint16(0x03B7), FcTo0: uint8(0x69)}, // η to i 28508 {FcFrom: uint16(0x03B8), FcTo0: uint8(0x74), FcTo1: uint8(0x68)}, // θ to th 28509 {FcFrom: uint16(0x03B9), FcTo0: uint8(0x69)}, // ι to i 28510 {FcFrom: uint16(0x03BA), FcTo0: uint8(0x6b)}, // κ to k 28511 {FcFrom: uint16(0x03BB), FcTo0: uint8(0x6c)}, // λ to l 28512 {FcFrom: uint16(0x03BC), FcTo0: uint8(0x6d)}, // μ to m 28513 {FcFrom: uint16(0x03BD), FcTo0: uint8(0x6e)}, // ν to n 28514 {FcFrom: uint16(0x03BE), FcTo0: uint8(0x78)}, // ξ to x 28515 {FcFrom: uint16(0x03BF), FcTo0: uint8(0x6f)}, // ο to o 28516 {FcFrom: uint16(0x03C0), FcTo0: uint8(0x70)}, // π to p 28517 {FcFrom: uint16(0x03C1), FcTo0: uint8(0x72)}, // ρ to r 28518 {FcFrom: uint16(0x03C3), FcTo0: uint8(0x73)}, // σ to s 28519 {FcFrom: uint16(0x03C4), FcTo0: uint8(0x74)}, // τ to t 28520 {FcFrom: uint16(0x03C5), FcTo0: uint8(0x79)}, // υ to y 28521 {FcFrom: uint16(0x03C6), FcTo0: uint8(0x66)}, // φ to f 28522 {FcFrom: uint16(0x03C7), FcTo0: uint8(0x63), FcTo1: uint8(0x68)}, // χ to ch 28523 {FcFrom: uint16(0x03C8), FcTo0: uint8(0x70), FcTo1: uint8(0x73)}, // ψ to ps 28524 {FcFrom: uint16(0x03C9), FcTo0: uint8(0x6f)}, // ω to o 28525 {FcFrom: uint16(0x03CA), FcTo0: uint8(0x69)}, // ϊ to i 28526 {FcFrom: uint16(0x03CB), FcTo0: uint8(0x79)}, // ϋ to y 28527 {FcFrom: uint16(0x03CC), FcTo0: uint8(0x6f)}, // ό to o 28528 {FcFrom: uint16(0x03CD), FcTo0: uint8(0x79)}, // ύ to y 28529 {FcFrom: uint16(0x03CE), FcTo0: uint8(0x69)}, // ώ to i 28530 {FcFrom: uint16(0x0400), FcTo0: uint8(0x45)}, // Ѐ to E 28531 {FcFrom: uint16(0x0401), FcTo0: uint8(0x45)}, // Ё to E 28532 {FcFrom: uint16(0x0402), FcTo0: uint8(0x44)}, // Ђ to D 28533 {FcFrom: uint16(0x0403), FcTo0: uint8(0x47)}, // Ѓ to G 28534 {FcFrom: uint16(0x0404), FcTo0: uint8(0x45)}, // Є to E 28535 {FcFrom: uint16(0x0405), FcTo0: uint8(0x5a)}, // Ѕ to Z 28536 {FcFrom: uint16(0x0406), FcTo0: uint8(0x49)}, // І to I 28537 {FcFrom: uint16(0x0407), FcTo0: uint8(0x49)}, // Ї to I 28538 {FcFrom: uint16(0x0408), FcTo0: uint8(0x4a)}, // Ј to J 28539 {FcFrom: uint16(0x0409), FcTo0: uint8(0x49)}, // Љ to I 28540 {FcFrom: uint16(0x040A), FcTo0: uint8(0x4e)}, // Њ to N 28541 {FcFrom: uint16(0x040B), FcTo0: uint8(0x44)}, // Ћ to D 28542 {FcFrom: uint16(0x040C), FcTo0: uint8(0x4b)}, // Ќ to K 28543 {FcFrom: uint16(0x040D), FcTo0: uint8(0x49)}, // Ѝ to I 28544 {FcFrom: uint16(0x040E), FcTo0: uint8(0x55)}, // Ў to U 28545 {FcFrom: uint16(0x040F), FcTo0: uint8(0x44)}, // Џ to D 28546 {FcFrom: uint16(0x0410), FcTo0: uint8(0x41)}, // А to A 28547 {FcFrom: uint16(0x0411), FcTo0: uint8(0x42)}, // Б to B 28548 {FcFrom: uint16(0x0412), FcTo0: uint8(0x56)}, // В to V 28549 {FcFrom: uint16(0x0413), FcTo0: uint8(0x47)}, // Г to G 28550 {FcFrom: uint16(0x0414), FcTo0: uint8(0x44)}, // Д to D 28551 {FcFrom: uint16(0x0415), FcTo0: uint8(0x45)}, // Е to E 28552 {FcFrom: uint16(0x0416), FcTo0: uint8(0x5a), FcTo1: uint8(0x68)}, // Ж to Zh 28553 {FcFrom: uint16(0x0417), FcTo0: uint8(0x5a)}, // З to Z 28554 {FcFrom: uint16(0x0418), FcTo0: uint8(0x49)}, // И to I 28555 {FcFrom: uint16(0x0419), FcTo0: uint8(0x49)}, // Й to I 28556 {FcFrom: uint16(0x041A), FcTo0: uint8(0x4b)}, // К to K 28557 {FcFrom: uint16(0x041B), FcTo0: uint8(0x4c)}, // Л to L 28558 {FcFrom: uint16(0x041C), FcTo0: uint8(0x4d)}, // М to M 28559 {FcFrom: uint16(0x041D), FcTo0: uint8(0x4e)}, // Н to N 28560 {FcFrom: uint16(0x041E), FcTo0: uint8(0x4f)}, // О to O 28561 {FcFrom: uint16(0x041F), FcTo0: uint8(0x50)}, // П to P 28562 {FcFrom: uint16(0x0420), FcTo0: uint8(0x52)}, // Р to R 28563 {FcFrom: uint16(0x0421), FcTo0: uint8(0x53)}, // С to S 28564 {FcFrom: uint16(0x0422), FcTo0: uint8(0x54)}, // Т to T 28565 {FcFrom: uint16(0x0423), FcTo0: uint8(0x55)}, // У to U 28566 {FcFrom: uint16(0x0424), FcTo0: uint8(0x46)}, // Ф to F 28567 {FcFrom: uint16(0x0425), FcTo0: uint8(0x4b), FcTo1: uint8(0x68)}, // Х to Kh 28568 {FcFrom: uint16(0x0426), FcTo0: uint8(0x54), FcTo1: uint8(0x63)}, // Ц to Tc 28569 {FcFrom: uint16(0x0427), FcTo0: uint8(0x43), FcTo1: uint8(0x68)}, // Ч to Ch 28570 {FcFrom: uint16(0x0428), FcTo0: uint8(0x53), FcTo1: uint8(0x68)}, // Ш to Sh 28571 {FcFrom: uint16(0x0429), FcTo0: uint8(0x53), FcTo1: uint8(0x68), FcTo2: uint8(0x63), FcTo3: uint8(0x68)}, // Щ to Shch 28572 {FcFrom: uint16(0x042A), FcTo0: uint8(0x61)}, // to A 28573 {FcFrom: uint16(0x042B), FcTo0: uint8(0x59)}, // Ы to Y 28574 {FcFrom: uint16(0x042C), FcTo0: uint8(0x59)}, // to Y 28575 {FcFrom: uint16(0x042D), FcTo0: uint8(0x45)}, // Э to E 28576 {FcFrom: uint16(0x042E), FcTo0: uint8(0x49), FcTo1: uint8(0x75)}, // Ю to Iu 28577 {FcFrom: uint16(0x042F), FcTo0: uint8(0x49), FcTo1: uint8(0x61)}, // Я to Ia 28578 {FcFrom: uint16(0x0430), FcTo0: uint8(0x61)}, // а to a 28579 {FcFrom: uint16(0x0431), FcTo0: uint8(0x62)}, // б to b 28580 {FcFrom: uint16(0x0432), FcTo0: uint8(0x76)}, // в to v 28581 {FcFrom: uint16(0x0433), FcTo0: uint8(0x67)}, // г to g 28582 {FcFrom: uint16(0x0434), FcTo0: uint8(0x64)}, // д to d 28583 {FcFrom: uint16(0x0435), FcTo0: uint8(0x65)}, // е to e 28584 {FcFrom: uint16(0x0436), FcTo0: uint8(0x7a), FcTo1: uint8(0x68)}, // ж to zh 28585 {FcFrom: uint16(0x0437), FcTo0: uint8(0x7a)}, // з to z 28586 {FcFrom: uint16(0x0438), FcTo0: uint8(0x69)}, // и to i 28587 {FcFrom: uint16(0x0439), FcTo0: uint8(0x69)}, // й to i 28588 {FcFrom: uint16(0x043A), FcTo0: uint8(0x6b)}, // к to k 28589 {FcFrom: uint16(0x043B), FcTo0: uint8(0x6c)}, // л to l 28590 {FcFrom: uint16(0x043C), FcTo0: uint8(0x6d)}, // м to m 28591 {FcFrom: uint16(0x043D), FcTo0: uint8(0x6e)}, // н to n 28592 {FcFrom: uint16(0x043E), FcTo0: uint8(0x6f)}, // о to o 28593 {FcFrom: uint16(0x043F), FcTo0: uint8(0x70)}, // п to p 28594 {FcFrom: uint16(0x0440), FcTo0: uint8(0x72)}, // р to r 28595 {FcFrom: uint16(0x0441), FcTo0: uint8(0x73)}, // с to s 28596 {FcFrom: uint16(0x0442), FcTo0: uint8(0x74)}, // т to t 28597 {FcFrom: uint16(0x0443), FcTo0: uint8(0x75)}, // у to u 28598 {FcFrom: uint16(0x0444), FcTo0: uint8(0x66)}, // ф to f 28599 {FcFrom: uint16(0x0445), FcTo0: uint8(0x6b), FcTo1: uint8(0x68)}, // х to kh 28600 {FcFrom: uint16(0x0446), FcTo0: uint8(0x74), FcTo1: uint8(0x63)}, // ц to tc 28601 {FcFrom: uint16(0x0447), FcTo0: uint8(0x63), FcTo1: uint8(0x68)}, // ч to ch 28602 {FcFrom: uint16(0x0448), FcTo0: uint8(0x73), FcTo1: uint8(0x68)}, // ш to sh 28603 {FcFrom: uint16(0x0449), FcTo0: uint8(0x73), FcTo1: uint8(0x68), FcTo2: uint8(0x63), FcTo3: uint8(0x68)}, // щ to shch 28604 {FcFrom: uint16(0x044A), FcTo0: uint8(0x61)}, // to a 28605 {FcFrom: uint16(0x044B), FcTo0: uint8(0x79)}, // ы to y 28606 {FcFrom: uint16(0x044C), FcTo0: uint8(0x79)}, // to y 28607 {FcFrom: uint16(0x044D), FcTo0: uint8(0x65)}, // э to e 28608 {FcFrom: uint16(0x044E), FcTo0: uint8(0x69), FcTo1: uint8(0x75)}, // ю to iu 28609 {FcFrom: uint16(0x044F), FcTo0: uint8(0x69), FcTo1: uint8(0x61)}, // я to ia 28610 {FcFrom: uint16(0x0450), FcTo0: uint8(0x65)}, // ѐ to e 28611 {FcFrom: uint16(0x0451), FcTo0: uint8(0x65)}, // ё to e 28612 {FcFrom: uint16(0x0452), FcTo0: uint8(0x64)}, // ђ to d 28613 {FcFrom: uint16(0x0453), FcTo0: uint8(0x67)}, // ѓ to g 28614 {FcFrom: uint16(0x0454), FcTo0: uint8(0x65)}, // є to e 28615 {FcFrom: uint16(0x0455), FcTo0: uint8(0x7a)}, // ѕ to z 28616 {FcFrom: uint16(0x0456), FcTo0: uint8(0x69)}, // і to i 28617 {FcFrom: uint16(0x0457), FcTo0: uint8(0x69)}, // ї to i 28618 {FcFrom: uint16(0x0458), FcTo0: uint8(0x6a)}, // ј to j 28619 {FcFrom: uint16(0x0459), FcTo0: uint8(0x69)}, // љ to i 28620 {FcFrom: uint16(0x045A), FcTo0: uint8(0x6e)}, // њ to n 28621 {FcFrom: uint16(0x045B), FcTo0: uint8(0x64)}, // ћ to d 28622 {FcFrom: uint16(0x045C), FcTo0: uint8(0x6b)}, // ќ to k 28623 {FcFrom: uint16(0x045D), FcTo0: uint8(0x69)}, // ѝ to i 28624 {FcFrom: uint16(0x045E), FcTo0: uint8(0x75)}, // ў to u 28625 {FcFrom: uint16(0x045F), FcTo0: uint8(0x64)}, // џ to d 28626 {FcFrom: uint16(0x1E02), FcTo0: uint8(0x42)}, // Ḃ to B 28627 {FcFrom: uint16(0x1E03), FcTo0: uint8(0x62)}, // ḃ to b 28628 {FcFrom: uint16(0x1E0A), FcTo0: uint8(0x44)}, // Ḋ to D 28629 {FcFrom: uint16(0x1E0B), FcTo0: uint8(0x64)}, // ḋ to d 28630 {FcFrom: uint16(0x1E1E), FcTo0: uint8(0x46)}, // Ḟ to F 28631 {FcFrom: uint16(0x1E1F), FcTo0: uint8(0x66)}, // ḟ to f 28632 {FcFrom: uint16(0x1E40), FcTo0: uint8(0x4D)}, // Ṁ to M 28633 {FcFrom: uint16(0x1E41), FcTo0: uint8(0x6D)}, // ṁ to m 28634 {FcFrom: uint16(0x1E56), FcTo0: uint8(0x50)}, // Ṗ to P 28635 {FcFrom: uint16(0x1E57), FcTo0: uint8(0x70)}, // ṗ to p 28636 {FcFrom: uint16(0x1E60), FcTo0: uint8(0x53)}, // Ṡ to S 28637 {FcFrom: uint16(0x1E61), FcTo0: uint8(0x73)}, // ṡ to s 28638 {FcFrom: uint16(0x1E6A), FcTo0: uint8(0x54)}, // Ṫ to T 28639 {FcFrom: uint16(0x1E6B), FcTo0: uint8(0x74)}, // ṫ to t 28640 {FcFrom: uint16(0x1E80), FcTo0: uint8(0x57)}, // Ẁ to W 28641 {FcFrom: uint16(0x1E81), FcTo0: uint8(0x77)}, // ẁ to w 28642 {FcFrom: uint16(0x1E82), FcTo0: uint8(0x57)}, // Ẃ to W 28643 {FcFrom: uint16(0x1E83), FcTo0: uint8(0x77)}, // ẃ to w 28644 {FcFrom: uint16(0x1E84), FcTo0: uint8(0x57)}, // Ẅ to W 28645 {FcFrom: uint16(0x1E85), FcTo0: uint8(0x77)}, // ẅ to w 28646 {FcFrom: uint16(0x1EF2), FcTo0: uint8(0x59)}, // Ỳ to Y 28647 {FcFrom: uint16(0x1EF3), FcTo0: uint8(0x79)}, // ỳ to y 28648 {FcFrom: uint16(0xFB00), FcTo0: uint8(0x66), FcTo1: uint8(0x66)}, // ff to ff 28649 {FcFrom: uint16(0xFB01), FcTo0: uint8(0x66), FcTo1: uint8(0x69)}, // fi to fi 28650 {FcFrom: uint16(0xFB02), FcTo0: uint8(0x66), FcTo1: uint8(0x6C)}, // fl to fl 28651 {FcFrom: uint16(0xFB05), FcTo0: uint8(0x73), FcTo1: uint8(0x74)}, // ſt to st 28652 {FcFrom: uint16(0xFB06), FcTo0: uint8(0x73), FcTo1: uint8(0x74)}, // st to st 28653 } /* spellfix.c:1306:30 */ 28654 28655 func spellfixFindTranslit(tls *libc.TLS, c int32, pxTop uintptr) uintptr { /* spellfix.c:1698:30: */ 28656 *(*int32)(unsafe.Pointer(pxTop)) = (int32((uint64(unsafe.Sizeof(translit)) / uint64(unsafe.Sizeof(Transliteration{}))) - uint64(1))) 28657 return uintptr(unsafe.Pointer(&translit)) 28658 } 28659 28660 // Convert the input string from UTF-8 into pure ASCII by converting 28661 // all non-ASCII characters to some combination of characters in the 28662 // ASCII subset. 28663 // 28664 // The returned string might contain more characters than the input. 28665 // 28666 // Space to hold the returned string comes from sqlite3_malloc() and 28667 // should be freed by the caller. 28668 func transliterate(tls *libc.TLS, zIn uintptr, nIn int32) uintptr { /* spellfix.c:1713:22: */ 28669 bp := tls.Alloc(8) 28670 defer tls.Free(8) 28671 28672 var zOut uintptr = sqlite3.Xsqlite3_malloc64(tls, (uint64((nIn * 4) + 1))) 28673 var c int32 28674 // var sz int32 at bp, 4 28675 28676 var nOut int32 28677 if zOut == uintptr(0) { 28678 return uintptr(0) 28679 } 28680 nOut = 0 28681 for nIn > 0 { 28682 c = utf8Read(tls, zIn, nIn, bp /* &sz */) 28683 zIn += uintptr(*(*int32)(unsafe.Pointer(bp /* sz */))) 28684 nIn = nIn - (*(*int32)(unsafe.Pointer(bp /* sz */))) 28685 if c <= 127 { 28686 *(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncInt32(&nOut, 1)))) = uint8(c) 28687 } else { 28688 // var xTop int32 at bp+4, 4 28689 28690 var xBtm int32 28691 var x int32 28692 var tbl uintptr = spellfixFindTranslit(tls, c, bp+4 /* &xTop */) 28693 xBtm = 0 28694 for *(*int32)(unsafe.Pointer(bp + 4 /* xTop */)) >= xBtm { 28695 x = ((*(*int32)(unsafe.Pointer(bp + 4 /* xTop */)) + xBtm) / 2) 28696 if int32((*Transliteration)(unsafe.Pointer(tbl+uintptr(x)*6)).FcFrom) == c { 28697 *(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncInt32(&nOut, 1)))) = (*Transliteration)(unsafe.Pointer(tbl + uintptr(x)*6)).FcTo0 28698 if (*Transliteration)(unsafe.Pointer(tbl+uintptr(x)*6)).FcTo1 != 0 { 28699 *(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncInt32(&nOut, 1)))) = (*Transliteration)(unsafe.Pointer(tbl + uintptr(x)*6)).FcTo1 28700 if (*Transliteration)(unsafe.Pointer(tbl+uintptr(x)*6)).FcTo2 != 0 { 28701 *(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncInt32(&nOut, 1)))) = (*Transliteration)(unsafe.Pointer(tbl + uintptr(x)*6)).FcTo2 28702 if (*Transliteration)(unsafe.Pointer(tbl+uintptr(x)*6)).FcTo3 != 0 { 28703 *(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncInt32(&nOut, 1)))) = (*Transliteration)(unsafe.Pointer(tbl + uintptr(x)*6)).FcTo3 28704 } 28705 } 28706 } 28707 c = 0 28708 break 28709 } else if int32((*Transliteration)(unsafe.Pointer(tbl+uintptr(x)*6)).FcFrom) > c { 28710 *(*int32)(unsafe.Pointer(bp + 4 /* xTop */)) = (x - 1) 28711 } else { 28712 xBtm = (x + 1) 28713 } 28714 } 28715 if c != 0 { 28716 *(*uint8)(unsafe.Pointer(zOut + uintptr(libc.PostIncInt32(&nOut, 1)))) = uint8('?') 28717 } 28718 } 28719 } 28720 *(*uint8)(unsafe.Pointer(zOut + uintptr(nOut))) = uint8(0) 28721 return zOut 28722 } 28723 28724 // Return the number of characters in the shortest prefix of the input 28725 // string that transliterates to an ASCII string nTrans bytes or longer. 28726 // Or, if the transliteration of the input string is less than nTrans 28727 // bytes in size, return the number of characters in the input string. 28728 func translen_to_charlen(tls *libc.TLS, zIn uintptr, nIn int32, nTrans int32) int32 { /* spellfix.c:1771:12: */ 28729 bp := tls.Alloc(8) 28730 defer tls.Free(8) 28731 28732 var i int32 28733 var c int32 28734 // var sz int32 at bp, 4 28735 28736 var nOut int32 28737 var nChar int32 28738 28739 i = libc.AssignInt32(&nOut, 0) 28740 for nChar = 0; (i < nIn) && (nOut < nTrans); nChar++ { 28741 c = utf8Read(tls, (zIn + uintptr(i)), (nIn - i), bp /* &sz */) 28742 i = i + (*(*int32)(unsafe.Pointer(bp /* sz */))) 28743 28744 nOut++ 28745 if c >= 128 { 28746 // var xTop int32 at bp+4, 4 28747 28748 var xBtm int32 28749 var x int32 28750 var tbl uintptr = spellfixFindTranslit(tls, c, bp+4 /* &xTop */) 28751 xBtm = 0 28752 for *(*int32)(unsafe.Pointer(bp + 4 /* xTop */)) >= xBtm { 28753 x = ((*(*int32)(unsafe.Pointer(bp + 4 /* xTop */)) + xBtm) / 2) 28754 if int32((*Transliteration)(unsafe.Pointer(tbl+uintptr(x)*6)).FcFrom) == c { 28755 if (*Transliteration)(unsafe.Pointer(tbl+uintptr(x)*6)).FcTo1 != 0 { 28756 nOut++ 28757 if (*Transliteration)(unsafe.Pointer(tbl+uintptr(x)*6)).FcTo2 != 0 { 28758 nOut++ 28759 if (*Transliteration)(unsafe.Pointer(tbl+uintptr(x)*6)).FcTo3 != 0 { 28760 nOut++ 28761 } 28762 } 28763 } 28764 break 28765 } else if int32((*Transliteration)(unsafe.Pointer(tbl+uintptr(x)*6)).FcFrom) > c { 28766 *(*int32)(unsafe.Pointer(bp + 4 /* xTop */)) = (x - 1) 28767 } else { 28768 xBtm = (x + 1) 28769 } 28770 } 28771 } 28772 } 28773 28774 return nChar 28775 } 28776 28777 // spellfix1_translit(X) 28778 // 28779 // Convert a string that contains non-ASCII Roman characters into 28780 // pure ASCII. 28781 func transliterateSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* spellfix.c:1817:13: */ 28782 var zIn uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 28783 var nIn int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) 28784 var zOut uintptr = transliterate(tls, zIn, nIn) 28785 if zOut == uintptr(0) { 28786 sqlite3.Xsqlite3_result_error_nomem(tls, context) 28787 } else { 28788 sqlite3.Xsqlite3_result_text(tls, context, zOut, -1, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) 28789 } 28790 } 28791 28792 // spellfix1_scriptcode(X) 28793 // 28794 // Try to determine the dominant script used by the word X and return 28795 // its ISO 15924 numeric code. 28796 // 28797 // The current implementation only understands the following scripts: 28798 // 28799 // 215 (Latin) 28800 // 220 (Cyrillic) 28801 // 200 (Greek) 28802 // 28803 // This routine will return 998 if the input X contains characters from 28804 // two or more of the above scripts or 999 if X contains no characters 28805 // from any of the above scripts. 28806 func scriptCodeSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* spellfix.c:1848:13: */ 28807 bp := tls.Alloc(4) 28808 defer tls.Free(4) 28809 28810 var zIn uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 28811 var nIn int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) 28812 var c int32 28813 // var sz int32 at bp, 4 28814 28815 var scriptMask int32 = 0 28816 var res int32 28817 var seenDigit int32 = 0 28818 28819 for nIn > 0 { 28820 c = utf8Read(tls, zIn, nIn, bp /* &sz */) 28821 zIn += uintptr(*(*int32)(unsafe.Pointer(bp /* sz */))) 28822 nIn = nIn - (*(*int32)(unsafe.Pointer(bp /* sz */))) 28823 if c < 0x02af { 28824 if (c >= 0x80) || (int32(midClass[(c&0x7f)]) < CCLASS_DIGIT) { 28825 scriptMask = scriptMask | (SCRIPT_LATIN) 28826 } else if (c >= '0') && (c <= '9') { 28827 seenDigit = 1 28828 } 28829 } else if (c >= 0x0400) && (c <= 0x04ff) { 28830 scriptMask = scriptMask | (SCRIPT_CYRILLIC) 28831 } else if (c >= 0x0386) && (c <= 0x03ce) { 28832 scriptMask = scriptMask | (SCRIPT_GREEK) 28833 } else if (c >= 0x0590) && (c <= 0x05ff) { 28834 scriptMask = scriptMask | (SCRIPT_HEBREW) 28835 } else if (c >= 0x0600) && (c <= 0x06ff) { 28836 scriptMask = scriptMask | (SCRIPT_ARABIC) 28837 } 28838 } 28839 if (scriptMask == 0) && (seenDigit != 0) { 28840 scriptMask = SCRIPT_LATIN 28841 } 28842 switch scriptMask { 28843 case 0: 28844 res = 999 28845 break 28846 case SCRIPT_LATIN: 28847 res = 215 28848 break 28849 case SCRIPT_CYRILLIC: 28850 res = 220 28851 break 28852 case SCRIPT_GREEK: 28853 res = 200 28854 break 28855 case SCRIPT_HEBREW: 28856 res = 125 28857 break 28858 case SCRIPT_ARABIC: 28859 res = 160 28860 break 28861 default: 28862 res = 998 28863 break 28864 } 28865 sqlite3.Xsqlite3_result_int(tls, context, res) 28866 } 28867 28868 // End transliterate 28869 // 28870 // 28871 // Begin spellfix1 virtual table. 28872 28873 // Maximum length of a phonehash used for querying the shadow table 28874 28875 // Maximum number of hash strings to examine per query 28876 28877 type spellfix1_vtab1 = struct { 28878 Fbase sqlite3_vtab 28879 Fdb uintptr 28880 FzDbName uintptr 28881 FzTableName uintptr 28882 FzCostTable uintptr 28883 FpConfig3 uintptr 28884 } /* spellfix.c:1910:9 */ 28885 28886 // End transliterate 28887 // 28888 // 28889 // Begin spellfix1 virtual table. 28890 28891 // Maximum length of a phonehash used for querying the shadow table 28892 28893 // Maximum number of hash strings to examine per query 28894 28895 type spellfix1_vtab = spellfix1_vtab1 /* spellfix.c:1910:31 */ 28896 type spellfix1_cursor1 = struct { 28897 Fbase sqlite3_vtab_cursor 28898 FpVTab uintptr 28899 FzPattern uintptr 28900 FidxNum int32 28901 FnRow int32 28902 FnAlloc int32 28903 FiRow int32 28904 FiLang int32 28905 FiTop int32 28906 FiScope int32 28907 FnSearch int32 28908 FpFullScan uintptr 28909 Fa uintptr 28910 } /* spellfix.c:1911:9 */ 28911 28912 type spellfix1_cursor = spellfix1_cursor1 /* spellfix.c:1911:33 */ 28913 28914 // Fuzzy-search cursor object 28915 type spellfix1_row = struct { 28916 FiRowid sqlite3_int64 28917 FzWord uintptr 28918 FiRank int32 28919 FiDistance int32 28920 FiScore int32 28921 FiMatchlen int32 28922 FzHash [32]int8 28923 } /* spellfix.c:1911:9 */ 28924 28925 // Construct one or more SQL statements from the format string given 28926 // and then evaluate those statements. The success code is written 28927 // into *pRc. 28928 // 28929 // If *pRc is initially non-zero then this routine is a no-op. 28930 func spellfix1DbExec(tls *libc.TLS, pRc uintptr, db uintptr, zFormat uintptr, va uintptr) { /* spellfix.c:1955:13: */ 28931 var ap va_list 28932 _ = ap 28933 var zSql uintptr 28934 if *(*int32)(unsafe.Pointer(pRc)) != 0 { 28935 return 28936 } 28937 ap = va 28938 zSql = sqlite3.Xsqlite3_vmprintf(tls, zFormat, ap) 28939 _ = ap 28940 if zSql == uintptr(0) { 28941 *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM 28942 } else { 28943 *(*int32)(unsafe.Pointer(pRc)) = sqlite3.Xsqlite3_exec(tls, db, zSql, uintptr(0), uintptr(0), uintptr(0)) 28944 sqlite3.Xsqlite3_free(tls, zSql) 28945 } 28946 } 28947 28948 // xDisconnect/xDestroy method for the fuzzy-search module. 28949 func spellfix1Uninit(tls *libc.TLS, isDestroy int32, pVTab uintptr) int32 { /* spellfix.c:1978:12: */ 28950 bp := tls.Alloc(20) 28951 defer tls.Free(20) 28952 28953 var p uintptr = pVTab 28954 *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) = SQLITE_OK 28955 if isDestroy != 0 { 28956 var db uintptr = (*spellfix1_vtab)(unsafe.Pointer(p)).Fdb 28957 spellfix1DbExec(tls, bp+16 /* &rc */, db, ts+6637, /* "DROP TABLE IF EX..." */ 28958 libc.VaList(bp, (*spellfix1_vtab)(unsafe.Pointer(p)).FzDbName, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName)) 28959 } 28960 if *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) == SQLITE_OK { 28961 sqlite3.Xsqlite3_free(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName) 28962 editDist3ConfigDelete(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3) 28963 sqlite3.Xsqlite3_free(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable) 28964 sqlite3.Xsqlite3_free(tls, p) 28965 } 28966 return *(*int32)(unsafe.Pointer(bp + 16 /* rc */)) 28967 } 28968 28969 func spellfix1Disconnect(tls *libc.TLS, pVTab uintptr) int32 { /* spellfix.c:1994:12: */ 28970 return spellfix1Uninit(tls, 0, pVTab) 28971 } 28972 28973 func spellfix1Destroy(tls *libc.TLS, pVTab uintptr) int32 { /* spellfix.c:1997:12: */ 28974 return spellfix1Uninit(tls, 1, pVTab) 28975 } 28976 28977 // Make a copy of a string. Remove leading and trailing whitespace 28978 // and dequote it. 28979 func spellfix1Dequote(tls *libc.TLS, zIn uintptr) uintptr { /* spellfix.c:2005:13: */ 28980 bp := tls.Alloc(8) 28981 defer tls.Free(8) 28982 28983 var zOut uintptr 28984 var i int32 28985 var j int32 28986 var c int8 28987 for (int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(zIn)))))*2))) & int32(_ISspace)) != 0 { 28988 zIn++ 28989 } 28990 zOut = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zIn)) 28991 if zOut == uintptr(0) { 28992 return uintptr(0) 28993 } 28994 i = int32(libc.Xstrlen(tls, zOut)) 28995 *(*int8)(unsafe.Pointer(zOut + uintptr(i))) = int8(0) 28996 c = *(*int8)(unsafe.Pointer(zOut)) 28997 if (int32(c) == '\'') || (int32(c) == '"') { 28998 i = 1 28999 j = 0 29000 for ; 1 != 0; i++ { 29001 *(*int8)(unsafe.Pointer(zOut + uintptr(libc.PostIncInt32(&j, 1)))) = *(*int8)(unsafe.Pointer(zOut + uintptr(i))) 29002 if int32(*(*int8)(unsafe.Pointer(zOut + uintptr(i)))) == int32(c) { 29003 if int32(*(*int8)(unsafe.Pointer(zOut + uintptr((i + 1))))) == int32(c) { 29004 i++ 29005 } else { 29006 *(*int8)(unsafe.Pointer(zOut + uintptr((j - 1)))) = int8(0) 29007 break 29008 } 29009 } 29010 } 29011 } 29012 return zOut 29013 } 29014 29015 // xConnect/xCreate method for the spellfix1 module. Arguments are: 29016 // 29017 // argv[0] -> module name ("spellfix1") 29018 // argv[1] -> database name 29019 // argv[2] -> table name 29020 // argv[3].. -> optional arguments (i.e. "edit_cost_table" parameter) 29021 func spellfix1Init(tls *libc.TLS, isCreate int32, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVTab uintptr, pzErr uintptr) int32 { /* spellfix.c:2043:12: */ 29022 bp := tls.Alloc(60) 29023 defer tls.Free(60) 29024 29025 var pNew uintptr = uintptr(0) 29026 // const char *zModule = argv[0]; // not used 29027 var zDbName uintptr = *(*uintptr)(unsafe.Pointer(argv + 1*8)) 29028 var zTableName uintptr = *(*uintptr)(unsafe.Pointer(argv + 2*8)) 29029 var nDbName int32 29030 *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = SQLITE_OK 29031 var i int32 29032 29033 nDbName = int32(libc.Xstrlen(tls, zDbName)) 29034 pNew = sqlite3.Xsqlite3_malloc64(tls, (uint64((uint64(unsafe.Sizeof(spellfix1_vtab{})) + uint64(nDbName)) + uint64(1)))) 29035 if pNew == uintptr(0) { 29036 *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = SQLITE_NOMEM 29037 } else { 29038 libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(spellfix1_vtab{}))) 29039 (*spellfix1_vtab)(unsafe.Pointer(pNew)).FzDbName = (pNew + 1*64) 29040 libc.Xmemcpy(tls, (*spellfix1_vtab)(unsafe.Pointer(pNew)).FzDbName, zDbName, (uint64(nDbName + 1))) 29041 (*spellfix1_vtab)(unsafe.Pointer(pNew)).FzTableName = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zTableName)) 29042 (*spellfix1_vtab)(unsafe.Pointer(pNew)).Fdb = db 29043 if (*spellfix1_vtab)(unsafe.Pointer(pNew)).FzTableName == uintptr(0) { 29044 *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = SQLITE_NOMEM 29045 } else { 29046 sqlite3.Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_INNOCUOUS, 0) 29047 *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = sqlite3.Xsqlite3_declare_vtab(tls, db, 29048 29049 ts+6674 /* "CREATE TABLE x(w..." */) 29050 } 29051 if (*(*int32)(unsafe.Pointer(bp + 56 /* rc */)) == SQLITE_OK) && (isCreate != 0) { 29052 spellfix1DbExec(tls, bp+56 /* &rc */, db, 29053 29054 ts+6828, /* "CREATE TABLE IF ..." */ 29055 libc.VaList(bp+8, zDbName, zTableName)) 29056 spellfix1DbExec(tls, bp+56 /* &rc */, db, 29057 29058 ts+6962, /* "CREATE INDEX IF ..." */ 29059 libc.VaList(bp+24, zDbName, zTableName, zTableName)) 29060 } 29061 for i = 3; (*(*int32)(unsafe.Pointer(bp + 56 /* rc */)) == SQLITE_OK) && (i < argc); i++ { 29062 if (libc.Xstrncmp(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), ts+7047 /* "edit_cost_table=" */, uint64(16)) == 0) && ((*spellfix1_vtab)(unsafe.Pointer(pNew)).FzCostTable == uintptr(0)) { 29063 (*spellfix1_vtab)(unsafe.Pointer(pNew)).FzCostTable = spellfix1Dequote(tls, (*(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)) + 16)) 29064 if (*spellfix1_vtab)(unsafe.Pointer(pNew)).FzCostTable == uintptr(0) { 29065 *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = SQLITE_NOMEM 29066 } 29067 continue 29068 } 29069 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+7064 /* "bad argument to ..." */, libc.VaList(bp+48, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)))) 29070 *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) = SQLITE_ERROR 29071 } 29072 } 29073 29074 if (*(*int32)(unsafe.Pointer(bp + 56 /* rc */)) != 0) && (pNew != 0) { 29075 *(*uintptr)(unsafe.Pointer(ppVTab)) = uintptr(0) 29076 spellfix1Uninit(tls, 0, (pNew /* &.base */)) 29077 } else { 29078 *(*uintptr)(unsafe.Pointer(ppVTab)) = pNew 29079 } 29080 return *(*int32)(unsafe.Pointer(bp + 56 /* rc */)) 29081 } 29082 29083 // The xConnect and xCreate methods 29084 func spellfix1Connect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVTab uintptr, pzErr uintptr) int32 { /* spellfix.c:2133:12: */ 29085 return spellfix1Init(tls, 0, db, pAux, argc, argv, ppVTab, pzErr) 29086 } 29087 29088 func spellfix1Create(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVTab uintptr, pzErr uintptr) int32 { /* spellfix.c:2142:12: */ 29089 return spellfix1Init(tls, 1, db, pAux, argc, argv, ppVTab, pzErr) 29090 } 29091 29092 // Clear all of the content from a cursor. 29093 func spellfix1ResetCursor(tls *libc.TLS, pCur uintptr) { /* spellfix.c:2155:13: */ 29094 var i int32 29095 for i = 0; i < (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow; i++ { 29096 sqlite3.Xsqlite3_free(tls, (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa+uintptr(i)*64)).FzWord) 29097 } 29098 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow = 0 29099 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow = 0 29100 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnSearch = 0 29101 if (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpFullScan != 0 { 29102 sqlite3.Xsqlite3_finalize(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpFullScan) 29103 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpFullScan = uintptr(0) 29104 } 29105 } 29106 29107 // Resize the cursor to hold up to N rows of content 29108 func spellfix1ResizeCursor(tls *libc.TLS, pCur uintptr, N int32) { /* spellfix.c:2172:13: */ 29109 var aNew uintptr 29110 29111 aNew = sqlite3.Xsqlite3_realloc64(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa, (uint64(uint64(unsafe.Sizeof(spellfix1_row{})) * uint64(N)))) 29112 if (aNew == uintptr(0)) && (N > 0) { 29113 spellfix1ResetCursor(tls, pCur) 29114 sqlite3.Xsqlite3_free(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa) 29115 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnAlloc = 0 29116 (*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa = uintptr(0) 29117 } else { 29118 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnAlloc = N 29119 (*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa = aNew 29120 } 29121 } 29122 29123 // Close a fuzzy-search cursor. 29124 func spellfix1Close(tls *libc.TLS, cur uintptr) int32 { /* spellfix.c:2191:12: */ 29125 var pCur uintptr = cur 29126 spellfix1ResetCursor(tls, pCur) 29127 spellfix1ResizeCursor(tls, pCur, 0) 29128 sqlite3.Xsqlite3_free(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FzPattern) 29129 sqlite3.Xsqlite3_free(tls, pCur) 29130 return SQLITE_OK 29131 } 29132 29133 // 29134 // The plan number is a bitmask of the SPELLFIX_IDXNUM_* values defined 29135 // above. 29136 // 29137 // filter.argv[*] values contains $str, $langid, $top, $scope and $rowid 29138 // if specified and in that order. 29139 func spellfix1BestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* spellfix.c:2217:12: */ 29140 var iPlan int32 = 0 29141 var iLangTerm int32 = -1 29142 var iTopTerm int32 = -1 29143 var iScopeTerm int32 = -1 29144 var iDistTerm int32 = -1 29145 var iRowidTerm int32 = -1 29146 var i int32 29147 var pConstraint uintptr 29148 pConstraint = (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint 29149 i = 0 29150 __1: 29151 if !(i < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { 29152 goto __3 29153 } 29154 { 29155 if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 { 29156 goto __2 29157 } 29158 29159 // Terms of the form: word MATCH $str 29160 if (((iPlan & SPELLFIX_IDXNUM_MATCH) == 0) && 29161 ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == SPELLFIX_COL_WORD)) && 29162 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH) { 29163 iPlan = iPlan | (SPELLFIX_IDXNUM_MATCH) 29164 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).FargvIndex = 1 29165 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(i)*8)).Fomit = uint8(1) 29166 } 29167 29168 // Terms of the form: langid = $langid 29169 if (((iPlan & SPELLFIX_IDXNUM_LANGID) == 0) && 29170 ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == SPELLFIX_COL_LANGID)) && 29171 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { 29172 iPlan = iPlan | (SPELLFIX_IDXNUM_LANGID) 29173 iLangTerm = i 29174 } 29175 29176 // Terms of the form: top = $top 29177 if (((iPlan & SPELLFIX_IDXNUM_TOP) == 0) && 29178 ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == SPELLFIX_COL_TOP)) && 29179 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { 29180 iPlan = iPlan | (SPELLFIX_IDXNUM_TOP) 29181 iTopTerm = i 29182 } 29183 29184 // Terms of the form: scope = $scope 29185 if (((iPlan & SPELLFIX_IDXNUM_SCOPE) == 0) && 29186 ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == SPELLFIX_COL_SCOPE)) && 29187 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { 29188 iPlan = iPlan | (SPELLFIX_IDXNUM_SCOPE) 29189 iScopeTerm = i 29190 } 29191 29192 // Terms of the form: distance < $dist or distance <= $dist 29193 if (((iPlan & (0x10 | 0x20)) == 0) && 29194 ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn == SPELLFIX_COL_DISTANCE)) && 29195 ((int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LT) || 29196 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LE)) { 29197 if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LT { 29198 iPlan = iPlan | (SPELLFIX_IDXNUM_DISTLT) 29199 } else { 29200 iPlan = iPlan | (SPELLFIX_IDXNUM_DISTLE) 29201 } 29202 iDistTerm = i 29203 } 29204 29205 // Terms of the form: distance < $dist or distance <= $dist 29206 if (((iPlan & SPELLFIX_IDXNUM_ROWID) == 0) && 29207 ((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn < 0)) && 29208 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { 29209 iPlan = iPlan | (SPELLFIX_IDXNUM_ROWID) 29210 iRowidTerm = i 29211 } 29212 29213 } 29214 goto __2 29215 __2: 29216 i++ 29217 pConstraint += 12 29218 goto __1 29219 goto __3 29220 __3: 29221 ; 29222 if (iPlan & SPELLFIX_IDXNUM_MATCH) != 0 { 29223 var idx int32 = 2 29224 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = iPlan 29225 if (((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy == 1) && 29226 ((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).FiColumn == SPELLFIX_COL_SCORE)) && 29227 (int32((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).Fdesc) == 0) { 29228 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 1 // Default order by iScore 29229 } 29230 if (iPlan & SPELLFIX_IDXNUM_LANGID) != 0 { 29231 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iLangTerm)*8)).FargvIndex = libc.PostIncInt32(&idx, 1) 29232 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iLangTerm)*8)).Fomit = uint8(1) 29233 } 29234 if (iPlan & SPELLFIX_IDXNUM_TOP) != 0 { 29235 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iTopTerm)*8)).FargvIndex = libc.PostIncInt32(&idx, 1) 29236 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iTopTerm)*8)).Fomit = uint8(1) 29237 } 29238 if (iPlan & SPELLFIX_IDXNUM_SCOPE) != 0 { 29239 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iScopeTerm)*8)).FargvIndex = libc.PostIncInt32(&idx, 1) 29240 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iScopeTerm)*8)).Fomit = uint8(1) 29241 } 29242 if (iPlan & (0x10 | 0x20)) != 0 { 29243 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iDistTerm)*8)).FargvIndex = libc.PostIncInt32(&idx, 1) 29244 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iDistTerm)*8)).Fomit = uint8(1) 29245 } 29246 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 1e5 29247 } else if (iPlan & SPELLFIX_IDXNUM_ROWID) != 0 { 29248 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = SPELLFIX_IDXNUM_ROWID 29249 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iRowidTerm)*8)).FargvIndex = 1 29250 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iRowidTerm)*8)).Fomit = uint8(1) 29251 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(5) 29252 } else { 29253 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 0 29254 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 1e50 29255 } 29256 return SQLITE_OK 29257 } 29258 29259 // Open a new fuzzy-search cursor. 29260 func spellfix1Open(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* spellfix.c:2331:12: */ 29261 var p uintptr = pVTab 29262 var pCur uintptr 29263 pCur = sqlite3.Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(spellfix1_cursor{}))) 29264 if pCur == uintptr(0) { 29265 return SQLITE_NOMEM 29266 } 29267 libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(spellfix1_cursor{}))) 29268 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpVTab = p 29269 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) 29270 return SQLITE_OK 29271 } 29272 29273 // Adjust a distance measurement by the words rank in order to show 29274 // preference to common words. 29275 func spellfix1Score(tls *libc.TLS, iDistance int32, iRank int32) int32 { /* spellfix.c:2346:12: */ 29276 var iLog2 int32 29277 iLog2 = 0 29278 __1: 29279 if !(iRank > 0) { 29280 goto __3 29281 } 29282 { 29283 } 29284 goto __2 29285 __2: 29286 iLog2++ 29287 iRank >>= 1 29288 goto __1 29289 goto __3 29290 __3: 29291 ; 29292 return ((iDistance + 32) - iLog2) 29293 } 29294 29295 // Compare two spellfix1_row objects for sorting purposes in qsort() such 29296 // that they sort in order of increasing distance. 29297 func spellfix1RowCompare(tls *libc.TLS, A uintptr, B uintptr) int32 { /* spellfix.c:2356:25: */ 29298 var a uintptr = A 29299 var b uintptr = B 29300 return ((*spellfix1_row)(unsafe.Pointer(a)).FiScore - (*spellfix1_row)(unsafe.Pointer(b)).FiScore) 29301 } 29302 29303 // A structure used to pass information from spellfix1FilterForMatch() 29304 // into spellfix1RunQuery(). 29305 type MatchQuery1 = struct { 29306 FpCur uintptr 29307 FpStmt uintptr 29308 FzHash [32]int8 29309 FzPattern uintptr 29310 FnPattern int32 29311 _ [4]byte 29312 FpMatchStr3 uintptr 29313 FpConfig3 uintptr 29314 FpLang uintptr 29315 FiLang int32 29316 FiScope int32 29317 FiMaxDist int32 29318 Frc int32 29319 FnRun int32 29320 FazPrior [1][32]int8 29321 _ [4]byte 29322 } /* spellfix.c:2366:9 */ 29323 29324 // A structure used to pass information from spellfix1FilterForMatch() 29325 // into spellfix1RunQuery(). 29326 type MatchQuery = MatchQuery1 /* spellfix.c:2381:3 */ 29327 29328 // Run a query looking for the best matches against zPattern using 29329 // zHash as the character class seed hash. 29330 func spellfix1RunQuery(tls *libc.TLS, p uintptr, zQuery uintptr, nQuery int32) { /* spellfix.c:2387:13: */ 29331 bp := tls.Alloc(76) 29332 defer tls.Free(76) 29333 29334 var zK1 uintptr 29335 var zWord uintptr 29336 var iDist int32 29337 var iRank int32 29338 var iScore int32 29339 var iWorst int32 = 0 29340 var idx int32 29341 var idxWorst int32 = -1 29342 var i int32 29343 var iScope int32 = (*MatchQuery)(unsafe.Pointer(p)).FiScope 29344 var pCur uintptr = (*MatchQuery)(unsafe.Pointer(p)).FpCur 29345 var pStmt uintptr = (*MatchQuery)(unsafe.Pointer(p)).FpStmt 29346 // var zHash1 [32]int8 at bp+8, 32 29347 29348 // var zHash2 [32]int8 at bp+40, 32 29349 29350 var zClass uintptr 29351 var nClass int32 29352 var rc int32 29353 29354 if ((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa == uintptr(0)) || ((*MatchQuery)(unsafe.Pointer(p)).Frc != 0) { 29355 return 29356 } // Prior memory allocation failure 29357 zClass = phoneticHash(tls, zQuery, nQuery) 29358 if zClass == uintptr(0) { 29359 (*MatchQuery)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM 29360 return 29361 } 29362 nClass = int32(libc.Xstrlen(tls, zClass)) 29363 if nClass > (SPELLFIX_MX_HASH - 2) { 29364 nClass = (SPELLFIX_MX_HASH - 2) 29365 *(*int8)(unsafe.Pointer(zClass + uintptr(nClass))) = int8(0) 29366 } 29367 if nClass <= iScope { 29368 if nClass > 2 { 29369 iScope = (nClass - 1) 29370 } else { 29371 iScope = nClass 29372 } 29373 } 29374 libc.Xmemcpy(tls, bp+8 /* &zHash1[0] */, zClass, uint64(iScope)) 29375 sqlite3.Xsqlite3_free(tls, zClass) 29376 *(*int8)(unsafe.Pointer(bp + 8 /* &zHash1[0] */ + uintptr(iScope))) = int8(0) 29377 libc.Xmemcpy(tls, bp+40 /* &zHash2[0] */, bp+8 /* &zHash1[0] */, uint64(iScope)) 29378 *(*int8)(unsafe.Pointer(bp + 40 /* &zHash2[0] */ + uintptr(iScope))) = int8('Z') 29379 *(*int8)(unsafe.Pointer(bp + 40 /* &zHash2[0] */ + uintptr((iScope + 1)))) = int8(0) 29380 29381 libc.Xmemcpy(tls, ((p + 108 /* &.azPrior */) + uintptr(libc.PostIncInt32(&(*MatchQuery)(unsafe.Pointer(p)).FnRun, 1))*32), bp+8 /* &zHash1[0] */, (uint64(iScope + 1))) 29382 if (sqlite3.Xsqlite3_bind_text(tls, pStmt, 1, bp+8 /* &zHash1[0] */, -1, uintptr(0)) == SQLITE_NOMEM) || 29383 (sqlite3.Xsqlite3_bind_text(tls, pStmt, 2, bp+40 /* &zHash2[0] */, -1, uintptr(0)) == SQLITE_NOMEM) { 29384 (*MatchQuery)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM 29385 return 29386 } 29387 for sqlite3.Xsqlite3_step(tls, pStmt) == SQLITE_ROW { 29388 *(*int32)(unsafe.Pointer(bp + 72 /* iMatchlen */)) = -1 29389 iRank = sqlite3.Xsqlite3_column_int(tls, pStmt, 2) 29390 if (*MatchQuery)(unsafe.Pointer(p)).FpMatchStr3 != 0 { 29391 var nWord int32 = sqlite3.Xsqlite3_column_bytes(tls, pStmt, 1) 29392 zWord = sqlite3.Xsqlite3_column_text(tls, pStmt, 1) 29393 iDist = editDist3Core(tls, (*MatchQuery)(unsafe.Pointer(p)).FpMatchStr3, zWord, nWord, (*MatchQuery)(unsafe.Pointer(p)).FpLang, bp+72 /* &iMatchlen */) 29394 } else { 29395 zK1 = sqlite3.Xsqlite3_column_text(tls, pStmt, 3) 29396 if zK1 == uintptr(0) { 29397 continue 29398 } 29399 iDist = editdist1(tls, (*MatchQuery)(unsafe.Pointer(p)).FzPattern, zK1, uintptr(0)) 29400 } 29401 if iDist < 0 { 29402 (*MatchQuery)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM 29403 break 29404 } 29405 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnSearch++ 29406 29407 // If there is a "distance < $dist" or "distance <= $dist" constraint, 29408 // check if this row meets it. If not, jump back up to the top of the 29409 // loop to process the next row. Otherwise, if the row does match the 29410 // distance constraint, check if the pCur->a[] array is already full. 29411 // If it is and no explicit "top = ?" constraint was present in the 29412 // query, grow the array to ensure there is room for the new entry. 29413 29414 if (*MatchQuery)(unsafe.Pointer(p)).FiMaxDist >= 0 { 29415 if iDist > (*MatchQuery)(unsafe.Pointer(p)).FiMaxDist { 29416 continue 29417 } 29418 if ((*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow >= (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnAlloc) && (((*spellfix1_cursor)(unsafe.Pointer(pCur)).FidxNum & SPELLFIX_IDXNUM_TOP) == 0) { 29419 spellfix1ResizeCursor(tls, pCur, (((*spellfix1_cursor)(unsafe.Pointer(pCur)).FnAlloc * 2) + 10)) 29420 if (*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa == uintptr(0) { 29421 break 29422 } 29423 } 29424 } 29425 29426 iScore = spellfix1Score(tls, iDist, iRank) 29427 if (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow < (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnAlloc { 29428 idx = (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow 29429 } else if iScore < iWorst { 29430 idx = idxWorst 29431 sqlite3.Xsqlite3_free(tls, (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa+uintptr(idx)*64)).FzWord) 29432 } else { 29433 continue 29434 } 29435 29436 (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa + uintptr(idx)*64)).FzWord = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, sqlite3.Xsqlite3_column_text(tls, pStmt, 1))) 29437 if (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa+uintptr(idx)*64)).FzWord == uintptr(0) { 29438 (*MatchQuery)(unsafe.Pointer(p)).Frc = SQLITE_NOMEM 29439 break 29440 } 29441 (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa + uintptr(idx)*64)).FiRowid = sqlite3.Xsqlite3_column_int64(tls, pStmt, 0) 29442 (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa + uintptr(idx)*64)).FiRank = iRank 29443 (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa + uintptr(idx)*64)).FiDistance = iDist 29444 (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa + uintptr(idx)*64)).FiScore = iScore 29445 (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa + uintptr(idx)*64)).FiMatchlen = *(*int32)(unsafe.Pointer(bp + 72 /* iMatchlen */)) 29446 libc.Xmemcpy(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa+uintptr(idx)*64+32 /* &.zHash */, bp+8 /* &zHash1[0] */, (uint64(iScope + 1))) 29447 if (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow < (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnAlloc { 29448 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow++ 29449 } 29450 if (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow == (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnAlloc { 29451 iWorst = (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa)).FiScore 29452 idxWorst = 0 29453 for i = 1; i < (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow; i++ { 29454 iScore = (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa + uintptr(i)*64)).FiScore 29455 if iWorst < iScore { 29456 iWorst = iScore 29457 idxWorst = i 29458 } 29459 } 29460 } 29461 } 29462 rc = sqlite3.Xsqlite3_reset(tls, pStmt) 29463 if rc != 0 { 29464 (*MatchQuery)(unsafe.Pointer(p)).Frc = rc 29465 } 29466 } 29467 29468 // This version of the xFilter method work if the MATCH term is present 29469 // and we are doing a scan. 29470 func spellfix1FilterForMatch(tls *libc.TLS, pCur uintptr, argc int32, argv uintptr) int32 { /* spellfix.c:2526:12: */ 29471 bp := tls.Alloc(176) 29472 defer tls.Free(176) 29473 29474 var idxNum int32 29475 var zMatchThis uintptr // RHS of the MATCH operator 29476 var pMatchStr3 uintptr // zMatchThis as an editdist string 29477 var zPattern uintptr // Transliteration of zMatchThis 29478 var nPattern int32 // Length of zPattern 29479 var iLimit int32 // Max number of rows of output 29480 var iScope int32 // Use this many characters of zClass 29481 var iLang int32 // Language code 29482 var zSql uintptr // SQL of shadow table query 29483 // var pStmt uintptr at bp+168, 8 29484 // Shadow table query 29485 var rc int32 // Result code 29486 var idx int32 // Next available filter parameter 29487 var p uintptr // The virtual table that owns pCur 29488 // var x MatchQuery at bp+24, 144 29489 idxNum = (*spellfix1_cursor)(unsafe.Pointer(pCur)).FidxNum 29490 pMatchStr3 = uintptr(0) 29491 iLimit = 20 29492 iScope = 3 29493 iLang = 0 29494 *(*uintptr)(unsafe.Pointer(bp + 168 /* pStmt */)) = uintptr(0) 29495 idx = 1 29496 p = (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpVTab // For passing info to RunQuery() 29497 29498 // Load the cost table if we have not already done so 29499 if !(((*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable != uintptr(0)) && ((*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3 == uintptr(0))) { 29500 goto __1 29501 } 29502 (*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3 = sqlite3.Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(EditDist3Config{}))) 29503 if !((*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3 == uintptr(0)) { 29504 goto __2 29505 } 29506 return SQLITE_NOMEM 29507 __2: 29508 ; 29509 libc.Xmemset(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3, 0, uint64(unsafe.Sizeof(EditDist3Config{}))) 29510 rc = editDist3ConfigLoad(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3, (*spellfix1_vtab)(unsafe.Pointer(p)).Fdb, (*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable) 29511 if !(rc != 0) { 29512 goto __3 29513 } 29514 return rc 29515 __3: 29516 ; 29517 __1: 29518 ; 29519 libc.Xmemset(tls, bp+24 /* &x */, 0, uint64(unsafe.Sizeof(MatchQuery{}))) 29520 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FiScope = 3 // Default scope if none specified by "WHERE scope=N" 29521 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FiMaxDist = -1 // Maximum allowed edit distance 29522 29523 if !((idxNum & 2) != 0) { 29524 goto __4 29525 } 29526 iLang = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(libc.PostIncInt32(&idx, 1))*8))) 29527 __4: 29528 ; 29529 if !((idxNum & 4) != 0) { 29530 goto __5 29531 } 29532 iLimit = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(libc.PostIncInt32(&idx, 1))*8))) 29533 if !(iLimit < 1) { 29534 goto __6 29535 } 29536 iLimit = 1 29537 __6: 29538 ; 29539 __5: 29540 ; 29541 if !((idxNum & 8) != 0) { 29542 goto __7 29543 } 29544 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FiScope = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(libc.PostIncInt32(&idx, 1))*8))) 29545 if !((*MatchQuery)(unsafe.Pointer(bp+24 /* &x */)).FiScope < 1) { 29546 goto __8 29547 } 29548 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FiScope = 1 29549 __8: 29550 ; 29551 if !((*MatchQuery)(unsafe.Pointer(bp+24 /* &x */)).FiScope > (SPELLFIX_MX_HASH - 2)) { 29552 goto __9 29553 } 29554 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FiScope = (SPELLFIX_MX_HASH - 2) 29555 __9: 29556 ; 29557 __7: 29558 ; 29559 if !((idxNum & (16 | 32)) != 0) { 29560 goto __10 29561 } 29562 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FiMaxDist = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(libc.PostIncInt32(&idx, 1))*8))) 29563 if !((idxNum & 16) != 0) { 29564 goto __11 29565 } 29566 (*MatchQuery)(unsafe.Pointer(bp+24 /* &x */)).FiMaxDist-- 29567 __11: 29568 ; 29569 if !((*MatchQuery)(unsafe.Pointer(bp+24 /* &x */)).FiMaxDist < 0) { 29570 goto __12 29571 } 29572 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FiMaxDist = 0 29573 __12: 29574 ; 29575 __10: 29576 ; 29577 spellfix1ResetCursor(tls, pCur) 29578 spellfix1ResizeCursor(tls, pCur, iLimit) 29579 zMatchThis = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 29580 if !(zMatchThis == uintptr(0)) { 29581 goto __13 29582 } 29583 return SQLITE_OK 29584 __13: 29585 ; 29586 if !((*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3 != 0) { 29587 goto __14 29588 } 29589 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FpLang = editDist3FindLang(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3, iLang) 29590 pMatchStr3 = editDist3FromStringNew(tls, (*MatchQuery)(unsafe.Pointer(bp+24 /* &x */)).FpLang, zMatchThis, -1) 29591 if !(pMatchStr3 == uintptr(0)) { 29592 goto __16 29593 } 29594 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).Frc = SQLITE_NOMEM 29595 goto filter_exit 29596 __16: 29597 ; 29598 goto __15 29599 __14: 29600 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FpLang = uintptr(0) 29601 __15: 29602 ; 29603 zPattern = transliterate(tls, zMatchThis, sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv)))) 29604 sqlite3.Xsqlite3_free(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FzPattern) 29605 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FzPattern = zPattern 29606 if !(zPattern == uintptr(0)) { 29607 goto __17 29608 } 29609 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).Frc = SQLITE_NOMEM 29610 goto filter_exit 29611 __17: 29612 ; 29613 nPattern = int32(libc.Xstrlen(tls, zPattern)) 29614 if !(int32(*(*int8)(unsafe.Pointer(zPattern + uintptr((nPattern - 1))))) == '*') { 29615 goto __18 29616 } 29617 nPattern-- 29618 __18: 29619 ; 29620 zSql = sqlite3.Xsqlite3_mprintf(tls, 29621 29622 ts+7098, /* "SELECT id, word,..." */ 29623 libc.VaList(bp, (*spellfix1_vtab)(unsafe.Pointer(p)).FzDbName, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName, iLang)) 29624 if !(zSql == uintptr(0)) { 29625 goto __19 29626 } 29627 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).Frc = SQLITE_NOMEM 29628 *(*uintptr)(unsafe.Pointer(bp + 168 /* pStmt */)) = uintptr(0) 29629 goto filter_exit 29630 __19: 29631 ; 29632 rc = sqlite3.Xsqlite3_prepare_v2(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).Fdb, zSql, -1, bp+168 /* &pStmt */, uintptr(0)) 29633 sqlite3.Xsqlite3_free(tls, zSql) 29634 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiLang = iLang 29635 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FpCur = pCur 29636 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FpStmt = *(*uintptr)(unsafe.Pointer(bp + 168 /* pStmt */)) 29637 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FzPattern = zPattern 29638 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FnPattern = nPattern 29639 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FpMatchStr3 = pMatchStr3 29640 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FiLang = iLang 29641 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).Frc = rc 29642 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).FpConfig3 = (*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3 29643 if !((*MatchQuery)(unsafe.Pointer(bp+24 /* &x */)).Frc == SQLITE_OK) { 29644 goto __20 29645 } 29646 spellfix1RunQuery(tls, bp+24 /* &x */, zPattern, nPattern) 29647 __20: 29648 ; 29649 29650 if !((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa != 0) { 29651 goto __21 29652 } 29653 libc.Xqsort(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa, uint64((*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow), uint64(unsafe.Sizeof(spellfix1_row{})), *(*uintptr)(unsafe.Pointer(&struct { 29654 f func(*libc.TLS, uintptr, uintptr) int32 29655 }{spellfix1RowCompare}))) 29656 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiTop = iLimit 29657 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiScope = iScope 29658 goto __22 29659 __21: 29660 (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).Frc = SQLITE_NOMEM 29661 __22: 29662 ; 29663 29664 filter_exit: 29665 sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 168 /* pStmt */))) 29666 editDist3FromStringDelete(tls, pMatchStr3) 29667 return (*MatchQuery)(unsafe.Pointer(bp + 24 /* &x */)).Frc 29668 } 29669 29670 // This version of xFilter handles a full-table scan case 29671 func spellfix1FilterForFullScan(tls *libc.TLS, pCur uintptr, argc int32, argv uintptr) int32 { /* spellfix.c:2641:12: */ 29672 bp := tls.Alloc(24) 29673 defer tls.Free(24) 29674 29675 var rc int32 = SQLITE_OK 29676 var idxNum int32 = (*spellfix1_cursor)(unsafe.Pointer(pCur)).FidxNum 29677 var zSql uintptr 29678 var pVTab uintptr = (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpVTab 29679 spellfix1ResetCursor(tls, pCur) 29680 29681 zSql = sqlite3.Xsqlite3_mprintf(tls, 29682 ts+7198, /* "SELECT word, ran..." */ 29683 libc.VaList(bp, (*spellfix1_vtab)(unsafe.Pointer(pVTab)).FzDbName, (*spellfix1_vtab)(unsafe.Pointer(pVTab)).FzTableName, 29684 func() uintptr { 29685 if (idxNum & 64) != 0 { 29686 return ts + 7257 /* " WHERE rowid=?" */ 29687 } 29688 return ts + 489 /* "" */ 29689 }())) 29690 if zSql == uintptr(0) { 29691 return SQLITE_NOMEM 29692 } 29693 rc = sqlite3.Xsqlite3_prepare_v2(tls, (*spellfix1_vtab)(unsafe.Pointer(pVTab)).Fdb, zSql, -1, (pCur + 56 /* &.pFullScan */), uintptr(0)) 29694 sqlite3.Xsqlite3_free(tls, zSql) 29695 if (rc == SQLITE_OK) && ((idxNum & 64) != 0) { 29696 29697 rc = sqlite3.Xsqlite3_bind_value(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpFullScan, 1, *(*uintptr)(unsafe.Pointer(argv))) 29698 } 29699 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow = libc.AssignPtrInt32(pCur+36 /* &.iRow */, 0) 29700 if rc == SQLITE_OK { 29701 rc = sqlite3.Xsqlite3_step(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpFullScan) 29702 if rc == SQLITE_ROW { 29703 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow = -1 29704 rc = SQLITE_OK 29705 } 29706 if rc == SQLITE_DONE { 29707 rc = SQLITE_OK 29708 } 29709 } else { 29710 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow = 0 29711 } 29712 return rc 29713 } 29714 29715 // Called to "rewind" a cursor back to the beginning so that 29716 // it starts its output over again. Always called at least once 29717 // prior to any spellfix1Column, spellfix1Rowid, or spellfix1Eof call. 29718 func spellfix1Filter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* spellfix.c:2681:12: */ 29719 var pCur uintptr = cur 29720 var rc int32 29721 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FidxNum = idxNum 29722 if (idxNum & 1) != 0 { 29723 rc = spellfix1FilterForMatch(tls, pCur, argc, argv) 29724 } else { 29725 rc = spellfix1FilterForFullScan(tls, pCur, argc, argv) 29726 } 29727 return rc 29728 } 29729 29730 // Advance a cursor to its next row of output 29731 func spellfix1Next(tls *libc.TLS, cur uintptr) int32 { /* spellfix.c:2701:12: */ 29732 var pCur uintptr = cur 29733 var rc int32 = SQLITE_OK 29734 if (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow < (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow { 29735 if (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpFullScan != 0 { 29736 rc = sqlite3.Xsqlite3_step(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpFullScan) 29737 if rc != SQLITE_ROW { 29738 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow = (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow 29739 } 29740 if (rc == SQLITE_ROW) || (rc == SQLITE_DONE) { 29741 rc = SQLITE_OK 29742 } 29743 } else { 29744 (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow++ 29745 } 29746 } 29747 return rc 29748 } 29749 29750 // Return TRUE if we are at the end-of-file 29751 func spellfix1Eof(tls *libc.TLS, cur uintptr) int32 { /* spellfix.c:2719:12: */ 29752 var pCur uintptr = cur 29753 return (libc.Bool32((*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow >= (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnRow)) 29754 } 29755 29756 // Return columns from the current row. 29757 func spellfix1Column(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* spellfix.c:2727:12: */ 29758 bp := tls.Alloc(4) 29759 defer tls.Free(4) 29760 29761 var pCur uintptr = cur 29762 if (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpFullScan != 0 { 29763 if i <= SPELLFIX_COL_LANGID { 29764 sqlite3.Xsqlite3_result_value(tls, ctx, sqlite3.Xsqlite3_column_value(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpFullScan, i)) 29765 } else { 29766 sqlite3.Xsqlite3_result_null(tls, ctx) 29767 } 29768 return SQLITE_OK 29769 } 29770 switch i { 29771 case SPELLFIX_COL_WORD: 29772 { 29773 sqlite3.Xsqlite3_result_text(tls, ctx, (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa+uintptr((*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow)*64)).FzWord, -1, uintptr(0)) 29774 break 29775 29776 } 29777 case SPELLFIX_COL_RANK: 29778 { 29779 sqlite3.Xsqlite3_result_int(tls, ctx, (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa+uintptr((*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow)*64)).FiRank) 29780 break 29781 29782 } 29783 case SPELLFIX_COL_DISTANCE: 29784 { 29785 sqlite3.Xsqlite3_result_int(tls, ctx, (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa+uintptr((*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow)*64)).FiDistance) 29786 break 29787 29788 } 29789 case SPELLFIX_COL_LANGID: 29790 { 29791 sqlite3.Xsqlite3_result_int(tls, ctx, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiLang) 29792 break 29793 29794 } 29795 case SPELLFIX_COL_SCORE: 29796 { 29797 sqlite3.Xsqlite3_result_int(tls, ctx, (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa+uintptr((*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow)*64)).FiScore) 29798 break 29799 29800 } 29801 case SPELLFIX_COL_MATCHLEN: 29802 { 29803 *(*int32)(unsafe.Pointer(bp /* iMatchlen */)) = (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa + uintptr((*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow)*64)).FiMatchlen 29804 if *(*int32)(unsafe.Pointer(bp /* iMatchlen */)) < 0 { 29805 var nPattern int32 = int32(libc.Xstrlen(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FzPattern)) 29806 var zWord uintptr = (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa + uintptr((*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow)*64)).FzWord 29807 var nWord int32 = int32(libc.Xstrlen(tls, zWord)) 29808 29809 if (nPattern > 0) && (int32(*(*int8)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).FzPattern + uintptr((nPattern - 1))))) == '*') { 29810 var zTranslit uintptr 29811 var res int32 29812 zTranslit = transliterate(tls, zWord, nWord) 29813 if !(zTranslit != 0) { 29814 return SQLITE_NOMEM 29815 } 29816 res = editdist1(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FzPattern, zTranslit, bp /* &iMatchlen */) 29817 sqlite3.Xsqlite3_free(tls, zTranslit) 29818 if res < 0 { 29819 return SQLITE_NOMEM 29820 } 29821 *(*int32)(unsafe.Pointer(bp /* iMatchlen */)) = translen_to_charlen(tls, zWord, nWord, *(*int32)(unsafe.Pointer(bp /* iMatchlen */))) 29822 } else { 29823 *(*int32)(unsafe.Pointer(bp /* iMatchlen */)) = utf8Charlen(tls, zWord, nWord) 29824 } 29825 } 29826 29827 sqlite3.Xsqlite3_result_int(tls, ctx, *(*int32)(unsafe.Pointer(bp /* iMatchlen */))) 29828 break 29829 29830 } 29831 case SPELLFIX_COL_PHONEHASH: 29832 { 29833 sqlite3.Xsqlite3_result_text(tls, ctx, (*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa+uintptr((*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow)*64+32 /* &.zHash */, -1, uintptr(0)) 29834 break 29835 29836 } 29837 case SPELLFIX_COL_TOP: 29838 { 29839 sqlite3.Xsqlite3_result_int(tls, ctx, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiTop) 29840 break 29841 29842 } 29843 case SPELLFIX_COL_SCOPE: 29844 { 29845 sqlite3.Xsqlite3_result_int(tls, ctx, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FiScope) 29846 break 29847 29848 } 29849 case SPELLFIX_COL_SRCHCNT: 29850 { 29851 sqlite3.Xsqlite3_result_int(tls, ctx, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FnSearch) 29852 break 29853 29854 } 29855 default: 29856 { 29857 sqlite3.Xsqlite3_result_null(tls, ctx) 29858 break 29859 29860 } 29861 } 29862 return SQLITE_OK 29863 } 29864 29865 // The rowid. 29866 func spellfix1Rowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* spellfix.c:2813:12: */ 29867 var pCur uintptr = cur 29868 if (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpFullScan != 0 { 29869 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite3.Xsqlite3_column_int64(tls, (*spellfix1_cursor)(unsafe.Pointer(pCur)).FpFullScan, 4) 29870 } else { 29871 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*spellfix1_row)(unsafe.Pointer((*spellfix1_cursor)(unsafe.Pointer(pCur)).Fa + uintptr((*spellfix1_cursor)(unsafe.Pointer(pCur)).FiRow)*64)).FiRowid 29872 } 29873 return SQLITE_OK 29874 } 29875 29876 // This function is called by the xUpdate() method. It returns a string 29877 // containing the conflict mode that xUpdate() should use for the current 29878 // operation. One of: "ROLLBACK", "IGNORE", "ABORT" or "REPLACE". 29879 func spellfix1GetConflict(tls *libc.TLS, db uintptr) uintptr { /* spellfix.c:2828:19: */ 29880 var eConflict int32 = sqlite3.Xsqlite3_vtab_on_conflict(tls, db) 29881 29882 return azConflict[(eConflict - 1)] 29883 } 29884 29885 var azConflict = [5]uintptr{ 29886 // Note: Instead of "FAIL" - "ABORT". 29887 ts + 7272 /* "ROLLBACK" */, ts + 7281 /* "IGNORE" */, ts + 7288 /* "ABORT" */, ts + 7288 /* "ABORT" */, ts + 7294, /* "REPLACE" */ 29888 } /* spellfix.c:2829:21 */ 29889 29890 // The xUpdate() method. 29891 func spellfix1Update(tls *libc.TLS, pVTab uintptr, argc int32, argv uintptr, pRowid uintptr) int32 { /* spellfix.c:2851:12: */ 29892 bp := tls.Alloc(284) 29893 defer tls.Free(284) 29894 29895 *(*int32)(unsafe.Pointer(bp + 280 /* rc */)) = SQLITE_OK 29896 var rowid sqlite3_int64 29897 var newRowid sqlite3_int64 29898 var p uintptr = pVTab 29899 var db uintptr = (*spellfix1_vtab)(unsafe.Pointer(p)).Fdb 29900 29901 if argc == 1 { 29902 // A delete operation on the rowid given by argv[0] 29903 rowid = libc.AssignPtrInt64(pRowid, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv)))) 29904 spellfix1DbExec(tls, bp+280 /* &rc */, db, 29905 ts+7302, /* "DELETE FROM \"%w\"..." */ 29906 libc.VaList(bp, (*spellfix1_vtab)(unsafe.Pointer(p)).FzDbName, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName, rowid)) 29907 } else { 29908 var zWord uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) 29909 var nWord int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) 29910 var iLang int32 = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 5*8))) 29911 var iRank int32 = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) 29912 var zSoundslike uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 12*8))) 29913 var nSoundslike int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + 12*8))) 29914 var zK1 uintptr 29915 var zK2 uintptr 29916 var i int32 29917 var c int8 29918 var zConflict uintptr = spellfix1GetConflict(tls, db) 29919 29920 if zWord == uintptr(0) { 29921 // Inserts of the form: INSERT INTO table(command) VALUES('xyzzy'); 29922 // cause zWord to be NULL, so we look at the "command" column to see 29923 // what special actions to take 29924 var zCmd uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 13*8))) 29925 if zCmd == uintptr(0) { 29926 (*sqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+7345, /* "NOT NULL constra..." */ 29927 libc.VaList(bp+24, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName)) 29928 return (SQLITE_CONSTRAINT | (int32(5) << 8)) 29929 } 29930 if libc.Xstrcmp(tls, zCmd, ts+7381 /* "reset" */) == 0 { 29931 // Reset the edit cost table (if there is one). 29932 editDist3ConfigDelete(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3) 29933 (*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3 = uintptr(0) 29934 return SQLITE_OK 29935 } 29936 if libc.Xstrncmp(tls, zCmd, ts+7047 /* "edit_cost_table=" */, uint64(16)) == 0 { 29937 editDist3ConfigDelete(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3) 29938 (*spellfix1_vtab)(unsafe.Pointer(p)).FpConfig3 = uintptr(0) 29939 sqlite3.Xsqlite3_free(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable) 29940 (*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable = spellfix1Dequote(tls, (zCmd + uintptr(16))) 29941 if (*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable == uintptr(0) { 29942 return SQLITE_NOMEM 29943 } 29944 if (int32(*(*int8)(unsafe.Pointer((*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable))) == 0) || (sqlite3.Xsqlite3_stricmp(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable, ts+7387 /* "null" */) == 0) { 29945 sqlite3.Xsqlite3_free(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable) 29946 (*spellfix1_vtab)(unsafe.Pointer(p)).FzCostTable = uintptr(0) 29947 } 29948 return SQLITE_OK 29949 } 29950 (*sqlite3_vtab)(unsafe.Pointer(pVTab)).FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+7392, /* "unknown value fo..." */ 29951 libc.VaList(bp+32, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName, zCmd)) 29952 return SQLITE_ERROR 29953 } 29954 if iRank < 1 { 29955 iRank = 1 29956 } 29957 if zSoundslike != 0 { 29958 zK1 = transliterate(tls, zSoundslike, nSoundslike) 29959 } else { 29960 zK1 = transliterate(tls, zWord, nWord) 29961 } 29962 if zK1 == uintptr(0) { 29963 return SQLITE_NOMEM 29964 } 29965 for i = 0; (int32(libc.AssignInt8(&c, *(*int8)(unsafe.Pointer(zK1 + uintptr(i)))))) != 0; i++ { 29966 if (int32(c) >= 'A') && (int32(c) <= 'Z') { 29967 *(*int8)(unsafe.Pointer(zK1 + uintptr(i))) += int8(('a' - 'A')) 29968 } 29969 } 29970 zK2 = phoneticHash(tls, zK1, i) 29971 if zK2 == uintptr(0) { 29972 sqlite3.Xsqlite3_free(tls, zK1) 29973 return SQLITE_NOMEM 29974 } 29975 if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { 29976 if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) == SQLITE_NULL { 29977 spellfix1DbExec(tls, bp+280 /* &rc */, db, 29978 29979 ts+7427, /* "INSERT INTO \"%w\"..." */ 29980 libc.VaList(bp+48, (*spellfix1_vtab)(unsafe.Pointer(p)).FzDbName, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName, 29981 iRank, iLang, zWord, zK1, zWord, zK2)) 29982 } else { 29983 newRowid = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 29984 spellfix1DbExec(tls, bp+280 /* &rc */, db, 29985 29986 ts+7513, /* "INSERT OR %s INT..." */ 29987 libc.VaList(bp+112, zConflict, (*spellfix1_vtab)(unsafe.Pointer(p)).FzDbName, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName, 29988 newRowid, iRank, iLang, zWord, zK1, zWord, zK2)) 29989 } 29990 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite3.Xsqlite3_last_insert_rowid(tls, db) 29991 } else { 29992 rowid = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) 29993 newRowid = libc.AssignPtrInt64(pRowid, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) 29994 spellfix1DbExec(tls, bp+280 /* &rc */, db, 29995 29996 ts+7613, /* "UPDATE OR %s \"%w..." */ 29997 libc.VaList(bp+192, zConflict, (*spellfix1_vtab)(unsafe.Pointer(p)).FzDbName, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName, newRowid, iRank, iLang, 29998 zWord, zK1, zWord, zK2, rowid)) 29999 } 30000 sqlite3.Xsqlite3_free(tls, zK1) 30001 sqlite3.Xsqlite3_free(tls, zK2) 30002 } 30003 return *(*int32)(unsafe.Pointer(bp + 280 /* rc */)) 30004 } 30005 30006 // Rename the spellfix1 table. 30007 func spellfix1Rename(tls *libc.TLS, pVTab uintptr, zNew uintptr) int32 { /* spellfix.c:2966:12: */ 30008 bp := tls.Alloc(36) 30009 defer tls.Free(36) 30010 30011 var p uintptr = pVTab 30012 var db uintptr = (*spellfix1_vtab)(unsafe.Pointer(p)).Fdb 30013 *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) = SQLITE_OK 30014 var zNewName uintptr = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zNew)) 30015 if zNewName == uintptr(0) { 30016 return SQLITE_NOMEM 30017 } 30018 spellfix1DbExec(tls, bp+32 /* &rc */, db, 30019 ts+7722, /* "ALTER TABLE \"%w\"..." */ 30020 libc.VaList(bp+8, (*spellfix1_vtab)(unsafe.Pointer(p)).FzDbName, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName, zNewName)) 30021 if *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) == SQLITE_OK { 30022 sqlite3.Xsqlite3_free(tls, (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName) 30023 (*spellfix1_vtab)(unsafe.Pointer(p)).FzTableName = zNewName 30024 } else { 30025 sqlite3.Xsqlite3_free(tls, zNewName) 30026 } 30027 return *(*int32)(unsafe.Pointer(bp + 32 /* rc */)) 30028 } 30029 30030 // A virtual table module that provides fuzzy search. 30031 var spellfix1Module = sqlite3_module{ // iVersion 30032 FxCreate: 0, // xCreate - handle CREATE VIRTUAL TABLE 30033 FxConnect: 0, // xConnect - reconnected to an existing table 30034 FxBestIndex: 0, // xBestIndex - figure out how to do a query 30035 FxDisconnect: 0, // xDisconnect - close a connection 30036 FxDestroy: 0, // xDestroy - handle DROP TABLE 30037 FxOpen: 0, // xOpen - open a cursor 30038 FxClose: 0, // xClose - close a cursor 30039 FxFilter: 0, // xFilter - configure scan constraints 30040 FxNext: 0, // xNext - advance a cursor 30041 FxEof: 0, // xEof - check for end of scan 30042 FxColumn: 0, // xColumn - read data 30043 FxRowid: 0, // xRowid - read data 30044 FxUpdate: 0, // xFindMethod 30045 FxRename: 0, // xRename 30046 } /* spellfix.c:2991:23 */ 30047 30048 // Register the various functions and the virtual table. 30049 func spellfix1Register(tls *libc.TLS, db uintptr) int32 { /* spellfix.c:3017:12: */ 30050 var rc int32 = SQLITE_OK 30051 var i int32 30052 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+7771 /* "spellfix1_transl..." */, 1, 30053 (SQLITE_UTF8 | SQLITE_DETERMINISTIC), uintptr(0), 30054 *(*uintptr)(unsafe.Pointer(&struct { 30055 f func(*libc.TLS, uintptr, int32, uintptr) 30056 }{transliterateSqlFunc})), uintptr(0), uintptr(0)) 30057 if rc == SQLITE_OK { 30058 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+7790 /* "spellfix1_editdi..." */, 2, 30059 (SQLITE_UTF8 | SQLITE_DETERMINISTIC), uintptr(0), 30060 *(*uintptr)(unsafe.Pointer(&struct { 30061 f func(*libc.TLS, uintptr, int32, uintptr) 30062 }{editdistSqlFunc})), uintptr(0), uintptr(0)) 30063 } 30064 if rc == SQLITE_OK { 30065 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+7809 /* "spellfix1_phoneh..." */, 1, 30066 (SQLITE_UTF8 | SQLITE_DETERMINISTIC), uintptr(0), 30067 *(*uintptr)(unsafe.Pointer(&struct { 30068 f func(*libc.TLS, uintptr, int32, uintptr) 30069 }{phoneticHashSqlFunc})), uintptr(0), uintptr(0)) 30070 } 30071 if rc == SQLITE_OK { 30072 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+7829 /* "spellfix1_script..." */, 1, 30073 (SQLITE_UTF8 | SQLITE_DETERMINISTIC), uintptr(0), 30074 *(*uintptr)(unsafe.Pointer(&struct { 30075 f func(*libc.TLS, uintptr, int32, uintptr) 30076 }{scriptCodeSqlFunc})), uintptr(0), uintptr(0)) 30077 } 30078 if rc == SQLITE_OK { 30079 rc = sqlite3.Xsqlite3_create_module(tls, db, ts+7850 /* "spellfix1" */, uintptr(unsafe.Pointer(&spellfix1Module)), uintptr(0)) 30080 } 30081 if rc == SQLITE_OK { 30082 rc = editDist3Install(tls, db) 30083 } 30084 30085 // Verify sanity of the translit[] table 30086 for i = 0; uint64(i) < ((uint64(unsafe.Sizeof(translit)) / uint64(unsafe.Sizeof(Transliteration{}))) - uint64(1)); i++ { 30087 30088 } 30089 30090 return rc 30091 } 30092 30093 // Extension load function. 30094 func sqlite3_spellfix_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* spellfix.c:3061:5: */ 30095 _ = pApi 30096 30097 return spellfix1Register(tls, db) 30098 return SQLITE_OK 30099 } 30100 30101 // Determine if this is running on a big-endian or little-endian 30102 // processor 30103 var totype_one int32 = 1 /* totype.c:49:13 */ 30104 30105 // Constants for the largest and smallest possible 64-bit signed integers. 30106 // These macros are designed to work correctly on both 32-bit and 64-bit 30107 // compilers. 30108 30109 // Return TRUE if character c is a whitespace character 30110 func totypeIsspace(tls *libc.TLS, c uint8) int32 { /* totype.c:70:12: */ 30111 return (libc.Bool32((((((int32(c) == ' ') || (int32(c) == '\t')) || (int32(c) == '\n')) || (int32(c) == '\v')) || (int32(c) == '\f')) || (int32(c) == '\r'))) 30112 } 30113 30114 // Return TRUE if character c is a digit 30115 func totypeIsdigit(tls *libc.TLS, c uint8) int32 { /* totype.c:77:12: */ 30116 return (libc.Bool32((int32(c) >= '0') && (int32(c) <= '9'))) 30117 } 30118 30119 // Compare the 19-character string zNum against the text representation 30120 // value 2^63: 9223372036854775808. Return negative, zero, or positive 30121 // if zNum is less than, equal to, or greater than the string. 30122 // Note that zNum must contain exactly 19 characters. 30123 // 30124 // Unlike memcmp() this routine is guaranteed to return the difference 30125 // in the values of the last digit if the only difference is in the 30126 // last digit. So, for example, 30127 // 30128 // totypeCompare2pow63("9223372036854775800") 30129 // 30130 // will return -8. 30131 func totypeCompare2pow63(tls *libc.TLS, zNum uintptr) int32 { /* totype.c:95:12: */ 30132 var c int32 = 0 30133 var i int32 30134 // 012345678901234567 30135 var pow63 uintptr = ts + 7860 /* "9223372036854775..." */ 30136 for i = 0; (c == 0) && (i < 18); i++ { 30137 c = ((int32(*(*int8)(unsafe.Pointer(zNum + uintptr(i)))) - int32(*(*int8)(unsafe.Pointer(pow63 + uintptr(i))))) * 10) 30138 } 30139 if c == 0 { 30140 c = (int32(*(*int8)(unsafe.Pointer(zNum + 18))) - '8') 30141 } 30142 return c 30143 } 30144 30145 // Convert zNum to a 64-bit signed integer. 30146 // 30147 // If the zNum value is representable as a 64-bit twos-complement 30148 // integer, then write that value into *pNum and return 0. 30149 // 30150 // If zNum is exactly 9223372036854665808, return 2. This special 30151 // case is broken out because while 9223372036854665808 cannot be a 30152 // signed 64-bit integer, its negative -9223372036854665808 can be. 30153 // 30154 // If zNum is too big for a 64-bit integer and is not 30155 // 9223372036854665808 or if zNum contains any non-numeric text, 30156 // then return 1. 30157 // 30158 // The string is not necessarily zero-terminated. 30159 func totypeAtoi64(tls *libc.TLS, zNum uintptr, pNum uintptr, length int32) int32 { /* totype.c:125:12: */ 30160 var u sqlite3_uint64 = uint64(0) 30161 var neg int32 = 0 // assume positive 30162 var i int32 30163 var c int32 = 0 30164 var nonNum int32 = 0 30165 var zStart uintptr 30166 var zEnd uintptr = (zNum + uintptr(length)) 30167 30168 for (zNum < zEnd) && (totypeIsspace(tls, uint8(*(*int8)(unsafe.Pointer(zNum)))) != 0) { 30169 zNum++ 30170 } 30171 if zNum < zEnd { 30172 if int32(*(*int8)(unsafe.Pointer(zNum))) == '-' { 30173 neg = 1 30174 zNum++ 30175 } else if int32(*(*int8)(unsafe.Pointer(zNum))) == '+' { 30176 zNum++ 30177 } 30178 } 30179 zStart = zNum 30180 for (zNum < zEnd) && (int32(*(*int8)(unsafe.Pointer(zNum))) == '0') { 30181 zNum++ 30182 } // Skip leading zeros. 30183 for i = 0; (((zNum + uintptr(i)) < zEnd) && ((libc.AssignInt32(&c, int32(*(*int8)(unsafe.Pointer(zNum + uintptr(i)))))) >= '0')) && (c <= '9'); i++ { 30184 u = (((u * uint64(10)) + sqlite3_uint64(c)) - uint64('0')) 30185 } 30186 if u > (uint64(int64(0xffffffff) | (sqlite3_int64((int64(0x7fffffff))) << 32))) { 30187 *(*sqlite3_int64)(unsafe.Pointer(pNum)) = ((int64(-1)) - (int64(0xffffffff) | (sqlite3_int64((int64(0x7fffffff))) << 32))) 30188 } else if neg != 0 { 30189 *(*sqlite3_int64)(unsafe.Pointer(pNum)) = -sqlite3_int64(u) 30190 } else { 30191 *(*sqlite3_int64)(unsafe.Pointer(pNum)) = sqlite3_int64(u) 30192 } 30193 if ((((c != 0) && ((zNum + uintptr(i)) < zEnd)) || ((i == 0) && (zStart == zNum))) || (i > 19)) || (nonNum != 0) { 30194 // zNum is empty or contains non-numeric text or is longer 30195 // than 19 digits (thus guaranteeing that it is too large) 30196 return 1 30197 } else if i < 19 { 30198 // Less than 19 digits, so we know that it fits in 64 bits 30199 30200 return 0 30201 } else { 30202 // zNum is a 19-digit numbers. Compare it against 9223372036854775808. 30203 c = totypeCompare2pow63(tls, zNum) 30204 if c < 0 { 30205 // zNum is less than 9223372036854775808 so it fits 30206 30207 return 0 30208 } else if c > 0 { 30209 // zNum is greater than 9223372036854775808 so it overflows 30210 return 1 30211 } else { 30212 // zNum is exactly 9223372036854775808. Fits if negative. The 30213 // special case 2 overflow if positive 30214 30215 if neg != 0 { 30216 return 0 30217 } 30218 return 2 30219 } 30220 } 30221 return int32(0) 30222 } 30223 30224 // The string z[] is an text representation of a real number. 30225 // Convert this string to a double and write it into *pResult. 30226 // 30227 // The string is not necessarily zero-terminated. 30228 // 30229 // Return TRUE if the result is a valid real number (or integer) and FALSE 30230 // if the string is empty or contains extraneous text. Valid numbers 30231 // are in one of these formats: 30232 // 30233 // [+-]digits[E[+-]digits] 30234 // [+-]digits.[digits][E[+-]digits] 30235 // [+-].digits[E[+-]digits] 30236 // 30237 // Leading and trailing whitespace is ignored for the purpose of determining 30238 // validity. 30239 // 30240 // If some prefix of the input string is a valid number, this routine 30241 // returns FALSE but it still converts the prefix and writes the result 30242 // into *pResult. 30243 func totypeAtoF(tls *libc.TLS, z uintptr, pResult uintptr, length int32) int32 { /* totype.c:204:12: */ 30244 var zEnd uintptr 30245 // sign * significand * (10 ^ (esign * exponent)) 30246 var sign int32 // sign of significand 30247 var s sqlite3_int64 // significand 30248 var d int32 // adjust exponent for shifting decimal point 30249 var esign int32 // sign of exponent 30250 var e int32 // exponent 30251 var eValid int32 // True exponent is either not used or is well-formed 30252 var result float64 30253 var nDigits int32 30254 var nonNum int32 30255 var scale float64 30256 zEnd = (z + uintptr(length)) 30257 sign = 1 30258 s = int64(0) 30259 d = 0 30260 esign = 1 30261 e = 0 30262 eValid = 1 30263 nDigits = 0 30264 nonNum = 0 30265 30266 *(*float64)(unsafe.Pointer(pResult)) = 0.0 // Default return value, in case of an error 30267 30268 // skip leading spaces 30269 __1: 30270 if !((z < zEnd) && (totypeIsspace(tls, uint8(*(*int8)(unsafe.Pointer(z)))) != 0)) { 30271 goto __2 30272 } 30273 z++ 30274 goto __1 30275 __2: 30276 ; 30277 if !(z >= zEnd) { 30278 goto __3 30279 } 30280 return 0 30281 __3: 30282 ; 30283 30284 // get sign of significand 30285 if !(int32(*(*int8)(unsafe.Pointer(z))) == '-') { 30286 goto __4 30287 } 30288 sign = -1 30289 z++ 30290 goto __5 30291 __4: 30292 if !(int32(*(*int8)(unsafe.Pointer(z))) == '+') { 30293 goto __6 30294 } 30295 z++ 30296 __6: 30297 ; 30298 __5: 30299 ; 30300 30301 // skip leading zeroes 30302 __7: 30303 if !((z < zEnd) && (int32(*(*int8)(unsafe.Pointer(z))) == '0')) { 30304 goto __8 30305 } 30306 z++ 30307 nDigits++ 30308 goto __7 30309 __8: 30310 ; 30311 30312 // copy max significant digits to significand 30313 __9: 30314 if !(((z < zEnd) && (totypeIsdigit(tls, uint8(*(*int8)(unsafe.Pointer(z)))) != 0)) && (s < (((int64(0xffffffff) | (sqlite3_int64((int64(0x7fffffff))) << 32)) - int64(9)) / int64(10)))) { 30315 goto __10 30316 } 30317 s = ((s * int64(10)) + (sqlite3_int64(int32(*(*int8)(unsafe.Pointer(z))) - '0'))) 30318 z++ 30319 nDigits++ 30320 goto __9 30321 __10: 30322 ; 30323 30324 // skip non-significant significand digits 30325 // (increase exponent by d to shift decimal left) 30326 __11: 30327 if !((z < zEnd) && (totypeIsdigit(tls, uint8(*(*int8)(unsafe.Pointer(z)))) != 0)) { 30328 goto __12 30329 } 30330 z++ 30331 nDigits++ 30332 d++ 30333 goto __11 30334 __12: 30335 ; 30336 if !(z >= zEnd) { 30337 goto __13 30338 } 30339 goto totype_atof_calc 30340 __13: 30341 ; 30342 30343 // if decimal point is present 30344 if !(int32(*(*int8)(unsafe.Pointer(z))) == '.') { 30345 goto __14 30346 } 30347 z++ 30348 // copy digits from after decimal to significand 30349 // (decrease exponent by d to shift decimal right) 30350 __15: 30351 if !(((z < zEnd) && (totypeIsdigit(tls, uint8(*(*int8)(unsafe.Pointer(z)))) != 0)) && (s < (((int64(0xffffffff) | (sqlite3_int64((int64(0x7fffffff))) << 32)) - int64(9)) / int64(10)))) { 30352 goto __16 30353 } 30354 s = ((s * int64(10)) + (sqlite3_int64(int32(*(*int8)(unsafe.Pointer(z))) - '0'))) 30355 z++ 30356 nDigits++ 30357 d-- 30358 goto __15 30359 __16: 30360 ; 30361 // skip non-significant digits 30362 __17: 30363 if !((z < zEnd) && (totypeIsdigit(tls, uint8(*(*int8)(unsafe.Pointer(z)))) != 0)) { 30364 goto __18 30365 } 30366 z++ 30367 nDigits++ 30368 goto __17 30369 __18: 30370 ; 30371 __14: 30372 ; 30373 if !(z >= zEnd) { 30374 goto __19 30375 } 30376 goto totype_atof_calc 30377 __19: 30378 ; 30379 30380 // if exponent is present 30381 if !((int32(*(*int8)(unsafe.Pointer(z))) == 'e') || (int32(*(*int8)(unsafe.Pointer(z))) == 'E')) { 30382 goto __20 30383 } 30384 z++ 30385 eValid = 0 30386 if !(z >= zEnd) { 30387 goto __21 30388 } 30389 goto totype_atof_calc 30390 __21: 30391 ; 30392 // get sign of exponent 30393 if !(int32(*(*int8)(unsafe.Pointer(z))) == '-') { 30394 goto __22 30395 } 30396 esign = -1 30397 z++ 30398 goto __23 30399 __22: 30400 if !(int32(*(*int8)(unsafe.Pointer(z))) == '+') { 30401 goto __24 30402 } 30403 z++ 30404 __24: 30405 ; 30406 __23: 30407 ; 30408 // copy digits to exponent 30409 __25: 30410 if !((z < zEnd) && (totypeIsdigit(tls, uint8(*(*int8)(unsafe.Pointer(z)))) != 0)) { 30411 goto __26 30412 } 30413 if e < 10000 { 30414 e = ((e * 10) + (int32(*(*int8)(unsafe.Pointer(z))) - '0')) 30415 } else { 30416 e = 10000 30417 } 30418 z++ 30419 eValid = 1 30420 goto __25 30421 __26: 30422 ; 30423 __20: 30424 ; 30425 30426 // skip trailing spaces 30427 if !((nDigits != 0) && (eValid != 0)) { 30428 goto __27 30429 } 30430 __28: 30431 if !((z < zEnd) && (totypeIsspace(tls, uint8(*(*int8)(unsafe.Pointer(z)))) != 0)) { 30432 goto __29 30433 } 30434 z++ 30435 goto __28 30436 __29: 30437 ; 30438 __27: 30439 ; 30440 30441 totype_atof_calc: 30442 // adjust exponent by d, and update sign 30443 e = ((e * esign) + d) 30444 if !(e < 0) { 30445 goto __30 30446 } 30447 esign = -1 30448 e = e * (-1) 30449 goto __31 30450 __30: 30451 esign = 1 30452 __31: 30453 ; 30454 30455 // if 0 significand 30456 if !(!(s != 0)) { 30457 goto __32 30458 } 30459 // In the IEEE 754 standard, zero is signed. 30460 // Add the sign if we've seen at least one digit 30461 if (sign < 0) && (nDigits != 0) { 30462 result = -libc.Float64FromFloat64(float64(0)) 30463 } else { 30464 result = float64(0) 30465 } 30466 goto __33 30467 __32: 30468 // attempt to reduce exponent 30469 if !(esign > 0) { 30470 goto __34 30471 } 30472 __36: 30473 if !((s < ((int64(0xffffffff) | (sqlite3_int64((int64(0x7fffffff))) << 32)) / int64(10))) && (e > 0)) { 30474 goto __37 30475 } 30476 e-- 30477 s = s * (int64(10)) 30478 goto __36 30479 __37: 30480 ; 30481 goto __35 30482 __34: 30483 __38: 30484 if !(!((int32(s % int64(10))) != 0) && (e > 0)) { 30485 goto __39 30486 } 30487 e-- 30488 s = s / (int64(10)) 30489 goto __38 30490 __39: 30491 ; 30492 __35: 30493 ; 30494 30495 // adjust the sign of significand 30496 if sign < 0 { 30497 s = -s 30498 } else { 30499 s = s 30500 } 30501 30502 // if exponent, scale significand as appropriate 30503 // and store in result. 30504 if !(e != 0) { 30505 goto __40 30506 } 30507 scale = 1.0 30508 // attempt to handle extremely small/large numbers better 30509 if !((e > 307) && (e < 342)) { 30510 goto __42 30511 } 30512 __44: 30513 if !((e % 308) != 0) { 30514 goto __45 30515 } 30516 scale = scale * (1.0e+1) 30517 e = e - (1) 30518 goto __44 30519 __45: 30520 ; 30521 if !(esign < 0) { 30522 goto __46 30523 } 30524 result = (float64(s) / scale) 30525 result = result / (1.0e+308) 30526 goto __47 30527 __46: 30528 result = (float64(s) * scale) 30529 result = result * (1.0e+308) 30530 __47: 30531 ; 30532 goto __43 30533 __42: 30534 if !(e >= 342) { 30535 goto __48 30536 } 30537 if !(esign < 0) { 30538 goto __50 30539 } 30540 result = (0.0 * float64(s)) 30541 goto __51 30542 __50: 30543 result = ((libc.Float64(1e308) * libc.Float64(1e308)) * float64(s)) // Infinity 30544 __51: 30545 ; 30546 goto __49 30547 __48: 30548 // 1.0e+22 is the largest power of 10 than can be 30549 // represented exactly. 30550 __52: 30551 if !((e % 22) != 0) { 30552 goto __53 30553 } 30554 scale = scale * (1.0e+1) 30555 e = e - (1) 30556 goto __52 30557 __53: 30558 ; 30559 __54: 30560 if !(e > 0) { 30561 goto __55 30562 } 30563 scale = scale * (1.0e+22) 30564 e = e - (22) 30565 goto __54 30566 __55: 30567 ; 30568 if !(esign < 0) { 30569 goto __56 30570 } 30571 result = (float64(s) / scale) 30572 goto __57 30573 __56: 30574 result = (float64(s) * scale) 30575 __57: 30576 ; 30577 __49: 30578 ; 30579 __43: 30580 ; 30581 goto __41 30582 __40: 30583 result = float64(s) 30584 __41: 30585 ; 30586 __33: 30587 ; 30588 30589 // store the result 30590 *(*float64)(unsafe.Pointer(pResult)) = result 30591 30592 // return true if number and no extra non-whitespace chracters after 30593 return (libc.Bool32((((z >= zEnd) && (nDigits > 0)) && (eValid != 0)) && (nonNum == 0))) 30594 } 30595 30596 // tointeger(X): If X is any value (integer, double, blob, or string) that 30597 // can be losslessly converted into an integer, then make the conversion and 30598 // return the result. Otherwise, return NULL. 30599 func tointegerFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* totype.c:358:13: */ 30600 bp := tls.Alloc(24) 30601 defer tls.Free(24) 30602 30603 _ = argc 30604 switch sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) { 30605 case SQLITE_FLOAT: 30606 { 30607 var rVal float64 = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) 30608 var iVal sqlite3_int64 = sqlite3_int64(rVal) 30609 if rVal == float64(iVal) { 30610 sqlite3.Xsqlite3_result_int64(tls, context, iVal) 30611 } 30612 break 30613 30614 } 30615 case SQLITE_INTEGER: 30616 { 30617 sqlite3.Xsqlite3_result_int64(tls, context, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv)))) 30618 break 30619 30620 } 30621 case SQLITE_BLOB: 30622 { 30623 var zBlob uintptr = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) 30624 if zBlob != 0 { 30625 var nBlob int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) 30626 if uint64(nBlob) == uint64(unsafe.Sizeof(sqlite3_int64(0))) { 30627 // var iVal sqlite3_int64 at bp+8, 8 30628 30629 if int32(*(*int8)(unsafe.Pointer(uintptr(unsafe.Pointer(&totype_one))))) == 0 { 30630 var i int32 30631 // var zBlobRev [8]uint8 at bp, 8 30632 30633 for i = 0; uint64(i) < uint64(unsafe.Sizeof(sqlite3_int64(0))); i++ { 30634 *(*uint8)(unsafe.Pointer(bp /* &zBlobRev[0] */ + uintptr(i))) = *(*uint8)(unsafe.Pointer(zBlob + uintptr(((uint64(unsafe.Sizeof(sqlite3_int64(0))) - uint64(1)) - uint64(i))))) 30635 } 30636 libc.Xmemcpy(tls, bp+8 /* &iVal */, bp /* &zBlobRev[0] */, uint64(unsafe.Sizeof(sqlite3_int64(0)))) 30637 } else { 30638 libc.Xmemcpy(tls, bp+8 /* &iVal */, zBlob, uint64(unsafe.Sizeof(sqlite3_int64(0)))) 30639 } 30640 sqlite3.Xsqlite3_result_int64(tls, context, *(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* iVal */))) 30641 } 30642 } 30643 break 30644 30645 } 30646 case SQLITE_TEXT: 30647 { 30648 var zStr uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 30649 if zStr != 0 { 30650 var nStr int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) 30651 if (nStr != 0) && !(totypeIsspace(tls, *(*uint8)(unsafe.Pointer(zStr))) != 0) { 30652 // var iVal sqlite3_int64 at bp+16, 8 30653 30654 if !(totypeAtoi64(tls, zStr, bp+16 /* &iVal */, nStr) != 0) { 30655 sqlite3.Xsqlite3_result_int64(tls, context, *(*sqlite3_int64)(unsafe.Pointer(bp + 16 /* iVal */))) 30656 } 30657 } 30658 } 30659 break 30660 30661 } 30662 default: 30663 { 30664 30665 break 30666 30667 } 30668 } 30669 } 30670 30671 // toreal(X): If X is any value (integer, double, blob, or string) that can 30672 // be losslessly converted into a real number, then do so and return that 30673 // real number. Otherwise return NULL. 30674 func torealFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* totype.c:428:13: */ 30675 bp := tls.Alloc(24) 30676 defer tls.Free(24) 30677 30678 _ = argc 30679 switch sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) { 30680 case SQLITE_FLOAT: 30681 { 30682 sqlite3.Xsqlite3_result_double(tls, context, sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv)))) 30683 break 30684 30685 } 30686 case SQLITE_INTEGER: 30687 { 30688 var iVal sqlite3_int64 = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) 30689 var rVal float64 = float64(iVal) 30690 if iVal == sqlite3_int64(rVal) { 30691 sqlite3.Xsqlite3_result_double(tls, context, rVal) 30692 } 30693 break 30694 30695 } 30696 case SQLITE_BLOB: 30697 { 30698 var zBlob uintptr = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) 30699 if zBlob != 0 { 30700 var nBlob int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) 30701 if uint64(nBlob) == uint64(unsafe.Sizeof(float64(0))) { 30702 // var rVal float64 at bp+8, 8 30703 30704 if int32(*(*int8)(unsafe.Pointer(uintptr(unsafe.Pointer(&totype_one))))) == 1 { 30705 var i int32 30706 // var zBlobRev [8]uint8 at bp, 8 30707 30708 for i = 0; uint64(i) < uint64(unsafe.Sizeof(float64(0))); i++ { 30709 *(*uint8)(unsafe.Pointer(bp /* &zBlobRev[0] */ + uintptr(i))) = *(*uint8)(unsafe.Pointer(zBlob + uintptr(((uint64(unsafe.Sizeof(float64(0))) - uint64(1)) - uint64(i))))) 30710 } 30711 libc.Xmemcpy(tls, bp+8 /* &rVal */, bp /* &zBlobRev[0] */, uint64(unsafe.Sizeof(float64(0)))) 30712 } else { 30713 libc.Xmemcpy(tls, bp+8 /* &rVal */, zBlob, uint64(unsafe.Sizeof(float64(0)))) 30714 } 30715 sqlite3.Xsqlite3_result_double(tls, context, *(*float64)(unsafe.Pointer(bp + 8 /* rVal */))) 30716 } 30717 } 30718 break 30719 30720 } 30721 case SQLITE_TEXT: 30722 { 30723 var zStr uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 30724 if zStr != 0 { 30725 var nStr int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) 30726 if ((nStr != 0) && !(totypeIsspace(tls, *(*uint8)(unsafe.Pointer(zStr))) != 0)) && !(totypeIsspace(tls, *(*uint8)(unsafe.Pointer(zStr + uintptr((nStr - 1))))) != 0) { 30727 // var rVal float64 at bp+16, 8 30728 30729 if totypeAtoF(tls, zStr, bp+16 /* &rVal */, nStr) != 0 { 30730 sqlite3.Xsqlite3_result_double(tls, context, *(*float64)(unsafe.Pointer(bp + 16 /* rVal */))) 30731 return 30732 } 30733 } 30734 } 30735 break 30736 30737 } 30738 default: 30739 { 30740 30741 break 30742 30743 } 30744 } 30745 } 30746 30747 func sqlite3_totype_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* totype.c:497:5: */ 30748 var rc int32 = SQLITE_OK 30749 _ = pApi 30750 30751 _ = pzErrMsg // Unused parameter 30752 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+7879 /* "tointeger" */, 1, 30753 ((SQLITE_UTF8 | SQLITE_DETERMINISTIC) | SQLITE_INNOCUOUS), uintptr(0), 30754 *(*uintptr)(unsafe.Pointer(&struct { 30755 f func(*libc.TLS, uintptr, int32, uintptr) 30756 }{tointegerFunc})), uintptr(0), uintptr(0)) 30757 if rc == SQLITE_OK { 30758 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+7889 /* "toreal" */, 1, 30759 ((SQLITE_UTF8 | SQLITE_DETERMINISTIC) | SQLITE_INNOCUOUS), uintptr(0), 30760 *(*uintptr)(unsafe.Pointer(&struct { 30761 f func(*libc.TLS, uintptr, int32, uintptr) 30762 }{torealFunc})), uintptr(0), uintptr(0)) 30763 } 30764 return rc 30765 } 30766 30767 // Floating-point inline functions for stdlib.h. 30768 // Copyright (C) 2012-2018 Free Software Foundation, Inc. 30769 // This file is part of the GNU C Library. 30770 // 30771 // The GNU C Library is free software; you can redistribute it and/or 30772 // modify it under the terms of the GNU Lesser General Public 30773 // License as published by the Free Software Foundation; either 30774 // version 2.1 of the License, or (at your option) any later version. 30775 // 30776 // The GNU C Library is distributed in the hope that it will be useful, 30777 // but WITHOUT ANY WARRANTY; without even the implied warranty of 30778 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 30779 // Lesser General Public License for more details. 30780 // 30781 // You should have received a copy of the GNU Lesser General Public 30782 // License along with the GNU C Library; if not, see 30783 // <http://www.gnu.org/licenses/>. 30784 30785 // Define some macros helping to catch buffer overflows. 30786 30787 // Largest and smallest possible 64-bit signed integers. These macros 30788 // copied from sqliteInt.h. 30789 30790 // The following is also copied from sqliteInt.h. To facilitate coverage 30791 // testing. 30792 30793 // The swarmvtab module attempts to keep the number of open database files 30794 // at or below this limit. This may not be possible if there are too many 30795 // simultaneous queries. 30796 30797 type UnionCsr1 = struct { 30798 Fbase sqlite3_vtab_cursor 30799 FpStmt uintptr 30800 FiMaxRowid sqlite3_int64 30801 FiTab int32 30802 _ [4]byte 30803 } /* unionvtab.c:181:9 */ 30804 30805 // Floating-point inline functions for stdlib.h. 30806 // Copyright (C) 2012-2018 Free Software Foundation, Inc. 30807 // This file is part of the GNU C Library. 30808 // 30809 // The GNU C Library is free software; you can redistribute it and/or 30810 // modify it under the terms of the GNU Lesser General Public 30811 // License as published by the Free Software Foundation; either 30812 // version 2.1 of the License, or (at your option) any later version. 30813 // 30814 // The GNU C Library is distributed in the hope that it will be useful, 30815 // but WITHOUT ANY WARRANTY; without even the implied warranty of 30816 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 30817 // Lesser General Public License for more details. 30818 // 30819 // You should have received a copy of the GNU Lesser General Public 30820 // License along with the GNU C Library; if not, see 30821 // <http://www.gnu.org/licenses/>. 30822 30823 // Define some macros helping to catch buffer overflows. 30824 30825 // Largest and smallest possible 64-bit signed integers. These macros 30826 // copied from sqliteInt.h. 30827 30828 // The following is also copied from sqliteInt.h. To facilitate coverage 30829 // testing. 30830 30831 // The swarmvtab module attempts to keep the number of open database files 30832 // at or below this limit. This may not be possible if there are too many 30833 // simultaneous queries. 30834 30835 type UnionCsr = UnionCsr1 /* unionvtab.c:181:25 */ 30836 type UnionTab1 = struct { 30837 Fbase sqlite3_vtab 30838 Fdb uintptr 30839 FbSwarm int32 30840 FiPK int32 30841 FnSrc int32 30842 _ [4]byte 30843 FaSrc uintptr 30844 FbHasContext int32 30845 _ [4]byte 30846 FzSourceStr uintptr 30847 FpNotFound uintptr 30848 FpOpenClose uintptr 30849 FpClosable uintptr 30850 FnOpen int32 30851 FnMaxOpen int32 30852 } /* unionvtab.c:182:9 */ 30853 30854 type UnionTab = UnionTab1 /* unionvtab.c:182:25 */ 30855 type UnionSrc1 = struct { 30856 FzDb uintptr 30857 FzTab uintptr 30858 FiMin sqlite3_int64 30859 FiMax sqlite3_int64 30860 FzFile uintptr 30861 FzContext uintptr 30862 FnUser int32 30863 _ [4]byte 30864 Fdb uintptr 30865 FpNextClosable uintptr 30866 } /* unionvtab.c:182:9 */ 30867 30868 type UnionSrc = UnionSrc1 /* unionvtab.c:183:25 */ 30869 30870 // Given UnionTab table pTab and UnionSrc object pSrc, return the database 30871 // handle that should be used to access the table identified by pSrc. This 30872 // is the main db handle for "unionvtab" tables, or the source-specific 30873 // handle for "swarmvtab". 30874 30875 // If *pRc is other than SQLITE_OK when this function is called, it 30876 // always returns NULL. Otherwise, it attempts to allocate and return 30877 // a pointer to nByte bytes of zeroed memory. If the memory allocation 30878 // is attempted but fails, NULL is returned and *pRc is set to 30879 // SQLITE_NOMEM. 30880 func unionMalloc(tls *libc.TLS, pRc uintptr, nByte sqlite3_int64) uintptr { /* unionvtab.c:253:13: */ 30881 var pRet uintptr 30882 30883 if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { 30884 pRet = sqlite3.Xsqlite3_malloc64(tls, uint64(nByte)) 30885 if pRet != 0 { 30886 libc.Xmemset(tls, pRet, 0, size_t(nByte)) 30887 } else { 30888 *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM 30889 } 30890 } else { 30891 pRet = uintptr(0) 30892 } 30893 return pRet 30894 } 30895 30896 // If *pRc is other than SQLITE_OK when this function is called, it 30897 // always returns NULL. Otherwise, it attempts to allocate and return 30898 // a copy of the nul-terminated string passed as the second argument. 30899 // If the allocation is attempted but fails, NULL is returned and *pRc is 30900 // set to SQLITE_NOMEM. 30901 func unionStrdup(tls *libc.TLS, pRc uintptr, zIn uintptr) uintptr { /* unionvtab.c:276:13: */ 30902 var zRet uintptr = uintptr(0) 30903 if zIn != 0 { 30904 var nByte sqlite3_int64 = (sqlite3_int64(libc.Xstrlen(tls, zIn) + uint64(1))) 30905 zRet = unionMalloc(tls, pRc, nByte) 30906 if zRet != 0 { 30907 libc.Xmemcpy(tls, zRet, zIn, size_t(nByte)) 30908 } 30909 } 30910 return zRet 30911 } 30912 30913 // If the first character of the string passed as the only argument to this 30914 // function is one of the 4 that may be used as an open quote character 30915 // in SQL, this function assumes that the input is a well-formed quoted SQL 30916 // string. In this case the string is dequoted in place. 30917 // 30918 // If the first character of the input is not an open quote, then this 30919 // function is a no-op. 30920 func unionDequote(tls *libc.TLS, z uintptr) { /* unionvtab.c:297:13: */ 30921 if z != 0 { 30922 var q int8 = *(*int8)(unsafe.Pointer(z)) 30923 30924 // Set stack variable q to the close-quote character 30925 if (((int32(q) == '[') || (int32(q) == '\'')) || (int32(q) == '"')) || (int32(q) == '`') { 30926 var iIn int32 = 1 30927 var iOut int32 = 0 30928 if int32(q) == '[' { 30929 q = int8(']') 30930 } 30931 for *(*int8)(unsafe.Pointer(z + uintptr(iIn))) != 0 { 30932 if int32(*(*int8)(unsafe.Pointer(z + uintptr(iIn)))) == int32(q) { 30933 if int32(*(*int8)(unsafe.Pointer(z + uintptr((iIn + 1))))) != int32(q) { 30934 // Character iIn was the close quote. 30935 iIn++ 30936 break 30937 } else { 30938 // Character iIn and iIn+1 form an escaped quote character. Skip 30939 // the input cursor past both and copy a single quote character 30940 // to the output buffer. 30941 iIn = iIn + (2) 30942 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&iOut, 1)))) = q 30943 } 30944 } else { 30945 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&iOut, 1)))) = *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&iIn, 1)))) 30946 } 30947 } 30948 *(*int8)(unsafe.Pointer(z + uintptr(iOut))) = int8(0) 30949 } 30950 } 30951 } 30952 30953 // This function is a no-op if *pRc is set to other than SQLITE_OK when it 30954 // is called. NULL is returned in this case. 30955 // 30956 // Otherwise, the SQL statement passed as the third argument is prepared 30957 // against the database handle passed as the second. If the statement is 30958 // successfully prepared, a pointer to the new statement handle is 30959 // returned. It is the responsibility of the caller to eventually free the 30960 // statement by calling sqlite3_finalize(). Alternatively, if statement 30961 // compilation fails, NULL is returned, *pRc is set to an SQLite error 30962 // code and *pzErr may be set to an error message buffer allocated by 30963 // sqlite3_malloc(). 30964 func unionPrepare(tls *libc.TLS, pRc uintptr, db uintptr, zSql uintptr, pzErr uintptr) uintptr { /* unionvtab.c:341:21: */ 30965 bp := tls.Alloc(16) 30966 defer tls.Free(16) 30967 30968 *(*uintptr)(unsafe.Pointer(bp + 8 /* pRet */)) = uintptr(0) 30969 30970 if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { 30971 var rc int32 = sqlite3.Xsqlite3_prepare_v2(tls, db, zSql, -1, bp+8 /* &pRet */, uintptr(0)) 30972 if rc != SQLITE_OK { 30973 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+7896 /* "sql error: %s" */, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, db))) 30974 *(*int32)(unsafe.Pointer(pRc)) = rc 30975 } 30976 } 30977 return *(*uintptr)(unsafe.Pointer(bp + 8 /* pRet */)) 30978 } 30979 30980 // Like unionPrepare(), except prepare the results of vprintf(zFmt, ...) 30981 // instead of a constant SQL string. 30982 func unionPreparePrintf(tls *libc.TLS, pRc uintptr, pzErr uintptr, db uintptr, zFmt uintptr, va uintptr) uintptr { /* unionvtab.c:363:21: */ 30983 var pRet uintptr = uintptr(0) 30984 var zSql uintptr 30985 var ap va_list 30986 _ = ap 30987 ap = va 30988 30989 zSql = sqlite3.Xsqlite3_vmprintf(tls, zFmt, ap) 30990 if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { 30991 if zSql == uintptr(0) { 30992 *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM 30993 } else { 30994 pRet = unionPrepare(tls, pRc, db, zSql, pzErr) 30995 } 30996 } 30997 sqlite3.Xsqlite3_free(tls, zSql) 30998 30999 _ = ap 31000 return pRet 31001 } 31002 31003 // Call sqlite3_reset() on SQL statement pStmt. If *pRc is set to 31004 // SQLITE_OK when this function is called, then it is set to the 31005 // value returned by sqlite3_reset() before this function exits. 31006 // In this case, *pzErr may be set to point to an error message 31007 // buffer allocated by sqlite3_malloc(). 31008 31009 // Call sqlite3_finalize() on SQL statement pStmt. If *pRc is set to 31010 // SQLITE_OK when this function is called, then it is set to the 31011 // value returned by sqlite3_finalize() before this function exits. 31012 func unionFinalize(tls *libc.TLS, pRc uintptr, pStmt uintptr, pzErr uintptr) { /* unionvtab.c:414:13: */ 31013 bp := tls.Alloc(8) 31014 defer tls.Free(8) 31015 31016 var db uintptr = sqlite3.Xsqlite3_db_handle(tls, pStmt) 31017 var rc int32 = sqlite3.Xsqlite3_finalize(tls, pStmt) 31018 if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { 31019 *(*int32)(unsafe.Pointer(pRc)) = rc 31020 if rc != 0 { 31021 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, db))) 31022 } 31023 } 31024 } 31025 31026 // If an "openclose" UDF was supplied when this virtual table was created, 31027 // invoke it now. The first argument passed is the name of the database 31028 // file for source pSrc. The second is integer value bClose. 31029 // 31030 // If successful, return SQLITE_OK. Otherwise an SQLite error code. In this 31031 // case if argument pzErr is not NULL, also set (*pzErr) to an English 31032 // language error message. The caller is responsible for eventually freeing 31033 // any error message using sqlite3_free(). 31034 func unionInvokeOpenClose(tls *libc.TLS, pTab uintptr, pSrc uintptr, bClose int32, pzErr uintptr) int32 { /* unionvtab.c:435:12: */ 31035 bp := tls.Alloc(8) 31036 defer tls.Free(8) 31037 31038 var rc int32 = SQLITE_OK 31039 if (*UnionTab)(unsafe.Pointer(pTab)).FpOpenClose != 0 { 31040 sqlite3.Xsqlite3_bind_text(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpOpenClose, 1, (*UnionSrc)(unsafe.Pointer(pSrc)).FzFile, -1, uintptr(0)) 31041 if (*UnionTab)(unsafe.Pointer(pTab)).FbHasContext != 0 { 31042 sqlite3.Xsqlite3_bind_text(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpOpenClose, 2, (*UnionSrc)(unsafe.Pointer(pSrc)).FzContext, -1, uintptr(0)) 31043 } 31044 sqlite3.Xsqlite3_bind_int(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpOpenClose, (2 + (*UnionTab)(unsafe.Pointer(pTab)).FbHasContext), bClose) 31045 sqlite3.Xsqlite3_step(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpOpenClose) 31046 if SQLITE_OK != (libc.AssignInt32(&rc, sqlite3.Xsqlite3_reset(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpOpenClose))) { 31047 if pzErr != 0 { 31048 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, (*UnionTab)(unsafe.Pointer(pTab)).Fdb))) 31049 } 31050 } 31051 } 31052 return rc 31053 } 31054 31055 // This function is a no-op for unionvtab. For swarmvtab, it attempts to 31056 // close open database files until at most nMax are open. An SQLite error 31057 // code is returned if an error occurs, or SQLITE_OK otherwise. 31058 func unionCloseSources(tls *libc.TLS, pTab uintptr, nMax int32) { /* unionvtab.c:463:13: */ 31059 for ((*UnionTab)(unsafe.Pointer(pTab)).FpClosable != 0) && ((*UnionTab)(unsafe.Pointer(pTab)).FnOpen > nMax) { 31060 var p uintptr 31061 var pp uintptr 31062 for pp = (pTab + 88 /* &.pClosable */); (*UnionSrc)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pp)))).FpNextClosable != 0; pp = (*(*uintptr)(unsafe.Pointer(pp)) + 64 /* &.pNextClosable */) { 31063 } 31064 p = *(*uintptr)(unsafe.Pointer(pp)) 31065 31066 sqlite3.Xsqlite3_close(tls, (*UnionSrc)(unsafe.Pointer(p)).Fdb) 31067 (*UnionSrc)(unsafe.Pointer(p)).Fdb = uintptr(0) 31068 *(*uintptr)(unsafe.Pointer(pp)) = uintptr(0) 31069 (*UnionTab)(unsafe.Pointer(pTab)).FnOpen-- 31070 unionInvokeOpenClose(tls, pTab, p, 1, uintptr(0)) 31071 } 31072 } 31073 31074 // xDisconnect method. 31075 func unionDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* unionvtab.c:481:12: */ 31076 if pVtab != 0 { 31077 var pTab uintptr = pVtab 31078 var i int32 31079 for i = 0; i < (*UnionTab)(unsafe.Pointer(pTab)).FnSrc; i++ { 31080 var pSrc uintptr = ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc + uintptr(i)*72) 31081 var bHaveSrcDb int32 = (libc.Bool32((*UnionSrc)(unsafe.Pointer(pSrc)).Fdb != uintptr(0))) 31082 sqlite3.Xsqlite3_close(tls, (*UnionSrc)(unsafe.Pointer(pSrc)).Fdb) 31083 if bHaveSrcDb != 0 { 31084 unionInvokeOpenClose(tls, pTab, pSrc, 1, uintptr(0)) 31085 } 31086 sqlite3.Xsqlite3_free(tls, (*UnionSrc)(unsafe.Pointer(pSrc)).FzDb) 31087 sqlite3.Xsqlite3_free(tls, (*UnionSrc)(unsafe.Pointer(pSrc)).FzTab) 31088 sqlite3.Xsqlite3_free(tls, (*UnionSrc)(unsafe.Pointer(pSrc)).FzFile) 31089 sqlite3.Xsqlite3_free(tls, (*UnionSrc)(unsafe.Pointer(pSrc)).FzContext) 31090 } 31091 sqlite3.Xsqlite3_finalize(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpNotFound) 31092 sqlite3.Xsqlite3_finalize(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpOpenClose) 31093 sqlite3.Xsqlite3_free(tls, (*UnionTab)(unsafe.Pointer(pTab)).FzSourceStr) 31094 sqlite3.Xsqlite3_free(tls, (*UnionTab)(unsafe.Pointer(pTab)).FaSrc) 31095 sqlite3.Xsqlite3_free(tls, pTab) 31096 } 31097 return SQLITE_OK 31098 } 31099 31100 // Check that the table identified by pSrc is a rowid table. If not, 31101 // return SQLITE_ERROR and set (*pzErr) to point to an English language 31102 // error message. If the table is a rowid table and no error occurs, 31103 // return SQLITE_OK and leave (*pzErr) unmodified. 31104 func unionIsIntkeyTable(tls *libc.TLS, db uintptr, pSrc uintptr, pzErr uintptr) int32 { /* unionvtab.c:512:12: */ 31105 bp := tls.Alloc(36) 31106 defer tls.Free(36) 31107 31108 *(*int32)(unsafe.Pointer(bp + 32 /* bPk */)) = 0 31109 *(*uintptr)(unsafe.Pointer(bp + 24 /* zType */)) = uintptr(0) 31110 var rc int32 31111 31112 sqlite3.Xsqlite3_table_column_metadata(tls, 31113 db, (*UnionSrc)(unsafe.Pointer(pSrc)).FzDb, (*UnionSrc)(unsafe.Pointer(pSrc)).FzTab, ts+7910 /* "_rowid_" */, bp+24 /* &zType */, uintptr(0), uintptr(0), bp+32 /* &bPk */, uintptr(0)) 31114 rc = sqlite3.Xsqlite3_errcode(tls, db) 31115 if (rc == SQLITE_ERROR) || 31116 ((rc == SQLITE_OK) && (!(*(*int32)(unsafe.Pointer(bp + 32 /* bPk */)) != 0) || (sqlite3.Xsqlite3_stricmp(tls, ts+7918 /* "integer" */, *(*uintptr)(unsafe.Pointer(bp + 24 /* zType */))) != 0))) { 31117 rc = SQLITE_ERROR 31118 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+7926, /* "no such rowid ta..." */ 31119 libc.VaList(bp, func() uintptr { 31120 if (*UnionSrc)(unsafe.Pointer(pSrc)).FzDb != 0 { 31121 return (*UnionSrc)(unsafe.Pointer(pSrc)).FzDb 31122 } 31123 return ts + 489 /* "" */ 31124 }(), 31125 func() uintptr { 31126 if (*UnionSrc)(unsafe.Pointer(pSrc)).FzDb != 0 { 31127 return ts + 7954 /* "." */ 31128 } 31129 return ts + 489 /* "" */ 31130 }(), 31131 (*UnionSrc)(unsafe.Pointer(pSrc)).FzTab)) 31132 } 31133 return rc 31134 } 31135 31136 // This function is a no-op if *pRc is other than SQLITE_OK when it is 31137 // called. In this case it returns NULL. 31138 // 31139 // Otherwise, this function checks that the source table passed as the 31140 // second argument (a) exists, (b) is not a view and (c) has a column 31141 // named "_rowid_" of type "integer" that is the primary key. 31142 // If this is not the case, *pRc is set to SQLITE_ERROR and NULL is 31143 // returned. 31144 // 31145 // Finally, if the source table passes the checks above, a nul-terminated 31146 // string describing the column names and types belonging to the source 31147 // table is returned. Tables with the same set of column names and types 31148 // cause this function to return identical strings. Is is the responsibility 31149 // of the caller to free the returned string using sqlite3_free() when 31150 // it is no longer required. 31151 func unionSourceToStr(tls *libc.TLS, pRc uintptr, pTab uintptr, pSrc uintptr, pzErr uintptr) uintptr { /* unionvtab.c:555:13: */ 31152 bp := tls.Alloc(4) 31153 defer tls.Free(4) 31154 31155 var zRet uintptr = uintptr(0) 31156 if *(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK { 31157 var db uintptr = func() uintptr { 31158 if (*UnionTab)(unsafe.Pointer(pTab)).FbSwarm != 0 { 31159 return (*UnionSrc)(unsafe.Pointer(pSrc)).Fdb 31160 } 31161 return (*UnionTab)(unsafe.Pointer(pTab)).Fdb 31162 }() 31163 *(*int32)(unsafe.Pointer(bp /* rc */)) = unionIsIntkeyTable(tls, db, pSrc, pzErr) 31164 var pStmt uintptr = unionPrepare(tls, bp /* &rc */, db, 31165 31166 ts+7956 /* "SELECT group_con..." */, pzErr) 31167 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 31168 sqlite3.Xsqlite3_bind_text(tls, pStmt, 1, (*UnionSrc)(unsafe.Pointer(pSrc)).FzTab, -1, uintptr(0)) 31169 sqlite3.Xsqlite3_bind_text(tls, pStmt, 2, (*UnionSrc)(unsafe.Pointer(pSrc)).FzDb, -1, uintptr(0)) 31170 if SQLITE_ROW == sqlite3.Xsqlite3_step(tls, pStmt) { 31171 var z uintptr = sqlite3.Xsqlite3_column_text(tls, pStmt, 0) 31172 zRet = unionStrdup(tls, bp /* &rc */, z) 31173 } 31174 unionFinalize(tls, bp /* &rc */, pStmt, pzErr) 31175 } 31176 *(*int32)(unsafe.Pointer(pRc)) = *(*int32)(unsafe.Pointer(bp /* rc */)) 31177 } 31178 31179 return zRet 31180 } 31181 31182 // Check that all configured source tables exist and have the same column 31183 // names and datatypes. If this is not the case, or if some other error 31184 // occurs, return an SQLite error code. In this case *pzErr may be set 31185 // to point to an error message buffer allocated by sqlite3_mprintf(). 31186 // Or, if no problems regarding the source tables are detected and no 31187 // other error occurs, SQLITE_OK is returned. 31188 func unionSourceCheck(tls *libc.TLS, pTab uintptr, pzErr uintptr) int32 { /* unionvtab.c:592:12: */ 31189 bp := tls.Alloc(4) 31190 defer tls.Free(4) 31191 31192 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK 31193 var z0 uintptr = uintptr(0) 31194 var i int32 31195 31196 z0 = unionSourceToStr(tls, bp /* &rc */, pTab, ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc), pzErr) 31197 for i = 1; i < (*UnionTab)(unsafe.Pointer(pTab)).FnSrc; i++ { 31198 var z uintptr = unionSourceToStr(tls, bp /* &rc */, pTab, ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc + uintptr(i)*72), pzErr) 31199 if (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (sqlite3.Xsqlite3_stricmp(tls, z, z0) != 0) { 31200 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+8040 /* "source table sch..." */, 0) 31201 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_ERROR 31202 } 31203 sqlite3.Xsqlite3_free(tls, z) 31204 } 31205 sqlite3.Xsqlite3_free(tls, z0) 31206 31207 return *(*int32)(unsafe.Pointer(bp /* rc */)) 31208 } 31209 31210 // Try to open the swarmvtab database. If initially unable, invoke the 31211 // not-found callback UDF and then try again. 31212 func unionOpenDatabaseInner(tls *libc.TLS, pTab uintptr, pSrc uintptr, pzErr uintptr) int32 { /* unionvtab.c:616:12: */ 31213 bp := tls.Alloc(16) 31214 defer tls.Free(16) 31215 31216 var rc int32 31217 31218 rc = unionInvokeOpenClose(tls, pTab, pSrc, 0, pzErr) 31219 if rc != SQLITE_OK { 31220 return rc 31221 } 31222 31223 rc = sqlite3.Xsqlite3_open_v2(tls, (*UnionSrc)(unsafe.Pointer(pSrc)).FzFile, (pSrc + 56 /* &.db */), openFlags, uintptr(0)) 31224 if rc == SQLITE_OK { 31225 return rc 31226 } 31227 if (*UnionTab)(unsafe.Pointer(pTab)).FpNotFound != 0 { 31228 sqlite3.Xsqlite3_close(tls, (*UnionSrc)(unsafe.Pointer(pSrc)).Fdb) 31229 (*UnionSrc)(unsafe.Pointer(pSrc)).Fdb = uintptr(0) 31230 sqlite3.Xsqlite3_bind_text(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpNotFound, 1, (*UnionSrc)(unsafe.Pointer(pSrc)).FzFile, -1, uintptr(0)) 31231 if (*UnionTab)(unsafe.Pointer(pTab)).FbHasContext != 0 { 31232 sqlite3.Xsqlite3_bind_text(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpNotFound, 2, (*UnionSrc)(unsafe.Pointer(pSrc)).FzContext, -1, uintptr(0)) 31233 } 31234 sqlite3.Xsqlite3_step(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpNotFound) 31235 if SQLITE_OK != (libc.AssignInt32(&rc, sqlite3.Xsqlite3_reset(tls, (*UnionTab)(unsafe.Pointer(pTab)).FpNotFound))) { 31236 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, (*UnionTab)(unsafe.Pointer(pTab)).Fdb))) 31237 return rc 31238 } 31239 rc = sqlite3.Xsqlite3_open_v2(tls, (*UnionSrc)(unsafe.Pointer(pSrc)).FzFile, (pSrc + 56 /* &.db */), openFlags, uintptr(0)) 31240 } 31241 if rc != SQLITE_OK { 31242 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+8, sqlite3.Xsqlite3_errmsg(tls, (*UnionSrc)(unsafe.Pointer(pSrc)).Fdb))) 31243 } 31244 return rc 31245 } 31246 31247 var openFlags int32 = (SQLITE_OPEN_READONLY | SQLITE_OPEN_URI) /* unionvtab.c:617:20 */ 31248 31249 // This function may only be called for swarmvtab tables. The results of 31250 // calling it on a unionvtab table are undefined. 31251 // 31252 // For a swarmvtab table, this function ensures that source database iSrc 31253 // is open. If the database is opened successfully and the schema is as 31254 // expected, or if it is already open when this function is called, SQLITE_OK 31255 // is returned. 31256 // 31257 // Alternatively If an error occurs while opening the databases, or if the 31258 // database schema is unsuitable, an SQLite error code is returned and (*pzErr) 31259 // may be set to point to an English language error message. In this case it is 31260 // the responsibility of the caller to eventually free the error message buffer 31261 // using sqlite3_free(). 31262 func unionOpenDatabase(tls *libc.TLS, pTab uintptr, iSrc int32, pzErr uintptr) int32 { /* unionvtab.c:660:12: */ 31263 bp := tls.Alloc(4) 31264 defer tls.Free(4) 31265 31266 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK 31267 var pSrc uintptr = ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc + uintptr(iSrc)*72) 31268 31269 if (*UnionSrc)(unsafe.Pointer(pSrc)).Fdb == uintptr(0) { 31270 unionCloseSources(tls, pTab, ((*UnionTab)(unsafe.Pointer(pTab)).FnMaxOpen - 1)) 31271 *(*int32)(unsafe.Pointer(bp /* rc */)) = unionOpenDatabaseInner(tls, pTab, pSrc, pzErr) 31272 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 31273 var z uintptr = unionSourceToStr(tls, bp /* &rc */, pTab, pSrc, pzErr) 31274 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 31275 if (*UnionTab)(unsafe.Pointer(pTab)).FzSourceStr == uintptr(0) { 31276 (*UnionTab)(unsafe.Pointer(pTab)).FzSourceStr = z 31277 } else { 31278 if sqlite3.Xsqlite3_stricmp(tls, z, (*UnionTab)(unsafe.Pointer(pTab)).FzSourceStr) != 0 { 31279 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+8040 /* "source table sch..." */, 0) 31280 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_ERROR 31281 } 31282 sqlite3.Xsqlite3_free(tls, z) 31283 } 31284 } 31285 } 31286 31287 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 31288 (*UnionSrc)(unsafe.Pointer(pSrc)).FpNextClosable = (*UnionTab)(unsafe.Pointer(pTab)).FpClosable 31289 (*UnionTab)(unsafe.Pointer(pTab)).FpClosable = pSrc 31290 (*UnionTab)(unsafe.Pointer(pTab)).FnOpen++ 31291 } else { 31292 sqlite3.Xsqlite3_close(tls, (*UnionSrc)(unsafe.Pointer(pSrc)).Fdb) 31293 (*UnionSrc)(unsafe.Pointer(pSrc)).Fdb = uintptr(0) 31294 unionInvokeOpenClose(tls, pTab, pSrc, 1, uintptr(0)) 31295 } 31296 } 31297 31298 return *(*int32)(unsafe.Pointer(bp /* rc */)) 31299 } 31300 31301 // This function is a no-op for unionvtab tables. For swarmvtab, increment 31302 // the reference count for source table iTab. If the reference count was 31303 // zero before it was incremented, also remove the source from the closable 31304 // list. 31305 func unionIncrRefcount(tls *libc.TLS, pTab uintptr, iTab int32) { /* unionvtab.c:704:13: */ 31306 if (*UnionTab)(unsafe.Pointer(pTab)).FbSwarm != 0 { 31307 var pSrc uintptr = ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc + uintptr(iTab)*72) 31308 31309 if (*UnionSrc)(unsafe.Pointer(pSrc)).FnUser == 0 { 31310 var pp uintptr 31311 for pp = (pTab + 88 /* &.pClosable */); *(*uintptr)(unsafe.Pointer(pp)) != pSrc; pp = (*(*uintptr)(unsafe.Pointer(pp)) + 64 /* &.pNextClosable */) { 31312 } 31313 *(*uintptr)(unsafe.Pointer(pp)) = (*UnionSrc)(unsafe.Pointer(pSrc)).FpNextClosable 31314 (*UnionSrc)(unsafe.Pointer(pSrc)).FpNextClosable = uintptr(0) 31315 } 31316 (*UnionSrc)(unsafe.Pointer(pSrc)).FnUser++ 31317 } 31318 } 31319 31320 // Finalize the SQL statement pCsr->pStmt and return the result. 31321 // 31322 // If this is a swarmvtab table (not unionvtab) and pCsr->pStmt was not 31323 // NULL when this function was called, also decrement the reference 31324 // count on the associated source table. If this means the source tables 31325 // refcount is now zero, add it to the closable list. 31326 func unionFinalizeCsrStmt(tls *libc.TLS, pCsr uintptr) int32 { /* unionvtab.c:726:12: */ 31327 var rc int32 = SQLITE_OK 31328 if (*UnionCsr)(unsafe.Pointer(pCsr)).FpStmt != 0 { 31329 var pTab uintptr = (*UnionCsr)(unsafe.Pointer(pCsr)).Fbase.FpVtab 31330 var pSrc uintptr = ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc + uintptr((*UnionCsr)(unsafe.Pointer(pCsr)).FiTab)*72) 31331 rc = sqlite3.Xsqlite3_finalize(tls, (*UnionCsr)(unsafe.Pointer(pCsr)).FpStmt) 31332 (*UnionCsr)(unsafe.Pointer(pCsr)).FpStmt = uintptr(0) 31333 if (*UnionTab)(unsafe.Pointer(pTab)).FbSwarm != 0 { 31334 (*UnionSrc)(unsafe.Pointer(pSrc)).FnUser-- 31335 31336 if (*UnionSrc)(unsafe.Pointer(pSrc)).FnUser == 0 { 31337 (*UnionSrc)(unsafe.Pointer(pSrc)).FpNextClosable = (*UnionTab)(unsafe.Pointer(pTab)).FpClosable 31338 (*UnionTab)(unsafe.Pointer(pTab)).FpClosable = pSrc 31339 } 31340 unionCloseSources(tls, pTab, (*UnionTab)(unsafe.Pointer(pTab)).FnMaxOpen) 31341 } 31342 } 31343 return rc 31344 } 31345 31346 // Return true if the argument is a space, tab, CR or LF character. 31347 func union_isspace(tls *libc.TLS, c int8) int32 { /* unionvtab.c:749:12: */ 31348 return (libc.Bool32((((int32(c) == ' ') || (int32(c) == '\n')) || (int32(c) == '\r')) || (int32(c) == '\t'))) 31349 } 31350 31351 // Return true if the argument is an alphanumeric character in the 31352 // ASCII range. 31353 func union_isidchar(tls *libc.TLS, c int8) int32 { /* unionvtab.c:757:12: */ 31354 return (libc.Bool32((((int32(c) >= 'a') && (int32(c) <= 'z')) || ((int32(c) >= 'A') && (int32(c) < 'Z'))) || ((int32(c) >= '0') && (int32(c) <= '9')))) 31355 } 31356 31357 // This function is called to handle all arguments following the first 31358 // (the SQL statement) passed to a swarmvtab (not unionvtab) CREATE 31359 // VIRTUAL TABLE statement. It may bind parameters to the SQL statement 31360 // or configure members of the UnionTab object passed as the second 31361 // argument. 31362 // 31363 // Refer to header comments at the top of this file for a description 31364 // of the arguments parsed. 31365 // 31366 // This function is a no-op if *pRc is other than SQLITE_OK when it is 31367 // called. Otherwise, if an error occurs, *pRc is set to an SQLite error 31368 // code. In this case *pzErr may be set to point to a buffer containing 31369 // an English language error message. It is the responsibility of the 31370 // caller to eventually free the buffer using sqlite3_free(). 31371 func unionConfigureVtab(tls *libc.TLS, pRc uintptr, pTab uintptr, pStmt uintptr, nArg int32, azArg uintptr, pzErr uintptr) { /* unionvtab.c:777:13: */ 31372 bp := tls.Alloc(68) 31373 defer tls.Free(68) 31374 31375 *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = *(*int32)(unsafe.Pointer(pRc)) 31376 var i int32 31377 if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == SQLITE_OK { 31378 (*UnionTab)(unsafe.Pointer(pTab)).FbHasContext = (libc.Bool32(sqlite3.Xsqlite3_column_count(tls, pStmt) > 4)) 31379 } 31380 for i = 0; (*(*int32)(unsafe.Pointer(bp + 64 /* rc */)) == SQLITE_OK) && (i < nArg); i++ { 31381 var zArg uintptr = unionStrdup(tls, bp+64 /* &rc */, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8))) 31382 if zArg != 0 { 31383 var nOpt int32 = 0 // Size of option name in bytes 31384 var zOpt uintptr // Pointer to option name 31385 var zVal uintptr // Pointer to value 31386 31387 unionDequote(tls, zArg) 31388 zOpt = zArg 31389 for union_isspace(tls, *(*int8)(unsafe.Pointer(zOpt))) != 0 { 31390 zOpt++ 31391 } 31392 zVal = zOpt 31393 if int32(*(*int8)(unsafe.Pointer(zVal))) == ':' { 31394 zVal++ 31395 } 31396 for union_isidchar(tls, *(*int8)(unsafe.Pointer(zVal))) != 0 { 31397 zVal++ 31398 } 31399 nOpt = (int32((int64(zVal) - int64(zOpt)) / 1)) 31400 31401 for union_isspace(tls, *(*int8)(unsafe.Pointer(zVal))) != 0 { 31402 zVal++ 31403 } 31404 if int32(*(*int8)(unsafe.Pointer(zVal))) == '=' { 31405 *(*int8)(unsafe.Pointer(zOpt + uintptr(nOpt))) = int8(0) 31406 zVal++ 31407 for union_isspace(tls, *(*int8)(unsafe.Pointer(zVal))) != 0 { 31408 zVal++ 31409 } 31410 zVal = unionStrdup(tls, bp+64 /* &rc */, zVal) 31411 if zVal != 0 { 31412 unionDequote(tls, zVal) 31413 if int32(*(*int8)(unsafe.Pointer(zOpt))) == ':' { 31414 // A value to bind to the SQL statement 31415 var iParam int32 = sqlite3.Xsqlite3_bind_parameter_index(tls, pStmt, zOpt) 31416 if iParam == 0 { 31417 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, 31418 ts+8069 /* "swarmvtab: no su..." */, libc.VaList(bp, zOpt)) 31419 *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_ERROR 31420 } else { 31421 *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = sqlite3.Xsqlite3_bind_text(tls, pStmt, iParam, zVal, -1, libc.UintptrFromInt32(-1)) 31422 } 31423 } else if (nOpt == 7) && (0 == sqlite3.Xsqlite3_strnicmp(tls, zOpt, ts+8106 /* "maxopen" */, 7)) { 31424 (*UnionTab)(unsafe.Pointer(pTab)).FnMaxOpen = libc.Xatoi(tls, zVal) 31425 if (*UnionTab)(unsafe.Pointer(pTab)).FnMaxOpen <= 0 { 31426 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+8114 /* "swarmvtab: illeg..." */, 0) 31427 *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_ERROR 31428 } 31429 } else if (nOpt == 7) && (0 == sqlite3.Xsqlite3_strnicmp(tls, zOpt, ts+8147 /* "missing" */, 7)) { 31430 if (*UnionTab)(unsafe.Pointer(pTab)).FpNotFound != 0 { 31431 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, 31432 ts+8155 /* "swarmvtab: dupli..." */, 0) 31433 *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_ERROR 31434 } else { 31435 (*UnionTab)(unsafe.Pointer(pTab)).FpNotFound = unionPreparePrintf(tls, bp+64 /* &rc */, pzErr, (*UnionTab)(unsafe.Pointer(pTab)).Fdb, 31436 ts+8193 /* "SELECT \"%w\"(?%s)" */, libc.VaList(bp+8, zVal, func() uintptr { 31437 if (*UnionTab)(unsafe.Pointer(pTab)).FbHasContext != 0 { 31438 return ts + 8210 /* ",?" */ 31439 } 31440 return ts + 489 /* "" */ 31441 }())) 31442 } 31443 } else if (nOpt == 9) && (0 == sqlite3.Xsqlite3_strnicmp(tls, zOpt, ts+8213 /* "openclose" */, 9)) { 31444 if (*UnionTab)(unsafe.Pointer(pTab)).FpOpenClose != 0 { 31445 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, 31446 ts+8223 /* "swarmvtab: dupli..." */, 0) 31447 *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_ERROR 31448 } else { 31449 (*UnionTab)(unsafe.Pointer(pTab)).FpOpenClose = unionPreparePrintf(tls, bp+64 /* &rc */, pzErr, (*UnionTab)(unsafe.Pointer(pTab)).Fdb, 31450 ts+8263 /* "SELECT \"%w\"(?,?%..." */, libc.VaList(bp+24, zVal, func() uintptr { 31451 if (*UnionTab)(unsafe.Pointer(pTab)).FbHasContext != 0 { 31452 return ts + 8210 /* ",?" */ 31453 } 31454 return ts + 489 /* "" */ 31455 }())) 31456 } 31457 } else { 31458 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+8282 /* "swarmvtab: unrec..." */, libc.VaList(bp+40, zOpt)) 31459 *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_ERROR 31460 } 31461 sqlite3.Xsqlite3_free(tls, zVal) 31462 } 31463 } else { 31464 if (i == 0) && (nArg == 1) { 31465 (*UnionTab)(unsafe.Pointer(pTab)).FpNotFound = unionPreparePrintf(tls, bp+64 /* &rc */, pzErr, (*UnionTab)(unsafe.Pointer(pTab)).Fdb, 31466 ts+8317 /* "SELECT \"%w\"(?)" */, libc.VaList(bp+48, zArg)) 31467 } else { 31468 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+8332 /* "swarmvtab: parse..." */, libc.VaList(bp+56, *(*uintptr)(unsafe.Pointer(azArg + uintptr(i)*8)))) 31469 *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = SQLITE_ERROR 31470 } 31471 } 31472 sqlite3.Xsqlite3_free(tls, zArg) 31473 } 31474 } 31475 *(*int32)(unsafe.Pointer(pRc)) = *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) 31476 } 31477 31478 // xConnect/xCreate method. 31479 // 31480 // The argv[] array contains the following: 31481 // 31482 // argv[0] -> module name ("unionvtab" or "swarmvtab") 31483 // argv[1] -> database name 31484 // argv[2] -> table name 31485 // argv[3] -> SQL statement 31486 // argv[4] -> not-found callback UDF name 31487 func unionConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* unionvtab.c:883:12: */ 31488 bp := tls.Alloc(44) 31489 defer tls.Free(44) 31490 31491 var pTab uintptr = uintptr(0) 31492 *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_OK 31493 var bSwarm int32 = func() int32 { 31494 if pAux == uintptr(0) { 31495 return 0 31496 } 31497 return 1 31498 }() 31499 var zVtab uintptr = func() uintptr { 31500 if bSwarm != 0 { 31501 return ts + 8359 /* "swarmvtab" */ 31502 } 31503 return ts + 8369 /* "unionvtab" */ 31504 }() 31505 31506 if sqlite3.Xsqlite3_stricmp(tls, ts+8379 /* "temp" */, *(*uintptr)(unsafe.Pointer(argv + 1*8))) != 0 { 31507 // unionvtab tables may only be created in the temp schema 31508 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+8384 /* "%s tables must b..." */, libc.VaList(bp, zVtab)) 31509 *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR 31510 } else if (argc < 4) || ((argc > 4) && (bSwarm == 0)) { 31511 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+8425 /* "wrong number of ..." */, libc.VaList(bp+8, zVtab)) 31512 *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR 31513 } else { 31514 var nAlloc int32 = 0 // Allocated size of pTab->aSrc[] 31515 var pStmt uintptr = uintptr(0) // Argument statement 31516 var zArg uintptr = unionStrdup(tls, bp+40 /* &rc */, *(*uintptr)(unsafe.Pointer(argv + 3*8))) // Copy of argument to CVT 31517 31518 // Prepare the SQL statement. Instead of executing it directly, sort 31519 // the results by the "minimum rowid" field. This makes it easier to 31520 // check that there are no rowid range overlaps between source tables 31521 // and that the UnionTab.aSrc[] array is always sorted by rowid. 31522 unionDequote(tls, zArg) 31523 pStmt = unionPreparePrintf(tls, bp+40 /* &rc */, pzErr, db, 31524 ts+8458 /* "SELECT * FROM (%..." */, libc.VaList(bp+16, zArg)) 31525 31526 // Allocate the UnionTab structure 31527 pTab = unionMalloc(tls, bp+40 /* &rc */, int64(unsafe.Sizeof(UnionTab{}))) 31528 if pTab != 0 { 31529 31530 (*UnionTab)(unsafe.Pointer(pTab)).Fdb = db 31531 (*UnionTab)(unsafe.Pointer(pTab)).FbSwarm = bSwarm 31532 (*UnionTab)(unsafe.Pointer(pTab)).FnMaxOpen = SWARMVTAB_MAX_OPEN 31533 } 31534 31535 // Parse other CVT arguments, if any 31536 if bSwarm != 0 { 31537 unionConfigureVtab(tls, bp+40 /* &rc */, pTab, pStmt, (argc - 4), (argv + 4*8), pzErr) 31538 } 31539 31540 // Iterate through the rows returned by the SQL statement specified 31541 // as an argument to the CREATE VIRTUAL TABLE statement. 31542 for (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, pStmt)) { 31543 var zDb uintptr = sqlite3.Xsqlite3_column_text(tls, pStmt, 0) 31544 var zTab uintptr = sqlite3.Xsqlite3_column_text(tls, pStmt, 1) 31545 var iMin sqlite3_int64 = sqlite3.Xsqlite3_column_int64(tls, pStmt, 2) 31546 var iMax sqlite3_int64 = sqlite3.Xsqlite3_column_int64(tls, pStmt, 3) 31547 var pSrc uintptr 31548 31549 // Grow the pTab->aSrc[] array if required. 31550 if nAlloc <= (*UnionTab)(unsafe.Pointer(pTab)).FnSrc { 31551 var nNew int32 31552 if nAlloc != 0 { 31553 nNew = (nAlloc * 2) 31554 } else { 31555 nNew = 8 31556 } 31557 var aNew uintptr = sqlite3.Xsqlite3_realloc64(tls, 31558 (*UnionTab)(unsafe.Pointer(pTab)).FaSrc, (uint64(uint64(nNew) * uint64(unsafe.Sizeof(UnionSrc{}))))) 31559 if aNew == uintptr(0) { 31560 *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_NOMEM 31561 break 31562 } else { 31563 libc.Xmemset(tls, (aNew + uintptr((*UnionTab)(unsafe.Pointer(pTab)).FnSrc)*72), 0, ((uint64(nNew - (*UnionTab)(unsafe.Pointer(pTab)).FnSrc)) * uint64(unsafe.Sizeof(UnionSrc{})))) 31564 (*UnionTab)(unsafe.Pointer(pTab)).FaSrc = aNew 31565 nAlloc = nNew 31566 } 31567 } 31568 31569 // Check for problems with the specified range of rowids 31570 if (iMax < iMin) || (((*UnionTab)(unsafe.Pointer(pTab)).FnSrc > 0) && (iMin <= (*UnionSrc)(unsafe.Pointer((*UnionTab)(unsafe.Pointer(pTab)).FaSrc+uintptr(((*UnionTab)(unsafe.Pointer(pTab)).FnSrc-1))*72)).FiMax)) { 31571 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+8488 /* "rowid range mism..." */, 0) 31572 *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR 31573 } 31574 31575 if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { 31576 pSrc = ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc + uintptr(libc.PostIncInt32(&(*UnionTab)(unsafe.Pointer(pTab)).FnSrc, 1))*72) 31577 (*UnionSrc)(unsafe.Pointer(pSrc)).FzTab = unionStrdup(tls, bp+40 /* &rc */, zTab) 31578 (*UnionSrc)(unsafe.Pointer(pSrc)).FiMin = iMin 31579 (*UnionSrc)(unsafe.Pointer(pSrc)).FiMax = iMax 31580 if bSwarm != 0 { 31581 (*UnionSrc)(unsafe.Pointer(pSrc)).FzFile = unionStrdup(tls, bp+40 /* &rc */, zDb) 31582 } else { 31583 (*UnionSrc)(unsafe.Pointer(pSrc)).FzDb = unionStrdup(tls, bp+40 /* &rc */, zDb) 31584 } 31585 if (*UnionTab)(unsafe.Pointer(pTab)).FbHasContext != 0 { 31586 var zContext uintptr = sqlite3.Xsqlite3_column_text(tls, pStmt, 4) 31587 (*UnionSrc)(unsafe.Pointer(pSrc)).FzContext = unionStrdup(tls, bp+40 /* &rc */, zContext) 31588 } 31589 } 31590 } 31591 unionFinalize(tls, bp+40 /* &rc */, pStmt, pzErr) 31592 pStmt = uintptr(0) 31593 31594 // It is an error if the SELECT statement returned zero rows. If only 31595 // because there is no way to determine the schema of the virtual 31596 // table in this case. 31597 if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && ((*UnionTab)(unsafe.Pointer(pTab)).FnSrc == 0) { 31598 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+8515 /* "no source tables..." */, 0) 31599 *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = SQLITE_ERROR 31600 } 31601 31602 // For unionvtab, verify that all source tables exist and have 31603 // compatible schemas. For swarmvtab, attach the first database and 31604 // check that the first table is a rowid table only. 31605 if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { 31606 if bSwarm != 0 { 31607 *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = unionOpenDatabase(tls, pTab, 0, pzErr) 31608 } else { 31609 *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = unionSourceCheck(tls, pTab, pzErr) 31610 } 31611 } 31612 31613 // Compose a CREATE TABLE statement and pass it to declare_vtab() 31614 if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK { 31615 var pSrc uintptr = ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc) 31616 var tdb uintptr = func() uintptr { 31617 if (*UnionTab)(unsafe.Pointer(pTab)).FbSwarm != 0 { 31618 return (*UnionSrc)(unsafe.Pointer(pSrc)).Fdb 31619 } 31620 return (*UnionTab)(unsafe.Pointer(pTab)).Fdb 31621 }() 31622 pStmt = unionPreparePrintf(tls, bp+40 /* &rc */, pzErr, tdb, 31623 31624 ts+8543, /* "SELECT 'CREATE T..." */ 31625 libc.VaList(bp+24, (*UnionSrc)(unsafe.Pointer(pSrc)).FzTab, (*UnionSrc)(unsafe.Pointer(pSrc)).FzDb)) 31626 } 31627 if (*(*int32)(unsafe.Pointer(bp + 40 /* rc */)) == SQLITE_OK) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, pStmt)) { 31628 var zDecl uintptr = sqlite3.Xsqlite3_column_text(tls, pStmt, 0) 31629 *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) = sqlite3.Xsqlite3_declare_vtab(tls, db, zDecl) 31630 (*UnionTab)(unsafe.Pointer(pTab)).FiPK = sqlite3.Xsqlite3_column_int(tls, pStmt, 1) 31631 } 31632 31633 unionFinalize(tls, bp+40 /* &rc */, pStmt, pzErr) 31634 } 31635 31636 if *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) != SQLITE_OK { 31637 unionDisconnect(tls, pTab) 31638 pTab = uintptr(0) 31639 } 31640 31641 *(*uintptr)(unsafe.Pointer(ppVtab)) = pTab 31642 return *(*int32)(unsafe.Pointer(bp + 40 /* rc */)) 31643 } 31644 31645 // xOpen 31646 func unionOpen(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* unionvtab.c:1033:12: */ 31647 bp := tls.Alloc(4) 31648 defer tls.Free(4) 31649 31650 var pCsr uintptr 31651 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK 31652 _ = p // Suppress harmless warning 31653 pCsr = unionMalloc(tls, bp /* &rc */, int64(unsafe.Sizeof(UnionCsr{}))) 31654 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCsr /* &.base */) 31655 return *(*int32)(unsafe.Pointer(bp /* rc */)) 31656 } 31657 31658 // xClose 31659 func unionClose(tls *libc.TLS, cur uintptr) int32 { /* unionvtab.c:1045:12: */ 31660 var pCsr uintptr = cur 31661 unionFinalizeCsrStmt(tls, pCsr) 31662 sqlite3.Xsqlite3_free(tls, pCsr) 31663 return SQLITE_OK 31664 } 31665 31666 // This function does the work of the xNext() method. Except that, if it 31667 // returns SQLITE_ROW, it should be called again within the same xNext() 31668 // method call. See unionNext() for details. 31669 func doUnionNext(tls *libc.TLS, pCsr uintptr) int32 { /* unionvtab.c:1057:12: */ 31670 bp := tls.Alloc(28) 31671 defer tls.Free(28) 31672 31673 *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = SQLITE_OK 31674 31675 if sqlite3.Xsqlite3_step(tls, (*UnionCsr)(unsafe.Pointer(pCsr)).FpStmt) != SQLITE_ROW { 31676 var pTab uintptr = (*UnionCsr)(unsafe.Pointer(pCsr)).Fbase.FpVtab 31677 *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = unionFinalizeCsrStmt(tls, pCsr) 31678 if (*(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK) && ((*UnionTab)(unsafe.Pointer(pTab)).FbSwarm != 0) { 31679 (*UnionCsr)(unsafe.Pointer(pCsr)).FiTab++ 31680 if (*UnionCsr)(unsafe.Pointer(pCsr)).FiTab < (*UnionTab)(unsafe.Pointer(pTab)).FnSrc { 31681 var pSrc uintptr = ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc + uintptr((*UnionCsr)(unsafe.Pointer(pCsr)).FiTab)*72) 31682 if (*UnionCsr)(unsafe.Pointer(pCsr)).FiMaxRowid >= (*UnionSrc)(unsafe.Pointer(pSrc)).FiMin { 31683 // It is necessary to scan the next table. 31684 *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = unionOpenDatabase(tls, pTab, (*UnionCsr)(unsafe.Pointer(pCsr)).FiTab, (pTab /* &.base */ + 16 /* &.zErrMsg */)) 31685 (*UnionCsr)(unsafe.Pointer(pCsr)).FpStmt = unionPreparePrintf(tls, bp+24 /* &rc */, (pTab /* &.base */ + 16 /* &.zErrMsg */), (*UnionSrc)(unsafe.Pointer(pSrc)).Fdb, 31686 ts+8721, /* "SELECT rowid, * ..." */ 31687 libc.VaList(bp, (*UnionSrc)(unsafe.Pointer(pSrc)).FzTab, 31688 func() uintptr { 31689 if (*UnionSrc)(unsafe.Pointer(pSrc)).FiMax > (*UnionCsr)(unsafe.Pointer(pCsr)).FiMaxRowid { 31690 return ts + 8753 /* "WHERE _rowid_ <=" */ 31691 } 31692 return ts + 8770 /* "-- " */ 31693 }(), 31694 (*UnionCsr)(unsafe.Pointer(pCsr)).FiMaxRowid)) 31695 if *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) == SQLITE_OK { 31696 31697 unionIncrRefcount(tls, pTab, (*UnionCsr)(unsafe.Pointer(pCsr)).FiTab) 31698 *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) = SQLITE_ROW 31699 } 31700 } 31701 } 31702 } 31703 } 31704 31705 return *(*int32)(unsafe.Pointer(bp + 24 /* rc */)) 31706 } 31707 31708 // xNext 31709 func unionNext(tls *libc.TLS, cur uintptr) int32 { /* unionvtab.c:1092:12: */ 31710 var rc int32 31711 for ok := true; ok; ok = (rc == SQLITE_ROW) { 31712 rc = doUnionNext(tls, cur) 31713 } 31714 return rc 31715 } 31716 31717 // xColumn 31718 func unionColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* unionvtab.c:1103:12: */ 31719 var pCsr uintptr = cur 31720 sqlite3.Xsqlite3_result_value(tls, ctx, sqlite3.Xsqlite3_column_value(tls, (*UnionCsr)(unsafe.Pointer(pCsr)).FpStmt, (i+1))) 31721 return SQLITE_OK 31722 } 31723 31724 // xRowid 31725 func unionRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* unionvtab.c:1116:12: */ 31726 var pCsr uintptr = cur 31727 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite3.Xsqlite3_column_int64(tls, (*UnionCsr)(unsafe.Pointer(pCsr)).FpStmt, 0) 31728 return SQLITE_OK 31729 } 31730 31731 // xEof 31732 func unionEof(tls *libc.TLS, cur uintptr) int32 { /* unionvtab.c:1125:12: */ 31733 var pCsr uintptr = cur 31734 return (libc.Bool32((*UnionCsr)(unsafe.Pointer(pCsr)).FpStmt == uintptr(0))) 31735 } 31736 31737 // xFilter 31738 func unionFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* unionvtab.c:1133:12: */ 31739 bp := tls.Alloc(108) 31740 defer tls.Free(108) 31741 31742 var pTab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab 31743 var pCsr uintptr = pVtabCursor 31744 *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = SQLITE_OK 31745 var i int32 31746 var zSql uintptr = uintptr(0) 31747 var bZero int32 = 0 31748 31749 var iMin sqlite3_int64 = ((int64(-1)) - (int64(0xffffffff) | (sqlite3_int64((int64(0x7fffffff))) << 32))) 31750 var iMax sqlite3_int64 = (int64(0xffffffff) | (sqlite3_int64((int64(0x7fffffff))) << 32)) 31751 31752 _ = idxStr // Suppress harmless warning 31753 31754 if idxNum == SQLITE_INDEX_CONSTRAINT_EQ { 31755 31756 iMin = libc.AssignInt64(&iMax, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv)))) 31757 } else { 31758 31759 if (idxNum & (SQLITE_INDEX_CONSTRAINT_LE | SQLITE_INDEX_CONSTRAINT_LT)) != 0 { 31760 31761 iMax = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) 31762 if (idxNum & SQLITE_INDEX_CONSTRAINT_LT) != 0 { 31763 if iMax == ((int64(-1)) - (int64(0xffffffff) | (sqlite3_int64((int64(0x7fffffff))) << 32))) { 31764 bZero = 1 31765 } else { 31766 iMax-- 31767 } 31768 } 31769 } 31770 31771 if (idxNum & (SQLITE_INDEX_CONSTRAINT_GE | SQLITE_INDEX_CONSTRAINT_GT)) != 0 { 31772 31773 iMin = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr((argc-1))*8))) 31774 if (idxNum & SQLITE_INDEX_CONSTRAINT_GT) != 0 { 31775 if iMin == (int64(0xffffffff) | (sqlite3_int64((int64(0x7fffffff))) << 32)) { 31776 bZero = 1 31777 } else { 31778 iMin++ 31779 } 31780 } 31781 } 31782 } 31783 31784 unionFinalizeCsrStmt(tls, pCsr) 31785 if bZero != 0 { 31786 return SQLITE_OK 31787 } 31788 31789 for i = 0; i < (*UnionTab)(unsafe.Pointer(pTab)).FnSrc; i++ { 31790 var pSrc uintptr = ((*UnionTab)(unsafe.Pointer(pTab)).FaSrc + uintptr(i)*72) 31791 if (iMin > (*UnionSrc)(unsafe.Pointer(pSrc)).FiMax) || (iMax < (*UnionSrc)(unsafe.Pointer(pSrc)).FiMin) { 31792 continue 31793 } 31794 31795 zSql = sqlite3.Xsqlite3_mprintf(tls, ts+8774 /* "%z%sSELECT rowid..." */, libc.VaList(bp, zSql, func() uintptr { 31796 if zSql != 0 { 31797 return ts + 8808 /* " UNION ALL " */ 31798 } 31799 return ts + 489 /* "" */ 31800 }(), func() uintptr { 31801 if (*UnionSrc)(unsafe.Pointer(pSrc)).FzDb != 0 { 31802 return ts + 5495 /* "'" */ 31803 } 31804 return ts + 489 /* "" */ 31805 }(), func() uintptr { 31806 if (*UnionSrc)(unsafe.Pointer(pSrc)).FzDb != 0 { 31807 return (*UnionSrc)(unsafe.Pointer(pSrc)).FzDb 31808 } 31809 return ts + 489 /* "" */ 31810 }(), func() uintptr { 31811 if (*UnionSrc)(unsafe.Pointer(pSrc)).FzDb != 0 { 31812 return ts + 5497 /* "'." */ 31813 } 31814 return ts + 489 /* "" */ 31815 }(), (*UnionSrc)(unsafe.Pointer(pSrc)).FzTab)) 31816 if zSql == uintptr(0) { 31817 *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = SQLITE_NOMEM 31818 break 31819 } 31820 31821 if iMin == iMax { 31822 zSql = sqlite3.Xsqlite3_mprintf(tls, ts+8820 /* "%z WHERE rowid=%..." */, libc.VaList(bp+48, zSql, iMin)) 31823 } else { 31824 var zWhere uintptr = ts + 8840 /* "WHERE" */ 31825 if (iMin != ((int64(-1)) - (int64(0xffffffff) | (sqlite3_int64((int64(0x7fffffff))) << 32)))) && (iMin > (*UnionSrc)(unsafe.Pointer(pSrc)).FiMin) { 31826 zSql = sqlite3.Xsqlite3_mprintf(tls, ts+8846 /* "%z WHERE rowid>=..." */, libc.VaList(bp+64, zSql, iMin)) 31827 zWhere = ts + 8867 /* "AND" */ 31828 } 31829 if (iMax != (int64(0xffffffff) | (sqlite3_int64((int64(0x7fffffff))) << 32))) && (iMax < (*UnionSrc)(unsafe.Pointer(pSrc)).FiMax) { 31830 zSql = sqlite3.Xsqlite3_mprintf(tls, ts+8871 /* "%z %s rowid<=%ll..." */, libc.VaList(bp+80, zSql, zWhere, iMax)) 31831 } 31832 } 31833 31834 if (*UnionTab)(unsafe.Pointer(pTab)).FbSwarm != 0 { 31835 (*UnionCsr)(unsafe.Pointer(pCsr)).FiTab = i 31836 (*UnionCsr)(unsafe.Pointer(pCsr)).FiMaxRowid = iMax 31837 *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = unionOpenDatabase(tls, pTab, i, (pTab /* &.base */ + 16 /* &.zErrMsg */)) 31838 break 31839 } 31840 } 31841 31842 if zSql == uintptr(0) { 31843 return *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) 31844 } else { 31845 var db uintptr = func() uintptr { 31846 if (*UnionTab)(unsafe.Pointer(pTab)).FbSwarm != 0 { 31847 return (*UnionSrc)(unsafe.Pointer(((*UnionTab)(unsafe.Pointer(pTab)).FaSrc + uintptr((*UnionCsr)(unsafe.Pointer(pCsr)).FiTab)*72))).Fdb 31848 } 31849 return (*UnionTab)(unsafe.Pointer(pTab)).Fdb 31850 }() 31851 (*UnionCsr)(unsafe.Pointer(pCsr)).FpStmt = unionPrepare(tls, bp+104 /* &rc */, db, zSql, (pTab /* &.base */ + 16 /* &.zErrMsg */)) 31852 if (*UnionCsr)(unsafe.Pointer(pCsr)).FpStmt != 0 { 31853 unionIncrRefcount(tls, pTab, (*UnionCsr)(unsafe.Pointer(pCsr)).FiTab) 31854 } 31855 sqlite3.Xsqlite3_free(tls, zSql) 31856 } 31857 if *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) != SQLITE_OK { 31858 return *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) 31859 } 31860 return unionNext(tls, pVtabCursor) 31861 } 31862 31863 // xBestIndex. 31864 // 31865 // This implementation searches for constraints on the rowid field. EQ, 31866 // LE, LT, GE and GT are handled. 31867 // 31868 // If there is an EQ comparison, then idxNum is set to INDEX_CONSTRAINT_EQ. 31869 // In this case the only argument passed to xFilter is the rhs of the == 31870 // operator. 31871 // 31872 // Otherwise, if an LE or LT constraint is found, then the INDEX_CONSTRAINT_LE 31873 // or INDEX_CONSTRAINT_LT (but not both) bit is set in idxNum. The first 31874 // argument to xFilter is the rhs of the <= or < operator. Similarly, if 31875 // an GE or GT constraint is found, then the INDEX_CONSTRAINT_GE or 31876 // INDEX_CONSTRAINT_GT bit is set in idxNum. The rhs of the >= or > operator 31877 // is passed as either the first or second argument to xFilter, depending 31878 // on whether or not there is also a LT|LE constraint. 31879 func unionBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* unionvtab.c:1266:12: */ 31880 var pTab uintptr = tab 31881 var iEq int32 = -1 31882 var iLt int32 = -1 31883 var iGt int32 = -1 31884 var i int32 31885 31886 for i = 0; i < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; i++ { 31887 var p uintptr = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12) 31888 if ((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0) && (((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn < 0) || ((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == (*UnionTab)(unsafe.Pointer(pTab)).FiPK)) { 31889 switch int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) { 31890 case SQLITE_INDEX_CONSTRAINT_EQ: 31891 iEq = i 31892 break 31893 fallthrough 31894 case SQLITE_INDEX_CONSTRAINT_LE: 31895 fallthrough 31896 case SQLITE_INDEX_CONSTRAINT_LT: 31897 iLt = i 31898 break 31899 fallthrough 31900 case SQLITE_INDEX_CONSTRAINT_GE: 31901 fallthrough 31902 case SQLITE_INDEX_CONSTRAINT_GT: 31903 iGt = i 31904 break 31905 } 31906 } 31907 } 31908 31909 if iEq >= 0 { 31910 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1) 31911 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = SQLITE_INDEX_SCAN_UNIQUE 31912 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 3.0 31913 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = SQLITE_INDEX_CONSTRAINT_EQ 31914 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iEq)*8)).FargvIndex = 1 31915 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iEq)*8)).Fomit = uint8(1) 31916 } else { 31917 var iCons int32 = 1 31918 var idxNum int32 = 0 31919 var nRow sqlite3_int64 = int64(1000000) 31920 if iLt >= 0 { 31921 nRow = (nRow / int64(2)) 31922 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iLt)*8)).FargvIndex = libc.PostIncInt32(&iCons, 1) 31923 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iLt)*8)).Fomit = uint8(1) 31924 idxNum = idxNum | (int32((*sqlite3_index_constraint)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(iLt)*12)).Fop)) 31925 } 31926 if iGt >= 0 { 31927 nRow = (nRow / int64(2)) 31928 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iGt)*8)).FargvIndex = libc.PostIncInt32(&iCons, 1) 31929 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iGt)*8)).Fomit = uint8(1) 31930 idxNum = idxNum | (int32((*sqlite3_index_constraint)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(iGt)*12)).Fop)) 31931 } 31932 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = nRow 31933 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = (3.0 * float64(nRow)) 31934 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = idxNum 31935 } 31936 31937 return SQLITE_OK 31938 } 31939 31940 // Register the unionvtab virtual table module with database handle db. 31941 func createUnionVtab(tls *libc.TLS, db uintptr) int32 { /* unionvtab.c:1329:12: */ 31942 var rc int32 31943 31944 rc = sqlite3.Xsqlite3_create_module(tls, db, ts+8369 /* "unionvtab" */, uintptr(unsafe.Pointer(&unionModule)), uintptr(0)) 31945 if rc == SQLITE_OK { 31946 rc = sqlite3.Xsqlite3_create_module(tls, db, ts+8359 /* "swarmvtab" */, uintptr(unsafe.Pointer(&unionModule)), db) 31947 } 31948 return rc 31949 } 31950 31951 var unionModule = sqlite3_module{ // iVersion 31952 FxCreate: 0, 31953 FxConnect: 0, 31954 FxBestIndex: 0, // xBestIndex - query planner 31955 FxDisconnect: 0, 31956 FxDestroy: 0, 31957 FxOpen: 0, // xOpen - open a cursor 31958 FxClose: 0, // xClose - close a cursor 31959 FxFilter: 0, // xFilter - configure scan constraints 31960 FxNext: 0, // xNext - advance a cursor 31961 FxEof: 0, // xEof - check for end of scan 31962 FxColumn: 0, // xColumn - read data 31963 FxRowid: 0, // xShadowName 31964 } /* unionvtab.c:1330:25 */ 31965 31966 func sqlite3_unionvtab_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* unionvtab.c:1370:5: */ 31967 var rc int32 = SQLITE_OK 31968 _ = pApi 31969 31970 _ = pzErrMsg // Suppress harmless warning 31971 rc = createUnionVtab(tls, db) 31972 return rc 31973 } 31974 31975 // A wholenumber cursor object 31976 type wholenumber_cursor1 = struct { 31977 Fbase sqlite3_vtab_cursor 31978 FiValue sqlite3_int64 31979 FmxValue sqlite3_int64 31980 } /* wholenumber.c:34:9 */ 31981 31982 // A wholenumber cursor object 31983 type wholenumber_cursor = wholenumber_cursor1 /* wholenumber.c:34:35 */ 31984 31985 // Methods for the wholenumber module 31986 func wholenumberConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* wholenumber.c:42:12: */ 31987 var pNew uintptr 31988 pNew = libc.AssignPtrUintptr(ppVtab, sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(sqlite3_vtab{})))) 31989 if pNew == uintptr(0) { 31990 return SQLITE_NOMEM 31991 } 31992 sqlite3.Xsqlite3_declare_vtab(tls, db, ts+8889 /* "CREATE TABLE x(v..." */) 31993 sqlite3.Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_INNOCUOUS, 0) 31994 libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(sqlite3_vtab{}))) 31995 return SQLITE_OK 31996 } 31997 31998 // Note that for this virtual table, the xCreate and xConnect 31999 // methods are identical. 32000 32001 func wholenumberDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* wholenumber.c:60:12: */ 32002 sqlite3.Xsqlite3_free(tls, pVtab) 32003 return SQLITE_OK 32004 } 32005 32006 // The xDisconnect and xDestroy methods are also the same 32007 32008 // Open a new wholenumber cursor. 32009 func wholenumberOpen(tls *libc.TLS, p uintptr, ppCursor uintptr) int32 { /* wholenumber.c:70:12: */ 32010 var pCur uintptr 32011 pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(wholenumber_cursor{}))) 32012 if pCur == uintptr(0) { 32013 return SQLITE_NOMEM 32014 } 32015 libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(wholenumber_cursor{}))) 32016 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) 32017 return SQLITE_OK 32018 } 32019 32020 // Close a wholenumber cursor. 32021 func wholenumberClose(tls *libc.TLS, cur uintptr) int32 { /* wholenumber.c:82:12: */ 32022 sqlite3.Xsqlite3_free(tls, cur) 32023 return SQLITE_OK 32024 } 32025 32026 // Advance a cursor to its next row of output 32027 func wholenumberNext(tls *libc.TLS, cur uintptr) int32 { /* wholenumber.c:91:12: */ 32028 var pCur uintptr = cur 32029 (*wholenumber_cursor)(unsafe.Pointer(pCur)).FiValue++ 32030 return SQLITE_OK 32031 } 32032 32033 // Return the value associated with a wholenumber. 32034 func wholenumberColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* wholenumber.c:100:12: */ 32035 var pCur uintptr = cur 32036 sqlite3.Xsqlite3_result_int64(tls, ctx, (*wholenumber_cursor)(unsafe.Pointer(pCur)).FiValue) 32037 return SQLITE_OK 32038 } 32039 32040 // The rowid. 32041 func wholenumberRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* wholenumber.c:113:12: */ 32042 var pCur uintptr = cur 32043 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*wholenumber_cursor)(unsafe.Pointer(pCur)).FiValue 32044 return SQLITE_OK 32045 } 32046 32047 // When the wholenumber_cursor.rLimit value is 0 or less, that is a signal 32048 // that the cursor has nothing more to output. 32049 func wholenumberEof(tls *libc.TLS, cur uintptr) int32 { /* wholenumber.c:123:12: */ 32050 var pCur uintptr = cur 32051 return (libc.Bool32(((*wholenumber_cursor)(unsafe.Pointer(pCur)).FiValue > (*wholenumber_cursor)(unsafe.Pointer(pCur)).FmxValue) || ((*wholenumber_cursor)(unsafe.Pointer(pCur)).FiValue == int64(0)))) 32052 } 32053 32054 // Called to "rewind" a cursor back to the beginning so that 32055 // it starts its output over again. Always called at least once 32056 // prior to any wholenumberColumn, wholenumberRowid, or wholenumberEof call. 32057 // 32058 // idxNum Constraints 32059 // ------ --------------------- 32060 // 0 (none) 32061 // 1 value > $argv0 32062 // 2 value >= $argv0 32063 // 4 value < $argv0 32064 // 8 value <= $argv0 32065 // 32066 // 5 value > $argv0 AND value < $argv1 32067 // 6 value >= $argv0 AND value < $argv1 32068 // 9 value > $argv0 AND value <= $argv1 32069 // 10 value >= $argv0 AND value <= $argv1 32070 func wholenumberFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* wholenumber.c:146:12: */ 32071 var pCur uintptr = pVtabCursor 32072 var v sqlite3_int64 32073 var i int32 = 0 32074 (*wholenumber_cursor)(unsafe.Pointer(pCur)).FiValue = int64(1) 32075 (*wholenumber_cursor)(unsafe.Pointer(pCur)).FmxValue = int64(0xffffffff) // 4294967295 32076 if (idxNum & 3) != 0 { 32077 v = (sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) + (sqlite3_int64(idxNum & 1))) 32078 if (v > (*wholenumber_cursor)(unsafe.Pointer(pCur)).FiValue) && (v <= (*wholenumber_cursor)(unsafe.Pointer(pCur)).FmxValue) { 32079 (*wholenumber_cursor)(unsafe.Pointer(pCur)).FiValue = v 32080 } 32081 i++ 32082 } 32083 if (idxNum & 12) != 0 { 32084 v = (sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) - (sqlite3_int64((idxNum >> 2) & 1))) 32085 if (v >= (*wholenumber_cursor)(unsafe.Pointer(pCur)).FiValue) && (v < (*wholenumber_cursor)(unsafe.Pointer(pCur)).FmxValue) { 32086 (*wholenumber_cursor)(unsafe.Pointer(pCur)).FmxValue = v 32087 } 32088 } 32089 return SQLITE_OK 32090 } 32091 32092 // Search for terms of these forms: 32093 // 32094 // (1) value > $value 32095 // (2) value >= $value 32096 // (4) value < $value 32097 // (8) value <= $value 32098 // 32099 // idxNum is an ORed combination of 1 or 2 with 4 or 8. 32100 func wholenumberBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* wholenumber.c:178:12: */ 32101 var i int32 32102 var idxNum int32 = 0 32103 var argvIdx int32 = 1 32104 var ltIdx int32 = -1 32105 var gtIdx int32 = -1 32106 var pConstraint uintptr 32107 pConstraint = (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint 32108 i = 0 32109 __1: 32110 if !(i < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { 32111 goto __3 32112 } 32113 { 32114 if int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) == 0 { 32115 goto __2 32116 } 32117 if ((idxNum & 3) == 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_GT) { 32118 idxNum = idxNum | (1) 32119 ltIdx = i 32120 } 32121 if ((idxNum & 3) == 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_GE) { 32122 idxNum = idxNum | (2) 32123 ltIdx = i 32124 } 32125 if ((idxNum & 12) == 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LT) { 32126 idxNum = idxNum | (4) 32127 gtIdx = i 32128 } 32129 if ((idxNum & 12) == 0) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) == SQLITE_INDEX_CONSTRAINT_LE) { 32130 idxNum = idxNum | (8) 32131 gtIdx = i 32132 } 32133 32134 } 32135 goto __2 32136 __2: 32137 i++ 32138 pConstraint += 12 32139 goto __1 32140 goto __3 32141 __3: 32142 ; 32143 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = idxNum 32144 if ltIdx >= 0 { 32145 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ltIdx)*8)).FargvIndex = libc.PostIncInt32(&argvIdx, 1) 32146 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ltIdx)*8)).Fomit = uint8(1) 32147 } 32148 if gtIdx >= 0 { 32149 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(gtIdx)*8)).FargvIndex = argvIdx 32150 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(gtIdx)*8)).Fomit = uint8(1) 32151 } 32152 if ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy == 1) && 32153 (int32((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).Fdesc) == 0) { 32154 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 1 32155 } 32156 if (idxNum & 12) == 0 { 32157 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 1e99 32158 } else if (idxNum & 3) == 0 { 32159 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(5) 32160 } else { 32161 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(1) 32162 } 32163 return SQLITE_OK 32164 } 32165 32166 // A virtual table module that provides read-only access to a 32167 // Tcl global variable namespace. 32168 var wholenumberModule = sqlite3_module{ // iVersion 32169 FxCreate: 0, 32170 FxConnect: 0, 32171 FxBestIndex: 0, 32172 FxDisconnect: 0, 32173 FxDestroy: 0, 32174 FxOpen: 0, // xOpen - open a cursor 32175 FxClose: 0, // xClose - close a cursor 32176 FxFilter: 0, // xFilter - configure scan constraints 32177 FxNext: 0, // xNext - advance a cursor 32178 FxEof: 0, // xEof - check for end of scan 32179 FxColumn: 0, // xColumn - read data 32180 FxRowid: 0, // xRename 32181 } /* wholenumber.c:236:23 */ 32182 32183 func sqlite3_wholenumber_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* wholenumber.c:264:5: */ 32184 var rc int32 = SQLITE_OK 32185 _ = pApi 32186 32187 rc = sqlite3.Xsqlite3_create_module(tls, db, ts+8911 /* "wholenumber" */, uintptr(unsafe.Pointer(&wholenumberModule)), uintptr(0)) 32188 return rc 32189 } 32190 32191 // In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. 32192 // are already defined. 32193 // BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. 32194 // NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here. 32195 32196 // A null pointer constant. 32197 32198 // Offset of member MEMBER in a struct of type TYPE. 32199 32200 // Type whose alignment is supported in every context and is at least 32201 // as great as that of any standard type not using alignment 32202 // specifiers. 32203 type max_align_t = struct { 32204 F__max_align_ll int64 32205 F__max_align_ld float64 32206 } /* stddef.h:437:3 */ 32207 32208 type z_size_t = size_t /* zconf.h:248:21 */ 32209 32210 // Maximum value for memLevel in deflateInit2 32211 32212 // Maximum value for windowBits in deflateInit2 and inflateInit2. 32213 // WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files 32214 // created by gzip. (Files created by minigzip can still be extracted by 32215 // gzip.) 32216 32217 // The memory requirements for deflate are (in bytes): 32218 // (1 << (windowBits+2)) + (1 << (memLevel+9)) 32219 // that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) 32220 // plus a few kilobytes for small objects. For example, if you want to reduce 32221 // the default memory requirements from 256K to 128K, compile with 32222 // make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" 32223 // Of course this will generally degrade compression (there's no free lunch). 32224 // 32225 // The memory requirements for inflate are (in bytes) 1 << windowBits 32226 // that is, 32K for windowBits=15 (default value) plus about 7 kilobytes 32227 // for small objects. 32228 32229 // Type declarations 32230 32231 // The following definitions for FAR are needed only for MSDOS mixed 32232 // model programming (small or medium model with some far allocations). 32233 // This was tested only with MSC; for other MSDOS compilers you may have 32234 // to define NO_MEMCPY in zutil.h. If you don't need the mixed model, 32235 // just define FAR to be empty. 32236 32237 type Byte = uint8 /* zconf.h:391:24 */ // 8 bits 32238 type uInt = uint32 /* zconf.h:393:24 */ // 16 bits or more 32239 type uLong = uint64 /* zconf.h:394:24 */ // 32 bits or more 32240 32241 type Bytef = Byte /* zconf.h:400:22 */ 32242 type charf = int8 /* zconf.h:402:19 */ 32243 type intf = int32 /* zconf.h:403:19 */ 32244 type uIntf = uInt /* zconf.h:404:19 */ 32245 type uLongf = uLong /* zconf.h:405:19 */ 32246 32247 type voidpc = uintptr /* zconf.h:408:23 */ 32248 type voidpf = uintptr /* zconf.h:409:23 */ 32249 type voidp = uintptr /* zconf.h:410:23 */ 32250 32251 // Copyright (C) 1992-2018 Free Software Foundation, Inc. 32252 // 32253 // This file is part of GCC. 32254 // 32255 // GCC is free software; you can redistribute it and/or modify it under 32256 // the terms of the GNU General Public License as published by the Free 32257 // Software Foundation; either version 3, or (at your option) any later 32258 // version. 32259 // 32260 // GCC is distributed in the hope that it will be useful, but WITHOUT ANY 32261 // WARRANTY; without even the implied warranty of MERCHANTABILITY or 32262 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 32263 // for more details. 32264 // 32265 // Under Section 7 of GPL version 3, you are granted additional 32266 // permissions described in the GCC Runtime Library Exception, version 32267 // 3.1, as published by the Free Software Foundation. 32268 // 32269 // You should have received a copy of the GNU General Public License and 32270 // a copy of the GCC Runtime Library Exception along with this program; 32271 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 32272 // <http://www.gnu.org/licenses/>. 32273 32274 // This administrivia gets added to the beginning of limits.h 32275 // if the system has its own version of limits.h. 32276 32277 // We use _GCC_LIMITS_H_ because we want this not to match 32278 // any macros that the system's limits.h uses for its own purposes. 32279 32280 // Use "..." so that we find syslimits.h only in this same directory. 32281 // syslimits.h stands for the system's own limits.h file. 32282 // If we can use it ok unmodified, then we install this text. 32283 // If fixincludes fixes it, then the fixed version is installed 32284 // instead of this text. 32285 32286 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 32287 // This file is part of the GNU C Library. 32288 // 32289 // The GNU C Library is free software; you can redistribute it and/or 32290 // modify it under the terms of the GNU Lesser General Public 32291 // License as published by the Free Software Foundation; either 32292 // version 2.1 of the License, or (at your option) any later version. 32293 // 32294 // The GNU C Library is distributed in the hope that it will be useful, 32295 // but WITHOUT ANY WARRANTY; without even the implied warranty of 32296 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 32297 // Lesser General Public License for more details. 32298 // 32299 // You should have received a copy of the GNU Lesser General Public 32300 // License along with the GNU C Library; if not, see 32301 // <http://www.gnu.org/licenses/>. 32302 32303 // ISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types <limits.h> 32304 32305 // Handle feature test macros at the start of a header. 32306 // Copyright (C) 2016-2018 Free Software Foundation, Inc. 32307 // This file is part of the GNU C Library. 32308 // 32309 // The GNU C Library is free software; you can redistribute it and/or 32310 // modify it under the terms of the GNU Lesser General Public 32311 // License as published by the Free Software Foundation; either 32312 // version 2.1 of the License, or (at your option) any later version. 32313 // 32314 // The GNU C Library is distributed in the hope that it will be useful, 32315 // but WITHOUT ANY WARRANTY; without even the implied warranty of 32316 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 32317 // Lesser General Public License for more details. 32318 // 32319 // You should have received a copy of the GNU Lesser General Public 32320 // License along with the GNU C Library; if not, see 32321 // <http://www.gnu.org/licenses/>. 32322 32323 // This header is internal to glibc and should not be included outside 32324 // of glibc headers. Headers including it must define 32325 // __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION first. This header 32326 // cannot have multiple include guards because ISO C feature test 32327 // macros depend on the definition of the macro when an affected 32328 // header is included, not when the first system header is 32329 // included. 32330 32331 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 32332 // This file is part of the GNU C Library. 32333 // 32334 // The GNU C Library is free software; you can redistribute it and/or 32335 // modify it under the terms of the GNU Lesser General Public 32336 // License as published by the Free Software Foundation; either 32337 // version 2.1 of the License, or (at your option) any later version. 32338 // 32339 // The GNU C Library is distributed in the hope that it will be useful, 32340 // but WITHOUT ANY WARRANTY; without even the implied warranty of 32341 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 32342 // Lesser General Public License for more details. 32343 // 32344 // You should have received a copy of the GNU Lesser General Public 32345 // License along with the GNU C Library; if not, see 32346 // <http://www.gnu.org/licenses/>. 32347 32348 // ISO/IEC TR 24731-2:2010 defines the __STDC_WANT_LIB_EXT2__ 32349 // macro. 32350 32351 // ISO/IEC TS 18661-1:2014 defines the __STDC_WANT_IEC_60559_BFP_EXT__ 32352 // macro. 32353 32354 // ISO/IEC TS 18661-4:2015 defines the 32355 // __STDC_WANT_IEC_60559_FUNCS_EXT__ macro. 32356 32357 // ISO/IEC TS 18661-3:2015 defines the 32358 // __STDC_WANT_IEC_60559_TYPES_EXT__ macro. 32359 32360 // Maximum length of any multibyte character in any locale. 32361 // We define this value here since the gcc header does not define 32362 // the correct value. 32363 32364 // If we are not using GNU CC we have to define all the symbols ourself. 32365 // Otherwise use gcc's definitions (see below). 32366 32367 // Get the compiler's limits.h, which defines almost all the ISO constants. 32368 // 32369 // We put this #include_next outside the double inclusion check because 32370 // it should be possible to include this file more than once and still get 32371 // the definitions from gcc's header. 32372 32373 // The <limits.h> files in some gcc versions don't define LLONG_MIN, 32374 // LLONG_MAX, and ULLONG_MAX. Instead only the values gcc defined for 32375 // ages are available. 32376 32377 // The integer width macros are not defined by GCC's <limits.h> before 32378 // GCC 7, or if _GNU_SOURCE rather than 32379 // __STDC_WANT_IEC_60559_BFP_EXT__ is used to enable this feature. 32380 32381 // POSIX adds things to <limits.h>. 32382 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 32383 // This file is part of the GNU C Library. 32384 // 32385 // The GNU C Library is free software; you can redistribute it and/or 32386 // modify it under the terms of the GNU Lesser General Public 32387 // License as published by the Free Software Foundation; either 32388 // version 2.1 of the License, or (at your option) any later version. 32389 // 32390 // The GNU C Library is distributed in the hope that it will be useful, 32391 // but WITHOUT ANY WARRANTY; without even the implied warranty of 32392 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 32393 // Lesser General Public License for more details. 32394 // 32395 // You should have received a copy of the GNU Lesser General Public 32396 // License along with the GNU C Library; if not, see 32397 // <http://www.gnu.org/licenses/>. 32398 32399 // POSIX Standard: 2.9.2 Minimum Values Added to <limits.h> 32400 // 32401 // Never include this file directly; use <limits.h> instead. 32402 32403 // Determine the wordsize from the preprocessor defines. 32404 32405 // These are the standard-mandated minimum values. 32406 32407 // Minimum number of operations in one list I/O call. 32408 32409 // Minimal number of outstanding asynchronous I/O operations. 32410 32411 // Maximum length of arguments to `execve', including environment. 32412 32413 // Maximum simultaneous processes per real user ID. 32414 32415 // Minimal number of timer expiration overruns. 32416 32417 // Maximum length of a host name (not including the terminating null) 32418 // as returned from the GETHOSTNAME function. 32419 32420 // Maximum link count of a file. 32421 32422 // Maximum length of login name. 32423 32424 // Number of bytes in a terminal canonical input queue. 32425 32426 // Number of bytes for which space will be 32427 // available in a terminal input queue. 32428 32429 // Maximum number of message queues open for a process. 32430 32431 // Maximum number of supported message priorities. 32432 32433 // Number of bytes in a filename. 32434 32435 // Number of simultaneous supplementary group IDs per process. 32436 32437 // Number of files one process can have open at once. 32438 32439 // Number of bytes in a pathname. 32440 32441 // Number of bytes than can be written atomically to a pipe. 32442 32443 // The number of repeated occurrences of a BRE permitted by the 32444 // REGEXEC and REGCOMP functions when using the interval notation. 32445 32446 // Minimal number of realtime signals reserved for the application. 32447 32448 // Number of semaphores a process can have. 32449 32450 // Maximal value of a semaphore. 32451 32452 // Number of pending realtime signals. 32453 32454 // Largest value of a `ssize_t'. 32455 32456 // Number of streams a process can have open at once. 32457 32458 // The number of bytes in a symbolic link. 32459 32460 // The number of symbolic links that can be traversed in the 32461 // resolution of a pathname in the absence of a loop. 32462 32463 // Number of timer for a process. 32464 32465 // Maximum number of characters in a tty name. 32466 32467 // Maximum length of a timezone name (element of `tzname'). 32468 32469 // Maximum clock resolution in nanoseconds. 32470 32471 // Get the implementation-specific values for the above. 32472 // Minimum guaranteed maximum values for system limits. Linux version. 32473 // Copyright (C) 1993-2018 Free Software Foundation, Inc. 32474 // This file is part of the GNU C Library. 32475 // 32476 // The GNU C Library is free software; you can redistribute it and/or 32477 // modify it under the terms of the GNU Lesser General Public License as 32478 // published by the Free Software Foundation; either version 2.1 of the 32479 // License, or (at your option) any later version. 32480 // 32481 // The GNU C Library is distributed in the hope that it will be useful, 32482 // but WITHOUT ANY WARRANTY; without even the implied warranty of 32483 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 32484 // Lesser General Public License for more details. 32485 // 32486 // You should have received a copy of the GNU Lesser General Public 32487 // License along with the GNU C Library; see the file COPYING.LIB. If 32488 // not, see <http://www.gnu.org/licenses/>. 32489 32490 // The kernel header pollutes the namespace with the NR_OPEN symbol 32491 // and defines LINK_MAX although filesystems have different maxima. A 32492 // similar thing is true for OPEN_MAX: the limit can be changed at 32493 // runtime and therefore the macro must not be defined. Remove this 32494 // after including the header if necessary. 32495 32496 // The kernel sources contain a file with all the needed information. 32497 // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note 32498 32499 // Have to remove NR_OPEN? 32500 // Have to remove LINK_MAX? 32501 // Have to remove OPEN_MAX? 32502 // Have to remove ARG_MAX? 32503 32504 // The number of data keys per process. 32505 // This is the value this implementation supports. 32506 32507 // Controlling the iterations of destructors for thread-specific data. 32508 // Number of iterations this implementation does. 32509 32510 // The number of threads per process. 32511 // We have no predefined limit on the number of threads. 32512 32513 // Maximum amount by which a process can descrease its asynchronous I/O 32514 // priority level. 32515 32516 // Minimum size for a thread. We are free to choose a reasonable value. 32517 32518 // Maximum number of timer expiration overruns. 32519 32520 // Maximum tty name length. 32521 32522 // Maximum login name length. This is arbitrary. 32523 32524 // Maximum host name length. 32525 32526 // Maximum message queue priority level. 32527 32528 // Maximum value the semaphore can have. 32529 32530 // ssize_t is not formally required to be the signed type 32531 // corresponding to size_t, but it is for all configurations supported 32532 // by glibc. 32533 32534 // This value is a guaranteed minimum maximum. 32535 // The current maximum can be got from `sysconf'. 32536 32537 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 32538 // This file is part of the GNU C Library. 32539 // 32540 // The GNU C Library is free software; you can redistribute it and/or 32541 // modify it under the terms of the GNU Lesser General Public 32542 // License as published by the Free Software Foundation; either 32543 // version 2.1 of the License, or (at your option) any later version. 32544 // 32545 // The GNU C Library is distributed in the hope that it will be useful, 32546 // but WITHOUT ANY WARRANTY; without even the implied warranty of 32547 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 32548 // Lesser General Public License for more details. 32549 // 32550 // You should have received a copy of the GNU Lesser General Public 32551 // License along with the GNU C Library; if not, see 32552 // <http://www.gnu.org/licenses/>. 32553 32554 // Never include this file directly; include <limits.h> instead. 32555 32556 // The maximum `ibase' and `obase' values allowed by the `bc' utility. 32557 32558 // The maximum number of elements allowed in an array by the `bc' utility. 32559 32560 // The maximum `scale' value allowed by the `bc' utility. 32561 32562 // The maximum length of a string constant accepted by the `bc' utility. 32563 32564 // The maximum number of weights that can be assigned to an entry of 32565 // the LC_COLLATE `order' keyword in the locale definition file. 32566 32567 // The maximum number of expressions that can be nested 32568 // within parentheses by the `expr' utility. 32569 32570 // The maximum length, in bytes, of an input line. 32571 32572 // The maximum number of repeated occurrences of a regular expression 32573 // permitted when using the interval notation `\{M,N\}'. 32574 32575 // The maximum number of bytes in a character class name. We have no 32576 // fixed limit, 2048 is a high number. 32577 32578 // These values are implementation-specific, 32579 // and may vary within the implementation. 32580 // Their precise values can be obtained from sysconf. 32581 32582 // This value is defined like this in regex.h. 32583 32584 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 32585 // 32586 // This file is part of GCC. 32587 // 32588 // GCC is free software; you can redistribute it and/or modify it under 32589 // the terms of the GNU General Public License as published by the Free 32590 // Software Foundation; either version 3, or (at your option) any later 32591 // version. 32592 // 32593 // GCC is distributed in the hope that it will be useful, but WITHOUT ANY 32594 // WARRANTY; without even the implied warranty of MERCHANTABILITY or 32595 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 32596 // for more details. 32597 // 32598 // Under Section 7 of GPL version 3, you are granted additional 32599 // permissions described in the GCC Runtime Library Exception, version 32600 // 3.1, as published by the Free Software Foundation. 32601 // 32602 // You should have received a copy of the GNU General Public License and 32603 // a copy of the GCC Runtime Library Exception along with this program; 32604 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 32605 // <http://www.gnu.org/licenses/>. 32606 32607 // Number of bits in a `char'. 32608 32609 // Maximum length of a multibyte character. 32610 32611 // Minimum and maximum values a `signed char' can hold. 32612 32613 // Maximum value an `unsigned char' can hold. (Minimum is 0). 32614 32615 // Minimum and maximum values a `char' can hold. 32616 32617 // Minimum and maximum values a `signed short int' can hold. 32618 32619 // Maximum value an `unsigned short int' can hold. (Minimum is 0). 32620 32621 // Minimum and maximum values a `signed int' can hold. 32622 32623 // Maximum value an `unsigned int' can hold. (Minimum is 0). 32624 32625 // Minimum and maximum values a `signed long int' can hold. 32626 // (Same as `int'). 32627 32628 // Maximum value an `unsigned long int' can hold. (Minimum is 0). 32629 32630 // Minimum and maximum values a `signed long long int' can hold. 32631 32632 // Maximum value an `unsigned long long int' can hold. (Minimum is 0). 32633 32634 // This administrivia gets added to the end of limits.h 32635 // if the system has its own version of limits.h. 32636 32637 type z_crc_t = uint32 /* zconf.h:429:17 */ 32638 32639 // Define some macros helping to catch buffer overflows. 32640 32641 // MVS linker does not support external names larger than 8 bytes 32642 32643 // 32644 // The 'zlib' compression library provides in-memory compression and 32645 // decompression functions, including integrity checks of the uncompressed data. 32646 // This version of the library supports only one compression method (deflation) 32647 // but other algorithms will be added later and will have the same stream 32648 // interface. 32649 // 32650 // Compression can be done in a single step if the buffers are large enough, 32651 // or can be done by repeated calls of the compression function. In the latter 32652 // case, the application must provide more input and/or consume the output 32653 // (providing more output space) before each call. 32654 // 32655 // The compressed data format used by default by the in-memory functions is 32656 // the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped 32657 // around a deflate stream, which is itself documented in RFC 1951. 32658 // 32659 // The library also supports reading and writing files in gzip (.gz) format 32660 // with an interface similar to that of stdio using the functions that start 32661 // with "gz". The gzip format is different from the zlib format. gzip is a 32662 // gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. 32663 // 32664 // This library can optionally read and write gzip and raw deflate streams in 32665 // memory as well. 32666 // 32667 // The zlib format was designed to be compact and fast for use in memory 32668 // and on communications channels. The gzip format was designed for single- 32669 // file compression on file systems, has a larger header than zlib to maintain 32670 // directory information, and uses a different, slower check method than zlib. 32671 // 32672 // The library does not install any signal handler. The decoder checks 32673 // the consistency of the compressed data, so the library should never crash 32674 // even in the case of corrupted input. 32675 32676 type alloc_func = uintptr /* zlib.h:81:16 */ 32677 type free_func = uintptr /* zlib.h:82:16 */ 32678 32679 type z_stream_s = struct { 32680 Fnext_in uintptr 32681 Favail_in uInt 32682 _ [4]byte 32683 Ftotal_in uLong 32684 Fnext_out uintptr 32685 Favail_out uInt 32686 _ [4]byte 32687 Ftotal_out uLong 32688 Fmsg uintptr 32689 Fstate uintptr 32690 Fzalloc alloc_func 32691 Fzfree free_func 32692 Fopaque voidpf 32693 Fdata_type int32 32694 _ [4]byte 32695 Fadler uLong 32696 Freserved uLong 32697 } /* zlib.h:86:9 */ 32698 32699 type z_stream = z_stream_s /* zlib.h:106:3 */ 32700 32701 type z_streamp = uintptr /* zlib.h:108:22 */ 32702 32703 // 32704 // gzip header information passed to and from zlib routines. See RFC 1952 32705 // for more details on the meanings of these fields. 32706 type gz_header_s = struct { 32707 Ftext int32 32708 _ [4]byte 32709 Ftime uLong 32710 Fxflags int32 32711 Fos int32 32712 Fextra uintptr 32713 Fextra_len uInt 32714 Fextra_max uInt 32715 Fname uintptr 32716 Fname_max uInt 32717 _ [4]byte 32718 Fcomment uintptr 32719 Fcomm_max uInt 32720 Fhcrc int32 32721 Fdone int32 32722 _ [4]byte 32723 } /* zlib.h:114:9 */ 32724 32725 // 32726 // gzip header information passed to and from zlib routines. See RFC 1952 32727 // for more details on the meanings of these fields. 32728 type gz_header = gz_header_s /* zlib.h:129:3 */ 32729 32730 type gz_headerp = uintptr /* zlib.h:131:23 */ 32731 // 32732 // inflateGetHeader() requests that gzip header information be stored in the 32733 // provided gz_header structure. inflateGetHeader() may be called after 32734 // inflateInit2() or inflateReset(), and before the first call of inflate(). 32735 // As inflate() processes the gzip stream, head->done is zero until the header 32736 // is completed, at which time head->done is set to one. If a zlib stream is 32737 // being decoded, then head->done is set to -1 to indicate that there will be 32738 // no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be 32739 // used to force inflate() to return immediately after header processing is 32740 // complete and before any actual data is decompressed. 32741 // 32742 // The text, time, xflags, and os fields are filled in with the gzip header 32743 // contents. hcrc is set to true if there is a header CRC. (The header CRC 32744 // was valid if done is set to one.) If extra is not Z_NULL, then extra_max 32745 // contains the maximum number of bytes to write to extra. Once done is true, 32746 // extra_len contains the actual extra field length, and extra contains the 32747 // extra field, or that field truncated if extra_max is less than extra_len. 32748 // If name is not Z_NULL, then up to name_max characters are written there, 32749 // terminated with a zero unless the length is greater than name_max. If 32750 // comment is not Z_NULL, then up to comm_max characters are written there, 32751 // terminated with a zero unless the length is greater than comm_max. When any 32752 // of extra, name, or comment are not Z_NULL and the respective field is not 32753 // present in the header, then that field is set to Z_NULL to signal its 32754 // absence. This allows the use of deflateSetHeader() with the returned 32755 // structure to duplicate the header. However if those fields are set to 32756 // allocated memory, then the application will need to save those pointers 32757 // elsewhere so that they can be eventually freed. 32758 // 32759 // If inflateGetHeader is not used, then the header information is simply 32760 // discarded. The header is always checked for validity, including the header 32761 // CRC if present. inflateReset() will reset the process to discard the header 32762 // information. The application would need to call inflateGetHeader() again to 32763 // retrieve the header from the next gzip stream. 32764 // 32765 // inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source 32766 // stream state was inconsistent. 32767 32768 // 32769 // ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, 32770 // unsigned char FAR *window)); 32771 // 32772 // Initialize the internal stream state for decompression using inflateBack() 32773 // calls. The fields zalloc, zfree and opaque in strm must be initialized 32774 // before the call. If zalloc and zfree are Z_NULL, then the default library- 32775 // derived memory allocation routines are used. windowBits is the base two 32776 // logarithm of the window size, in the range 8..15. window is a caller 32777 // supplied buffer of that size. Except for special applications where it is 32778 // assured that deflate was used with small window sizes, windowBits must be 15 32779 // and a 32K byte window must be supplied to be able to decompress general 32780 // deflate streams. 32781 // 32782 // See inflateBack() for the usage of these routines. 32783 // 32784 // inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of 32785 // the parameters are invalid, Z_MEM_ERROR if the internal state could not be 32786 // allocated, or Z_VERSION_ERROR if the version of the library does not match 32787 // the version of the header file. 32788 32789 type in_func = uintptr /* zlib.h:1092:18 */ 32790 type out_func = uintptr /* zlib.h:1094:13 */ 32791 // 32792 // Same as uncompress, except that sourceLen is a pointer, where the 32793 // length of the source is *sourceLen. On return, *sourceLen is the number of 32794 // source bytes consumed. 32795 32796 // gzip file access functions 32797 32798 // 32799 // This library supports reading and writing files in gzip (.gz) format with 32800 // an interface similar to that of stdio, using the functions that start with 32801 // "gz". The gzip format is different from the zlib format. gzip is a gzip 32802 // wrapper, documented in RFC 1952, wrapped around a deflate stream. 32803 32804 type gzFile_s = struct { 32805 Fhave uint32 32806 _ [4]byte 32807 Fnext uintptr 32808 Fpos off_t 32809 } /* zlib.h:1300:9 */ 32810 32811 // 32812 // Same as uncompress, except that sourceLen is a pointer, where the 32813 // length of the source is *sourceLen. On return, *sourceLen is the number of 32814 // source bytes consumed. 32815 32816 // gzip file access functions 32817 32818 // 32819 // This library supports reading and writing files in gzip (.gz) format with 32820 // an interface similar to that of stdio, using the functions that start with 32821 // "gz". The gzip format is different from the zlib format. gzip is a gzip 32822 // wrapper, documented in RFC 1952, wrapped around a deflate stream. 32823 32824 type gzFile = uintptr /* zlib.h:1300:25 */ 32825 type u321 = uint64 /* zipfile.c:42:23 */ 32826 32827 // Definitions for mode bitmasks S_IFDIR, S_IFREG and S_IFLNK. 32828 // 32829 // In some ways it would be better to obtain these values from system 32830 // header files. But, the dependency is undesirable and (a) these 32831 // have been stable for decades, (b) the values are part of POSIX and 32832 // are also made explicit in [man stat], and (c) are part of the 32833 // file format for zip archives. 32834 32835 var ZIPFILE_SCHEMA = 32836 32837 // 0: Name of file in zip archive 32838 // 1: POSIX mode for file 32839 // 2: Last modification time (secs since 1970) 32840 // 3: Size of object 32841 // 4: Raw data 32842 // 5: Uncompressed data 32843 // 6: Compression method (integer) 32844 // 7: Name of zip file 32845 *(*[91]int8)(unsafe.Pointer(ts + 8923 /* "CREATE TABLE y(n..." */)) /* zipfile.c:77:19 */ 32846 32847 // Magic numbers used to read and write zip files. 32848 // 32849 // ZIPFILE_NEWENTRY_MADEBY: 32850 // Use this value for the "version-made-by" field in new zip file 32851 // entries. The upper byte indicates "unix", and the lower byte 32852 // indicates that the zip file matches pkzip specification 3.0. 32853 // This is what info-zip seems to do. 32854 // 32855 // ZIPFILE_NEWENTRY_REQUIRED: 32856 // Value for "version-required-to-extract" field of new entries. 32857 // Version 2.0 is required to support folders and deflate compression. 32858 // 32859 // ZIPFILE_NEWENTRY_FLAGS: 32860 // Value for "general-purpose-bit-flags" field of new entries. Bit 32861 // 11 means "utf-8 filename and comment". 32862 // 32863 // ZIPFILE_SIGNATURE_CDS: 32864 // First 4 bytes of a valid CDS record. 32865 // 32866 // ZIPFILE_SIGNATURE_LFH: 32867 // First 4 bytes of a valid LFH record. 32868 // 32869 // ZIPFILE_SIGNATURE_EOCD 32870 // First 4 bytes of a valid EOCD record. 32871 32872 // The sizes of the fixed-size part of each of the three main data 32873 // structures in a zip archive. 32874 32875 // 4.3.16 End of central directory record: 32876 // 32877 // end of central dir signature 4 bytes (0x06054b50) 32878 // number of this disk 2 bytes 32879 // number of the disk with the 32880 // start of the central directory 2 bytes 32881 // total number of entries in the 32882 // central directory on this disk 2 bytes 32883 // total number of entries in 32884 // the central directory 2 bytes 32885 // size of the central directory 4 bytes 32886 // offset of start of central 32887 // directory with respect to 32888 // the starting disk number 4 bytes 32889 // .ZIP file comment length 2 bytes 32890 // .ZIP file comment (variable size) 32891 type ZipfileEOCD1 = struct { 32892 FiDisk u16 32893 FiFirstDisk u16 32894 FnEntry u16 32895 FnEntryTotal u16 32896 FnSize u321 32897 FiOffset u321 32898 } /* zipfile.c:153:9 */ 32899 32900 // Magic numbers used to read and write zip files. 32901 // 32902 // ZIPFILE_NEWENTRY_MADEBY: 32903 // Use this value for the "version-made-by" field in new zip file 32904 // entries. The upper byte indicates "unix", and the lower byte 32905 // indicates that the zip file matches pkzip specification 3.0. 32906 // This is what info-zip seems to do. 32907 // 32908 // ZIPFILE_NEWENTRY_REQUIRED: 32909 // Value for "version-required-to-extract" field of new entries. 32910 // Version 2.0 is required to support folders and deflate compression. 32911 // 32912 // ZIPFILE_NEWENTRY_FLAGS: 32913 // Value for "general-purpose-bit-flags" field of new entries. Bit 32914 // 11 means "utf-8 filename and comment". 32915 // 32916 // ZIPFILE_SIGNATURE_CDS: 32917 // First 4 bytes of a valid CDS record. 32918 // 32919 // ZIPFILE_SIGNATURE_LFH: 32920 // First 4 bytes of a valid LFH record. 32921 // 32922 // ZIPFILE_SIGNATURE_EOCD 32923 // First 4 bytes of a valid EOCD record. 32924 32925 // The sizes of the fixed-size part of each of the three main data 32926 // structures in a zip archive. 32927 32928 // 4.3.16 End of central directory record: 32929 // 32930 // end of central dir signature 4 bytes (0x06054b50) 32931 // number of this disk 2 bytes 32932 // number of the disk with the 32933 // start of the central directory 2 bytes 32934 // total number of entries in the 32935 // central directory on this disk 2 bytes 32936 // total number of entries in 32937 // the central directory 2 bytes 32938 // size of the central directory 4 bytes 32939 // offset of start of central 32940 // directory with respect to 32941 // the starting disk number 4 bytes 32942 // .ZIP file comment length 2 bytes 32943 // .ZIP file comment (variable size) 32944 type ZipfileEOCD = ZipfileEOCD1 /* zipfile.c:153:28 */ 32945 32946 // 4.3.12 Central directory structure: 32947 // 32948 // ... 32949 // 32950 // central file header signature 4 bytes (0x02014b50) 32951 // version made by 2 bytes 32952 // version needed to extract 2 bytes 32953 // general purpose bit flag 2 bytes 32954 // compression method 2 bytes 32955 // last mod file time 2 bytes 32956 // last mod file date 2 bytes 32957 // crc-32 4 bytes 32958 // compressed size 4 bytes 32959 // uncompressed size 4 bytes 32960 // file name length 2 bytes 32961 // extra field length 2 bytes 32962 // file comment length 2 bytes 32963 // disk number start 2 bytes 32964 // internal file attributes 2 bytes 32965 // external file attributes 4 bytes 32966 // relative offset of local header 4 bytes 32967 type ZipfileCDS1 = struct { 32968 FiVersionMadeBy u16 32969 FiVersionExtract u16 32970 Fflags u16 32971 FiCompression u16 32972 FmTime u16 32973 FmDate u16 32974 _ [4]byte 32975 Fcrc32 u321 32976 FszCompressed u321 32977 FszUncompressed u321 32978 FnFile u16 32979 FnExtra u16 32980 FnComment u16 32981 FiDiskStart u16 32982 FiInternalAttr u16 32983 _ [6]byte 32984 FiExternalAttr u321 32985 FiOffset u321 32986 FzFile uintptr 32987 } /* zipfile.c:186:9 */ 32988 32989 // 4.3.12 Central directory structure: 32990 // 32991 // ... 32992 // 32993 // central file header signature 4 bytes (0x02014b50) 32994 // version made by 2 bytes 32995 // version needed to extract 2 bytes 32996 // general purpose bit flag 2 bytes 32997 // compression method 2 bytes 32998 // last mod file time 2 bytes 32999 // last mod file date 2 bytes 33000 // crc-32 4 bytes 33001 // compressed size 4 bytes 33002 // uncompressed size 4 bytes 33003 // file name length 2 bytes 33004 // extra field length 2 bytes 33005 // file comment length 2 bytes 33006 // disk number start 2 bytes 33007 // internal file attributes 2 bytes 33008 // external file attributes 4 bytes 33009 // relative offset of local header 4 bytes 33010 type ZipfileCDS = ZipfileCDS1 /* zipfile.c:186:27 */ 33011 33012 // 4.3.7 Local file header: 33013 // 33014 // local file header signature 4 bytes (0x04034b50) 33015 // version needed to extract 2 bytes 33016 // general purpose bit flag 2 bytes 33017 // compression method 2 bytes 33018 // last mod file time 2 bytes 33019 // last mod file date 2 bytes 33020 // crc-32 4 bytes 33021 // compressed size 4 bytes 33022 // uncompressed size 4 bytes 33023 // file name length 2 bytes 33024 // extra field length 2 bytes 33025 // 33026 type ZipfileLFH1 = struct { 33027 FiVersionExtract u16 33028 Fflags u16 33029 FiCompression u16 33030 FmTime u16 33031 FmDate u16 33032 _ [6]byte 33033 Fcrc32 u321 33034 FszCompressed u321 33035 FszUncompressed u321 33036 FnFile u16 33037 FnExtra u16 33038 _ [4]byte 33039 } /* zipfile.c:223:9 */ 33040 33041 // 4.3.7 Local file header: 33042 // 33043 // local file header signature 4 bytes (0x04034b50) 33044 // version needed to extract 2 bytes 33045 // general purpose bit flag 2 bytes 33046 // compression method 2 bytes 33047 // last mod file time 2 bytes 33048 // last mod file date 2 bytes 33049 // crc-32 4 bytes 33050 // compressed size 4 bytes 33051 // uncompressed size 4 bytes 33052 // file name length 2 bytes 33053 // extra field length 2 bytes 33054 // 33055 type ZipfileLFH = ZipfileLFH1 /* zipfile.c:223:27 */ 33056 33057 type ZipfileEntry1 = struct { 33058 Fcds ZipfileCDS 33059 FmUnixTime u321 33060 FaExtra uintptr 33061 FiDataOff i64 33062 FaData uintptr 33063 FpNext uintptr 33064 } /* zipfile.c:237:9 */ 33065 33066 type ZipfileEntry = ZipfileEntry1 /* zipfile.c:237:29 */ 33067 33068 // Cursor type for zipfile tables. 33069 type ZipfileCsr1 = struct { 33070 Fbase sqlite3_vtab_cursor 33071 FiId i64 33072 FbEof u8 33073 FbNoop u8 33074 _ [6]byte 33075 FpFile uintptr 33076 FiNextOff i64 33077 Feocd ZipfileEOCD 33078 FpFreeEntry uintptr 33079 FpCurrent uintptr 33080 FpCsrNext uintptr 33081 } /* zipfile.c:250:9 */ 33082 33083 // Cursor type for zipfile tables. 33084 type ZipfileCsr = ZipfileCsr1 /* zipfile.c:250:27 */ 33085 33086 type ZipfileTab1 = struct { 33087 Fbase sqlite3_vtab 33088 FzFile uintptr 33089 Fdb uintptr 33090 FaBuffer uintptr 33091 FpCsrList uintptr 33092 FiNextCsrid i64 33093 FpFirstEntry uintptr 33094 FpLastEntry uintptr 33095 FpWriteFd uintptr 33096 FszCurrent i64 33097 FszOrig i64 33098 } /* zipfile.c:267:9 */ 33099 33100 type ZipfileTab = ZipfileTab1 /* zipfile.c:267:27 */ 33101 33102 // Set the error message contained in context ctx to the results of 33103 // vprintf(zFmt, ...). 33104 func zipfileCtxErrorMsg(tls *libc.TLS, ctx uintptr, zFmt uintptr, va uintptr) { /* zipfile.c:289:13: */ 33105 var zMsg uintptr = uintptr(0) 33106 var ap va_list 33107 _ = ap 33108 ap = va 33109 zMsg = sqlite3.Xsqlite3_vmprintf(tls, zFmt, ap) 33110 sqlite3.Xsqlite3_result_error(tls, ctx, zMsg, -1) 33111 sqlite3.Xsqlite3_free(tls, zMsg) 33112 _ = ap 33113 } 33114 33115 // If string zIn is quoted, dequote it in place. Otherwise, if the string 33116 // is not quoted, do nothing. 33117 func zipfileDequote(tls *libc.TLS, zIn uintptr) { /* zipfile.c:303:13: */ 33118 var q int8 = *(*int8)(unsafe.Pointer(zIn)) 33119 if (((int32(q) == '"') || (int32(q) == '\'')) || (int32(q) == '`')) || (int32(q) == '[') { 33120 var iIn int32 = 1 33121 var iOut int32 = 0 33122 if int32(q) == '[' { 33123 q = int8(']') 33124 } 33125 for *(*int8)(unsafe.Pointer(zIn + uintptr(iIn))) != 0 { 33126 var c int8 = *(*int8)(unsafe.Pointer(zIn + uintptr(libc.PostIncInt32(&iIn, 1)))) 33127 if (int32(c) == int32(q)) && (int32(*(*int8)(unsafe.Pointer(zIn + uintptr(libc.PostIncInt32(&iIn, 1))))) != int32(q)) { 33128 break 33129 } 33130 *(*int8)(unsafe.Pointer(zIn + uintptr(libc.PostIncInt32(&iOut, 1)))) = c 33131 } 33132 *(*int8)(unsafe.Pointer(zIn + uintptr(iOut))) = int8(0) 33133 } 33134 } 33135 33136 // Construct a new ZipfileTab virtual table object. 33137 // 33138 // argv[0] -> module name ("zipfile") 33139 // argv[1] -> database name 33140 // argv[2] -> table name 33141 // argv[...] -> "column name" and other module argument fields. 33142 func zipfileConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* zipfile.c:326:12: */ 33143 var nByte int32 = (int32(uint64(unsafe.Sizeof(ZipfileTab{})) + (uint64(64 * 1024)))) 33144 var nFile int32 = 0 33145 var zFile uintptr = uintptr(0) 33146 var pNew uintptr = uintptr(0) 33147 var rc int32 33148 33149 // If the table name is not "zipfile", require that the argument be 33150 // specified. This stops zipfile tables from being created as: 33151 // 33152 // CREATE VIRTUAL TABLE zzz USING zipfile(); 33153 // 33154 // It does not prevent: 33155 // 33156 // CREATE VIRTUAL TABLE zipfile USING zipfile(); 33157 33158 if ((0 != sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)), ts+9014 /* "zipfile" */)) && (argc < 4)) || (argc > 4) { 33159 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+9022 /* "zipfile construc..." */, 0) 33160 return SQLITE_ERROR 33161 } 33162 33163 if argc > 3 { 33164 zFile = *(*uintptr)(unsafe.Pointer(argv + 3*8)) 33165 nFile = (int32(libc.Xstrlen(tls, zFile)) + 1) 33166 } 33167 33168 rc = sqlite3.Xsqlite3_declare_vtab(tls, db, uintptr(unsafe.Pointer(&ZIPFILE_SCHEMA))) 33169 if rc == SQLITE_OK { 33170 pNew = sqlite3.Xsqlite3_malloc64(tls, (uint64(sqlite3_int64(nByte) + sqlite3_int64(nFile)))) 33171 if pNew == uintptr(0) { 33172 return SQLITE_NOMEM 33173 } 33174 libc.Xmemset(tls, pNew, 0, (uint64(nByte + nFile))) 33175 (*ZipfileTab)(unsafe.Pointer(pNew)).Fdb = db 33176 (*ZipfileTab)(unsafe.Pointer(pNew)).FaBuffer = (pNew + 1*104) 33177 if zFile != 0 { 33178 (*ZipfileTab)(unsafe.Pointer(pNew)).FzFile = ((*ZipfileTab)(unsafe.Pointer(pNew)).FaBuffer + 65536) 33179 libc.Xmemcpy(tls, (*ZipfileTab)(unsafe.Pointer(pNew)).FzFile, zFile, uint64(nFile)) 33180 zipfileDequote(tls, (*ZipfileTab)(unsafe.Pointer(pNew)).FzFile) 33181 } 33182 } 33183 sqlite3.Xsqlite3_vtab_config(tls, db, SQLITE_VTAB_DIRECTONLY, 0) 33184 *(*uintptr)(unsafe.Pointer(ppVtab)) = pNew 33185 return rc 33186 } 33187 33188 // Free the ZipfileEntry structure indicated by the only argument. 33189 func zipfileEntryFree(tls *libc.TLS, p uintptr) { /* zipfile.c:380:13: */ 33190 if p != 0 { 33191 sqlite3.Xsqlite3_free(tls, (*ZipfileEntry)(unsafe.Pointer(p)).Fcds.FzFile) 33192 sqlite3.Xsqlite3_free(tls, p) 33193 } 33194 } 33195 33196 // Release resources that should be freed at the end of a write 33197 // transaction. 33198 func zipfileCleanupTransaction(tls *libc.TLS, pTab uintptr) { /* zipfile.c:391:13: */ 33199 var pEntry uintptr 33200 var pNext uintptr 33201 33202 if (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd != 0 { 33203 libc.Xfclose(tls, (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd) 33204 (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd = uintptr(0) 33205 } 33206 for pEntry = (*ZipfileTab)(unsafe.Pointer(pTab)).FpFirstEntry; pEntry != 0; pEntry = pNext { 33207 pNext = (*ZipfileEntry)(unsafe.Pointer(pEntry)).FpNext 33208 zipfileEntryFree(tls, pEntry) 33209 } 33210 (*ZipfileTab)(unsafe.Pointer(pTab)).FpFirstEntry = uintptr(0) 33211 (*ZipfileTab)(unsafe.Pointer(pTab)).FpLastEntry = uintptr(0) 33212 (*ZipfileTab)(unsafe.Pointer(pTab)).FszCurrent = int64(0) 33213 (*ZipfileTab)(unsafe.Pointer(pTab)).FszOrig = int64(0) 33214 } 33215 33216 // This method is the destructor for zipfile vtab objects. 33217 func zipfileDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* zipfile.c:412:12: */ 33218 zipfileCleanupTransaction(tls, pVtab) 33219 sqlite3.Xsqlite3_free(tls, pVtab) 33220 return SQLITE_OK 33221 } 33222 33223 // Constructor for a new ZipfileCsr object. 33224 func zipfileOpen(tls *libc.TLS, p uintptr, ppCsr uintptr) int32 { /* zipfile.c:421:12: */ 33225 var pTab uintptr = p 33226 var pCsr uintptr 33227 pCsr = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(ZipfileCsr{}))) 33228 *(*uintptr)(unsafe.Pointer(ppCsr)) = pCsr 33229 if pCsr == uintptr(0) { 33230 return SQLITE_NOMEM 33231 } 33232 libc.Xmemset(tls, pCsr, 0, uint64(unsafe.Sizeof(ZipfileCsr{}))) 33233 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FiId = libc.PreIncInt64(&(*ZipfileTab)(unsafe.Pointer(pTab)).FiNextCsrid, 1) 33234 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCsrNext = (*ZipfileTab)(unsafe.Pointer(pTab)).FpCsrList 33235 (*ZipfileTab)(unsafe.Pointer(pTab)).FpCsrList = pCsr 33236 return SQLITE_OK 33237 } 33238 33239 // Reset a cursor back to the state it was in when first returned 33240 // by zipfileOpen(). 33241 func zipfileResetCursor(tls *libc.TLS, pCsr uintptr) { /* zipfile.c:440:13: */ 33242 var p uintptr 33243 var pNext uintptr 33244 33245 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FbEof = u8(0) 33246 if (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFile != 0 { 33247 libc.Xfclose(tls, (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFile) 33248 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFile = uintptr(0) 33249 zipfileEntryFree(tls, (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent) 33250 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent = uintptr(0) 33251 } 33252 33253 for p = (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFreeEntry; p != 0; p = pNext { 33254 pNext = (*ZipfileEntry)(unsafe.Pointer(p)).FpNext 33255 zipfileEntryFree(tls, p) 33256 } 33257 } 33258 33259 // Destructor for an ZipfileCsr. 33260 func zipfileClose(tls *libc.TLS, cur uintptr) int32 { /* zipfile.c:461:12: */ 33261 var pCsr uintptr = cur 33262 var pTab uintptr = (*ZipfileCsr)(unsafe.Pointer(pCsr)).Fbase.FpVtab 33263 var pp uintptr 33264 zipfileResetCursor(tls, pCsr) 33265 33266 // Remove this cursor from the ZipfileTab.pCsrList list. 33267 for pp = (pTab + 48 /* &.pCsrList */); *(*uintptr)(unsafe.Pointer(pp)) != pCsr; pp = (*(*uintptr)(unsafe.Pointer(pp)) + 80 /* &.pCsrNext */) { 33268 } 33269 *(*uintptr)(unsafe.Pointer(pp)) = (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCsrNext 33270 33271 sqlite3.Xsqlite3_free(tls, pCsr) 33272 return SQLITE_OK 33273 } 33274 33275 // Set the error message for the virtual table associated with cursor 33276 // pCsr to the results of vprintf(zFmt, ...). 33277 func zipfileTableErr(tls *libc.TLS, pTab uintptr, zFmt uintptr, va uintptr) { /* zipfile.c:479:13: */ 33278 var ap va_list 33279 _ = ap 33280 ap = va 33281 sqlite3.Xsqlite3_free(tls, (*ZipfileTab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg) 33282 (*ZipfileTab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_vmprintf(tls, zFmt, ap) 33283 _ = ap 33284 } 33285 33286 func zipfileCursorErr(tls *libc.TLS, pCsr uintptr, zFmt uintptr, va uintptr) { /* zipfile.c:486:13: */ 33287 var ap va_list 33288 _ = ap 33289 ap = va 33290 sqlite3.Xsqlite3_free(tls, (*sqlite3_vtab)(unsafe.Pointer((*ZipfileCsr)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FzErrMsg) 33291 (*sqlite3_vtab)(unsafe.Pointer((*ZipfileCsr)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FzErrMsg = sqlite3.Xsqlite3_vmprintf(tls, zFmt, ap) 33292 _ = ap 33293 } 33294 33295 // Read nRead bytes of data from offset iOff of file pFile into buffer 33296 // aRead[]. Return SQLITE_OK if successful, or an SQLite error code 33297 // otherwise. 33298 // 33299 // If an error does occur, output variable (*pzErrmsg) may be set to point 33300 // to an English language error message. It is the responsibility of the 33301 // caller to eventually free this buffer using 33302 // sqlite3_free(). 33303 func zipfileReadData(tls *libc.TLS, pFile uintptr, aRead uintptr, nRead int32, iOff i64, pzErrmsg uintptr) int32 { /* zipfile.c:504:12: */ 33304 var n size_t 33305 libc.Xfseek(tls, pFile, int64(iOff), SEEK_SET) 33306 n = libc.Xfread(tls, aRead, uint64(1), uint64(nRead), pFile) 33307 if int32(n) != nRead { 33308 *(*uintptr)(unsafe.Pointer(pzErrmsg)) = sqlite3.Xsqlite3_mprintf(tls, ts+9064 /* "error in fread()" */, 0) 33309 return SQLITE_ERROR 33310 } 33311 return SQLITE_OK 33312 } 33313 33314 func zipfileAppendData(tls *libc.TLS, pTab uintptr, aWrite uintptr, nWrite int32) int32 { /* zipfile.c:521:12: */ 33315 if nWrite > 0 { 33316 var n size_t = size_t(nWrite) 33317 libc.Xfseek(tls, (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd, int64((*ZipfileTab)(unsafe.Pointer(pTab)).FszCurrent), SEEK_SET) 33318 n = libc.Xfwrite(tls, aWrite, uint64(1), uint64(nWrite), (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd) 33319 if int32(n) != nWrite { 33320 (*ZipfileTab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+9081 /* "error in fwrite(..." */, 0) 33321 return SQLITE_ERROR 33322 } 33323 *(*i64)(unsafe.Pointer(pTab + 88 /* &.szCurrent */)) += (i64(nWrite)) 33324 } 33325 return SQLITE_OK 33326 } 33327 33328 // Read and return a 16-bit little-endian unsigned integer from buffer aBuf. 33329 func zipfileGetU16(tls *libc.TLS, aBuf uintptr) u16 { /* zipfile.c:542:12: */ 33330 return (u16((int32(*(*u8)(unsafe.Pointer(aBuf + 1))) << 8) + int32(*(*u8)(unsafe.Pointer(aBuf))))) 33331 } 33332 33333 // Read and return a 32-bit little-endian unsigned integer from buffer aBuf. 33334 func zipfileGetU32(tls *libc.TLS, aBuf uintptr) u321 { /* zipfile.c:549:12: */ 33335 return (((((u321(*(*u8)(unsafe.Pointer(aBuf + 3)))) << 24) + 33336 ((u321(*(*u8)(unsafe.Pointer(aBuf + 2)))) << 16)) + 33337 ((u321(*(*u8)(unsafe.Pointer(aBuf + 1)))) << 8)) + 33338 ((u321(*(*u8)(unsafe.Pointer(aBuf)))) << 0)) 33339 } 33340 33341 // Write a 16-bit little endiate integer into buffer aBuf. 33342 func zipfilePutU16(tls *libc.TLS, aBuf uintptr, val u16) { /* zipfile.c:559:13: */ 33343 *(*u8)(unsafe.Pointer(aBuf)) = (u8(int32(val) & 0xFF)) 33344 *(*u8)(unsafe.Pointer(aBuf + 1)) = (u8((int32(val) >> 8) & 0xFF)) 33345 } 33346 33347 // Write a 32-bit little endiate integer into buffer aBuf. 33348 func zipfilePutU32(tls *libc.TLS, aBuf uintptr, val u321) { /* zipfile.c:567:13: */ 33349 *(*u8)(unsafe.Pointer(aBuf)) = (u8(val & uint64(0xFF))) 33350 *(*u8)(unsafe.Pointer(aBuf + 1)) = (u8((val >> 8) & uint64(0xFF))) 33351 *(*u8)(unsafe.Pointer(aBuf + 2)) = (u8((val >> 16) & uint64(0xFF))) 33352 *(*u8)(unsafe.Pointer(aBuf + 3)) = (u8((val >> 24) & uint64(0xFF))) 33353 } 33354 33355 // Magic numbers used to read CDS records. 33356 33357 // Decode the CDS record in buffer aBuf into (*pCDS). Return SQLITE_ERROR 33358 // if the record is not well-formed, or SQLITE_OK otherwise. 33359 func zipfileReadCDS(tls *libc.TLS, aBuf uintptr, pCDS uintptr) int32 { /* zipfile.c:590:12: */ 33360 var aRead uintptr = aBuf 33361 var sig u321 = func() u321 { aRead += uintptr(4); return zipfileGetU32(tls, (aRead - uintptr(4))) }() 33362 var rc int32 = SQLITE_OK 33363 if sig != uint64(ZIPFILE_SIGNATURE_CDS) { 33364 rc = SQLITE_ERROR 33365 } else { 33366 (*ZipfileCDS)(unsafe.Pointer(pCDS)).FiVersionMadeBy = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33367 (*ZipfileCDS)(unsafe.Pointer(pCDS)).FiVersionExtract = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33368 (*ZipfileCDS)(unsafe.Pointer(pCDS)).Fflags = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33369 (*ZipfileCDS)(unsafe.Pointer(pCDS)).FiCompression = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33370 (*ZipfileCDS)(unsafe.Pointer(pCDS)).FmTime = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33371 (*ZipfileCDS)(unsafe.Pointer(pCDS)).FmDate = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33372 (*ZipfileCDS)(unsafe.Pointer(pCDS)).Fcrc32 = func() u321 { aRead += uintptr(4); return zipfileGetU32(tls, (aRead - uintptr(4))) }() 33373 (*ZipfileCDS)(unsafe.Pointer(pCDS)).FszCompressed = func() u321 { aRead += uintptr(4); return zipfileGetU32(tls, (aRead - uintptr(4))) }() 33374 (*ZipfileCDS)(unsafe.Pointer(pCDS)).FszUncompressed = func() u321 { aRead += uintptr(4); return zipfileGetU32(tls, (aRead - uintptr(4))) }() 33375 33376 (*ZipfileCDS)(unsafe.Pointer(pCDS)).FnFile = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33377 (*ZipfileCDS)(unsafe.Pointer(pCDS)).FnExtra = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33378 (*ZipfileCDS)(unsafe.Pointer(pCDS)).FnComment = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33379 (*ZipfileCDS)(unsafe.Pointer(pCDS)).FiDiskStart = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33380 (*ZipfileCDS)(unsafe.Pointer(pCDS)).FiInternalAttr = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33381 (*ZipfileCDS)(unsafe.Pointer(pCDS)).FiExternalAttr = func() u321 { aRead += uintptr(4); return zipfileGetU32(tls, (aRead - uintptr(4))) }() 33382 (*ZipfileCDS)(unsafe.Pointer(pCDS)).FiOffset = func() u321 { aRead += uintptr(4); return zipfileGetU32(tls, (aRead - uintptr(4))) }() 33383 33384 } 33385 33386 return rc 33387 } 33388 33389 // Decode the LFH record in buffer aBuf into (*pLFH). Return SQLITE_ERROR 33390 // if the record is not well-formed, or SQLITE_OK otherwise. 33391 func zipfileReadLFH(tls *libc.TLS, aBuffer uintptr, pLFH uintptr) int32 { /* zipfile.c:624:12: */ 33392 var aRead uintptr = aBuffer 33393 var rc int32 = SQLITE_OK 33394 33395 var sig u321 = func() u321 { aRead += uintptr(4); return zipfileGetU32(tls, (aRead - uintptr(4))) }() 33396 if sig != uint64(ZIPFILE_SIGNATURE_LFH) { 33397 rc = SQLITE_ERROR 33398 } else { 33399 (*ZipfileLFH)(unsafe.Pointer(pLFH)).FiVersionExtract = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33400 (*ZipfileLFH)(unsafe.Pointer(pLFH)).Fflags = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33401 (*ZipfileLFH)(unsafe.Pointer(pLFH)).FiCompression = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33402 (*ZipfileLFH)(unsafe.Pointer(pLFH)).FmTime = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33403 (*ZipfileLFH)(unsafe.Pointer(pLFH)).FmDate = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33404 (*ZipfileLFH)(unsafe.Pointer(pLFH)).Fcrc32 = func() u321 { aRead += uintptr(4); return zipfileGetU32(tls, (aRead - uintptr(4))) }() 33405 (*ZipfileLFH)(unsafe.Pointer(pLFH)).FszCompressed = func() u321 { aRead += uintptr(4); return zipfileGetU32(tls, (aRead - uintptr(4))) }() 33406 (*ZipfileLFH)(unsafe.Pointer(pLFH)).FszUncompressed = func() u321 { aRead += uintptr(4); return zipfileGetU32(tls, (aRead - uintptr(4))) }() 33407 (*ZipfileLFH)(unsafe.Pointer(pLFH)).FnFile = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33408 (*ZipfileLFH)(unsafe.Pointer(pLFH)).FnExtra = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33409 } 33410 return rc 33411 } 33412 33413 // Buffer aExtra (size nExtra bytes) contains zip archive "extra" fields. 33414 // Scan through this buffer to find an "extra-timestamp" field. If one 33415 // exists, extract the 32-bit modification-timestamp from it and store 33416 // the value in output parameter *pmTime. 33417 // 33418 // Zero is returned if no extra-timestamp record could be found (and so 33419 // *pmTime is left unchanged), or non-zero otherwise. 33420 // 33421 // The general format of an extra field is: 33422 // 33423 // Header ID 2 bytes 33424 // Data Size 2 bytes 33425 // Data N bytes 33426 func zipfileScanExtra(tls *libc.TLS, aExtra uintptr, nExtra int32, pmTime uintptr) int32 { /* zipfile.c:665:12: */ 33427 var ret int32 = 0 33428 var p uintptr = aExtra 33429 var pEnd uintptr = (aExtra + uintptr(nExtra)) 33430 33431 for p < pEnd { 33432 var id u16 = func() u16 { p += uintptr(2); return zipfileGetU16(tls, (p - uintptr(2))) }() 33433 var nByte u16 = func() u16 { p += uintptr(2); return zipfileGetU16(tls, (p - uintptr(2))) }() 33434 33435 switch int32(id) { 33436 case ZIPFILE_EXTRA_TIMESTAMP: 33437 { 33438 var b u8 = *(*u8)(unsafe.Pointer(p)) 33439 if (int32(b) & 0x01) != 0 { // 0x01 -> modtime is present 33440 *(*u321)(unsafe.Pointer(pmTime)) = zipfileGetU32(tls, (p + 1)) 33441 ret = 1 33442 } 33443 break 33444 33445 } 33446 } 33447 33448 p += uintptr(nByte) 33449 } 33450 return ret 33451 } 33452 33453 // Convert the standard MS-DOS timestamp stored in the mTime and mDate 33454 // fields of the CDS structure passed as the only argument to a 32-bit 33455 // UNIX seconds-since-the-epoch timestamp. Return the result. 33456 // 33457 // "Standard" MS-DOS time format: 33458 // 33459 // File modification time: 33460 // Bits 00-04: seconds divided by 2 33461 // Bits 05-10: minute 33462 // Bits 11-15: hour 33463 // File modification date: 33464 // Bits 00-04: day 33465 // Bits 05-08: month (1-12) 33466 // Bits 09-15: years from 1980 33467 // 33468 // https://msdn.microsoft.com/en-us/library/9kkf9tah.aspx 33469 func zipfileMtime(tls *libc.TLS, pCDS uintptr) u321 { /* zipfile.c:708:12: */ 33470 var Y int32 = (1980 + ((int32((*ZipfileCDS)(unsafe.Pointer(pCDS)).FmDate) >> 9) & 0x7F)) 33471 var M int32 = ((int32((*ZipfileCDS)(unsafe.Pointer(pCDS)).FmDate) >> 5) & 0x0F) 33472 var D int32 = (int32((*ZipfileCDS)(unsafe.Pointer(pCDS)).FmDate) & 0x1F) 33473 var B int32 = -13 33474 33475 var sec int32 = ((int32((*ZipfileCDS)(unsafe.Pointer(pCDS)).FmTime) & 0x1F) * 2) 33476 var min int32 = ((int32((*ZipfileCDS)(unsafe.Pointer(pCDS)).FmTime) >> 5) & 0x3F) 33477 var hr int32 = ((int32((*ZipfileCDS)(unsafe.Pointer(pCDS)).FmTime) >> 11) & 0x1F) 33478 var JD i64 33479 33480 // JD = INT(365.25 * (Y+4716)) + INT(30.6001 * (M+1)) + D + B - 1524.5 33481 33482 // Calculate the JD in seconds for noon on the day in question 33483 if M < 3 { 33484 Y = (Y - 1) 33485 M = (M + 12) 33486 } 33487 JD = ((int64((24 * 60) * 60)) * (i64(((((int32(365.25 * (float64(Y + 4716)))) + 33488 (int32(30.6001 * (float64(M + 1))))) + 33489 D) + B) - 1524))) 33490 33491 // Correct the JD for the time within the day 33492 JD = JD + (i64((((hr - 12) * 3600) + (min * 60)) + sec)) 33493 33494 // Convert JD to unix timestamp (the JD epoch is 2440587.5) 33495 return (u321(JD - ((((int64(24405875)) * int64(24)) * int64(60)) * int64(6)))) 33496 } 33497 33498 // The opposite of zipfileMtime(). This function populates the mTime and 33499 // mDate fields of the CDS structure passed as the first argument according 33500 // to the UNIX timestamp value passed as the second. 33501 func zipfileMtimeToDos(tls *libc.TLS, pCds uintptr, mUnixTime u321) { /* zipfile.c:744:13: */ 33502 // Convert unix timestamp to JD (2440588 is noon on 1/1/1970) 33503 var JD i64 = (i64(uint64(int64(2440588)) + (uint64(mUnixTime / (uint64((24 * 60) * 60)))))) 33504 var A int32 33505 var B int32 33506 var C int32 33507 var D int32 33508 var E int32 33509 var yr int32 33510 var mon int32 33511 var day int32 33512 var hr int32 33513 var min int32 33514 var sec int32 33515 33516 A = (int32((float64(JD) - 1867216.25) / 36524.25)) 33517 A = (int32(((JD + int64(1)) + i64(A)) - (i64(A / 4)))) 33518 B = (A + 1524) 33519 C = (int32((float64(B) - 122.1) / 365.25)) 33520 D = ((36525 * (C & 32767)) / 100) 33521 E = (int32((float64(B - D)) / 30.6001)) 33522 33523 day = ((B - D) - (int32(30.6001 * float64(E)))) 33524 mon = func() int32 { 33525 if E < 14 { 33526 return (E - 1) 33527 } 33528 return (E - 13) 33529 }() 33530 if mon > 2 { 33531 yr = (C - 4716) 33532 } else { 33533 yr = (C - 4715) 33534 } 33535 33536 hr = (int32((mUnixTime % (uint64((24 * 60) * 60))) / (uint64(60 * 60)))) 33537 min = (int32((mUnixTime % (uint64(60 * 60))) / uint64(60))) 33538 sec = (int32(mUnixTime % uint64(60))) 33539 33540 if yr >= 1980 { 33541 (*ZipfileCDS)(unsafe.Pointer(pCds)).FmDate = (u16((day + (mon << 5)) + ((yr - 1980) << 9))) 33542 (*ZipfileCDS)(unsafe.Pointer(pCds)).FmTime = (u16(((sec / 2) + (min << 5)) + (hr << 11))) 33543 } else { 33544 (*ZipfileCDS)(unsafe.Pointer(pCds)).FmDate = libc.AssignPtrUint16(pCds+8 /* &.mTime */, u16(0)) 33545 } 33546 33547 } 33548 33549 // If aBlob is not NULL, then it is a pointer to a buffer (nBlob bytes in 33550 // size) containing an entire zip archive image. Or, if aBlob is NULL, 33551 // then pFile is a file-handle open on a zip file. In either case, this 33552 // function creates a ZipfileEntry object based on the zip archive entry 33553 // for which the CDS record is at offset iOff. 33554 // 33555 // If successful, SQLITE_OK is returned and (*ppEntry) set to point to 33556 // the new object. Otherwise, an SQLite error code is returned and the 33557 // final value of (*ppEntry) undefined. 33558 func zipfileGetEntry(tls *libc.TLS, pTab uintptr, aBlob uintptr, nBlob int32, pFile uintptr, iOff i64, ppEntry uintptr) int32 { /* zipfile.c:792:12: */ 33559 bp := tls.Alloc(80) 33560 defer tls.Free(80) 33561 33562 var aRead uintptr 33563 var pzErr uintptr = (pTab /* &.base */ + 16 /* &.zErrMsg */) 33564 var rc int32 = SQLITE_OK 33565 33566 if aBlob == uintptr(0) { 33567 aRead = (*ZipfileTab)(unsafe.Pointer(pTab)).FaBuffer 33568 rc = zipfileReadData(tls, pFile, aRead, ZIPFILE_CDS_FIXED_SZ, iOff, pzErr) 33569 } else { 33570 aRead = (aBlob + uintptr(iOff)) 33571 } 33572 33573 if rc == SQLITE_OK { 33574 var nAlloc sqlite3_int64 33575 var pNew uintptr 33576 33577 var nFile int32 = int32(zipfileGetU16(tls, (aRead + 28))) 33578 var nExtra int32 = int32(zipfileGetU16(tls, (aRead + 30))) 33579 nExtra = nExtra + (int32(zipfileGetU16(tls, (aRead + 32)))) 33580 33581 nAlloc = (sqlite3_int64(uint64(unsafe.Sizeof(ZipfileEntry{})) + uint64(nExtra))) 33582 if aBlob != 0 { 33583 nAlloc = sqlite3_int64(uint64(nAlloc) + (uint64(zipfileGetU32(tls, (aRead + 20))))) 33584 } 33585 33586 pNew = sqlite3.Xsqlite3_malloc64(tls, uint64(nAlloc)) 33587 if pNew == uintptr(0) { 33588 rc = SQLITE_NOMEM 33589 } else { 33590 libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(ZipfileEntry{}))) 33591 rc = zipfileReadCDS(tls, aRead, (pNew /* &.cds */)) 33592 if rc != SQLITE_OK { 33593 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+9099 /* "failed to read C..." */, libc.VaList(bp, iOff)) 33594 } else if aBlob == uintptr(0) { 33595 rc = zipfileReadData(tls, 33596 pFile, aRead, (nExtra + nFile), (iOff + int64(ZIPFILE_CDS_FIXED_SZ)), pzErr) 33597 } else { 33598 aRead = (aBlob + uintptr((iOff + int64(ZIPFILE_CDS_FIXED_SZ)))) 33599 } 33600 } 33601 33602 if rc == SQLITE_OK { 33603 var pt uintptr = (pNew + 80 /* &.mUnixTime */) 33604 (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FzFile = sqlite3.Xsqlite3_mprintf(tls, ts+9133 /* "%.*s" */, libc.VaList(bp+8, nFile, aRead)) 33605 (*ZipfileEntry)(unsafe.Pointer(pNew)).FaExtra = (pNew + 1*120) 33606 libc.Xmemcpy(tls, (*ZipfileEntry)(unsafe.Pointer(pNew)).FaExtra, (aRead + uintptr(nFile)), uint64(nExtra)) 33607 if (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FzFile == uintptr(0) { 33608 rc = SQLITE_NOMEM 33609 } else if 0 == zipfileScanExtra(tls, (aRead+uintptr(nFile)), int32((*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FnExtra), pt) { 33610 (*ZipfileEntry)(unsafe.Pointer(pNew)).FmUnixTime = zipfileMtime(tls, (pNew /* &.cds */)) 33611 } 33612 } 33613 33614 if rc == SQLITE_OK { 33615 // var lfh ZipfileLFH at bp+32, 48 33616 33617 if pFile != 0 { 33618 rc = zipfileReadData(tls, pFile, aRead, szFix, int64((*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FiOffset), pzErr) 33619 } else { 33620 aRead = (aBlob + uintptr((*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FiOffset)) 33621 } 33622 33623 rc = zipfileReadLFH(tls, aRead, bp+32 /* &lfh */) 33624 if rc == SQLITE_OK { 33625 (*ZipfileEntry)(unsafe.Pointer(pNew)).FiDataOff = (i64((*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FiOffset + uint64(ZIPFILE_LFH_FIXED_SZ))) 33626 *(*i64)(unsafe.Pointer(pNew + 96 /* &.iDataOff */)) += (i64(int32((*ZipfileLFH)(unsafe.Pointer(bp+32 /* &lfh */)).FnFile) + int32((*ZipfileLFH)(unsafe.Pointer(bp+32 /* &lfh */)).FnExtra))) 33627 if (aBlob != 0) && ((*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FszCompressed != 0) { 33628 (*ZipfileEntry)(unsafe.Pointer(pNew)).FaData = ((*ZipfileEntry)(unsafe.Pointer(pNew)).FaExtra + uintptr(nExtra)) 33629 libc.Xmemcpy(tls, (*ZipfileEntry)(unsafe.Pointer(pNew)).FaData, (aBlob + uintptr((*ZipfileEntry)(unsafe.Pointer(pNew)).FiDataOff)), (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FszCompressed) 33630 } 33631 } else { 33632 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+9138, /* "failed to read L..." */ 33633 libc.VaList(bp+24, int32((*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FiOffset))) 33634 } 33635 } 33636 33637 if rc != SQLITE_OK { 33638 zipfileEntryFree(tls, pNew) 33639 } else { 33640 *(*uintptr)(unsafe.Pointer(ppEntry)) = pNew 33641 } 33642 } 33643 33644 return rc 33645 } 33646 33647 var szFix int32 = ZIPFILE_LFH_FIXED_SZ /* zipfile.c:854:24 */ 33648 33649 // Advance an ZipfileCsr to its next row of output. 33650 func zipfileNext(tls *libc.TLS, cur uintptr) int32 { /* zipfile.c:890:12: */ 33651 bp := tls.Alloc(8) 33652 defer tls.Free(8) 33653 33654 var pCsr uintptr = cur 33655 var rc int32 = SQLITE_OK 33656 33657 if (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFile != 0 { 33658 var iEof i64 = (i64((*ZipfileCsr)(unsafe.Pointer(pCsr)).Feocd.FiOffset + (*ZipfileCsr)(unsafe.Pointer(pCsr)).Feocd.FnSize)) 33659 zipfileEntryFree(tls, (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent) 33660 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent = uintptr(0) 33661 if (*ZipfileCsr)(unsafe.Pointer(pCsr)).FiNextOff >= iEof { 33662 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FbEof = u8(1) 33663 } else { 33664 *(*uintptr)(unsafe.Pointer(bp /* p */)) = uintptr(0) 33665 var pTab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab 33666 rc = zipfileGetEntry(tls, pTab, uintptr(0), 0, (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFile, (*ZipfileCsr)(unsafe.Pointer(pCsr)).FiNextOff, bp /* &p */) 33667 if rc == SQLITE_OK { 33668 *(*i64)(unsafe.Pointer(pCsr + 32 /* &.iNextOff */)) += (int64(ZIPFILE_CDS_FIXED_SZ)) 33669 *(*i64)(unsafe.Pointer(pCsr + 32 /* &.iNextOff */)) += (i64((int32((*ZipfileEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* p */)))).Fcds.FnExtra) + int32((*ZipfileEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* p */)))).Fcds.FnFile)) + int32((*ZipfileEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* p */)))).Fcds.FnComment))) 33670 } 33671 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent = *(*uintptr)(unsafe.Pointer(bp /* p */)) 33672 } 33673 } else { 33674 if !(int32((*ZipfileCsr)(unsafe.Pointer(pCsr)).FbNoop) != 0) { 33675 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent = (*ZipfileEntry)(unsafe.Pointer((*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent)).FpNext 33676 } 33677 if (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent == uintptr(0) { 33678 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FbEof = u8(1) 33679 } 33680 } 33681 33682 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FbNoop = u8(0) 33683 return rc 33684 } 33685 33686 func zipfileFree(tls *libc.TLS, p uintptr) { /* zipfile.c:923:13: */ 33687 sqlite3.Xsqlite3_free(tls, p) 33688 } 33689 33690 // Buffer aIn (size nIn bytes) contains compressed data. Uncompressed, the 33691 // size is nOut bytes. This function uncompresses the data and sets the 33692 // return value in context pCtx to the result (a blob). 33693 // 33694 // If an error occurs, an error code is left in pCtx instead. 33695 func zipfileInflate(tls *libc.TLS, pCtx uintptr, aIn uintptr, nIn int32, nOut int32) { /* zipfile.c:934:13: */ 33696 bp := tls.Alloc(128) 33697 defer tls.Free(128) 33698 33699 var aRes uintptr = sqlite3.Xsqlite3_malloc(tls, nOut) 33700 if aRes == uintptr(0) { 33701 sqlite3.Xsqlite3_result_error_nomem(tls, pCtx) 33702 } else { 33703 var err int32 33704 // var str z_stream at bp+16, 112 33705 33706 libc.Xmemset(tls, bp+16 /* &str */, 0, uint64(unsafe.Sizeof(z_stream{}))) 33707 33708 (*z_stream)(unsafe.Pointer(bp + 16 /* &str */)).Fnext_in = aIn 33709 (*z_stream)(unsafe.Pointer(bp + 16 /* &str */)).Favail_in = uInt(nIn) 33710 (*z_stream)(unsafe.Pointer(bp + 16 /* &str */)).Fnext_out = aRes 33711 (*z_stream)(unsafe.Pointer(bp + 16 /* &str */)).Favail_out = uInt(nOut) 33712 33713 err = tcl.XinflateInit2_(tls, bp+16 /* &str */, -15, ts+9170 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{}))) 33714 if err != Z_OK { 33715 zipfileCtxErrorMsg(tls, pCtx, ts+9177 /* "inflateInit2() f..." */, libc.VaList(bp, err)) 33716 } else { 33717 err = tcl.Xinflate(tls, bp+16 /* &str */, Z_NO_FLUSH) 33718 if err != Z_STREAM_END { 33719 zipfileCtxErrorMsg(tls, pCtx, ts+9204 /* "inflate() failed..." */, libc.VaList(bp+8, err)) 33720 } else { 33721 sqlite3.Xsqlite3_result_blob(tls, pCtx, aRes, nOut, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{zipfileFree}))) 33722 aRes = uintptr(0) 33723 } 33724 } 33725 sqlite3.Xsqlite3_free(tls, aRes) 33726 tcl.XinflateEnd(tls, bp+16 /* &str */) 33727 } 33728 } 33729 33730 // Buffer aIn (size nIn bytes) contains uncompressed data. This function 33731 // compresses it and sets (*ppOut) to point to a buffer containing the 33732 // compressed data. The caller is responsible for eventually calling 33733 // sqlite3_free() to release buffer (*ppOut). Before returning, (*pnOut) 33734 // is set to the size of buffer (*ppOut) in bytes. 33735 // 33736 // If no error occurs, SQLITE_OK is returned. Otherwise, an SQLite error 33737 // code is returned and an error message left in virtual-table handle 33738 // pTab. The values of (*ppOut) and (*pnOut) are left unchanged in this 33739 // case. 33740 func zipfileDeflate(tls *libc.TLS, aIn uintptr, nIn int32, ppOut uintptr, pnOut uintptr, pzErr uintptr) int32 { /* zipfile.c:982:12: */ 33741 bp := tls.Alloc(112) 33742 defer tls.Free(112) 33743 33744 var rc int32 = SQLITE_OK 33745 var nAlloc sqlite3_int64 33746 // var str z_stream at bp, 112 33747 33748 var aOut uintptr 33749 33750 libc.Xmemset(tls, bp /* &str */, 0, uint64(unsafe.Sizeof(z_stream{}))) 33751 (*z_stream)(unsafe.Pointer(bp /* &str */)).Fnext_in = aIn 33752 (*z_stream)(unsafe.Pointer(bp /* &str */)).Favail_in = uInt(nIn) 33753 tcl.XdeflateInit2_(tls, bp /* &str */, 9, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY, ts+9170 /* "1.2.11" */, int32(unsafe.Sizeof(z_stream{}))) 33754 33755 nAlloc = sqlite3_int64(tcl.XdeflateBound(tls, bp /* &str */, uint64(nIn))) 33756 aOut = sqlite3.Xsqlite3_malloc64(tls, uint64(nAlloc)) 33757 if aOut == uintptr(0) { 33758 rc = SQLITE_NOMEM 33759 } else { 33760 var res int32 33761 (*z_stream)(unsafe.Pointer(bp /* &str */)).Fnext_out = aOut 33762 (*z_stream)(unsafe.Pointer(bp /* &str */)).Favail_out = uInt(nAlloc) 33763 res = tcl.Xdeflate(tls, bp /* &str */, Z_FINISH) 33764 if res == Z_STREAM_END { 33765 *(*uintptr)(unsafe.Pointer(ppOut)) = aOut 33766 *(*int32)(unsafe.Pointer(pnOut)) = int32((*z_stream)(unsafe.Pointer(bp /* &str */)).Ftotal_out) 33767 } else { 33768 sqlite3.Xsqlite3_free(tls, aOut) 33769 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+9226 /* "zipfile: deflate..." */, 0) 33770 rc = SQLITE_ERROR 33771 } 33772 tcl.XdeflateEnd(tls, bp /* &str */) 33773 } 33774 33775 return rc 33776 } 33777 33778 // Return values of columns for the row at which the series_cursor 33779 // is currently pointing. 33780 func zipfileColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* zipfile.c:1025:12: */ 33781 var pCsr uintptr = cur 33782 var pCDS uintptr = ((*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent /* &.cds */) 33783 var rc int32 = SQLITE_OK 33784 switch i { 33785 case 0: // name 33786 sqlite3.Xsqlite3_result_text(tls, ctx, (*ZipfileCDS)(unsafe.Pointer(pCDS)).FzFile, -1, libc.UintptrFromInt32(-1)) 33787 break 33788 case 1: // mode 33789 // TODO: Whether or not the following is correct surely depends on 33790 // the platform on which the archive was created. 33791 sqlite3.Xsqlite3_result_int(tls, ctx, (int32((*ZipfileCDS)(unsafe.Pointer(pCDS)).FiExternalAttr >> 16))) 33792 break 33793 case 2: 33794 { // mtime 33795 sqlite3.Xsqlite3_result_int64(tls, ctx, int64((*ZipfileEntry)(unsafe.Pointer((*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent)).FmUnixTime)) 33796 break 33797 33798 } 33799 case 3: 33800 { // sz 33801 if sqlite3.Xsqlite3_vtab_nochange(tls, ctx) == 0 { 33802 sqlite3.Xsqlite3_result_int64(tls, ctx, int64((*ZipfileCDS)(unsafe.Pointer(pCDS)).FszUncompressed)) 33803 } 33804 break 33805 33806 } 33807 case 4: // rawdata 33808 if sqlite3.Xsqlite3_vtab_nochange(tls, ctx) != 0 { 33809 break 33810 } 33811 fallthrough 33812 case 5: 33813 { // data 33814 if ((i == 4) || (int32((*ZipfileCDS)(unsafe.Pointer(pCDS)).FiCompression) == 0)) || (int32((*ZipfileCDS)(unsafe.Pointer(pCDS)).FiCompression) == 8) { 33815 var sz int32 = int32((*ZipfileCDS)(unsafe.Pointer(pCDS)).FszCompressed) 33816 var szFinal int32 = int32((*ZipfileCDS)(unsafe.Pointer(pCDS)).FszUncompressed) 33817 if szFinal > 0 { 33818 var aBuf uintptr 33819 var aFree uintptr = uintptr(0) 33820 if (*ZipfileEntry)(unsafe.Pointer((*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent)).FaData != 0 { 33821 aBuf = (*ZipfileEntry)(unsafe.Pointer((*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent)).FaData 33822 } else { 33823 aBuf = libc.AssignUintptr(&aFree, sqlite3.Xsqlite3_malloc64(tls, uint64(sz))) 33824 if aBuf == uintptr(0) { 33825 rc = SQLITE_NOMEM 33826 } else { 33827 var pFile uintptr = (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFile 33828 if pFile == uintptr(0) { 33829 pFile = (*ZipfileTab)(unsafe.Pointer((*ZipfileCsr)(unsafe.Pointer(pCsr)).Fbase.FpVtab)).FpWriteFd 33830 } 33831 rc = zipfileReadData(tls, pFile, aBuf, sz, (*ZipfileEntry)(unsafe.Pointer((*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent)).FiDataOff, 33832 ((*ZipfileCsr)(unsafe.Pointer(pCsr)).Fbase.FpVtab + 16 /* &.zErrMsg */)) 33833 } 33834 } 33835 if rc == SQLITE_OK { 33836 if (i == 5) && ((*ZipfileCDS)(unsafe.Pointer(pCDS)).FiCompression != 0) { 33837 zipfileInflate(tls, ctx, aBuf, sz, szFinal) 33838 } else { 33839 sqlite3.Xsqlite3_result_blob(tls, ctx, aBuf, sz, libc.UintptrFromInt32(-1)) 33840 } 33841 } 33842 sqlite3.Xsqlite3_free(tls, aFree) 33843 } else { 33844 // Figure out if this is a directory or a zero-sized file. Consider 33845 // it to be a directory either if the mode suggests so, or if 33846 // the final character in the name is '/'. 33847 var mode u321 = ((*ZipfileCDS)(unsafe.Pointer(pCDS)).FiExternalAttr >> 16) 33848 if !((mode & uint64(S_IFDIR)) != 0) && (int32(*(*int8)(unsafe.Pointer((*ZipfileCDS)(unsafe.Pointer(pCDS)).FzFile + uintptr((int32((*ZipfileCDS)(unsafe.Pointer(pCDS)).FnFile) - 1))))) != '/') { 33849 sqlite3.Xsqlite3_result_blob(tls, ctx, ts+489 /* "" */, 0, uintptr(0)) 33850 } 33851 } 33852 } 33853 break 33854 33855 } 33856 case 6: // method 33857 sqlite3.Xsqlite3_result_int(tls, ctx, int32((*ZipfileCDS)(unsafe.Pointer(pCDS)).FiCompression)) 33858 break 33859 default: // z 33860 33861 sqlite3.Xsqlite3_result_int64(tls, ctx, (*ZipfileCsr)(unsafe.Pointer(pCsr)).FiId) 33862 break 33863 } 33864 33865 return rc 33866 } 33867 33868 // Return TRUE if the cursor is at EOF. 33869 func zipfileEof(tls *libc.TLS, cur uintptr) int32 { /* zipfile.c:1112:12: */ 33870 var pCsr uintptr = cur 33871 return int32((*ZipfileCsr)(unsafe.Pointer(pCsr)).FbEof) 33872 } 33873 33874 // If aBlob is not NULL, then it points to a buffer nBlob bytes in size 33875 // containing an entire zip archive image. Or, if aBlob is NULL, then pFile 33876 // is guaranteed to be a file-handle open on a zip file. 33877 // 33878 // This function attempts to locate the EOCD record within the zip archive 33879 // and populate *pEOCD with the results of decoding it. SQLITE_OK is 33880 // returned if successful. Otherwise, an SQLite error code is returned and 33881 // an English language error message may be left in virtual-table pTab. 33882 func zipfileReadEOCD(tls *libc.TLS, pTab uintptr, aBlob uintptr, nBlob int32, pFile uintptr, pEOCD uintptr) int32 { /* zipfile.c:1127:12: */ 33883 var aRead uintptr = (*ZipfileTab)(unsafe.Pointer(pTab)).FaBuffer // Temporary buffer 33884 var nRead int32 // Bytes to read from file 33885 var rc int32 = SQLITE_OK 33886 33887 if aBlob == uintptr(0) { 33888 var iOff i64 // Offset to read from 33889 var szFile i64 // Total size of file in bytes 33890 libc.Xfseek(tls, pFile, int64(0), SEEK_END) 33891 szFile = i64(libc.Xftell(tls, pFile)) 33892 if szFile == int64(0) { 33893 libc.Xmemset(tls, pEOCD, 0, uint64(unsafe.Sizeof(ZipfileEOCD{}))) 33894 return SQLITE_OK 33895 } 33896 nRead = func() int32 { 33897 if (szFile) < (int64(64 * 1024)) { 33898 return int32(szFile) 33899 } 33900 return (64 * 1024) 33901 }() 33902 iOff = (szFile - i64(nRead)) 33903 rc = zipfileReadData(tls, pFile, aRead, nRead, iOff, (pTab /* &.base */ + 16 /* &.zErrMsg */)) 33904 } else { 33905 nRead = func() int32 { 33906 if (nBlob) < (64 * 1024) { 33907 return nBlob 33908 } 33909 return (64 * 1024) 33910 }() 33911 aRead = (aBlob + uintptr((nBlob - nRead))) 33912 } 33913 33914 if rc == SQLITE_OK { 33915 var i int32 33916 33917 // Scan backwards looking for the signature bytes 33918 for i = (nRead - 20); i >= 0; i-- { 33919 if (((int32(*(*u8)(unsafe.Pointer(aRead + uintptr(i)))) == 0x50) && (int32(*(*u8)(unsafe.Pointer(aRead + uintptr((i + 1))))) == 0x4b)) && 33920 (int32(*(*u8)(unsafe.Pointer(aRead + uintptr((i + 2))))) == 0x05)) && (int32(*(*u8)(unsafe.Pointer(aRead + uintptr((i + 3))))) == 0x06) { 33921 break 33922 } 33923 } 33924 if i < 0 { 33925 (*ZipfileTab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, 33926 ts+9251 /* "cannot find end ..." */, 0) 33927 return SQLITE_ERROR 33928 } 33929 33930 aRead += (uintptr(i + 4)) 33931 (*ZipfileEOCD)(unsafe.Pointer(pEOCD)).FiDisk = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33932 (*ZipfileEOCD)(unsafe.Pointer(pEOCD)).FiFirstDisk = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33933 (*ZipfileEOCD)(unsafe.Pointer(pEOCD)).FnEntry = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33934 (*ZipfileEOCD)(unsafe.Pointer(pEOCD)).FnEntryTotal = func() u16 { aRead += uintptr(2); return zipfileGetU16(tls, (aRead - uintptr(2))) }() 33935 (*ZipfileEOCD)(unsafe.Pointer(pEOCD)).FnSize = func() u321 { aRead += uintptr(4); return zipfileGetU32(tls, (aRead - uintptr(4))) }() 33936 (*ZipfileEOCD)(unsafe.Pointer(pEOCD)).FiOffset = func() u321 { aRead += uintptr(4); return zipfileGetU32(tls, (aRead - uintptr(4))) }() 33937 } 33938 33939 return rc 33940 } 33941 33942 // Add object pNew to the linked list that begins at ZipfileTab.pFirstEntry 33943 // and ends with pLastEntry. If argument pBefore is NULL, then pNew is added 33944 // to the end of the list. Otherwise, it is added to the list immediately 33945 // before pBefore (which is guaranteed to be a part of said list). 33946 func zipfileAddEntry(tls *libc.TLS, pTab uintptr, pBefore uintptr, pNew uintptr) { /* zipfile.c:1191:13: */ 33947 33948 if pBefore == uintptr(0) { 33949 if (*ZipfileTab)(unsafe.Pointer(pTab)).FpFirstEntry == uintptr(0) { 33950 (*ZipfileTab)(unsafe.Pointer(pTab)).FpFirstEntry = libc.AssignPtrUintptr(pTab+72 /* &.pLastEntry */, pNew) 33951 } else { 33952 33953 (*ZipfileEntry)(unsafe.Pointer((*ZipfileTab)(unsafe.Pointer(pTab)).FpLastEntry)).FpNext = pNew 33954 (*ZipfileTab)(unsafe.Pointer(pTab)).FpLastEntry = pNew 33955 } 33956 } else { 33957 var pp uintptr 33958 for pp = (pTab + 64 /* &.pFirstEntry */); *(*uintptr)(unsafe.Pointer(pp)) != pBefore; pp = (*(*uintptr)(unsafe.Pointer(pp)) + 112 /* &.pNext */) { 33959 } 33960 (*ZipfileEntry)(unsafe.Pointer(pNew)).FpNext = pBefore 33961 *(*uintptr)(unsafe.Pointer(pp)) = pNew 33962 } 33963 } 33964 33965 func zipfileLoadDirectory(tls *libc.TLS, pTab uintptr, aBlob uintptr, nBlob int32) int32 { /* zipfile.c:1214:12: */ 33966 bp := tls.Alloc(32) 33967 defer tls.Free(32) 33968 33969 // var eocd ZipfileEOCD at bp, 24 33970 33971 var rc int32 33972 var i int32 33973 var iOff i64 33974 33975 rc = zipfileReadEOCD(tls, pTab, aBlob, nBlob, (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd, bp /* &eocd */) 33976 iOff = i64((*ZipfileEOCD)(unsafe.Pointer(bp /* &eocd */)).FiOffset) 33977 for i = 0; (rc == SQLITE_OK) && (i < int32((*ZipfileEOCD)(unsafe.Pointer(bp /* &eocd */)).FnEntry)); i++ { 33978 *(*uintptr)(unsafe.Pointer(bp + 24 /* pNew */)) = uintptr(0) 33979 rc = zipfileGetEntry(tls, pTab, aBlob, nBlob, (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd, iOff, bp+24 /* &pNew */) 33980 33981 if rc == SQLITE_OK { 33982 zipfileAddEntry(tls, pTab, uintptr(0), *(*uintptr)(unsafe.Pointer(bp + 24 /* pNew */))) 33983 iOff = iOff + (int64(ZIPFILE_CDS_FIXED_SZ)) 33984 iOff = iOff + (i64((int32((*ZipfileEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pNew */)))).Fcds.FnExtra) + int32((*ZipfileEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pNew */)))).Fcds.FnFile)) + int32((*ZipfileEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pNew */)))).Fcds.FnComment))) 33985 } 33986 } 33987 return rc 33988 } 33989 33990 // xFilter callback. 33991 func zipfileFilter(tls *libc.TLS, cur uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* zipfile.c:1238:12: */ 33992 bp := tls.Alloc(8) 33993 defer tls.Free(8) 33994 33995 var pTab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab 33996 var pCsr uintptr = cur 33997 var zFile uintptr = uintptr(0) // Zip file to scan 33998 var rc int32 = SQLITE_OK // Return Code 33999 var bInMemory int32 = 0 // True for an in-memory zipfile 34000 34001 zipfileResetCursor(tls, pCsr) 34002 34003 if (*ZipfileTab)(unsafe.Pointer(pTab)).FzFile != 0 { 34004 zFile = (*ZipfileTab)(unsafe.Pointer(pTab)).FzFile 34005 } else if idxNum == 0 { 34006 zipfileCursorErr(tls, pCsr, ts+9295 /* "zipfile() functi..." */, 0) 34007 return SQLITE_ERROR 34008 } else if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_BLOB { 34009 var aBlob uintptr = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) 34010 var nBlob int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) 34011 34012 rc = zipfileLoadDirectory(tls, pTab, aBlob, nBlob) 34013 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFreeEntry = (*ZipfileTab)(unsafe.Pointer(pTab)).FpFirstEntry 34014 (*ZipfileTab)(unsafe.Pointer(pTab)).FpFirstEntry = libc.AssignPtrUintptr(pTab+72 /* &.pLastEntry */, uintptr(0)) 34015 if rc != SQLITE_OK { 34016 return rc 34017 } 34018 bInMemory = 1 34019 } else { 34020 zFile = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 34021 } 34022 34023 if (uintptr(0) == (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd) && (0 == bInMemory) { 34024 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFile = libc.Xfopen(tls, zFile, ts+4273 /* "rb" */) 34025 if (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFile == uintptr(0) { 34026 zipfileCursorErr(tls, pCsr, ts+9335 /* "cannot open file..." */, libc.VaList(bp, zFile)) 34027 rc = SQLITE_ERROR 34028 } else { 34029 rc = zipfileReadEOCD(tls, pTab, uintptr(0), 0, (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFile, (pCsr + 40 /* &.eocd */)) 34030 if rc == SQLITE_OK { 34031 if int32((*ZipfileCsr)(unsafe.Pointer(pCsr)).Feocd.FnEntry) == 0 { 34032 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FbEof = u8(1) 34033 } else { 34034 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FiNextOff = i64((*ZipfileCsr)(unsafe.Pointer(pCsr)).Feocd.FiOffset) 34035 rc = zipfileNext(tls, cur) 34036 } 34037 } 34038 } 34039 } else { 34040 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FbNoop = u8(1) 34041 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent = func() uintptr { 34042 if (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFreeEntry != 0 { 34043 return (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpFreeEntry 34044 } 34045 return (*ZipfileTab)(unsafe.Pointer(pTab)).FpFirstEntry 34046 }() 34047 rc = zipfileNext(tls, cur) 34048 } 34049 34050 return rc 34051 } 34052 34053 // xBestIndex callback. 34054 func zipfileBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* zipfile.c:1297:12: */ 34055 var i int32 34056 var idx int32 = -1 34057 var unusable int32 = 0 34058 34059 for i = 0; i < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; i++ { 34060 var pCons uintptr = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(i)*12) 34061 if (*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn != ZIPFILE_F_COLUMN_IDX { 34062 continue 34063 } 34064 if int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fusable) == 0 { 34065 unusable = 1 34066 } else if int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ { 34067 idx = i 34068 } 34069 } 34070 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 1000.0 34071 if idx >= 0 { 34072 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(idx)*8)).FargvIndex = 1 34073 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(idx)*8)).Fomit = uint8(1) 34074 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 1 34075 } else if unusable != 0 { 34076 return SQLITE_CONSTRAINT 34077 } 34078 return SQLITE_OK 34079 } 34080 34081 func zipfileNewEntry(tls *libc.TLS, zPath uintptr) uintptr { /* zipfile.c:1325:21: */ 34082 bp := tls.Alloc(8) 34083 defer tls.Free(8) 34084 34085 var pNew uintptr 34086 pNew = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(ZipfileEntry{}))) 34087 if pNew != 0 { 34088 libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(ZipfileEntry{}))) 34089 (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FzFile = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zPath)) 34090 if (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FzFile == uintptr(0) { 34091 sqlite3.Xsqlite3_free(tls, pNew) 34092 pNew = uintptr(0) 34093 } 34094 } 34095 return pNew 34096 } 34097 34098 func zipfileSerializeLFH(tls *libc.TLS, pEntry uintptr, aBuf uintptr) int32 { /* zipfile.c:1339:12: */ 34099 var pCds uintptr = (pEntry /* &.cds */) 34100 var a uintptr = aBuf 34101 34102 (*ZipfileCDS)(unsafe.Pointer(pCds)).FnExtra = u16(9) 34103 34104 /* Write the LFH itself */ 34105 { 34106 zipfilePutU32(tls, a, uint64(ZIPFILE_SIGNATURE_LFH)) 34107 a += uintptr(4) 34108 } 34109 34110 { 34111 zipfilePutU16(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCds)).FiVersionExtract) 34112 a += uintptr(2) 34113 } 34114 34115 { 34116 zipfilePutU16(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCds)).Fflags) 34117 a += uintptr(2) 34118 } 34119 34120 { 34121 zipfilePutU16(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCds)).FiCompression) 34122 a += uintptr(2) 34123 } 34124 34125 { 34126 zipfilePutU16(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCds)).FmTime) 34127 a += uintptr(2) 34128 } 34129 34130 { 34131 zipfilePutU16(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCds)).FmDate) 34132 a += uintptr(2) 34133 } 34134 34135 { 34136 zipfilePutU32(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCds)).Fcrc32) 34137 a += uintptr(4) 34138 } 34139 34140 { 34141 zipfilePutU32(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCds)).FszCompressed) 34142 a += uintptr(4) 34143 } 34144 34145 { 34146 zipfilePutU32(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCds)).FszUncompressed) 34147 a += uintptr(4) 34148 } 34149 34150 { 34151 zipfilePutU16(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCds)).FnFile) 34152 a += uintptr(2) 34153 } 34154 34155 { 34156 zipfilePutU16(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCds)).FnExtra) 34157 a += uintptr(2) 34158 } 34159 34160 // Add the file name 34161 libc.Xmemcpy(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCds)).FzFile, uint64(int32((*ZipfileCDS)(unsafe.Pointer(pCds)).FnFile))) 34162 a += uintptr(int32((*ZipfileCDS)(unsafe.Pointer(pCds)).FnFile)) 34163 34164 /* The "extra" data */ 34165 { 34166 zipfilePutU16(tls, a, uint16(ZIPFILE_EXTRA_TIMESTAMP)) 34167 a += uintptr(2) 34168 } 34169 34170 { 34171 zipfilePutU16(tls, a, uint16(5)) 34172 a += uintptr(2) 34173 } 34174 34175 *(*u8)(unsafe.Pointer(libc.PostIncUintptr(&a, 1))) = u8(0x01) 34176 { 34177 zipfilePutU32(tls, a, (*ZipfileEntry)(unsafe.Pointer(pEntry)).FmUnixTime) 34178 a += uintptr(4) 34179 } 34180 34181 return (int32((int64(a) - int64(aBuf)) / 1)) 34182 } 34183 34184 func zipfileAppendEntry(tls *libc.TLS, pTab uintptr, pEntry uintptr, pData uintptr, nData int32) int32 { /* zipfile.c:1372:12: */ 34185 var aBuf uintptr = (*ZipfileTab)(unsafe.Pointer(pTab)).FaBuffer 34186 var nBuf int32 34187 var rc int32 34188 34189 nBuf = zipfileSerializeLFH(tls, pEntry, aBuf) 34190 rc = zipfileAppendData(tls, pTab, aBuf, nBuf) 34191 if rc == SQLITE_OK { 34192 (*ZipfileEntry)(unsafe.Pointer(pEntry)).FiDataOff = (*ZipfileTab)(unsafe.Pointer(pTab)).FszCurrent 34193 rc = zipfileAppendData(tls, pTab, pData, nData) 34194 } 34195 34196 return rc 34197 } 34198 34199 func zipfileGetMode(tls *libc.TLS, pVal uintptr, bIsDir int32, pMode uintptr, pzErr uintptr) int32 { /* zipfile.c:1392:12: */ 34200 bp := tls.Alloc(19) 34201 defer tls.Free(19) 34202 34203 var z uintptr 34204 var mode u321 34205 // var zTemplate [11]int8 at bp+8, 11 34206 34207 var i int32 34208 z = sqlite3.Xsqlite3_value_text(tls, pVal) 34209 mode = uint64(0) 34210 if !(z == uintptr(0)) { 34211 goto __1 34212 } 34213 mode = func() uint64 { 34214 if bIsDir != 0 { 34215 return (uint64(S_IFDIR + 0755)) 34216 } 34217 return (uint64(S_IFREG + 0644)) 34218 }() 34219 goto __2 34220 __1: 34221 if !((int32(*(*int8)(unsafe.Pointer(z))) >= '0') && (int32(*(*int8)(unsafe.Pointer(z))) <= '9')) { 34222 goto __3 34223 } 34224 mode = u321(uint32(sqlite3.Xsqlite3_value_int(tls, pVal))) 34225 goto __4 34226 __3: 34227 *(*[11]int8)(unsafe.Pointer(bp + 8 /* zTemplate */)) = *(*[11]int8)(unsafe.Pointer(ts + 9356 /* "-rwxrwxrwx" */)) 34228 if !(libc.Xstrlen(tls, z) != uint64(10)) { 34229 goto __5 34230 } 34231 goto parse_error 34232 __5: 34233 ; 34234 switch int32(*(*int8)(unsafe.Pointer(z))) { 34235 case '-': 34236 goto __7 34237 case 'd': 34238 goto __8 34239 case 'l': 34240 goto __9 34241 default: 34242 goto __10 34243 } 34244 goto __6 34245 __7: 34246 mode = mode | (uint64(S_IFREG)) 34247 goto __6 34248 __8: 34249 mode = mode | (uint64(S_IFDIR)) 34250 goto __6 34251 __9: 34252 mode = mode | (uint64(S_IFLNK)) 34253 goto __6 34254 __10: 34255 goto parse_error 34256 __6: 34257 ; 34258 i = 1 34259 __11: 34260 if !(i < 10) { 34261 goto __13 34262 } 34263 if !(int32(*(*int8)(unsafe.Pointer(z + uintptr(i)))) == int32(*(*int8)(unsafe.Pointer(bp + 8 /* &zTemplate[0] */ + uintptr(i))))) { 34264 goto __14 34265 } 34266 mode = mode | (u321(int32(1) << (9 - i))) 34267 goto __15 34268 __14: 34269 if !(int32(*(*int8)(unsafe.Pointer(z + uintptr(i)))) != '-') { 34270 goto __16 34271 } 34272 goto parse_error 34273 __16: 34274 ; 34275 __15: 34276 ; 34277 goto __12 34278 __12: 34279 i++ 34280 goto __11 34281 goto __13 34282 __13: 34283 ; 34284 __4: 34285 ; 34286 __2: 34287 ; 34288 if !((libc.Bool32((mode & uint64(S_IFDIR)) == uint64(0))) == bIsDir) { 34289 goto __17 34290 } 34291 // The "mode" attribute is a directory, but data has been specified. 34292 // Or vice-versa - no data but "mode" is a file or symlink. 34293 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+9367 /* "zipfile: mode do..." */, 0) 34294 return SQLITE_CONSTRAINT 34295 __17: 34296 ; 34297 *(*u321)(unsafe.Pointer(pMode)) = mode 34298 return SQLITE_OK 34299 34300 parse_error: 34301 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+9401 /* "zipfile: parse e..." */, libc.VaList(bp, z)) 34302 return SQLITE_ERROR 34303 } 34304 34305 // 34306 // Both (const char*) arguments point to nul-terminated strings. Argument 34307 // nB is the value of strlen(zB). This function returns 0 if the strings are 34308 // identical, ignoring any trailing '/' character in either path. 34309 func zipfileComparePath(tls *libc.TLS, zA uintptr, zB uintptr, nB int32) int32 { /* zipfile.c:1437:12: */ 34310 var nA int32 = int32(libc.Xstrlen(tls, zA)) 34311 if (nA > 0) && (int32(*(*int8)(unsafe.Pointer(zA + uintptr((nA - 1))))) == '/') { 34312 nA-- 34313 } 34314 if (nB > 0) && (int32(*(*int8)(unsafe.Pointer(zB + uintptr((nB - 1))))) == '/') { 34315 nB-- 34316 } 34317 if (nA == nB) && (libc.Xmemcmp(tls, zA, zB, uint64(nA)) == 0) { 34318 return 0 34319 } 34320 return 1 34321 } 34322 34323 func zipfileBegin(tls *libc.TLS, pVtab uintptr) int32 { /* zipfile.c:1445:12: */ 34324 bp := tls.Alloc(8) 34325 defer tls.Free(8) 34326 34327 var pTab uintptr = pVtab 34328 var rc int32 = SQLITE_OK 34329 34330 if ((*ZipfileTab)(unsafe.Pointer(pTab)).FzFile == uintptr(0)) || (int32(*(*int8)(unsafe.Pointer((*ZipfileTab)(unsafe.Pointer(pTab)).FzFile))) == 0) { 34331 (*ZipfileTab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+9434 /* "zipfile: missing..." */, 0) 34332 return SQLITE_ERROR 34333 } 34334 34335 // Open a write fd on the file. Also load the entire central directory 34336 // structure into memory. During the transaction any new file data is 34337 // appended to the archive file, but the central directory is accumulated 34338 // in main-memory until the transaction is committed. 34339 (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd = libc.Xfopen(tls, (*ZipfileTab)(unsafe.Pointer(pTab)).FzFile, ts+9460 /* "ab+" */) 34340 if (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd == uintptr(0) { 34341 (*ZipfileTab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, 34342 ts+9464 /* "zipfile: failed ..." */, libc.VaList(bp, (*ZipfileTab)(unsafe.Pointer(pTab)).FzFile)) 34343 rc = SQLITE_ERROR 34344 } else { 34345 libc.Xfseek(tls, (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd, int64(0), SEEK_END) 34346 (*ZipfileTab)(unsafe.Pointer(pTab)).FszCurrent = libc.AssignPtrInt64(pTab+96 /* &.szOrig */, i64(libc.Xftell(tls, (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd))) 34347 rc = zipfileLoadDirectory(tls, pTab, uintptr(0), 0) 34348 } 34349 34350 if rc != SQLITE_OK { 34351 zipfileCleanupTransaction(tls, pTab) 34352 } 34353 34354 return rc 34355 } 34356 34357 // Return the current time as a 32-bit timestamp in UNIX epoch format (like 34358 // time(2)). 34359 func zipfileTime(tls *libc.TLS) u321 { /* zipfile.c:1482:12: */ 34360 bp := tls.Alloc(16) 34361 defer tls.Free(16) 34362 34363 var pVfs uintptr = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 34364 var ret u321 34365 if ((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FiVersion >= 2) && ((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FxCurrentTimeInt64 != 0) { 34366 // var ms i64 at bp, 8 34367 34368 (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pVfs + 136 /* &.xCurrentTimeInt64 */))))(tls, pVfs, bp /* &ms */) 34369 ret = (u321((*(*i64)(unsafe.Pointer(bp /* ms */)) / int64(1000)) - (int64(24405875) * int64(8640)))) 34370 } else { 34371 // var day float64 at bp+8, 8 34372 34373 (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pVfs + 120 /* &.xCurrentTime */))))(tls, pVfs, bp+8 /* &day */) 34374 ret = (u321((*(*float64)(unsafe.Pointer(bp + 8 /* day */)) - 2440587.5) * float64(86400))) 34375 } 34376 return ret 34377 } 34378 34379 // Return a 32-bit timestamp in UNIX epoch format. 34380 // 34381 // If the value passed as the only argument is either NULL or an SQL NULL, 34382 // return the current time. Otherwise, return the value stored in (*pVal) 34383 // cast to a 32-bit unsigned integer. 34384 func zipfileGetTime(tls *libc.TLS, pVal uintptr) u321 { /* zipfile.c:1504:12: */ 34385 if (pVal == uintptr(0)) || (sqlite3.Xsqlite3_value_type(tls, pVal) == SQLITE_NULL) { 34386 return zipfileTime(tls) 34387 } 34388 return u321(sqlite3.Xsqlite3_value_int64(tls, pVal)) 34389 } 34390 34391 // Unless it is NULL, entry pOld is currently part of the pTab->pFirstEntry 34392 // linked list. Remove it from the list and free the object. 34393 func zipfileRemoveEntryFromList(tls *libc.TLS, pTab uintptr, pOld uintptr) { /* zipfile.c:1515:13: */ 34394 if pOld != 0 { 34395 var pp uintptr 34396 for pp = (pTab + 64 /* &.pFirstEntry */); (*(*uintptr)(unsafe.Pointer(pp))) != pOld; pp = (*(*uintptr)(unsafe.Pointer(pp)) + 112 /* &.pNext */) { 34397 } 34398 *(*uintptr)(unsafe.Pointer(pp)) = (*ZipfileEntry)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pp)))).FpNext 34399 zipfileEntryFree(tls, pOld) 34400 } 34401 } 34402 34403 // xUpdate method. 34404 func zipfileUpdate(tls *libc.TLS, pVtab uintptr, nVal int32, apVal uintptr, pRowid uintptr) int32 { /* zipfile.c:1527:12: */ 34405 bp := tls.Alloc(48) 34406 defer tls.Free(48) 34407 34408 var pTab uintptr 34409 var rc int32 // Return Code 34410 var pNew uintptr // New in-memory CDS entry 34411 34412 // var mode u321 at bp+40, 8 34413 // Mode for new entry 34414 var mTime u321 // Modification time for new entry 34415 var sz i64 // Uncompressed size 34416 var zPath uintptr // Path for new entry 34417 var nPath int32 // strlen(zPath) 34418 var pData uintptr // Pointer to buffer containing content 34419 var nData int32 // Size of pData buffer in bytes 34420 var iMethod int32 // Compression method for new entry 34421 // var pFree uintptr at bp+24, 8 34422 // Free this 34423 var zFree uintptr // Also free this 34424 var pOld uintptr 34425 var pOld2 uintptr 34426 var bUpdate int32 // True for an update that modifies "name" 34427 var bIsDir int32 34428 var iCrc32 u321 34429 var zUpdate uintptr 34430 var zDelete uintptr 34431 var nDelete int32 34432 // var nCmp int32 at bp+32, 4 34433 34434 // Value specified for "data", and possibly "method". This must be 34435 // a regular file or a symlink. 34436 var aIn uintptr 34437 var nIn int32 34438 var bAuto int32 34439 var p uintptr 34440 var pCsr uintptr 34441 pTab = pVtab 34442 rc = SQLITE_OK 34443 pNew = uintptr(0) 34444 *(*u321)(unsafe.Pointer(bp + 40 /* mode */)) = uint64(0) 34445 mTime = uint64(0) 34446 sz = int64(0) 34447 zPath = uintptr(0) 34448 nPath = 0 34449 pData = uintptr(0) 34450 nData = 0 34451 iMethod = 0 34452 *(*uintptr)(unsafe.Pointer(bp + 24 /* pFree */)) = uintptr(0) 34453 zFree = uintptr(0) 34454 pOld = uintptr(0) 34455 pOld2 = uintptr(0) 34456 bUpdate = 0 34457 bIsDir = 0 34458 iCrc32 = uint64(0) 34459 34460 if !((*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd == uintptr(0)) { 34461 goto __1 34462 } 34463 rc = zipfileBegin(tls, pVtab) 34464 if !(rc != SQLITE_OK) { 34465 goto __2 34466 } 34467 return rc 34468 __2: 34469 ; 34470 __1: 34471 ; 34472 34473 // If this is a DELETE or UPDATE, find the archive entry to delete. 34474 if !(sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal))) != SQLITE_NULL) { 34475 goto __3 34476 } 34477 zDelete = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal))) 34478 nDelete = int32(libc.Xstrlen(tls, zDelete)) 34479 if !(nVal > 1) { 34480 goto __4 34481 } 34482 zUpdate = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + 1*8))) 34483 if !((zUpdate != 0) && (zipfileComparePath(tls, zUpdate, zDelete, nDelete) != 0)) { 34484 goto __5 34485 } 34486 bUpdate = 1 34487 __5: 34488 ; 34489 __4: 34490 ; 34491 pOld = (*ZipfileTab)(unsafe.Pointer(pTab)).FpFirstEntry 34492 __6: 34493 if !(1 != 0) { 34494 goto __8 34495 } 34496 if !(zipfileComparePath(tls, (*ZipfileEntry)(unsafe.Pointer(pOld)).Fcds.FzFile, zDelete, nDelete) == 0) { 34497 goto __9 34498 } 34499 goto __8 34500 __9: 34501 ; 34502 34503 goto __7 34504 __7: 34505 pOld = (*ZipfileEntry)(unsafe.Pointer(pOld)).FpNext 34506 goto __6 34507 goto __8 34508 __8: 34509 ; 34510 __3: 34511 ; 34512 34513 if !(nVal > 1) { 34514 goto __10 34515 } 34516 // Check that "sz" and "rawdata" are both NULL: 34517 if !(sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + 5*8))) != SQLITE_NULL) { 34518 goto __11 34519 } 34520 zipfileTableErr(tls, pTab, ts+9508 /* "sz must be NULL" */, 0) 34521 rc = SQLITE_CONSTRAINT 34522 __11: 34523 ; 34524 if !(sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + 6*8))) != SQLITE_NULL) { 34525 goto __12 34526 } 34527 zipfileTableErr(tls, pTab, ts+9524 /* "rawdata must be ..." */, 0) 34528 rc = SQLITE_CONSTRAINT 34529 __12: 34530 ; 34531 34532 if !(rc == SQLITE_OK) { 34533 goto __13 34534 } 34535 if !(sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + 7*8))) == SQLITE_NULL) { 34536 goto __14 34537 } 34538 // data=NULL. A directory 34539 bIsDir = 1 34540 goto __15 34541 __14: 34542 // Value specified for "data", and possibly "method". This must be 34543 // a regular file or a symlink. 34544 aIn = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apVal + 7*8))) 34545 nIn = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal + 7*8))) 34546 bAuto = (libc.Bool32(sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apVal + 8*8))) == SQLITE_NULL)) 34547 34548 iMethod = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(apVal + 8*8))) 34549 sz = i64(nIn) 34550 pData = aIn 34551 nData = nIn 34552 if !((iMethod != 0) && (iMethod != 8)) { 34553 goto __16 34554 } 34555 zipfileTableErr(tls, pTab, ts+9545 /* "unknown compress..." */, libc.VaList(bp, iMethod)) 34556 rc = SQLITE_CONSTRAINT 34557 goto __17 34558 __16: 34559 if !((bAuto != 0) || (iMethod != 0)) { 34560 goto __18 34561 } 34562 rc = zipfileDeflate(tls, aIn, nIn, bp+24 /* &pFree */, bp+32 /* &nCmp */, (pTab /* &.base */ + 16 /* &.zErrMsg */)) 34563 if !(rc == SQLITE_OK) { 34564 goto __19 34565 } 34566 if !((iMethod != 0) || (*(*int32)(unsafe.Pointer(bp + 32 /* nCmp */)) < nIn)) { 34567 goto __20 34568 } 34569 iMethod = 8 34570 pData = *(*uintptr)(unsafe.Pointer(bp + 24 /* pFree */)) 34571 nData = *(*int32)(unsafe.Pointer(bp + 32 /* nCmp */)) 34572 __20: 34573 ; 34574 __19: 34575 ; 34576 __18: 34577 ; 34578 iCrc32 = tcl.Xcrc32(tls, uint64(0), aIn, uint32(nIn)) 34579 __17: 34580 ; 34581 __15: 34582 ; 34583 __13: 34584 ; 34585 34586 if !(rc == SQLITE_OK) { 34587 goto __21 34588 } 34589 rc = zipfileGetMode(tls, *(*uintptr)(unsafe.Pointer(apVal + 3*8)), bIsDir, bp+40 /* &mode */, (pTab /* &.base */ + 16 /* &.zErrMsg */)) 34590 __21: 34591 ; 34592 34593 if !(rc == SQLITE_OK) { 34594 goto __22 34595 } 34596 zPath = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apVal + 2*8))) 34597 if !(zPath == uintptr(0)) { 34598 goto __23 34599 } 34600 zPath = ts + 489 /* "" */ 34601 __23: 34602 ; 34603 nPath = int32(libc.Xstrlen(tls, zPath)) 34604 mTime = zipfileGetTime(tls, *(*uintptr)(unsafe.Pointer(apVal + 4*8))) 34605 __22: 34606 ; 34607 34608 if !((rc == SQLITE_OK) && (bIsDir != 0)) { 34609 goto __24 34610 } 34611 // For a directory, check that the last character in the path is a 34612 // '/'. This appears to be required for compatibility with info-zip 34613 // (the unzip command on unix). It does not create directories 34614 // otherwise. 34615 if !((nPath <= 0) || (int32(*(*int8)(unsafe.Pointer(zPath + uintptr((nPath - 1))))) != '/')) { 34616 goto __25 34617 } 34618 zFree = sqlite3.Xsqlite3_mprintf(tls, ts+9576 /* "%s/" */, libc.VaList(bp+8, zPath)) 34619 zPath = zFree 34620 if !(zFree == uintptr(0)) { 34621 goto __26 34622 } 34623 rc = SQLITE_NOMEM 34624 nPath = 0 34625 goto __27 34626 __26: 34627 nPath = int32(libc.Xstrlen(tls, zPath)) 34628 __27: 34629 ; 34630 __25: 34631 ; 34632 __24: 34633 ; 34634 34635 // Check that we're not inserting a duplicate entry -OR- updating an 34636 // entry with a path, thereby making it into a duplicate. 34637 if !(((pOld == uintptr(0)) || (bUpdate != 0)) && (rc == SQLITE_OK)) { 34638 goto __28 34639 } 34640 p = (*ZipfileTab)(unsafe.Pointer(pTab)).FpFirstEntry 34641 __29: 34642 if !(p != 0) { 34643 goto __31 34644 } 34645 if !(zipfileComparePath(tls, (*ZipfileEntry)(unsafe.Pointer(p)).Fcds.FzFile, zPath, nPath) == 0) { 34646 goto __32 34647 } 34648 switch sqlite3.Xsqlite3_vtab_on_conflict(tls, (*ZipfileTab)(unsafe.Pointer(pTab)).Fdb) { 34649 case SQLITE_IGNORE: 34650 goto __34 34651 case SQLITE_REPLACE: 34652 goto __35 34653 default: 34654 goto __36 34655 } 34656 goto __33 34657 __34: 34658 goto zipfile_update_done 34659 34660 __35: 34661 pOld2 = p 34662 goto __33 34663 34664 __36: 34665 zipfileTableErr(tls, pTab, ts+9580 /* "duplicate name: ..." */, libc.VaList(bp+16, zPath)) 34666 rc = SQLITE_CONSTRAINT 34667 goto __33 34668 34669 __33: 34670 ; 34671 goto __31 34672 __32: 34673 ; 34674 goto __30 34675 __30: 34676 p = (*ZipfileEntry)(unsafe.Pointer(p)).FpNext 34677 goto __29 34678 goto __31 34679 __31: 34680 ; 34681 __28: 34682 ; 34683 34684 if !(rc == SQLITE_OK) { 34685 goto __37 34686 } 34687 // Create the new CDS record. 34688 pNew = zipfileNewEntry(tls, zPath) 34689 if !(pNew == uintptr(0)) { 34690 goto __38 34691 } 34692 rc = SQLITE_NOMEM 34693 goto __39 34694 __38: 34695 (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FiVersionMadeBy = (u16((int32(3) << 8) + 30)) 34696 (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FiVersionExtract = u16(ZIPFILE_NEWENTRY_REQUIRED) 34697 (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.Fflags = u16(ZIPFILE_NEWENTRY_FLAGS) 34698 (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FiCompression = u16(iMethod) 34699 zipfileMtimeToDos(tls, (pNew /* &.cds */), mTime) 34700 (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.Fcrc32 = iCrc32 34701 (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FszCompressed = u321(nData) 34702 (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FszUncompressed = u321(sz) 34703 (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FiExternalAttr = (*(*u321)(unsafe.Pointer(bp + 40 /* mode */)) << 16) 34704 (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FiOffset = u321((*ZipfileTab)(unsafe.Pointer(pTab)).FszCurrent) 34705 (*ZipfileEntry)(unsafe.Pointer(pNew)).Fcds.FnFile = u16(nPath) 34706 (*ZipfileEntry)(unsafe.Pointer(pNew)).FmUnixTime = mTime 34707 rc = zipfileAppendEntry(tls, pTab, pNew, pData, nData) 34708 zipfileAddEntry(tls, pTab, pOld, pNew) 34709 __39: 34710 ; 34711 __37: 34712 ; 34713 __10: 34714 ; 34715 34716 if !((rc == SQLITE_OK) && ((pOld != 0) || (pOld2 != 0))) { 34717 goto __40 34718 } 34719 pCsr = (*ZipfileTab)(unsafe.Pointer(pTab)).FpCsrList 34720 __41: 34721 if !(pCsr != 0) { 34722 goto __43 34723 } 34724 if !(((*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent != 0) && (((*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent == pOld) || ((*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent == pOld2))) { 34725 goto __44 34726 } 34727 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent = (*ZipfileEntry)(unsafe.Pointer((*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent)).FpNext 34728 (*ZipfileCsr)(unsafe.Pointer(pCsr)).FbNoop = u8(1) 34729 __44: 34730 ; 34731 goto __42 34732 __42: 34733 pCsr = (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCsrNext 34734 goto __41 34735 goto __43 34736 __43: 34737 ; 34738 34739 zipfileRemoveEntryFromList(tls, pTab, pOld) 34740 zipfileRemoveEntryFromList(tls, pTab, pOld2) 34741 __40: 34742 ; 34743 34744 zipfile_update_done: 34745 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pFree */))) 34746 sqlite3.Xsqlite3_free(tls, zFree) 34747 return rc 34748 } 34749 34750 func zipfileSerializeEOCD(tls *libc.TLS, p uintptr, aBuf uintptr) int32 { /* zipfile.c:1718:12: */ 34751 var a uintptr = aBuf 34752 { 34753 zipfilePutU32(tls, a, uint64(ZIPFILE_SIGNATURE_EOCD)) 34754 a += uintptr(4) 34755 } 34756 34757 { 34758 zipfilePutU16(tls, a, (*ZipfileEOCD)(unsafe.Pointer(p)).FiDisk) 34759 a += uintptr(2) 34760 } 34761 34762 { 34763 zipfilePutU16(tls, a, (*ZipfileEOCD)(unsafe.Pointer(p)).FiFirstDisk) 34764 a += uintptr(2) 34765 } 34766 34767 { 34768 zipfilePutU16(tls, a, (*ZipfileEOCD)(unsafe.Pointer(p)).FnEntry) 34769 a += uintptr(2) 34770 } 34771 34772 { 34773 zipfilePutU16(tls, a, (*ZipfileEOCD)(unsafe.Pointer(p)).FnEntryTotal) 34774 a += uintptr(2) 34775 } 34776 34777 { 34778 zipfilePutU32(tls, a, (*ZipfileEOCD)(unsafe.Pointer(p)).FnSize) 34779 a += uintptr(4) 34780 } 34781 34782 { 34783 zipfilePutU32(tls, a, (*ZipfileEOCD)(unsafe.Pointer(p)).FiOffset) 34784 a += uintptr(4) 34785 } 34786 34787 { 34788 zipfilePutU16(tls, a, uint16(0)) 34789 a += uintptr(2) 34790 } 34791 // Size of trailing comment in bytes 34792 34793 return (int32((int64(a) - int64(aBuf)) / 1)) 34794 } 34795 34796 func zipfileAppendEOCD(tls *libc.TLS, pTab uintptr, p uintptr) int32 { /* zipfile.c:1732:12: */ 34797 var nBuf int32 = zipfileSerializeEOCD(tls, p, (*ZipfileTab)(unsafe.Pointer(pTab)).FaBuffer) 34798 34799 return zipfileAppendData(tls, pTab, (*ZipfileTab)(unsafe.Pointer(pTab)).FaBuffer, nBuf) 34800 } 34801 34802 // Serialize the CDS structure into buffer aBuf[]. Return the number 34803 // of bytes written. 34804 func zipfileSerializeCDS(tls *libc.TLS, pEntry uintptr, aBuf uintptr) int32 { /* zipfile.c:1742:12: */ 34805 var a uintptr = aBuf 34806 var pCDS uintptr = (pEntry /* &.cds */) 34807 34808 if (*ZipfileEntry)(unsafe.Pointer(pEntry)).FaExtra == uintptr(0) { 34809 (*ZipfileCDS)(unsafe.Pointer(pCDS)).FnExtra = u16(9) 34810 } 34811 34812 { 34813 zipfilePutU32(tls, a, uint64(ZIPFILE_SIGNATURE_CDS)) 34814 a += uintptr(4) 34815 } 34816 34817 { 34818 zipfilePutU16(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCDS)).FiVersionMadeBy) 34819 a += uintptr(2) 34820 } 34821 34822 { 34823 zipfilePutU16(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCDS)).FiVersionExtract) 34824 a += uintptr(2) 34825 } 34826 34827 { 34828 zipfilePutU16(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCDS)).Fflags) 34829 a += uintptr(2) 34830 } 34831 34832 { 34833 zipfilePutU16(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCDS)).FiCompression) 34834 a += uintptr(2) 34835 } 34836 34837 { 34838 zipfilePutU16(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCDS)).FmTime) 34839 a += uintptr(2) 34840 } 34841 34842 { 34843 zipfilePutU16(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCDS)).FmDate) 34844 a += uintptr(2) 34845 } 34846 34847 { 34848 zipfilePutU32(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCDS)).Fcrc32) 34849 a += uintptr(4) 34850 } 34851 34852 { 34853 zipfilePutU32(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCDS)).FszCompressed) 34854 a += uintptr(4) 34855 } 34856 34857 { 34858 zipfilePutU32(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCDS)).FszUncompressed) 34859 a += uintptr(4) 34860 } 34861 34862 { 34863 zipfilePutU16(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCDS)).FnFile) 34864 a += uintptr(2) 34865 } 34866 34867 { 34868 zipfilePutU16(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCDS)).FnExtra) 34869 a += uintptr(2) 34870 } 34871 34872 { 34873 zipfilePutU16(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCDS)).FnComment) 34874 a += uintptr(2) 34875 } 34876 34877 { 34878 zipfilePutU16(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCDS)).FiDiskStart) 34879 a += uintptr(2) 34880 } 34881 34882 { 34883 zipfilePutU16(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCDS)).FiInternalAttr) 34884 a += uintptr(2) 34885 } 34886 34887 { 34888 zipfilePutU32(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCDS)).FiExternalAttr) 34889 a += uintptr(4) 34890 } 34891 34892 { 34893 zipfilePutU32(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCDS)).FiOffset) 34894 a += uintptr(4) 34895 } 34896 34897 libc.Xmemcpy(tls, a, (*ZipfileCDS)(unsafe.Pointer(pCDS)).FzFile, uint64((*ZipfileCDS)(unsafe.Pointer(pCDS)).FnFile)) 34898 a += uintptr((*ZipfileCDS)(unsafe.Pointer(pCDS)).FnFile) 34899 34900 if (*ZipfileEntry)(unsafe.Pointer(pEntry)).FaExtra != 0 { 34901 var n int32 = (int32((*ZipfileCDS)(unsafe.Pointer(pCDS)).FnExtra) + int32((*ZipfileCDS)(unsafe.Pointer(pCDS)).FnComment)) 34902 libc.Xmemcpy(tls, a, (*ZipfileEntry)(unsafe.Pointer(pEntry)).FaExtra, uint64(n)) 34903 a += uintptr(n) 34904 } else { 34905 34906 { 34907 zipfilePutU16(tls, a, uint16(ZIPFILE_EXTRA_TIMESTAMP)) 34908 a += uintptr(2) 34909 } 34910 34911 { 34912 zipfilePutU16(tls, a, uint16(5)) 34913 a += uintptr(2) 34914 } 34915 34916 *(*u8)(unsafe.Pointer(libc.PostIncUintptr(&a, 1))) = u8(0x01) 34917 { 34918 zipfilePutU32(tls, a, (*ZipfileEntry)(unsafe.Pointer(pEntry)).FmUnixTime) 34919 a += uintptr(4) 34920 } 34921 34922 } 34923 34924 return (int32((int64(a) - int64(aBuf)) / 1)) 34925 } 34926 34927 func zipfileCommit(tls *libc.TLS, pVtab uintptr) int32 { /* zipfile.c:1787:12: */ 34928 bp := tls.Alloc(24) 34929 defer tls.Free(24) 34930 34931 var pTab uintptr = pVtab 34932 var rc int32 = SQLITE_OK 34933 if (*ZipfileTab)(unsafe.Pointer(pTab)).FpWriteFd != 0 { 34934 var iOffset i64 = (*ZipfileTab)(unsafe.Pointer(pTab)).FszCurrent 34935 var p uintptr 34936 // var eocd ZipfileEOCD at bp, 24 34937 34938 var nEntry int32 = 0 34939 34940 // Write out all entries 34941 for p = (*ZipfileTab)(unsafe.Pointer(pTab)).FpFirstEntry; (rc == SQLITE_OK) && (p != 0); p = (*ZipfileEntry)(unsafe.Pointer(p)).FpNext { 34942 var n int32 = zipfileSerializeCDS(tls, p, (*ZipfileTab)(unsafe.Pointer(pTab)).FaBuffer) 34943 rc = zipfileAppendData(tls, pTab, (*ZipfileTab)(unsafe.Pointer(pTab)).FaBuffer, n) 34944 nEntry++ 34945 } 34946 34947 // Write out the EOCD record 34948 (*ZipfileEOCD)(unsafe.Pointer(bp /* &eocd */)).FiDisk = u16(0) 34949 (*ZipfileEOCD)(unsafe.Pointer(bp /* &eocd */)).FiFirstDisk = u16(0) 34950 (*ZipfileEOCD)(unsafe.Pointer(bp /* &eocd */)).FnEntry = u16(nEntry) 34951 (*ZipfileEOCD)(unsafe.Pointer(bp /* &eocd */)).FnEntryTotal = u16(nEntry) 34952 (*ZipfileEOCD)(unsafe.Pointer(bp /* &eocd */)).FnSize = (u321((*ZipfileTab)(unsafe.Pointer(pTab)).FszCurrent - iOffset)) 34953 (*ZipfileEOCD)(unsafe.Pointer(bp /* &eocd */)).FiOffset = u321(iOffset) 34954 rc = zipfileAppendEOCD(tls, pTab, bp /* &eocd */) 34955 34956 zipfileCleanupTransaction(tls, pTab) 34957 } 34958 return rc 34959 } 34960 34961 func zipfileRollback(tls *libc.TLS, pVtab uintptr) int32 { /* zipfile.c:1817:12: */ 34962 return zipfileCommit(tls, pVtab) 34963 } 34964 34965 func zipfileFindCursor(tls *libc.TLS, pTab uintptr, iId i64) uintptr { /* zipfile.c:1821:19: */ 34966 var pCsr uintptr 34967 for pCsr = (*ZipfileTab)(unsafe.Pointer(pTab)).FpCsrList; pCsr != 0; pCsr = (*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCsrNext { 34968 if iId == (*ZipfileCsr)(unsafe.Pointer(pCsr)).FiId { 34969 break 34970 } 34971 } 34972 return pCsr 34973 } 34974 34975 func zipfileFunctionCds(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* zipfile.c:1829:13: */ 34976 bp := tls.Alloc(128) 34977 defer tls.Free(128) 34978 34979 var pCsr uintptr 34980 var pTab uintptr = sqlite3.Xsqlite3_user_data(tls, context) 34981 34982 pCsr = zipfileFindCursor(tls, pTab, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv)))) 34983 if pCsr != 0 { 34984 var p uintptr = ((*ZipfileCsr)(unsafe.Pointer(pCsr)).FpCurrent /* &.cds */) 34985 var zRes uintptr = sqlite3.Xsqlite3_mprintf(tls, 34986 34987 ts+9601, /* "{\"version-made-b..." */ 34988 libc.VaList(bp, u321((*ZipfileCDS)(unsafe.Pointer(p)).FiVersionMadeBy), u321((*ZipfileCDS)(unsafe.Pointer(p)).FiVersionExtract), 34989 u321((*ZipfileCDS)(unsafe.Pointer(p)).Fflags), u321((*ZipfileCDS)(unsafe.Pointer(p)).FiCompression), 34990 u321((*ZipfileCDS)(unsafe.Pointer(p)).FmTime), u321((*ZipfileCDS)(unsafe.Pointer(p)).FmDate), 34991 (*ZipfileCDS)(unsafe.Pointer(p)).Fcrc32, (*ZipfileCDS)(unsafe.Pointer(p)).FszCompressed, 34992 (*ZipfileCDS)(unsafe.Pointer(p)).FszUncompressed, u321((*ZipfileCDS)(unsafe.Pointer(p)).FnFile), 34993 u321((*ZipfileCDS)(unsafe.Pointer(p)).FnExtra), u321((*ZipfileCDS)(unsafe.Pointer(p)).FnComment), 34994 u321((*ZipfileCDS)(unsafe.Pointer(p)).FiDiskStart), u321((*ZipfileCDS)(unsafe.Pointer(p)).FiInternalAttr), 34995 (*ZipfileCDS)(unsafe.Pointer(p)).FiExternalAttr, (*ZipfileCDS)(unsafe.Pointer(p)).FiOffset)) 34996 34997 if zRes == uintptr(0) { 34998 sqlite3.Xsqlite3_result_error_nomem(tls, context) 34999 } else { 35000 sqlite3.Xsqlite3_result_text(tls, context, zRes, -1, libc.UintptrFromInt32(-1)) 35001 sqlite3.Xsqlite3_free(tls, zRes) 35002 } 35003 } 35004 } 35005 35006 // xFindFunction method. 35007 func zipfileFindFunction(tls *libc.TLS, pVtab uintptr, nArg int32, zName uintptr, pxFunc uintptr, ppArg uintptr) int32 { /* zipfile.c:1880:12: */ 35008 if sqlite3.Xsqlite3_stricmp(tls, ts+9943 /* "zipfile_cds" */, zName) == 0 { 35009 *(*uintptr)(unsafe.Pointer(pxFunc)) = *(*uintptr)(unsafe.Pointer(&struct { 35010 f func(*libc.TLS, uintptr, int32, uintptr) 35011 }{zipfileFunctionCds})) 35012 *(*uintptr)(unsafe.Pointer(ppArg)) = pVtab 35013 return 1 35014 } 35015 return 0 35016 } 35017 35018 type ZipfileBuffer1 = struct { 35019 Fa uintptr 35020 Fn int32 35021 FnAlloc int32 35022 } /* zipfile.c:1895:9 */ 35023 35024 type ZipfileBuffer = ZipfileBuffer1 /* zipfile.c:1895:30 */ 35025 35026 type ZipfileCtx1 = struct { 35027 FnEntry int32 35028 _ [4]byte 35029 Fbody ZipfileBuffer 35030 Fcds ZipfileBuffer 35031 } /* zipfile.c:1902:9 */ 35032 35033 type ZipfileCtx = ZipfileCtx1 /* zipfile.c:1902:27 */ 35034 35035 func zipfileBufferGrow(tls *libc.TLS, pBuf uintptr, nByte int32) int32 { /* zipfile.c:1909:12: */ 35036 if ((*ZipfileBuffer)(unsafe.Pointer(pBuf)).Fn + nByte) > (*ZipfileBuffer)(unsafe.Pointer(pBuf)).FnAlloc { 35037 var aNew uintptr 35038 var nNew sqlite3_int64 35039 if (*ZipfileBuffer)(unsafe.Pointer(pBuf)).Fn != 0 { 35040 nNew = (int64((*ZipfileBuffer)(unsafe.Pointer(pBuf)).Fn * 2)) 35041 } else { 35042 nNew = int64(512) 35043 } 35044 var nReq int32 = ((*ZipfileBuffer)(unsafe.Pointer(pBuf)).Fn + nByte) 35045 35046 for nNew < sqlite3_int64(nReq) { 35047 nNew = (nNew * int64(2)) 35048 } 35049 aNew = sqlite3.Xsqlite3_realloc64(tls, (*ZipfileBuffer)(unsafe.Pointer(pBuf)).Fa, uint64(nNew)) 35050 if aNew == uintptr(0) { 35051 return SQLITE_NOMEM 35052 } 35053 (*ZipfileBuffer)(unsafe.Pointer(pBuf)).Fa = aNew 35054 (*ZipfileBuffer)(unsafe.Pointer(pBuf)).FnAlloc = int32(nNew) 35055 } 35056 return SQLITE_OK 35057 } 35058 35059 // xStep() callback for the zipfile() aggregate. This can be called in 35060 // any of the following ways: 35061 // 35062 // SELECT zipfile(name,data) ... 35063 // SELECT zipfile(name,mode,mtime,data) ... 35064 // SELECT zipfile(name,mode,mtime,data,method) ... 35065 func zipfileStep(tls *libc.TLS, pCtx uintptr, nVal int32, apVal uintptr) { /* zipfile.c:1932:6: */ 35066 bp := tls.Alloc(168) 35067 defer tls.Free(168) 35068 35069 var p uintptr // Aggregate function context 35070 // var e ZipfileEntry at bp+16, 120 35071 // New entry to add to zip archive 35072 35073 var pName uintptr 35074 var pMode uintptr 35075 var pMtime uintptr 35076 var pData uintptr 35077 var pMethod uintptr 35078 var bIsDir int32 35079 // var mode u321 at bp+160, 8 35080 35081 var rc int32 35082 // var zErr uintptr at bp+152, 8 35083 35084 var iMethod int32 // Compression method to use (0 or 8) 35085 35086 var aData uintptr // Possibly compressed data for new entry 35087 var nData int32 // Size of aData[] in bytes 35088 var szUncompressed int32 // Size of data before compression 35089 // var aFree uintptr at bp+136, 8 35090 // Free this before returning 35091 var iCrc32 u321 // crc32 of uncompressed data 35092 35093 var zName uintptr // Path (name) of new entry 35094 var nName int32 // Size of zName in bytes 35095 var zFree uintptr // Free this before returning 35096 var nByte int32 35097 // var nOut int32 at bp+144, 4 35098 pName = uintptr(0) 35099 pMode = uintptr(0) 35100 pMtime = uintptr(0) 35101 pData = uintptr(0) 35102 pMethod = uintptr(0) 35103 bIsDir = 0 35104 rc = SQLITE_OK 35105 *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */)) = uintptr(0) 35106 iMethod = -1 35107 aData = uintptr(0) 35108 nData = 0 35109 szUncompressed = 0 35110 *(*uintptr)(unsafe.Pointer(bp + 136 /* aFree */)) = uintptr(0) 35111 iCrc32 = uint64(0) 35112 zName = uintptr(0) 35113 nName = 0 35114 zFree = uintptr(0) 35115 35116 libc.Xmemset(tls, bp+16 /* &e */, 0, uint64(unsafe.Sizeof(ZipfileEntry{}))) 35117 p = sqlite3.Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(ZipfileCtx{}))) 35118 if !(p == uintptr(0)) { 35119 goto __1 35120 } 35121 return 35122 __1: 35123 ; 35124 35125 // Martial the arguments into stack variables 35126 if !(((nVal != 2) && (nVal != 4)) && (nVal != 5)) { 35127 goto __2 35128 } 35129 *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */)) = sqlite3.Xsqlite3_mprintf(tls, ts+9955 /* "wrong number of ..." */, 0) 35130 rc = SQLITE_ERROR 35131 goto zipfile_step_out 35132 __2: 35133 ; 35134 pName = *(*uintptr)(unsafe.Pointer(apVal)) 35135 if !(nVal == 2) { 35136 goto __3 35137 } 35138 pData = *(*uintptr)(unsafe.Pointer(apVal + 1*8)) 35139 goto __4 35140 __3: 35141 pMode = *(*uintptr)(unsafe.Pointer(apVal + 1*8)) 35142 pMtime = *(*uintptr)(unsafe.Pointer(apVal + 2*8)) 35143 pData = *(*uintptr)(unsafe.Pointer(apVal + 3*8)) 35144 if !(nVal == 5) { 35145 goto __5 35146 } 35147 pMethod = *(*uintptr)(unsafe.Pointer(apVal + 4*8)) 35148 __5: 35149 ; 35150 __4: 35151 ; 35152 35153 // Check that the 'name' parameter looks ok. 35154 zName = sqlite3.Xsqlite3_value_text(tls, pName) 35155 nName = sqlite3.Xsqlite3_value_bytes(tls, pName) 35156 if !(zName == uintptr(0)) { 35157 goto __6 35158 } 35159 *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */)) = sqlite3.Xsqlite3_mprintf(tls, ts+10003 /* "first argument t..." */, 0) 35160 rc = SQLITE_ERROR 35161 goto zipfile_step_out 35162 __6: 35163 ; 35164 35165 // Inspect the 'method' parameter. This must be either 0 (store), 8 (use 35166 // deflate compression) or NULL (choose automatically). 35167 if !((pMethod != 0) && (SQLITE_NULL != sqlite3.Xsqlite3_value_type(tls, pMethod))) { 35168 goto __7 35169 } 35170 iMethod = int32(sqlite3.Xsqlite3_value_int64(tls, pMethod)) 35171 if !((iMethod != 0) && (iMethod != 8)) { 35172 goto __8 35173 } 35174 *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */)) = sqlite3.Xsqlite3_mprintf(tls, ts+10048 /* "illegal method v..." */, libc.VaList(bp, iMethod)) 35175 rc = SQLITE_ERROR 35176 goto zipfile_step_out 35177 __8: 35178 ; 35179 __7: 35180 ; 35181 35182 // Now inspect the data. If this is NULL, then the new entry must be a 35183 // directory. Otherwise, figure out whether or not the data should 35184 // be deflated or simply stored in the zip archive. 35185 if !(sqlite3.Xsqlite3_value_type(tls, pData) == SQLITE_NULL) { 35186 goto __9 35187 } 35188 bIsDir = 1 35189 iMethod = 0 35190 goto __10 35191 __9: 35192 aData = sqlite3.Xsqlite3_value_blob(tls, pData) 35193 szUncompressed = libc.AssignInt32(&nData, sqlite3.Xsqlite3_value_bytes(tls, pData)) 35194 iCrc32 = tcl.Xcrc32(tls, uint64(0), aData, uint32(nData)) 35195 if !((iMethod < 0) || (iMethod == 8)) { 35196 goto __11 35197 } 35198 *(*int32)(unsafe.Pointer(bp + 144 /* nOut */)) = 0 35199 rc = zipfileDeflate(tls, aData, nData, bp+136 /* &aFree */, bp+144 /* &nOut */, bp+152 /* &zErr */) 35200 if !(rc != SQLITE_OK) { 35201 goto __12 35202 } 35203 goto zipfile_step_out 35204 __12: 35205 ; 35206 if !((iMethod == 8) || (*(*int32)(unsafe.Pointer(bp + 144 /* nOut */)) < nData)) { 35207 goto __13 35208 } 35209 aData = *(*uintptr)(unsafe.Pointer(bp + 136 /* aFree */)) 35210 nData = *(*int32)(unsafe.Pointer(bp + 144 /* nOut */)) 35211 iMethod = 8 35212 goto __14 35213 __13: 35214 iMethod = 0 35215 __14: 35216 ; 35217 __11: 35218 ; 35219 __10: 35220 ; 35221 35222 // Decode the "mode" argument. 35223 rc = zipfileGetMode(tls, pMode, bIsDir, bp+160 /* &mode */, bp+152 /* &zErr */) 35224 if !(rc != 0) { 35225 goto __15 35226 } 35227 goto zipfile_step_out 35228 __15: 35229 ; 35230 35231 // Decode the "mtime" argument. 35232 (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).FmUnixTime = zipfileGetTime(tls, pMtime) 35233 35234 // If this is a directory entry, ensure that there is exactly one '/' 35235 // at the end of the path. Or, if this is not a directory and the path 35236 // ends in '/' it is an error. 35237 if !(bIsDir == 0) { 35238 goto __16 35239 } 35240 if !((nName > 0) && (int32(*(*int8)(unsafe.Pointer(zName + uintptr((nName - 1))))) == '/')) { 35241 goto __18 35242 } 35243 *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */)) = sqlite3.Xsqlite3_mprintf(tls, ts+10073 /* "non-directory na..." */, 0) 35244 rc = SQLITE_ERROR 35245 goto zipfile_step_out 35246 __18: 35247 ; 35248 goto __17 35249 __16: 35250 if !((nName == 0) || (int32(*(*int8)(unsafe.Pointer(zName + uintptr((nName - 1))))) != '/')) { 35251 goto __19 35252 } 35253 zName = libc.AssignUintptr(&zFree, sqlite3.Xsqlite3_mprintf(tls, ts+9576 /* "%s/" */, libc.VaList(bp+8, zName))) 35254 if !(zName == uintptr(0)) { 35255 goto __21 35256 } 35257 rc = SQLITE_NOMEM 35258 goto zipfile_step_out 35259 __21: 35260 ; 35261 nName = int32(libc.Xstrlen(tls, zName)) 35262 goto __20 35263 __19: 35264 __22: 35265 if !((nName > 1) && (int32(*(*int8)(unsafe.Pointer(zName + uintptr((nName - 2))))) == '/')) { 35266 goto __23 35267 } 35268 nName-- 35269 goto __22 35270 __23: 35271 ; 35272 __20: 35273 ; 35274 __17: 35275 ; 35276 35277 // Assemble the ZipfileEntry object for the new zip archive entry 35278 (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.FiVersionMadeBy = (u16((int32(3) << 8) + 30)) 35279 (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.FiVersionExtract = u16(ZIPFILE_NEWENTRY_REQUIRED) 35280 (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.Fflags = u16(ZIPFILE_NEWENTRY_FLAGS) 35281 (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.FiCompression = u16(iMethod) 35282 zipfileMtimeToDos(tls, (bp + 16 /* &e */ /* &.cds */), (*ZipfileEntry)(unsafe.Pointer(bp+16 /* &e */)).FmUnixTime) 35283 (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.Fcrc32 = iCrc32 35284 (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.FszCompressed = u321(nData) 35285 (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.FszUncompressed = u321(szUncompressed) 35286 (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.FiExternalAttr = (*(*u321)(unsafe.Pointer(bp + 160 /* mode */)) << 16) 35287 (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.FiOffset = u321((*ZipfileCtx)(unsafe.Pointer(p)).Fbody.Fn) 35288 (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.FnFile = u16(nName) 35289 (*ZipfileEntry)(unsafe.Pointer(bp + 16 /* &e */)).Fcds.FzFile = zName 35290 35291 // Append the LFH to the body of the new archive 35292 nByte = ((ZIPFILE_LFH_FIXED_SZ + int32((*ZipfileEntry)(unsafe.Pointer(bp+16 /* &e */)).Fcds.FnFile)) + 9) 35293 if !(libc.AssignInt32(&rc, zipfileBufferGrow(tls, (p+8 /* &.body */), nByte)) != 0) { 35294 goto __24 35295 } 35296 goto zipfile_step_out 35297 __24: 35298 ; 35299 *(*int32)(unsafe.Pointer(p + 8 /* &.body */ + 8 /* &.n */)) += (zipfileSerializeLFH(tls, bp+16 /* &e */, ((*ZipfileCtx)(unsafe.Pointer(p)).Fbody.Fa + uintptr((*ZipfileCtx)(unsafe.Pointer(p)).Fbody.Fn)))) 35300 35301 // Append the data to the body of the new archive 35302 if !(nData > 0) { 35303 goto __25 35304 } 35305 if !(libc.AssignInt32(&rc, zipfileBufferGrow(tls, (p+8 /* &.body */), nData)) != 0) { 35306 goto __26 35307 } 35308 goto zipfile_step_out 35309 __26: 35310 ; 35311 libc.Xmemcpy(tls, ((*ZipfileCtx)(unsafe.Pointer(p)).Fbody.Fa + uintptr((*ZipfileCtx)(unsafe.Pointer(p)).Fbody.Fn)), aData, uint64(nData)) 35312 *(*int32)(unsafe.Pointer(p + 8 /* &.body */ + 8 /* &.n */)) += (nData) 35313 __25: 35314 ; 35315 35316 // Append the CDS record to the directory of the new archive 35317 nByte = ((ZIPFILE_CDS_FIXED_SZ + int32((*ZipfileEntry)(unsafe.Pointer(bp+16 /* &e */)).Fcds.FnFile)) + 9) 35318 if !(libc.AssignInt32(&rc, zipfileBufferGrow(tls, (p+24 /* &.cds */), nByte)) != 0) { 35319 goto __27 35320 } 35321 goto zipfile_step_out 35322 __27: 35323 ; 35324 *(*int32)(unsafe.Pointer(p + 24 /* &.cds */ + 8 /* &.n */)) += (zipfileSerializeCDS(tls, bp+16 /* &e */, ((*ZipfileCtx)(unsafe.Pointer(p)).Fcds.Fa + uintptr((*ZipfileCtx)(unsafe.Pointer(p)).Fcds.Fn)))) 35325 35326 // Increment the count of entries in the archive 35327 (*ZipfileCtx)(unsafe.Pointer(p)).FnEntry++ 35328 35329 zipfile_step_out: 35330 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 136 /* aFree */))) 35331 sqlite3.Xsqlite3_free(tls, zFree) 35332 if !(rc != 0) { 35333 goto __28 35334 } 35335 if !(*(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */)) != 0) { 35336 goto __29 35337 } 35338 sqlite3.Xsqlite3_result_error(tls, pCtx, *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */)), -1) 35339 goto __30 35340 __29: 35341 sqlite3.Xsqlite3_result_error_code(tls, pCtx, rc) 35342 __30: 35343 ; 35344 __28: 35345 ; 35346 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 152 /* zErr */))) 35347 } 35348 35349 // xFinalize() callback for zipfile aggregate function. 35350 func zipfileFinal(tls *libc.TLS, pCtx uintptr) { /* zipfile.c:2107:6: */ 35351 bp := tls.Alloc(24) 35352 defer tls.Free(24) 35353 35354 var p uintptr 35355 // var eocd ZipfileEOCD at bp, 24 35356 35357 var nZip sqlite3_int64 35358 var aZip uintptr 35359 35360 p = sqlite3.Xsqlite3_aggregate_context(tls, pCtx, int32(unsafe.Sizeof(ZipfileCtx{}))) 35361 if p == uintptr(0) { 35362 return 35363 } 35364 if (*ZipfileCtx)(unsafe.Pointer(p)).FnEntry > 0 { 35365 libc.Xmemset(tls, bp /* &eocd */, 0, uint64(unsafe.Sizeof(ZipfileEOCD{}))) 35366 (*ZipfileEOCD)(unsafe.Pointer(bp /* &eocd */)).FnEntry = u16((*ZipfileCtx)(unsafe.Pointer(p)).FnEntry) 35367 (*ZipfileEOCD)(unsafe.Pointer(bp /* &eocd */)).FnEntryTotal = u16((*ZipfileCtx)(unsafe.Pointer(p)).FnEntry) 35368 (*ZipfileEOCD)(unsafe.Pointer(bp /* &eocd */)).FnSize = u321((*ZipfileCtx)(unsafe.Pointer(p)).Fcds.Fn) 35369 (*ZipfileEOCD)(unsafe.Pointer(bp /* &eocd */)).FiOffset = u321((*ZipfileCtx)(unsafe.Pointer(p)).Fbody.Fn) 35370 35371 nZip = (sqlite3_int64(((*ZipfileCtx)(unsafe.Pointer(p)).Fbody.Fn + (*ZipfileCtx)(unsafe.Pointer(p)).Fcds.Fn) + ZIPFILE_EOCD_FIXED_SZ)) 35372 aZip = sqlite3.Xsqlite3_malloc64(tls, uint64(nZip)) 35373 if aZip == uintptr(0) { 35374 sqlite3.Xsqlite3_result_error_nomem(tls, pCtx) 35375 } else { 35376 libc.Xmemcpy(tls, aZip, (*ZipfileCtx)(unsafe.Pointer(p)).Fbody.Fa, uint64((*ZipfileCtx)(unsafe.Pointer(p)).Fbody.Fn)) 35377 libc.Xmemcpy(tls, (aZip + uintptr((*ZipfileCtx)(unsafe.Pointer(p)).Fbody.Fn)), (*ZipfileCtx)(unsafe.Pointer(p)).Fcds.Fa, uint64((*ZipfileCtx)(unsafe.Pointer(p)).Fcds.Fn)) 35378 zipfileSerializeEOCD(tls, bp /* &eocd */, (aZip + uintptr(((*ZipfileCtx)(unsafe.Pointer(p)).Fbody.Fn + (*ZipfileCtx)(unsafe.Pointer(p)).Fcds.Fn)))) 35379 sqlite3.Xsqlite3_result_blob(tls, pCtx, aZip, int32(nZip), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{zipfileFree}))) 35380 } 35381 } 35382 35383 sqlite3.Xsqlite3_free(tls, (*ZipfileCtx)(unsafe.Pointer(p)).Fbody.Fa) 35384 sqlite3.Xsqlite3_free(tls, (*ZipfileCtx)(unsafe.Pointer(p)).Fcds.Fa) 35385 } 35386 35387 // Register the "zipfile" virtual table. 35388 func zipfileRegister(tls *libc.TLS, db uintptr) int32 { /* zipfile.c:2142:12: */ 35389 35390 var rc int32 = sqlite3.Xsqlite3_create_module(tls, db, ts+9014 /* "zipfile" */, uintptr(unsafe.Pointer(&zipfileModule)), uintptr(0)) 35391 if rc == SQLITE_OK { 35392 rc = sqlite3.Xsqlite3_overload_function(tls, db, ts+9943 /* "zipfile_cds" */, -1) 35393 } 35394 if rc == SQLITE_OK { 35395 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+9014 /* "zipfile" */, -1, SQLITE_UTF8, uintptr(0), uintptr(0), 35396 *(*uintptr)(unsafe.Pointer(&struct { 35397 f func(*libc.TLS, uintptr, int32, uintptr) 35398 }{zipfileStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{zipfileFinal}))) 35399 } 35400 return rc 35401 } 35402 35403 var zipfileModule = sqlite3_module{ 35404 FiVersion: 1, // iVersion 35405 FxCreate: 0, // xCreate 35406 FxConnect: 0, // xConnect 35407 FxBestIndex: 0, // xBestIndex 35408 FxDisconnect: 0, // xDisconnect 35409 FxDestroy: 0, // xDestroy 35410 FxOpen: 0, // xOpen - open a cursor 35411 FxClose: 0, // xClose - close a cursor 35412 FxFilter: 0, // xFilter - configure scan constraints 35413 FxNext: 0, // xNext - advance a cursor 35414 FxEof: 0, // xEof - check for end of scan 35415 FxColumn: 0, // xRowid - read data 35416 FxUpdate: 0, // xUpdate 35417 FxBegin: 0, // xSync 35418 FxCommit: 0, // xCommit 35419 FxRollback: 0, // xRollback 35420 FxFindFunction: 0, // xRename 35421 } /* zipfile.c:2143:25 */ 35422 35423 func sqlite3_zipfile_init(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* zipfile.c:2182:5: */ 35424 _ = pApi 35425 35426 _ = pzErrMsg // Unused parameter 35427 return zipfileRegister(tls, db) 35428 } 35429 35430 func test_rbu_delta(tls *libc.TLS, pCtx uintptr, nArg int32, apVal uintptr) { /* test_rbu.c:34:6: */ 35431 var interp uintptr = sqlite3.Xsqlite3_user_data(tls, pCtx) 35432 var pScript uintptr 35433 var i int32 35434 35435 pScript = tcl.XTcl_NewObj(tls) 35436 (*Tcl_Obj)(unsafe.Pointer(pScript)).FrefCount++ 35437 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pScript, tcl.XTcl_NewStringObj(tls, ts+10112 /* "rbu_delta" */, -1)) 35438 for i = 0; i < nArg; i++ { 35439 var pIn uintptr = *(*uintptr)(unsafe.Pointer(apVal + uintptr(i)*8)) 35440 var z uintptr = sqlite3.Xsqlite3_value_text(tls, pIn) 35441 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pScript, tcl.XTcl_NewStringObj(tls, z, -1)) 35442 } 35443 35444 if TCL_OK == tcl.XTcl_EvalObjEx(tls, interp, pScript, TCL_GLOBAL_ONLY) { 35445 var z uintptr = tcl.XTcl_GetStringResult(tls, interp) 35446 sqlite3.Xsqlite3_result_text(tls, pCtx, z, -1, libc.UintptrFromInt32(-1)) 35447 } else { 35448 tcl.XTcl_BackgroundError(tls, interp) 35449 } 35450 35451 for ok := true; ok; ok = 0 != 0 { 35452 var _objPtr uintptr = pScript 35453 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 35454 tcl.XTclFreeObj(tls, _objPtr) 35455 } 35456 } 35457 } 35458 35459 func test_sqlite3rbu_cmd(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_rbu.c:59:26: */ 35460 bp := tls.Alloc(496) 35461 defer tls.Free(496) 35462 35463 var ret int32 = TCL_OK 35464 var pRbu uintptr = clientData 35465 *(*[14]RbuCmd)(unsafe.Pointer(bp + 24 /* aCmd */)) = [14]RbuCmd{ 35466 {FzName: ts + 10122 /* "step" */, FnArg: 2, FzUsage: ts + 489 /* "" */}, // 0 35467 {FzName: ts + 10127 /* "close" */, FnArg: 2, FzUsage: ts + 489 /* "" */}, // 1 35468 {FzName: ts + 10133 /* "create_rbu_delta" */, FnArg: 2, FzUsage: ts + 489 /* "" */}, // 2 35469 {FzName: ts + 10150 /* "savestate" */, FnArg: 2, FzUsage: ts + 489 /* "" */}, // 3 35470 {FzName: ts + 10160 /* "dbMain_eval" */, FnArg: 3, FzUsage: ts + 10172 /* "SQL" */}, // 4 35471 {FzName: ts + 10176 /* "bp_progress" */, FnArg: 2, FzUsage: ts + 489 /* "" */}, // 5 35472 {FzName: ts + 10188 /* "db" */, FnArg: 3, FzUsage: ts + 10191 /* "RBU" */}, // 6 35473 {FzName: ts + 10195 /* "state" */, FnArg: 2, FzUsage: ts + 489 /* "" */}, // 7 35474 {FzName: ts + 10201 /* "progress" */, FnArg: 2, FzUsage: ts + 489 /* "" */}, // 8 35475 {FzName: ts + 10210 /* "close_no_error" */, FnArg: 2, FzUsage: ts + 489 /* "" */}, // 9 35476 {FzName: ts + 10225 /* "temp_size_limit" */, FnArg: 3, FzUsage: ts + 10241 /* "LIMIT" */}, // 10 35477 {FzName: ts + 10247 /* "temp_size" */, FnArg: 2, FzUsage: ts + 489 /* "" */}, // 11 35478 {FzName: ts + 10257 /* "dbRbu_eval" */, FnArg: 3, FzUsage: ts + 10172 /* "SQL" */}, // 12 35479 {}, 35480 } 35481 // var iCmd int32 at bp+360, 4 35482 35483 if objc < 2 { 35484 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+10268 /* "METHOD" */) 35485 return TCL_ERROR 35486 } 35487 ret = tcl.XTcl_GetIndexFromObjStruct(tls, 35488 interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+24 /* &aCmd[0] */, int32(unsafe.Sizeof(RbuCmd{})), ts+10275 /* "method" */, 0, bp+360 /* &iCmd */) 35489 if ret != 0 { 35490 return TCL_ERROR 35491 } 35492 if objc != (*RbuCmd)(unsafe.Pointer(bp+24 /* &aCmd */ +uintptr(*(*int32)(unsafe.Pointer(bp + 360 /* iCmd */)))*24)).FnArg { 35493 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, (*RbuCmd)(unsafe.Pointer(bp+24 /* &aCmd */ +uintptr(*(*int32)(unsafe.Pointer(bp + 360 /* iCmd */)))*24)).FzUsage) 35494 return TCL_ERROR 35495 } 35496 35497 switch *(*int32)(unsafe.Pointer(bp + 360 /* iCmd */)) { 35498 case 0: /* step */ 35499 { 35500 var rc int32 = sqlite3.Xsqlite3rbu_step(tls, pRbu) 35501 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 35502 break 35503 35504 } 35505 35506 case 9: 35507 fallthrough /* close_no_error */ 35508 case 1: /* close */ 35509 { 35510 *(*uintptr)(unsafe.Pointer(bp + 368 /* zErrmsg */)) = uintptr(0) 35511 var rc int32 35512 tcl.XTcl_DeleteCommand(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv)))) 35513 if *(*int32)(unsafe.Pointer(bp + 360 /* iCmd */)) == 1 { 35514 rc = sqlite3.Xsqlite3rbu_close(tls, pRbu, bp+368 /* &zErrmsg */) 35515 } else { 35516 rc = sqlite3.Xsqlite3rbu_close(tls, pRbu, uintptr(0)) 35517 } 35518 if (rc == SQLITE_OK) || (rc == SQLITE_DONE) { 35519 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 35520 35521 } else { 35522 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 35523 if *(*uintptr)(unsafe.Pointer(bp + 368 /* zErrmsg */)) != 0 { 35524 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+10282 /* " - " */, *(*uintptr)(unsafe.Pointer(bp + 368 /* zErrmsg */)), 0)) 35525 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 368 /* zErrmsg */))) 35526 } 35527 ret = TCL_ERROR 35528 } 35529 break 35530 35531 } 35532 35533 case 2: /* create_rbu_delta */ 35534 { 35535 var db uintptr = sqlite3.Xsqlite3rbu_db(tls, pRbu, 0) 35536 var rc int32 = sqlite3.Xsqlite3_create_function(tls, 35537 db, ts+10112 /* "rbu_delta" */, -1, SQLITE_UTF8, interp, *(*uintptr)(unsafe.Pointer(&struct { 35538 f func(*libc.TLS, uintptr, int32, uintptr) 35539 }{test_rbu_delta})), uintptr(0), uintptr(0)) 35540 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 35541 ret = func() int32 { 35542 if rc == SQLITE_OK { 35543 return TCL_OK 35544 } 35545 return TCL_ERROR 35546 }() 35547 break 35548 35549 } 35550 35551 case 3: /* savestate */ 35552 { 35553 var rc int32 = sqlite3.Xsqlite3rbu_savestate(tls, pRbu) 35554 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 35555 ret = func() int32 { 35556 if rc == SQLITE_OK { 35557 return TCL_OK 35558 } 35559 return TCL_ERROR 35560 }() 35561 break 35562 35563 } 35564 35565 case 12: 35566 fallthrough /* dbRbu_eval */ 35567 case 4: /* dbMain_eval */ 35568 { 35569 var db uintptr = sqlite3.Xsqlite3rbu_db(tls, pRbu, (libc.Bool32(*(*int32)(unsafe.Pointer(bp + 360 /* iCmd */)) == 12))) 35570 var rc int32 = sqlite3.Xsqlite3_exec(tls, db, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), uintptr(0), uintptr(0), uintptr(0)) 35571 if rc != SQLITE_OK { 35572 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_errmsg(tls, db), -1)) 35573 ret = TCL_ERROR 35574 } 35575 break 35576 35577 } 35578 35579 case 5: /* bp_progress */ 35580 { 35581 // var one int32 at bp+376, 4 35582 35583 // var two int32 at bp+380, 4 35584 35585 var pObj uintptr 35586 sqlite3.Xsqlite3rbu_bp_progress(tls, pRbu, bp+376 /* &one */, bp+380 /* &two */) 35587 35588 pObj = tcl.XTcl_NewObj(tls) 35589 tcl.XTcl_ListObjAppendElement(tls, interp, pObj, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 376 /* one */)))) 35590 tcl.XTcl_ListObjAppendElement(tls, interp, pObj, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 380 /* two */)))) 35591 tcl.XTcl_SetObjResult(tls, interp, pObj) 35592 break 35593 35594 } 35595 35596 case 6: /* db */ 35597 { 35598 // var bArg int32 at bp+384, 4 35599 35600 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+384 /* &bArg */) != 0 { 35601 ret = TCL_ERROR 35602 } else { 35603 // var zBuf [50]int8 at bp+388, 50 35604 35605 var db uintptr = sqlite3.Xsqlite3rbu_db(tls, pRbu, *(*int32)(unsafe.Pointer(bp + 384 /* bArg */))) 35606 if sqlite3TestMakePointerStr(tls, interp, bp+388 /* &zBuf[0] */, db) != 0 { 35607 ret = TCL_ERROR 35608 } else { 35609 tcl.XTcl_SetResult(tls, interp, bp+388 /* &zBuf[0] */, uintptr(1)) 35610 } 35611 } 35612 break 35613 35614 } 35615 case 7: /* state */ 35616 { 35617 *(*[6]uintptr)(unsafe.Pointer(bp + 440 /* aRes */)) = [6]uintptr{uintptr(0), ts + 10286 /* "oal" */, ts + 10290 /* "move" */, ts + 10295 /* "checkpoint" */, ts + 10306 /* "done" */, ts + 10311 /* "error" */} 35618 var eState int32 = sqlite3.Xsqlite3rbu_state(tls, pRbu) 35619 35620 tcl.XTcl_SetResult(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 440 /* &aRes[0] */ + uintptr(eState)*8)), uintptr(0)) 35621 break 35622 35623 } 35624 case 8: /* progress */ 35625 { 35626 var nStep sqlite3_int64 = sqlite3.Xsqlite3rbu_progress(tls, pRbu) 35627 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, nStep)) 35628 break 35629 35630 } 35631 35632 case 10: /* temp_size_limit */ 35633 { 35634 // var nLimit sqlite3_int64 at bp+488, 8 35635 35636 if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+488 /* &nLimit */) != 0 { 35637 ret = TCL_ERROR 35638 } else { 35639 *(*sqlite3_int64)(unsafe.Pointer(bp + 488 /* nLimit */)) = sqlite3.Xsqlite3rbu_temp_size_limit(tls, pRbu, *(*sqlite3_int64)(unsafe.Pointer(bp + 488 /* nLimit */))) 35640 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, *(*sqlite3_int64)(unsafe.Pointer(bp + 488 /* nLimit */)))) 35641 } 35642 break 35643 35644 } 35645 case 11: /* temp_size */ 35646 { 35647 var sz sqlite3_int64 = sqlite3.Xsqlite3rbu_temp_size(tls, pRbu) 35648 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, sz)) 35649 break 35650 35651 } 35652 35653 default: // seems unlikely 35654 35655 break 35656 } 35657 35658 return ret 35659 } 35660 35661 type RbuCmd = struct { 35662 FzName uintptr 35663 FnArg int32 35664 _ [4]byte 35665 FzUsage uintptr 35666 } /* test_rbu.c:67:3 */ 35667 35668 // Tclcmd: sqlite3rbu CMD <target-db> <rbu-db> ?<state-db>? 35669 func test_sqlite3rbu(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_rbu.c:228:26: */ 35670 var pRbu uintptr = uintptr(0) 35671 var zCmd uintptr 35672 var zTarget uintptr 35673 var zRbu uintptr 35674 var zStateDb uintptr = uintptr(0) 35675 35676 if (objc != 4) && (objc != 5) { 35677 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+10317 /* "NAME TARGET-DB R..." */) 35678 return TCL_ERROR 35679 } 35680 zCmd = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 35681 zTarget = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 35682 zRbu = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 35683 if objc == 5 { 35684 zStateDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8))) 35685 } 35686 35687 pRbu = sqlite3.Xsqlite3rbu_open(tls, zTarget, zRbu, zStateDb) 35688 tcl.XTcl_CreateObjCommand(tls, interp, zCmd, *(*uintptr)(unsafe.Pointer(&struct { 35689 f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 35690 }{test_sqlite3rbu_cmd})), pRbu, uintptr(0)) 35691 tcl.XTcl_SetObjResult(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 35692 return TCL_OK 35693 } 35694 35695 // Tclcmd: sqlite3rbu_vacuum CMD <target-db> <state-db> 35696 func test_sqlite3rbu_vacuum(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_rbu.c:258:26: */ 35697 var pRbu uintptr = uintptr(0) 35698 var zCmd uintptr 35699 var zTarget uintptr 35700 var zStateDb uintptr = uintptr(0) 35701 35702 if (objc != 3) && (objc != 4) { 35703 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+10350 /* "NAME TARGET-DB ?..." */) 35704 return TCL_ERROR 35705 } 35706 zCmd = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 35707 zTarget = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 35708 if objc == 4 { 35709 zStateDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 35710 } 35711 if (zStateDb != 0) && (int32(*(*int8)(unsafe.Pointer(zStateDb))) == 0) { 35712 zStateDb = uintptr(0) 35713 } 35714 35715 pRbu = sqlite3.Xsqlite3rbu_vacuum(tls, zTarget, zStateDb) 35716 tcl.XTcl_CreateObjCommand(tls, interp, zCmd, *(*uintptr)(unsafe.Pointer(&struct { 35717 f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 35718 }{test_sqlite3rbu_cmd})), pRbu, uintptr(0)) 35719 tcl.XTcl_SetObjResult(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 35720 return TCL_OK 35721 } 35722 35723 // Tclcmd: sqlite3rbu_create_vfs ?-default? NAME PARENT 35724 func test_sqlite3rbu_create_vfs(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_rbu.c:287:26: */ 35725 var zName uintptr 35726 var zParent uintptr 35727 var rc int32 35728 35729 if (objc != 3) && (objc != 4) { 35730 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+10376 /* "?-default? NAME ..." */) 35731 return TCL_ERROR 35732 } 35733 35734 zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-2))*8))) 35735 zParent = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-1))*8))) 35736 if int32(*(*int8)(unsafe.Pointer(zParent))) == 0 { 35737 zParent = uintptr(0) 35738 } 35739 35740 rc = sqlite3.Xsqlite3rbu_create_vfs(tls, zName, zParent) 35741 if rc != SQLITE_OK { 35742 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 35743 return TCL_ERROR 35744 } else if objc == 4 { 35745 var pVfs uintptr = sqlite3.Xsqlite3_vfs_find(tls, zName) 35746 sqlite3.Xsqlite3_vfs_register(tls, pVfs, 1) 35747 } 35748 35749 tcl.XTcl_ResetResult(tls, interp) 35750 return TCL_OK 35751 } 35752 35753 // Tclcmd: sqlite3rbu_destroy_vfs NAME 35754 func test_sqlite3rbu_destroy_vfs(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_rbu.c:322:26: */ 35755 var zName uintptr 35756 35757 if objc != 2 { 35758 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+10399 /* "NAME" */) 35759 return TCL_ERROR 35760 } 35761 35762 zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 35763 sqlite3.Xsqlite3rbu_destroy_vfs(tls, zName) 35764 return TCL_OK 35765 } 35766 35767 // Tclcmd: sqlite3rbu_internal_test 35768 func test_sqlite3rbu_internal_test(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_rbu.c:343:26: */ 35769 bp := tls.Alloc(16) 35770 defer tls.Free(16) 35771 35772 var db uintptr 35773 35774 if objc != 1 { 35775 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 35776 return TCL_ERROR 35777 } 35778 35779 db = sqlite3.Xsqlite3rbu_db(tls, uintptr(0), 0) 35780 if db != uintptr(0) { 35781 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+10404 /* "sqlite3rbu_db(0,..." */, 0)) 35782 return TCL_ERROR 35783 } 35784 35785 return TCL_OK 35786 } 35787 35788 func SqliteRbu_Init(tls *libc.TLS, interp uintptr) int32 { /* test_rbu.c:365:5: */ 35789 var i int32 35790 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aObjCmd)) / uint64(unsafe.Sizeof(struct { 35791 FzName uintptr 35792 FxProc uintptr 35793 }{}))); i++ { 35794 tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd[i].FzName, aObjCmd[i].FxProc, uintptr(0), uintptr(0)) 35795 } 35796 return TCL_OK 35797 } 35798 35799 var aObjCmd = [5]struct { 35800 FzName uintptr 35801 FxProc uintptr 35802 }{ 35803 {FzName: ts + 10427 /* "sqlite3rbu" */, FxProc: 0}, 35804 {FzName: ts + 10438 /* "sqlite3rbu_vacuu..." */, FxProc: 0}, 35805 {FzName: ts + 10456 /* "sqlite3rbu_creat..." */, FxProc: 0}, 35806 {FzName: ts + 10478 /* "sqlite3rbu_destr..." */, FxProc: 0}, 35807 {FzName: ts + 10501 /* "sqlite3rbu_inter..." */, FxProc: 0}, 35808 } /* test_rbu.c:369:5 */ 35809 35810 // 2014-09-08 35811 // 35812 // The author disclaims copyright to this source code. In place of 35813 // a legal notice, here is a blessing: 35814 // 35815 // May you do good and not evil. 35816 // May you find forgiveness for yourself and forgive others. 35817 // May you share freely, never taking more than you give. 35818 // 35819 // 35820 // 35821 // This file contains the bulk of the implementation of the 35822 // user-authentication extension feature. Some parts of the user- 35823 // authentication code are contained within the SQLite core (in the 35824 // src/ subdirectory of the main source code tree) but those parts 35825 // that could reasonable be separated out are moved into this file. 35826 // 35827 // To compile with the user-authentication feature, append this file to 35828 // end of an SQLite amalgamation, then add the SQLITE_USER_AUTHENTICATION 35829 // compile-time option. See the user-auth.txt file in the same source 35830 // directory as this file for additional information. 35831 35832 // Used to get the current process ID 35833 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 35834 // This file is part of the GNU C Library. 35835 // 35836 // The GNU C Library is free software; you can redistribute it and/or 35837 // modify it under the terms of the GNU Lesser General Public 35838 // License as published by the Free Software Foundation; either 35839 // version 2.1 of the License, or (at your option) any later version. 35840 // 35841 // The GNU C Library is distributed in the hope that it will be useful, 35842 // but WITHOUT ANY WARRANTY; without even the implied warranty of 35843 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 35844 // Lesser General Public License for more details. 35845 // 35846 // You should have received a copy of the GNU Lesser General Public 35847 // License along with the GNU C Library; if not, see 35848 // <http://www.gnu.org/licenses/>. 35849 35850 // ISO C99 Standard: 7.14 Signal handling <signal.h> 35851 35852 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 35853 // This file is part of the GNU C Library. 35854 // 35855 // The GNU C Library is free software; you can redistribute it and/or 35856 // modify it under the terms of the GNU Lesser General Public 35857 // License as published by the Free Software Foundation; either 35858 // version 2.1 of the License, or (at your option) any later version. 35859 // 35860 // The GNU C Library is distributed in the hope that it will be useful, 35861 // but WITHOUT ANY WARRANTY; without even the implied warranty of 35862 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 35863 // Lesser General Public License for more details. 35864 // 35865 // You should have received a copy of the GNU Lesser General Public 35866 // License along with the GNU C Library; if not, see 35867 // <http://www.gnu.org/licenses/>. 35868 35869 // bits/types.h -- definitions of __*_t types underlying *_t types. 35870 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 35871 // This file is part of the GNU C Library. 35872 // 35873 // The GNU C Library is free software; you can redistribute it and/or 35874 // modify it under the terms of the GNU Lesser General Public 35875 // License as published by the Free Software Foundation; either 35876 // version 2.1 of the License, or (at your option) any later version. 35877 // 35878 // The GNU C Library is distributed in the hope that it will be useful, 35879 // but WITHOUT ANY WARRANTY; without even the implied warranty of 35880 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 35881 // Lesser General Public License for more details. 35882 // 35883 // You should have received a copy of the GNU Lesser General Public 35884 // License along with the GNU C Library; if not, see 35885 // <http://www.gnu.org/licenses/>. 35886 35887 // Never include this file directly; use <sys/types.h> instead. 35888 35889 // Signal number definitions. Linux version. 35890 // Copyright (C) 1995-2018 Free Software Foundation, Inc. 35891 // This file is part of the GNU C Library. 35892 // 35893 // The GNU C Library is free software; you can redistribute it and/or 35894 // modify it under the terms of the GNU Lesser General Public 35895 // License as published by the Free Software Foundation; either 35896 // version 2.1 of the License, or (at your option) any later version. 35897 // 35898 // The GNU C Library is distributed in the hope that it will be useful, 35899 // but WITHOUT ANY WARRANTY; without even the implied warranty of 35900 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 35901 // Lesser General Public License for more details. 35902 // 35903 // You should have received a copy of the GNU Lesser General Public 35904 // License along with the GNU C Library; if not, see 35905 // <http://www.gnu.org/licenses/>. 35906 35907 // Signal number constants. Generic template. 35908 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 35909 // This file is part of the GNU C Library. 35910 // 35911 // The GNU C Library is free software; you can redistribute it and/or 35912 // modify it under the terms of the GNU Lesser General Public 35913 // License as published by the Free Software Foundation; either 35914 // version 2.1 of the License, or (at your option) any later version. 35915 // 35916 // The GNU C Library is distributed in the hope that it will be useful, 35917 // but WITHOUT ANY WARRANTY; without even the implied warranty of 35918 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 35919 // Lesser General Public License for more details. 35920 // 35921 // You should have received a copy of the GNU Lesser General Public 35922 // License along with the GNU C Library; if not, see 35923 // <http://www.gnu.org/licenses/>. 35924 35925 // Fake signal functions. 35926 35927 // We define here all the signal names listed in POSIX (1003.1-2008); 35928 // as of 1003.1-2013, no additional signals have been added by POSIX. 35929 // We also define here signal names that historically exist in every 35930 // real-world POSIX variant (e.g. SIGWINCH). 35931 // 35932 // Signals in the 1-15 range are defined with their historical numbers. 35933 // For other signals, we use the BSD numbers. 35934 // There are two unallocated signal numbers in the 1-31 range: 7 and 29. 35935 // Signal number 0 is reserved for use as kill(pid, 0), to test whether 35936 // a process exists without sending it a signal. 35937 35938 // ISO C99 signals. 35939 35940 // Historical signals specified by POSIX. 35941 35942 // New(er) POSIX signals (1003.1-2008, 1003.1-2013). 35943 35944 // Nonstandard signals found in all modern POSIX systems 35945 // (including both BSD and Linux). 35946 35947 // Archaic names for compatibility. 35948 35949 // Not all systems support real-time signals. bits/signum.h indicates 35950 // that they are supported by overriding __SIGRTMAX to a value greater 35951 // than __SIGRTMIN. These constants give the kernel-level hard limits, 35952 // but some real-time signals may be used internally by glibc. Do not 35953 // use these constants in application code; use SIGRTMIN and SIGRTMAX 35954 // (defined in signal.h) instead. 35955 35956 // Biggest signal number + 1 (including real-time signals). 35957 35958 // Adjustments and additions to the signal number constants for 35959 // most Linux systems. 35960 35961 // bits/types.h -- definitions of __*_t types underlying *_t types. 35962 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 35963 // This file is part of the GNU C Library. 35964 // 35965 // The GNU C Library is free software; you can redistribute it and/or 35966 // modify it under the terms of the GNU Lesser General Public 35967 // License as published by the Free Software Foundation; either 35968 // version 2.1 of the License, or (at your option) any later version. 35969 // 35970 // The GNU C Library is distributed in the hope that it will be useful, 35971 // but WITHOUT ANY WARRANTY; without even the implied warranty of 35972 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 35973 // Lesser General Public License for more details. 35974 // 35975 // You should have received a copy of the GNU Lesser General Public 35976 // License along with the GNU C Library; if not, see 35977 // <http://www.gnu.org/licenses/>. 35978 35979 // Never include this file directly; use <sys/types.h> instead. 35980 35981 // An integral type that can be modified atomically, without the 35982 // possibility of a signal arriving in the middle of the operation. 35983 type sig_atomic_t = int32 /* sig_atomic_t.h:8:24 */ 35984 35985 // We need `struct timespec' later on. 35986 // NB: Include guard matches what <linux/time.h> uses. 35987 35988 // Determine the wordsize from the preprocessor defines. 35989 35990 // bits/types.h -- definitions of __*_t types underlying *_t types. 35991 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 35992 // This file is part of the GNU C Library. 35993 // 35994 // The GNU C Library is free software; you can redistribute it and/or 35995 // modify it under the terms of the GNU Lesser General Public 35996 // License as published by the Free Software Foundation; either 35997 // version 2.1 of the License, or (at your option) any later version. 35998 // 35999 // The GNU C Library is distributed in the hope that it will be useful, 36000 // but WITHOUT ANY WARRANTY; without even the implied warranty of 36001 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 36002 // Lesser General Public License for more details. 36003 // 36004 // You should have received a copy of the GNU Lesser General Public 36005 // License along with the GNU C Library; if not, see 36006 // <http://www.gnu.org/licenses/>. 36007 36008 // Never include this file directly; use <sys/types.h> instead. 36009 36010 // Define __sigval_t. 36011 // Copyright (C) 1997-2018 Free Software Foundation, Inc. 36012 // This file is part of the GNU C Library. 36013 // 36014 // The GNU C Library is free software; you can redistribute it and/or 36015 // modify it under the terms of the GNU Lesser General Public 36016 // License as published by the Free Software Foundation; either 36017 // version 2.1 of the License, or (at your option) any later version. 36018 // 36019 // The GNU C Library is distributed in the hope that it will be useful, 36020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 36021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 36022 // Lesser General Public License for more details. 36023 // 36024 // You should have received a copy of the GNU Lesser General Public 36025 // License along with the GNU C Library; if not, see 36026 // <http://www.gnu.org/licenses/>. 36027 36028 // Type for data associated with a signal. 36029 type sigval = struct { 36030 _ [0]uint64 36031 Fsival_int int32 36032 _ [4]byte 36033 } /* __sigval_t.h:24:1 */ 36034 36035 // Some fields of siginfo_t have architecture-specific variations. 36036 // Architecture-specific adjustments to siginfo_t. 36037 36038 // This architecture has no adjustments to make to siginfo_t. 36039 36040 type siginfo_t = struct { 36041 Fsi_signo int32 36042 Fsi_errno int32 36043 Fsi_code int32 36044 F__pad0 int32 36045 F_sifields struct { 36046 _ [0]uint64 36047 F_pad [28]int32 36048 } 36049 } /* siginfo_t.h:124:5 */ 36050 36051 // Architectures might also add architecture-specific constants. 36052 // These are all considered GNU extensions. 36053 36054 // Define __sigval_t. 36055 // Copyright (C) 1997-2018 Free Software Foundation, Inc. 36056 // This file is part of the GNU C Library. 36057 // 36058 // The GNU C Library is free software; you can redistribute it and/or 36059 // modify it under the terms of the GNU Lesser General Public 36060 // License as published by the Free Software Foundation; either 36061 // version 2.1 of the License, or (at your option) any later version. 36062 // 36063 // The GNU C Library is distributed in the hope that it will be useful, 36064 // but WITHOUT ANY WARRANTY; without even the implied warranty of 36065 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 36066 // Lesser General Public License for more details. 36067 // 36068 // You should have received a copy of the GNU Lesser General Public 36069 // License along with the GNU C Library; if not, see 36070 // <http://www.gnu.org/licenses/>. 36071 36072 // To avoid sigval_t (not a standard type name) having C++ name 36073 // mangling depending on whether the selected standard includes union 36074 // sigval, it should not be defined at all when using a standard for 36075 // which the sigval name is not reserved; in that case, headers should 36076 // not include <bits/types/sigval_t.h> and should use only the 36077 // internal __sigval_t name. 36078 36079 type sigval_t = sigval /* sigval_t.h:16:20 */ 36080 36081 // Determine the wordsize from the preprocessor defines. 36082 36083 // bits/types.h -- definitions of __*_t types underlying *_t types. 36084 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 36085 // This file is part of the GNU C Library. 36086 // 36087 // The GNU C Library is free software; you can redistribute it and/or 36088 // modify it under the terms of the GNU Lesser General Public 36089 // License as published by the Free Software Foundation; either 36090 // version 2.1 of the License, or (at your option) any later version. 36091 // 36092 // The GNU C Library is distributed in the hope that it will be useful, 36093 // but WITHOUT ANY WARRANTY; without even the implied warranty of 36094 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 36095 // Lesser General Public License for more details. 36096 // 36097 // You should have received a copy of the GNU Lesser General Public 36098 // License along with the GNU C Library; if not, see 36099 // <http://www.gnu.org/licenses/>. 36100 36101 // Never include this file directly; use <sys/types.h> instead. 36102 36103 // Define __sigval_t. 36104 // Copyright (C) 1997-2018 Free Software Foundation, Inc. 36105 // This file is part of the GNU C Library. 36106 // 36107 // The GNU C Library is free software; you can redistribute it and/or 36108 // modify it under the terms of the GNU Lesser General Public 36109 // License as published by the Free Software Foundation; either 36110 // version 2.1 of the License, or (at your option) any later version. 36111 // 36112 // The GNU C Library is distributed in the hope that it will be useful, 36113 // but WITHOUT ANY WARRANTY; without even the implied warranty of 36114 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 36115 // Lesser General Public License for more details. 36116 // 36117 // You should have received a copy of the GNU Lesser General Public 36118 // License along with the GNU C Library; if not, see 36119 // <http://www.gnu.org/licenses/>. 36120 36121 // Forward declaration. 36122 36123 // Structure to transport application-defined values with signals. 36124 type sigevent_t = sigevent /* sigevent_t.h:42:5 */ 36125 36126 // 4.4 BSD uses the name `sig_t' for this. 36127 type sig_t = uintptr /* signal.h:190:24 */ 36128 36129 // Get the system-specific definitions of `struct sigaction' 36130 // and the `SA_*' and `SIG_*'. constants. 36131 // Definitions for 31 & 64 bit S/390 sigaction. 36132 // Copyright (C) 2001-2018 Free Software Foundation, Inc. 36133 // This file is part of the GNU C Library. 36134 // 36135 // The GNU C Library is free software; you can redistribute it and/or 36136 // modify it under the terms of the GNU Lesser General Public 36137 // License as published by the Free Software Foundation; either 36138 // version 2.1 of the License, or (at your option) any later version. 36139 // 36140 // The GNU C Library is distributed in the hope that it will be useful, 36141 // but WITHOUT ANY WARRANTY; without even the implied warranty of 36142 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 36143 // Lesser General Public License for more details. 36144 // 36145 // You should have received a copy of the GNU Lesser General Public 36146 // License along with the GNU C Library; if not, see 36147 // <http://www.gnu.org/licenses/>. 36148 36149 // Determine the wordsize from the preprocessor defines. 36150 36151 // Structure describing the action to be taken when a signal arrives. 36152 type sigaction = struct { 36153 F__sigaction_handler struct{ Fsa_handler uintptr } 36154 F__glibc_reserved0 int32 36155 Fsa_flags int32 36156 Fsa_restorer uintptr 36157 Fsa_mask struct{ F__val [16]uint64 } 36158 } /* sigaction.h:30:1 */ 36159 36160 // A address type so that arithmetic can be done on it & it can be upgraded to 36161 // 64 bit when necessary 36162 type addr_t = uint64 /* types.h:18:23 */ 36163 type saddr_t = int64 /* types.h:19:25 */ 36164 36165 // Has to be at least _NSIG_WORDS from asm/signal.h 36166 // Size of stack frame allocated when calling signal handler. 36167 36168 type _psw_t = struct { 36169 Fmask uint64 36170 Faddr uint64 36171 } /* sigcontext.h:45:32 */ 36172 36173 type _s390_regs_common = struct { 36174 Fpsw _psw_t 36175 Fgprs [16]uint64 36176 Facrs [16]uint32 36177 } /* sigcontext.h:52:3 */ 36178 36179 type _s390_fp_regs = struct { 36180 Ffpc uint32 36181 Fpad uint32 36182 Ffprs [16]float64 36183 } /* sigcontext.h:59:3 */ 36184 36185 type _sigregs = struct { 36186 Fregs _s390_regs_common 36187 Ffpregs _s390_fp_regs 36188 } /* sigcontext.h:65:3 */ 36189 36190 type _sigregs_ext = struct { 36191 Fvxrs_low [16]uint64 36192 Fvxrs_high [16]struct{ Fu [4]uint32 } 36193 F__reserved [128]uint8 36194 } /* sigcontext.h:75:3 */ 36195 36196 type sigcontext = struct { 36197 Foldmask [1]uint64 36198 Fsregs uintptr 36199 } /* sigcontext.h:77:1 */ 36200 36201 // Copyright (C) 1989-2018 Free Software Foundation, Inc. 36202 // 36203 // This file is part of GCC. 36204 // 36205 // GCC is free software; you can redistribute it and/or modify 36206 // it under the terms of the GNU General Public License as published by 36207 // the Free Software Foundation; either version 3, or (at your option) 36208 // any later version. 36209 // 36210 // GCC is distributed in the hope that it will be useful, 36211 // but WITHOUT ANY WARRANTY; without even the implied warranty of 36212 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 36213 // GNU General Public License for more details. 36214 // 36215 // Under Section 7 of GPL version 3, you are granted additional 36216 // permissions described in the GCC Runtime Library Exception, version 36217 // 3.1, as published by the Free Software Foundation. 36218 // 36219 // You should have received a copy of the GNU General Public License and 36220 // a copy of the GCC Runtime Library Exception along with this program; 36221 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 36222 // <http://www.gnu.org/licenses/>. 36223 36224 // ISO C Standard: 7.17 Common definitions <stddef.h> 36225 36226 // Any one of these symbols __need_* means that GNU libc 36227 // wants us just to define one data type. So don't define 36228 // the symbols that indicate this file's entire job has been done. 36229 36230 // This avoids lossage on SunOS but only if stdtypes.h comes first. 36231 // There's no way to win with the other order! Sun lossage. 36232 36233 // On 4.3bsd-net2, make sure ansi.h is included, so we have 36234 // one less case to deal with in the following. 36235 // On FreeBSD 5, machine/ansi.h does not exist anymore... 36236 36237 // In 4.3bsd-net2, machine/ansi.h defines these symbols, which are 36238 // defined if the corresponding type is *not* defined. 36239 // FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_. 36240 // NetBSD defines _I386_ANSI_H_ and _X86_64_ANSI_H_ instead of _ANSI_H_ 36241 36242 // Sequent's header files use _PTRDIFF_T_ in some conflicting way. 36243 // Just ignore it. 36244 36245 // On VxWorks, <type/vxTypesBase.h> may have defined macros like 36246 // _TYPE_size_t which will typedef size_t. fixincludes patched the 36247 // vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is 36248 // not defined, and so that defining this macro defines _GCC_SIZE_T. 36249 // If we find that the macros are still defined at this point, we must 36250 // invoke them so that the type is defined as expected. 36251 36252 // In case nobody has defined these types, but we aren't running under 36253 // GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and 36254 // __WCHAR_TYPE__ have reasonable values. This can happen if the 36255 // parts of GCC is compiled by an older compiler, that actually 36256 // include gstddef.h, such as collect2. 36257 36258 // Signed type of difference of two pointers. 36259 36260 // Define this type if we are doing the whole job, 36261 // or if we want this type in particular. 36262 36263 // Unsigned type of `sizeof' something. 36264 36265 // Define this type if we are doing the whole job, 36266 // or if we want this type in particular. 36267 36268 // Wide character type. 36269 // Locale-writers should change this as necessary to 36270 // be big enough to hold unique values not between 0 and 127, 36271 // and not (wchar_t) -1, for each defined multibyte character. 36272 36273 // Define this type if we are doing the whole job, 36274 // or if we want this type in particular. 36275 36276 // In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. 36277 // are already defined. 36278 // BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. 36279 // NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here. 36280 36281 // A null pointer constant. 36282 36283 // Define stack_t. Linux version. 36284 // Copyright (C) 1998-2018 Free Software Foundation, Inc. 36285 // This file is part of the GNU C Library. 36286 // 36287 // The GNU C Library is free software; you can redistribute it and/or 36288 // modify it under the terms of the GNU Lesser General Public 36289 // License as published by the Free Software Foundation; either 36290 // version 2.1 of the License, or (at your option) any later version. 36291 // 36292 // The GNU C Library is distributed in the hope that it will be useful, 36293 // but WITHOUT ANY WARRANTY; without even the implied warranty of 36294 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 36295 // Lesser General Public License for more details. 36296 // 36297 // You should have received a copy of the GNU Lesser General Public 36298 // License along with the GNU C Library; if not, see 36299 // <http://www.gnu.org/licenses/>. 36300 36301 // Copyright (C) 1989-2018 Free Software Foundation, Inc. 36302 // 36303 // This file is part of GCC. 36304 // 36305 // GCC is free software; you can redistribute it and/or modify 36306 // it under the terms of the GNU General Public License as published by 36307 // the Free Software Foundation; either version 3, or (at your option) 36308 // any later version. 36309 // 36310 // GCC is distributed in the hope that it will be useful, 36311 // but WITHOUT ANY WARRANTY; without even the implied warranty of 36312 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 36313 // GNU General Public License for more details. 36314 // 36315 // Under Section 7 of GPL version 3, you are granted additional 36316 // permissions described in the GCC Runtime Library Exception, version 36317 // 3.1, as published by the Free Software Foundation. 36318 // 36319 // You should have received a copy of the GNU General Public License and 36320 // a copy of the GCC Runtime Library Exception along with this program; 36321 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 36322 // <http://www.gnu.org/licenses/>. 36323 36324 // ISO C Standard: 7.17 Common definitions <stddef.h> 36325 36326 // Any one of these symbols __need_* means that GNU libc 36327 // wants us just to define one data type. So don't define 36328 // the symbols that indicate this file's entire job has been done. 36329 36330 // This avoids lossage on SunOS but only if stdtypes.h comes first. 36331 // There's no way to win with the other order! Sun lossage. 36332 36333 // On 4.3bsd-net2, make sure ansi.h is included, so we have 36334 // one less case to deal with in the following. 36335 // On FreeBSD 5, machine/ansi.h does not exist anymore... 36336 36337 // In 4.3bsd-net2, machine/ansi.h defines these symbols, which are 36338 // defined if the corresponding type is *not* defined. 36339 // FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_. 36340 // NetBSD defines _I386_ANSI_H_ and _X86_64_ANSI_H_ instead of _ANSI_H_ 36341 36342 // Sequent's header files use _PTRDIFF_T_ in some conflicting way. 36343 // Just ignore it. 36344 36345 // On VxWorks, <type/vxTypesBase.h> may have defined macros like 36346 // _TYPE_size_t which will typedef size_t. fixincludes patched the 36347 // vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is 36348 // not defined, and so that defining this macro defines _GCC_SIZE_T. 36349 // If we find that the macros are still defined at this point, we must 36350 // invoke them so that the type is defined as expected. 36351 36352 // In case nobody has defined these types, but we aren't running under 36353 // GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and 36354 // __WCHAR_TYPE__ have reasonable values. This can happen if the 36355 // parts of GCC is compiled by an older compiler, that actually 36356 // include gstddef.h, such as collect2. 36357 36358 // Signed type of difference of two pointers. 36359 36360 // Define this type if we are doing the whole job, 36361 // or if we want this type in particular. 36362 36363 // Unsigned type of `sizeof' something. 36364 36365 // Define this type if we are doing the whole job, 36366 // or if we want this type in particular. 36367 36368 // Wide character type. 36369 // Locale-writers should change this as necessary to 36370 // be big enough to hold unique values not between 0 and 127, 36371 // and not (wchar_t) -1, for each defined multibyte character. 36372 36373 // Define this type if we are doing the whole job, 36374 // or if we want this type in particular. 36375 36376 // In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. 36377 // are already defined. 36378 // BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. 36379 // NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here. 36380 36381 // A null pointer constant. 36382 36383 // Structure describing a signal stack. 36384 type stack_t = struct { 36385 Fss_sp uintptr 36386 Fss_flags int32 36387 _ [4]byte 36388 Fss_size size_t 36389 } /* stack_t.h:31:5 */ 36390 36391 // Type for a general-purpose register. 36392 type greg_t = uint64 /* ucontext.h:42:23 */ 36393 36394 // And the whole bunch of them. We should have used `struct s390_regs', 36395 // but to avoid name space pollution and since the tradition says that 36396 // the register set is an array, we make gregset_t a simple array 36397 // that has the same size as s390_regs. This is needed for the 36398 // elf_prstatus structure. 36399 // Must match kernels psw_t alignment. 36400 type gregset_t = [27]greg_t /* ucontext.h:58:16 */ 36401 36402 type fpreg_t = struct{ Fd float64 } /* ucontext.h:64:5 */ 36403 36404 // Register set for the floating-point registers. 36405 type fpregset_t = struct { 36406 Ffpc uint32 36407 _ [4]byte 36408 Ffprs [16]fpreg_t 36409 } /* ucontext.h:71:5 */ 36410 36411 // Context to describe whole processor state. 36412 type mcontext_t = struct { 36413 Fpsw struct { 36414 Fmask uint64 36415 Faddr uint64 36416 } 36417 Fgregs [16]uint64 36418 Faregs [16]uint32 36419 Ffpregs fpregset_t 36420 } /* ucontext.h:80:5 */ 36421 36422 // Userlevel context. 36423 type ucontext_t1 = struct { 36424 Fuc_flags uint64 36425 Fuc_link uintptr 36426 Fuc_stack stack_t 36427 Fuc_mcontext mcontext_t 36428 Fuc_sigmask sigset_t 36429 } /* ucontext.h:83:9 */ 36430 36431 // Userlevel context. 36432 type ucontext_t = ucontext_t1 /* ucontext.h:90:5 */ 36433 36434 // Define struct sigstack. 36435 // Copyright (C) 1998-2018 Free Software Foundation, Inc. 36436 // This file is part of the GNU C Library. 36437 // 36438 // The GNU C Library is free software; you can redistribute it and/or 36439 // modify it under the terms of the GNU Lesser General Public 36440 // License as published by the Free Software Foundation; either 36441 // version 2.1 of the License, or (at your option) any later version. 36442 // 36443 // The GNU C Library is distributed in the hope that it will be useful, 36444 // but WITHOUT ANY WARRANTY; without even the implied warranty of 36445 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 36446 // Lesser General Public License for more details. 36447 // 36448 // You should have received a copy of the GNU Lesser General Public 36449 // License along with the GNU C Library; if not, see 36450 // <http://www.gnu.org/licenses/>. 36451 36452 // Structure describing a signal stack (obsolete). 36453 type sigstack = struct { 36454 Fss_sp uintptr 36455 Fss_onstack int32 36456 _ [4]byte 36457 } /* struct_sigstack.h:23:1 */ 36458 36459 // Define some macros helping to catch buffer overflows. 36460 36461 // Windows needs to know which symbols to export. Unix does not. 36462 // BUILD_sqlite should be undefined for Unix. 36463 36464 // Forward declaration 36465 type SqliteDb = struct { 36466 Fdb uintptr 36467 Finterp uintptr 36468 FzBusy uintptr 36469 FzCommit uintptr 36470 FzTrace uintptr 36471 FzTraceV2 uintptr 36472 FzProfile uintptr 36473 FzProgress uintptr 36474 FzBindFallback uintptr 36475 FzAuth uintptr 36476 FdisableAuth int32 36477 _ [4]byte 36478 FzNull uintptr 36479 FpFunc uintptr 36480 FpUpdateHook uintptr 36481 FpPreUpdateHook uintptr 36482 FpRollbackHook uintptr 36483 FpWalHook uintptr 36484 FpUnlockNotify uintptr 36485 FpCollate uintptr 36486 Frc int32 36487 _ [4]byte 36488 FpCollateNeeded uintptr 36489 FstmtList uintptr 36490 FstmtLast uintptr 36491 FmaxStmt int32 36492 FnStmt int32 36493 FpIncrblob uintptr 36494 FnStep int32 36495 FnSort int32 36496 FnIndex int32 36497 FnVMStep int32 36498 FnTransaction int32 36499 FopenFlags int32 36500 FbLegacyPrepare int32 36501 _ [4]byte 36502 } /* tclsqlite.c:91:25 */ 36503 36504 // New SQL functions can be created as TCL scripts. Each such function 36505 // is described by an instance of the following structure. 36506 // 36507 // Variable eType may be set to SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT, 36508 // SQLITE_BLOB or SQLITE_NULL. If it is SQLITE_NULL, then the implementation 36509 // attempts to determine the type of the result based on the Tcl object. 36510 // If it is SQLITE_TEXT or SQLITE_BLOB, then a text (sqlite3_result_text()) 36511 // or blob (sqlite3_result_blob()) is returned. If it is SQLITE_INTEGER 36512 // or SQLITE_FLOAT, then an attempt is made to return an integer or float 36513 // value, falling back to float and then text if this is not possible. 36514 type SqlFunc1 = struct { 36515 Finterp uintptr 36516 FpScript uintptr 36517 FpDb uintptr 36518 FuseEvalObjv int32 36519 FeType int32 36520 FzName uintptr 36521 FpNext uintptr 36522 } /* tclsqlite.c:105:9 */ 36523 36524 // New SQL functions can be created as TCL scripts. Each such function 36525 // is described by an instance of the following structure. 36526 // 36527 // Variable eType may be set to SQLITE_INTEGER, SQLITE_FLOAT, SQLITE_TEXT, 36528 // SQLITE_BLOB or SQLITE_NULL. If it is SQLITE_NULL, then the implementation 36529 // attempts to determine the type of the result based on the Tcl object. 36530 // If it is SQLITE_TEXT or SQLITE_BLOB, then a text (sqlite3_result_text()) 36531 // or blob (sqlite3_result_blob()) is returned. If it is SQLITE_INTEGER 36532 // or SQLITE_FLOAT, then an attempt is made to return an integer or float 36533 // value, falling back to float and then text if this is not possible. 36534 type SqlFunc = SqlFunc1 /* tclsqlite.c:105:24 */ 36535 36536 // New collation sequences function can be created as TCL scripts. Each such 36537 // function is described by an instance of the following structure. 36538 type SqlCollate1 = struct { 36539 Finterp uintptr 36540 FzScript uintptr 36541 FpNext uintptr 36542 } /* tclsqlite.c:120:9 */ 36543 36544 // New collation sequences function can be created as TCL scripts. Each such 36545 // function is described by an instance of the following structure. 36546 type SqlCollate = SqlCollate1 /* tclsqlite.c:120:27 */ 36547 36548 // Prepared statements are cached for faster execution. Each prepared 36549 // statement is described by an instance of the following structure. 36550 type SqlPreparedStmt1 = struct { 36551 FpNext uintptr 36552 FpPrev uintptr 36553 FpStmt uintptr 36554 FnSql int32 36555 _ [4]byte 36556 FzSql uintptr 36557 FnParm int32 36558 _ [4]byte 36559 FapParm uintptr 36560 } /* tclsqlite.c:131:9 */ 36561 36562 // Prepared statements are cached for faster execution. Each prepared 36563 // statement is described by an instance of the following structure. 36564 type SqlPreparedStmt = SqlPreparedStmt1 /* tclsqlite.c:131:32 */ 36565 36566 type IncrblobChannel1 = struct { 36567 FpBlob uintptr 36568 FpDb uintptr 36569 FiSeek int32 36570 _ [4]byte 36571 Fchannel Tcl_Channel 36572 FpNext uintptr 36573 FpPrev uintptr 36574 } /* tclsqlite.c:142:9 */ 36575 36576 type IncrblobChannel = IncrblobChannel1 /* tclsqlite.c:142:32 */ 36577 36578 // Compute a string length that is limited to what can be stored in 36579 // lower 30 bits of a 32-bit signed integer. 36580 func strlen30(tls *libc.TLS, z uintptr) int32 { /* tclsqlite.c:202:12: */ 36581 var z2 uintptr = z 36582 for *(*int8)(unsafe.Pointer(z2)) != 0 { 36583 z2++ 36584 } 36585 return (0x3fffffff & (int32((int64(z2) - int64(z)) / 1))) 36586 } 36587 36588 // Close all incrblob channels opened using database connection pDb. 36589 // This is called when shutting down the database connection. 36590 func closeIncrblobChannels(tls *libc.TLS, pDb uintptr) { /* tclsqlite.c:214:13: */ 36591 var p uintptr 36592 var pNext uintptr 36593 36594 for p = (*SqliteDb)(unsafe.Pointer(pDb)).FpIncrblob; p != 0; p = pNext { 36595 pNext = (*IncrblobChannel)(unsafe.Pointer(p)).FpNext 36596 36597 // Note: Calling unregister here call Tcl_Close on the incrblob channel, 36598 // which deletes the IncrblobChannel structure at *p. So do not 36599 // call Tcl_Free() here. 36600 tcl.XTcl_UnregisterChannel(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, (*IncrblobChannel)(unsafe.Pointer(p)).Fchannel) 36601 } 36602 } 36603 36604 // Close an incremental blob channel. 36605 func incrblobClose(tls *libc.TLS, instanceData ClientData, interp uintptr) int32 { /* tclsqlite.c:232:26: */ 36606 var p uintptr = instanceData 36607 var rc int32 = sqlite3.Xsqlite3_blob_close(tls, (*IncrblobChannel)(unsafe.Pointer(p)).FpBlob) 36608 var db uintptr = (*SqliteDb)(unsafe.Pointer((*IncrblobChannel)(unsafe.Pointer(p)).FpDb)).Fdb 36609 36610 // Remove the channel from the SqliteDb.pIncrblob list. 36611 if (*IncrblobChannel)(unsafe.Pointer(p)).FpNext != 0 { 36612 (*IncrblobChannel)(unsafe.Pointer((*IncrblobChannel)(unsafe.Pointer(p)).FpNext)).FpPrev = (*IncrblobChannel)(unsafe.Pointer(p)).FpPrev 36613 } 36614 if (*IncrblobChannel)(unsafe.Pointer(p)).FpPrev != 0 { 36615 (*IncrblobChannel)(unsafe.Pointer((*IncrblobChannel)(unsafe.Pointer(p)).FpPrev)).FpNext = (*IncrblobChannel)(unsafe.Pointer(p)).FpNext 36616 } 36617 if (*SqliteDb)(unsafe.Pointer((*IncrblobChannel)(unsafe.Pointer(p)).FpDb)).FpIncrblob == p { 36618 (*SqliteDb)(unsafe.Pointer((*IncrblobChannel)(unsafe.Pointer(p)).FpDb)).FpIncrblob = (*IncrblobChannel)(unsafe.Pointer(p)).FpNext 36619 } 36620 36621 // Free the IncrblobChannel structure 36622 tcl.XTcl_Free(tls, p) 36623 36624 if rc != SQLITE_OK { 36625 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3_errmsg(tls, db), uintptr(1)) 36626 return TCL_ERROR 36627 } 36628 return TCL_OK 36629 } 36630 36631 // Read data from an incremental blob channel. 36632 func incrblobInput(tls *libc.TLS, instanceData ClientData, buf uintptr, bufSize int32, errorCodePtr uintptr) int32 { /* tclsqlite.c:264:26: */ 36633 var p uintptr = instanceData 36634 var nRead int32 = bufSize // Number of bytes to read 36635 var nBlob int32 // Total size of the blob 36636 var rc int32 // sqlite error code 36637 36638 nBlob = sqlite3.Xsqlite3_blob_bytes(tls, (*IncrblobChannel)(unsafe.Pointer(p)).FpBlob) 36639 if ((*IncrblobChannel)(unsafe.Pointer(p)).FiSeek + nRead) > nBlob { 36640 nRead = (nBlob - (*IncrblobChannel)(unsafe.Pointer(p)).FiSeek) 36641 } 36642 if nRead <= 0 { 36643 return 0 36644 } 36645 36646 rc = sqlite3.Xsqlite3_blob_read(tls, (*IncrblobChannel)(unsafe.Pointer(p)).FpBlob, buf, nRead, (*IncrblobChannel)(unsafe.Pointer(p)).FiSeek) 36647 if rc != SQLITE_OK { 36648 *(*int32)(unsafe.Pointer(errorCodePtr)) = rc 36649 return -1 36650 } 36651 36652 *(*int32)(unsafe.Pointer(p + 16 /* &.iSeek */)) += (nRead) 36653 return nRead 36654 } 36655 36656 // Write data to an incremental blob channel. 36657 func incrblobOutput(tls *libc.TLS, instanceData ClientData, buf uintptr, toWrite int32, errorCodePtr uintptr) int32 { /* tclsqlite.c:296:26: */ 36658 var p uintptr = instanceData 36659 var nWrite int32 = toWrite // Number of bytes to write 36660 var nBlob int32 // Total size of the blob 36661 var rc int32 // sqlite error code 36662 36663 nBlob = sqlite3.Xsqlite3_blob_bytes(tls, (*IncrblobChannel)(unsafe.Pointer(p)).FpBlob) 36664 if ((*IncrblobChannel)(unsafe.Pointer(p)).FiSeek + nWrite) > nBlob { 36665 *(*int32)(unsafe.Pointer(errorCodePtr)) = EINVAL 36666 return -1 36667 } 36668 if nWrite <= 0 { 36669 return 0 36670 } 36671 36672 rc = sqlite3.Xsqlite3_blob_write(tls, (*IncrblobChannel)(unsafe.Pointer(p)).FpBlob, buf, nWrite, (*IncrblobChannel)(unsafe.Pointer(p)).FiSeek) 36673 if rc != SQLITE_OK { 36674 *(*int32)(unsafe.Pointer(errorCodePtr)) = EIO 36675 return -1 36676 } 36677 36678 *(*int32)(unsafe.Pointer(p + 16 /* &.iSeek */)) += (nWrite) 36679 return nWrite 36680 } 36681 36682 // Seek an incremental blob channel. 36683 func incrblobSeek(tls *libc.TLS, instanceData ClientData, offset int64, seekMode int32, errorCodePtr uintptr) int32 { /* tclsqlite.c:329:26: */ 36684 var p uintptr = instanceData 36685 36686 switch seekMode { 36687 case SEEK_SET: 36688 (*IncrblobChannel)(unsafe.Pointer(p)).FiSeek = int32(offset) 36689 break 36690 case SEEK_CUR: 36691 *(*int32)(unsafe.Pointer(p + 16 /* &.iSeek */)) += int32((offset)) 36692 break 36693 case SEEK_END: 36694 (*IncrblobChannel)(unsafe.Pointer(p)).FiSeek = (int32(int64(sqlite3.Xsqlite3_blob_bytes(tls, (*IncrblobChannel)(unsafe.Pointer(p)).FpBlob)) + offset)) 36695 break 36696 36697 default: 36698 } 36699 36700 return (*IncrblobChannel)(unsafe.Pointer(p)).FiSeek 36701 } 36702 36703 func incrblobWatch(tls *libc.TLS, instanceData ClientData, mode int32) { /* tclsqlite.c:355:27: */ 36704 // NO-OP 36705 } 36706 36707 func incrblobHandle(tls *libc.TLS, instanceData ClientData, dir int32, hPtr uintptr) int32 { /* tclsqlite.c:361:26: */ 36708 return TCL_ERROR 36709 } 36710 36711 var IncrblobChannelType = Tcl_ChannelType{ 36712 FtypeName: ts + 10526, /* "incrblob" */ // typeName 36713 Fversion: uintptr(0x2), // version 36714 FcloseProc: 0, // closeProc 36715 FinputProc: 0, // inputProc 36716 FoutputProc: 0, // outputProc 36717 FseekProc: 0, // getOptionProc 36718 FwatchProc: 0, // watchProc (this is a no-op) 36719 FgetHandleProc: 0, // wideSeekProc 36720 } /* tclsqlite.c:369:24 */ 36721 36722 // Create a new incrblob channel. 36723 func createIncrblobChannel(tls *libc.TLS, interp uintptr, pDb uintptr, zDb uintptr, zTable uintptr, zColumn uintptr, iRow sqlite_int64, isReadonly int32) int32 { /* tclsqlite.c:390:12: */ 36724 bp := tls.Alloc(80) 36725 defer tls.Free(80) 36726 36727 var p uintptr 36728 var db uintptr = (*SqliteDb)(unsafe.Pointer(pDb)).Fdb 36729 // var pBlob uintptr at bp+8, 8 36730 36731 var rc int32 36732 var flags int32 = ((int32(1) << 1) | (func() int32 { 36733 if isReadonly != 0 { 36734 return 0 36735 } 36736 return (int32(1) << 2) 36737 }())) 36738 // var zChannel [64]int8 at bp+16, 64 36739 36740 rc = sqlite3.Xsqlite3_blob_open(tls, db, zDb, zTable, zColumn, iRow, libc.BoolInt32(!(isReadonly != 0)), bp+8 /* &pBlob */) 36741 if rc != SQLITE_OK { 36742 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(1)) 36743 return TCL_ERROR 36744 } 36745 36746 p = tcl.XTcl_Alloc(tls, uint32(unsafe.Sizeof(IncrblobChannel{}))) 36747 (*IncrblobChannel)(unsafe.Pointer(p)).FiSeek = 0 36748 (*IncrblobChannel)(unsafe.Pointer(p)).FpBlob = *(*uintptr)(unsafe.Pointer(bp + 8 /* pBlob */)) 36749 36750 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([64]int8{})), bp+16 /* &zChannel[0] */, ts+10535 /* "incrblob_%d" */, libc.VaList(bp, libc.PreIncInt32(&count, 1))) 36751 (*IncrblobChannel)(unsafe.Pointer(p)).Fchannel = tcl.XTcl_CreateChannel(tls, uintptr(unsafe.Pointer(&IncrblobChannelType)), bp+16 /* &zChannel[0] */, p, flags) 36752 tcl.XTcl_RegisterChannel(tls, interp, (*IncrblobChannel)(unsafe.Pointer(p)).Fchannel) 36753 36754 // Link the new channel into the SqliteDb.pIncrblob list. 36755 (*IncrblobChannel)(unsafe.Pointer(p)).FpNext = (*SqliteDb)(unsafe.Pointer(pDb)).FpIncrblob 36756 (*IncrblobChannel)(unsafe.Pointer(p)).FpPrev = uintptr(0) 36757 if (*IncrblobChannel)(unsafe.Pointer(p)).FpNext != 0 { 36758 (*IncrblobChannel)(unsafe.Pointer((*IncrblobChannel)(unsafe.Pointer(p)).FpNext)).FpPrev = p 36759 } 36760 (*SqliteDb)(unsafe.Pointer(pDb)).FpIncrblob = p 36761 (*IncrblobChannel)(unsafe.Pointer(p)).FpDb = pDb 36762 36763 tcl.XTcl_SetResult(tls, interp, tcl.XTcl_GetChannelName(tls, (*IncrblobChannel)(unsafe.Pointer(p)).Fchannel), uintptr(1)) 36764 return TCL_OK 36765 } 36766 36767 var count int32 = 0 /* tclsqlite.c:406:14 */ 36768 36769 // Look at the script prefix in pCmd. We will be executing this script 36770 // after first appending one or more arguments. This routine analyzes 36771 // the script to see if it is safe to use Tcl_EvalObjv() on the script 36772 // rather than the more general Tcl_EvalEx(). Tcl_EvalObjv() is much 36773 // faster. 36774 // 36775 // Scripts that are safe to use with Tcl_EvalObjv() consists of a 36776 // command name followed by zero or more arguments with no [...] or $ 36777 // or {...} or ; to be seen anywhere. Most callback scripts consist 36778 // of just a single procedure name and they meet this requirement. 36779 func safeToUseEvalObjv(tls *libc.TLS, interp uintptr, pCmd uintptr) int32 { /* tclsqlite.c:451:12: */ 36780 bp := tls.Alloc(4) 36781 defer tls.Free(4) 36782 36783 // We could try to do something with Tcl_Parse(). But we will instead 36784 // just do a search for forbidden characters. If any of the forbidden 36785 // characters appear in pCmd, we will report the string as unsafe. 36786 var z uintptr 36787 // var n int32 at bp, 4 36788 36789 z = tcl.XTcl_GetStringFromObj(tls, pCmd, bp /* &n */) 36790 for libc.PostDecInt32(&*(*int32)(unsafe.Pointer(bp /* n */)), 1) > 0 { 36791 var c int32 = int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1)))) 36792 if ((c == '$') || (c == '[')) || (c == ';') { 36793 return 0 36794 } 36795 } 36796 return 1 36797 } 36798 36799 // Find an SqlFunc structure with the given name. Or create a new 36800 // one if an existing one cannot be found. Return a pointer to the 36801 // structure. 36802 func findSqlFunc(tls *libc.TLS, pDb uintptr, zName uintptr) uintptr { /* tclsqlite.c:471:16: */ 36803 var p uintptr 36804 var pNew uintptr 36805 var nName int32 = strlen30(tls, zName) 36806 pNew = tcl.XTcl_Alloc(tls, (uint32((uint64(unsafe.Sizeof(SqlFunc{})) + uint64(nName)) + uint64(1)))) 36807 (*SqlFunc)(unsafe.Pointer(pNew)).FzName = (pNew + 1*48) 36808 libc.Xmemcpy(tls, (*SqlFunc)(unsafe.Pointer(pNew)).FzName, zName, (uint64(nName + 1))) 36809 for p = (*SqliteDb)(unsafe.Pointer(pDb)).FpFunc; p != 0; p = (*SqlFunc)(unsafe.Pointer(p)).FpNext { 36810 if sqlite3.Xsqlite3_stricmp(tls, (*SqlFunc)(unsafe.Pointer(p)).FzName, (*SqlFunc)(unsafe.Pointer(pNew)).FzName) == 0 { 36811 tcl.XTcl_Free(tls, pNew) 36812 return p 36813 } 36814 } 36815 (*SqlFunc)(unsafe.Pointer(pNew)).Finterp = (*SqliteDb)(unsafe.Pointer(pDb)).Finterp 36816 (*SqlFunc)(unsafe.Pointer(pNew)).FpDb = pDb 36817 (*SqlFunc)(unsafe.Pointer(pNew)).FpScript = uintptr(0) 36818 (*SqlFunc)(unsafe.Pointer(pNew)).FpNext = (*SqliteDb)(unsafe.Pointer(pDb)).FpFunc 36819 (*SqliteDb)(unsafe.Pointer(pDb)).FpFunc = pNew 36820 return pNew 36821 } 36822 36823 // Free a single SqlPreparedStmt object. 36824 func dbFreeStmt(tls *libc.TLS, pStmt uintptr) { /* tclsqlite.c:494:13: */ 36825 if sqlite3.Xsqlite3_sql(tls, (*SqlPreparedStmt)(unsafe.Pointer(pStmt)).FpStmt) == uintptr(0) { 36826 tcl.XTcl_Free(tls, (*SqlPreparedStmt)(unsafe.Pointer(pStmt)).FzSql) 36827 } 36828 sqlite3.Xsqlite3_finalize(tls, (*SqlPreparedStmt)(unsafe.Pointer(pStmt)).FpStmt) 36829 tcl.XTcl_Free(tls, pStmt) 36830 } 36831 36832 // Finalize and free a list of prepared statements 36833 func flushStmtCache(tls *libc.TLS, pDb uintptr) { /* tclsqlite.c:507:13: */ 36834 var pPreStmt uintptr 36835 var pNext uintptr 36836 36837 for pPreStmt = (*SqliteDb)(unsafe.Pointer(pDb)).FstmtList; pPreStmt != 0; pPreStmt = pNext { 36838 pNext = (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FpNext 36839 dbFreeStmt(tls, pPreStmt) 36840 } 36841 (*SqliteDb)(unsafe.Pointer(pDb)).FnStmt = 0 36842 (*SqliteDb)(unsafe.Pointer(pDb)).FstmtLast = uintptr(0) 36843 (*SqliteDb)(unsafe.Pointer(pDb)).FstmtList = uintptr(0) 36844 } 36845 36846 // TCL calls this procedure when an sqlite3 database command is 36847 // deleted. 36848 func DbDeleteCmd(tls *libc.TLS, db uintptr) { /* tclsqlite.c:524:27: */ 36849 var pDb uintptr = db 36850 flushStmtCache(tls, pDb) 36851 closeIncrblobChannels(tls, pDb) 36852 sqlite3.Xsqlite3_close(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb) 36853 for (*SqliteDb)(unsafe.Pointer(pDb)).FpFunc != 0 { 36854 var pFunc uintptr = (*SqliteDb)(unsafe.Pointer(pDb)).FpFunc 36855 (*SqliteDb)(unsafe.Pointer(pDb)).FpFunc = (*SqlFunc)(unsafe.Pointer(pFunc)).FpNext 36856 36857 for ok := true; ok; ok = 0 != 0 { 36858 var _objPtr uintptr = (*SqlFunc)(unsafe.Pointer(pFunc)).FpScript 36859 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 36860 tcl.XTclFreeObj(tls, _objPtr) 36861 } 36862 } 36863 tcl.XTcl_Free(tls, pFunc) 36864 } 36865 for (*SqliteDb)(unsafe.Pointer(pDb)).FpCollate != 0 { 36866 var pCollate uintptr = (*SqliteDb)(unsafe.Pointer(pDb)).FpCollate 36867 (*SqliteDb)(unsafe.Pointer(pDb)).FpCollate = (*SqlCollate)(unsafe.Pointer(pCollate)).FpNext 36868 tcl.XTcl_Free(tls, pCollate) 36869 } 36870 if (*SqliteDb)(unsafe.Pointer(pDb)).FzBusy != 0 { 36871 tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzBusy) 36872 } 36873 if (*SqliteDb)(unsafe.Pointer(pDb)).FzTrace != 0 { 36874 tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzTrace) 36875 } 36876 if (*SqliteDb)(unsafe.Pointer(pDb)).FzTraceV2 != 0 { 36877 tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzTraceV2) 36878 } 36879 if (*SqliteDb)(unsafe.Pointer(pDb)).FzProfile != 0 { 36880 tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzProfile) 36881 } 36882 if (*SqliteDb)(unsafe.Pointer(pDb)).FzBindFallback != 0 { 36883 tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzBindFallback) 36884 } 36885 if (*SqliteDb)(unsafe.Pointer(pDb)).FzAuth != 0 { 36886 tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzAuth) 36887 } 36888 if (*SqliteDb)(unsafe.Pointer(pDb)).FzNull != 0 { 36889 tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzNull) 36890 } 36891 if (*SqliteDb)(unsafe.Pointer(pDb)).FpUpdateHook != 0 { 36892 for ok1 := true; ok1; ok1 = 0 != 0 { 36893 var _objPtr uintptr = (*SqliteDb)(unsafe.Pointer(pDb)).FpUpdateHook 36894 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 36895 tcl.XTclFreeObj(tls, _objPtr) 36896 } 36897 } 36898 } 36899 if (*SqliteDb)(unsafe.Pointer(pDb)).FpPreUpdateHook != 0 { 36900 for ok2 := true; ok2; ok2 = 0 != 0 { 36901 var _objPtr uintptr = (*SqliteDb)(unsafe.Pointer(pDb)).FpPreUpdateHook 36902 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 36903 tcl.XTclFreeObj(tls, _objPtr) 36904 } 36905 } 36906 } 36907 if (*SqliteDb)(unsafe.Pointer(pDb)).FpRollbackHook != 0 { 36908 for ok3 := true; ok3; ok3 = 0 != 0 { 36909 var _objPtr uintptr = (*SqliteDb)(unsafe.Pointer(pDb)).FpRollbackHook 36910 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 36911 tcl.XTclFreeObj(tls, _objPtr) 36912 } 36913 } 36914 } 36915 if (*SqliteDb)(unsafe.Pointer(pDb)).FpWalHook != 0 { 36916 for ok4 := true; ok4; ok4 = 0 != 0 { 36917 var _objPtr uintptr = (*SqliteDb)(unsafe.Pointer(pDb)).FpWalHook 36918 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 36919 tcl.XTclFreeObj(tls, _objPtr) 36920 } 36921 } 36922 } 36923 if (*SqliteDb)(unsafe.Pointer(pDb)).FpCollateNeeded != 0 { 36924 for ok5 := true; ok5; ok5 = 0 != 0 { 36925 var _objPtr uintptr = (*SqliteDb)(unsafe.Pointer(pDb)).FpCollateNeeded 36926 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 36927 tcl.XTclFreeObj(tls, _objPtr) 36928 } 36929 } 36930 } 36931 tcl.XTcl_Free(tls, pDb) 36932 } 36933 36934 // This routine is called when a database file is locked while trying 36935 // to execute SQL. 36936 func DbBusyHandler(tls *libc.TLS, cd uintptr, nTries int32) int32 { /* tclsqlite.c:584:12: */ 36937 bp := tls.Alloc(70) 36938 defer tls.Free(70) 36939 36940 var pDb uintptr = cd 36941 var rc int32 36942 // var zVal [30]int8 at bp+40, 30 36943 36944 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+40 /* &zVal[0] */, ts+1238 /* "%d" */, libc.VaList(bp, nTries)) 36945 rc = tcl.XTcl_VarEval(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, libc.VaList(bp+8, (*SqliteDb)(unsafe.Pointer(pDb)).FzBusy, ts+4765 /* " " */, bp+40 /* &zVal[0] */, uintptr(0))) 36946 if (rc != TCL_OK) || (libc.Xatoi(tls, tcl.XTcl_GetStringResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp)) != 0) { 36947 return 0 36948 } 36949 return 1 36950 } 36951 36952 // This routine is invoked as the 'progress callback' for the database. 36953 func DbProgressHandler(tls *libc.TLS, cd uintptr) int32 { /* tclsqlite.c:601:12: */ 36954 var pDb uintptr = cd 36955 var rc int32 36956 36957 rc = tcl.XTcl_Eval(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, (*SqliteDb)(unsafe.Pointer(pDb)).FzProgress) 36958 if (rc != TCL_OK) || (libc.Xatoi(tls, tcl.XTcl_GetStringResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp)) != 0) { 36959 return 1 36960 } 36961 return 0 36962 } 36963 36964 // This routine is called by the SQLite trace handler whenever a new 36965 // block of SQL is executed. The TCL script in pDb->zTrace is executed. 36966 func DbTraceHandler(tls *libc.TLS, cd uintptr, zSql uintptr) { /* tclsqlite.c:620:13: */ 36967 bp := tls.Alloc(216) 36968 defer tls.Free(216) 36969 36970 var pDb uintptr = cd 36971 // var str Tcl_DString at bp, 216 36972 36973 tcl.XTcl_DStringInit(tls, bp /* &str */) 36974 tcl.XTcl_DStringAppend(tls, bp /* &str */, (*SqliteDb)(unsafe.Pointer(pDb)).FzTrace, -1) 36975 tcl.XTcl_DStringAppendElement(tls, bp /* &str */, zSql) 36976 tcl.XTcl_Eval(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, (*Tcl_DString)(unsafe.Pointer(bp /* &str */)).Fstring) 36977 tcl.XTcl_DStringFree(tls, bp /* &str */) 36978 tcl.XTcl_ResetResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp) 36979 } 36980 36981 // This routine is called by the SQLite trace_v2 handler whenever a new 36982 // supported event is generated. Unsupported event types are ignored. 36983 // The TCL script in pDb->zTraceV2 is executed, with the arguments for 36984 // the event appended to it (as list elements). 36985 func DbTraceV2Handler(tls *libc.TLS, type1 uint32, cd uintptr, pd uintptr, xd uintptr) int32 { /* tclsqlite.c:640:12: */ 36986 var pDb uintptr = cd 36987 var pCmd uintptr 36988 36989 switch type1 { 36990 case uint32(SQLITE_TRACE_STMT): 36991 { 36992 var pStmt uintptr = pd 36993 var zSql uintptr = xd 36994 36995 pCmd = tcl.XTcl_NewStringObj(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzTraceV2, -1) 36996 (*Tcl_Obj)(unsafe.Pointer(pCmd)).FrefCount++ 36997 tcl.XTcl_ListObjAppendElement(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, 36998 tcl.XTcl_NewWideIntObj(tls, int64(pStmt))) 36999 tcl.XTcl_ListObjAppendElement(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, 37000 tcl.XTcl_NewStringObj(tls, zSql, -1)) 37001 tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, TCL_EVAL_DIRECT) 37002 for ok := true; ok; ok = 0 != 0 { 37003 var _objPtr uintptr = pCmd 37004 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 37005 tcl.XTclFreeObj(tls, _objPtr) 37006 } 37007 } 37008 tcl.XTcl_ResetResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp) 37009 break 37010 37011 } 37012 case uint32(SQLITE_TRACE_PROFILE): 37013 { 37014 var pStmt uintptr = pd 37015 var ns sqlite3_int64 = *(*sqlite3_int64)(unsafe.Pointer(xd)) 37016 37017 pCmd = tcl.XTcl_NewStringObj(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzTraceV2, -1) 37018 (*Tcl_Obj)(unsafe.Pointer(pCmd)).FrefCount++ 37019 tcl.XTcl_ListObjAppendElement(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, 37020 tcl.XTcl_NewWideIntObj(tls, int64(pStmt))) 37021 tcl.XTcl_ListObjAppendElement(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, 37022 tcl.XTcl_NewWideIntObj(tls, ns)) 37023 tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, TCL_EVAL_DIRECT) 37024 for ok1 := true; ok1; ok1 = 0 != 0 { 37025 var _objPtr uintptr = pCmd 37026 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 37027 tcl.XTclFreeObj(tls, _objPtr) 37028 } 37029 } 37030 tcl.XTcl_ResetResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp) 37031 break 37032 37033 } 37034 case uint32(SQLITE_TRACE_ROW): 37035 { 37036 var pStmt uintptr = pd 37037 37038 pCmd = tcl.XTcl_NewStringObj(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzTraceV2, -1) 37039 (*Tcl_Obj)(unsafe.Pointer(pCmd)).FrefCount++ 37040 tcl.XTcl_ListObjAppendElement(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, 37041 tcl.XTcl_NewWideIntObj(tls, int64(pStmt))) 37042 tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, TCL_EVAL_DIRECT) 37043 for ok2 := true; ok2; ok2 = 0 != 0 { 37044 var _objPtr uintptr = pCmd 37045 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 37046 tcl.XTclFreeObj(tls, _objPtr) 37047 } 37048 } 37049 tcl.XTcl_ResetResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp) 37050 break 37051 37052 } 37053 case uint32(SQLITE_TRACE_CLOSE): 37054 { 37055 var db uintptr = pd 37056 37057 pCmd = tcl.XTcl_NewStringObj(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzTraceV2, -1) 37058 (*Tcl_Obj)(unsafe.Pointer(pCmd)).FrefCount++ 37059 tcl.XTcl_ListObjAppendElement(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, 37060 tcl.XTcl_NewWideIntObj(tls, int64(db))) 37061 tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, TCL_EVAL_DIRECT) 37062 for ok3 := true; ok3; ok3 = 0 != 0 { 37063 var _objPtr uintptr = pCmd 37064 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 37065 tcl.XTclFreeObj(tls, _objPtr) 37066 } 37067 } 37068 tcl.XTcl_ResetResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp) 37069 break 37070 37071 } 37072 } 37073 return SQLITE_OK 37074 } 37075 37076 // This routine is called by the SQLite profile handler after a statement 37077 // SQL has executed. The TCL script in pDb->zProfile is evaluated. 37078 func DbProfileHandler(tls *libc.TLS, cd uintptr, zSql uintptr, tm1 sqlite_uint64) { /* tclsqlite.c:715:13: */ 37079 bp := tls.Alloc(328) 37080 defer tls.Free(328) 37081 37082 var pDb uintptr = cd 37083 // var str Tcl_DString at bp+112, 216 37084 37085 // var zTm [100]int8 at bp+8, 100 37086 37087 sqlite3.Xsqlite3_snprintf(tls, (int32(uint64(unsafe.Sizeof([100]int8{})) - uint64(1))), bp+8 /* &zTm[0] */, ts+10547 /* "%lld" */, libc.VaList(bp, tm1)) 37088 tcl.XTcl_DStringInit(tls, bp+112 /* &str */) 37089 tcl.XTcl_DStringAppend(tls, bp+112 /* &str */, (*SqliteDb)(unsafe.Pointer(pDb)).FzProfile, -1) 37090 tcl.XTcl_DStringAppendElement(tls, bp+112 /* &str */, zSql) 37091 tcl.XTcl_DStringAppendElement(tls, bp+112 /* &str */, bp+8 /* &zTm[0] */) 37092 tcl.XTcl_Eval(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, (*Tcl_DString)(unsafe.Pointer(bp+112 /* &str */)).Fstring) 37093 tcl.XTcl_DStringFree(tls, bp+112 /* &str */) 37094 tcl.XTcl_ResetResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp) 37095 } 37096 37097 // This routine is called when a transaction is committed. The 37098 // TCL script in pDb->zCommit is executed. If it returns non-zero or 37099 // if it throws an exception, the transaction is rolled back instead 37100 // of being committed. 37101 func DbCommitHandler(tls *libc.TLS, cd uintptr) int32 { /* tclsqlite.c:737:12: */ 37102 var pDb uintptr = cd 37103 var rc int32 37104 37105 rc = tcl.XTcl_Eval(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, (*SqliteDb)(unsafe.Pointer(pDb)).FzCommit) 37106 if (rc != TCL_OK) || (libc.Xatoi(tls, tcl.XTcl_GetStringResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp)) != 0) { 37107 return 1 37108 } 37109 return 0 37110 } 37111 37112 func DbRollbackHandler(tls *libc.TLS, clientData uintptr) { /* tclsqlite.c:748:13: */ 37113 var pDb uintptr = clientData 37114 37115 if TCL_OK != tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, (*SqliteDb)(unsafe.Pointer(pDb)).FpRollbackHook, 0) { 37116 tcl.XTcl_BackgroundError(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp) 37117 } 37118 } 37119 37120 // This procedure handles wal_hook callbacks. 37121 func DbWalHandler(tls *libc.TLS, clientData uintptr, db uintptr, zDb uintptr, nEntry int32) int32 { /* tclsqlite.c:759:12: */ 37122 bp := tls.Alloc(4) 37123 defer tls.Free(4) 37124 37125 *(*int32)(unsafe.Pointer(bp /* ret */)) = SQLITE_OK 37126 var p uintptr 37127 var pDb uintptr = clientData 37128 var interp uintptr = (*SqliteDb)(unsafe.Pointer(pDb)).Finterp 37129 37130 p = tcl.XTcl_DuplicateObj(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FpWalHook) 37131 (*Tcl_Obj)(unsafe.Pointer(p)).FrefCount++ 37132 tcl.XTcl_ListObjAppendElement(tls, interp, p, tcl.XTcl_NewStringObj(tls, zDb, -1)) 37133 tcl.XTcl_ListObjAppendElement(tls, interp, p, tcl.XTcl_NewIntObj(tls, nEntry)) 37134 if (TCL_OK != tcl.XTcl_EvalObjEx(tls, interp, p, 0)) || 37135 (TCL_OK != tcl.XTcl_GetIntFromObj(tls, interp, tcl.XTcl_GetObjResult(tls, interp), bp /* &ret */)) { 37136 tcl.XTcl_BackgroundError(tls, interp) 37137 } 37138 for ok := true; ok; ok = 0 != 0 { 37139 var _objPtr uintptr = p 37140 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 37141 tcl.XTclFreeObj(tls, _objPtr) 37142 } 37143 } 37144 37145 return *(*int32)(unsafe.Pointer(bp /* ret */)) 37146 } 37147 37148 func setTestUnlockNotifyVars(tls *libc.TLS, interp uintptr, iArg int32, nArg int32) { /* tclsqlite.c:787:13: */ 37149 bp := tls.Alloc(80) 37150 defer tls.Free(80) 37151 37152 // var zBuf [64]int8 at bp+16, 64 37153 37154 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([64]int8{})), bp+16 /* &zBuf[0] */, ts+1238 /* "%d" */, libc.VaList(bp, iArg)) 37155 tcl.XTcl_SetVar2(tls, interp, ts+10552 /* "sqlite_unlock_no..." */, uintptr(0), bp+16 /* &zBuf[0] */, TCL_GLOBAL_ONLY) 37156 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([64]int8{})), bp+16 /* &zBuf[0] */, ts+1238 /* "%d" */, libc.VaList(bp+8, nArg)) 37157 tcl.XTcl_SetVar2(tls, interp, ts+10577 /* "sqlite_unlock_no..." */, uintptr(0), bp+16 /* &zBuf[0] */, TCL_GLOBAL_ONLY) 37158 } 37159 37160 func DbUnlockNotify(tls *libc.TLS, apArg uintptr, nArg int32) { /* tclsqlite.c:799:13: */ 37161 var i int32 37162 for i = 0; i < nArg; i++ { 37163 var flags int32 = (TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT) 37164 var pDb uintptr = *(*uintptr)(unsafe.Pointer(apArg + uintptr(i)*8)) 37165 setTestUnlockNotifyVars(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, i, nArg) 37166 37167 tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, (*SqliteDb)(unsafe.Pointer(pDb)).FpUnlockNotify, flags) 37168 for ok := true; ok; ok = 0 != 0 { 37169 var _objPtr uintptr = (*SqliteDb)(unsafe.Pointer(pDb)).FpUnlockNotify 37170 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 37171 tcl.XTclFreeObj(tls, _objPtr) 37172 } 37173 } 37174 (*SqliteDb)(unsafe.Pointer(pDb)).FpUnlockNotify = uintptr(0) 37175 } 37176 } 37177 37178 // Pre-update hook callback. 37179 func DbPreUpdateHandler(tls *libc.TLS, p uintptr, db uintptr, op int32, zDb uintptr, zTbl uintptr, iKey1 sqlite_int64, iKey2 sqlite_int64) { /* tclsqlite.c:817:13: */ 37180 var pDb uintptr = p 37181 var pCmd uintptr 37182 37183 pCmd = tcl.XTcl_DuplicateObj(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FpPreUpdateHook) 37184 (*Tcl_Obj)(unsafe.Pointer(pCmd)).FrefCount++ 37185 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pCmd, tcl.XTcl_NewStringObj(tls, azStr[((op-1)/9)], -1)) 37186 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pCmd, tcl.XTcl_NewStringObj(tls, zDb, -1)) 37187 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pCmd, tcl.XTcl_NewStringObj(tls, zTbl, -1)) 37188 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pCmd, tcl.XTcl_NewWideIntObj(tls, iKey1)) 37189 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pCmd, tcl.XTcl_NewWideIntObj(tls, iKey2)) 37190 tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, TCL_EVAL_DIRECT) 37191 for ok := true; ok; ok = 0 != 0 { 37192 var _objPtr uintptr = pCmd 37193 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 37194 tcl.XTclFreeObj(tls, _objPtr) 37195 } 37196 } 37197 } 37198 37199 var azStr = [3]uintptr{ts + 10607 /* "DELETE" */, ts + 10614 /* "INSERT" */, ts + 10621 /* "UPDATE" */} /* tclsqlite.c:828:21 */ 37200 37201 func DbUpdateHandler(tls *libc.TLS, p uintptr, op int32, zDb uintptr, zTbl uintptr, rowid sqlite_int64) { /* tclsqlite.c:849:13: */ 37202 var pDb uintptr = p 37203 var pCmd uintptr 37204 37205 pCmd = tcl.XTcl_DuplicateObj(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FpUpdateHook) 37206 (*Tcl_Obj)(unsafe.Pointer(pCmd)).FrefCount++ 37207 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pCmd, tcl.XTcl_NewStringObj(tls, azStr1[((op-1)/9)], -1)) 37208 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pCmd, tcl.XTcl_NewStringObj(tls, zDb, -1)) 37209 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pCmd, tcl.XTcl_NewStringObj(tls, zTbl, -1)) 37210 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pCmd, tcl.XTcl_NewWideIntObj(tls, rowid)) 37211 tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pCmd, TCL_EVAL_DIRECT) 37212 for ok := true; ok; ok = 0 != 0 { 37213 var _objPtr uintptr = pCmd 37214 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 37215 tcl.XTclFreeObj(tls, _objPtr) 37216 } 37217 } 37218 } 37219 37220 var azStr1 = [3]uintptr{ts + 10607 /* "DELETE" */, ts + 10614 /* "INSERT" */, ts + 10621 /* "UPDATE" */} /* tclsqlite.c:858:21 */ 37221 37222 func tclCollateNeeded(tls *libc.TLS, pCtx uintptr, db uintptr, enc int32, zName uintptr) { /* tclsqlite.c:877:13: */ 37223 var pDb uintptr = pCtx 37224 var pScript uintptr = tcl.XTcl_DuplicateObj(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FpCollateNeeded) 37225 (*Tcl_Obj)(unsafe.Pointer(pScript)).FrefCount++ 37226 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pScript, tcl.XTcl_NewStringObj(tls, zName, -1)) 37227 tcl.XTcl_EvalObjEx(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, pScript, 0) 37228 for ok := true; ok; ok = 0 != 0 { 37229 var _objPtr uintptr = pScript 37230 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 37231 tcl.XTclFreeObj(tls, _objPtr) 37232 } 37233 } 37234 } 37235 37236 // This routine is called to evaluate an SQL collation function implemented 37237 // using TCL script. 37238 func tclSqlCollate(tls *libc.TLS, pCtx uintptr, nA int32, zA uintptr, nB int32, zB uintptr) int32 { /* tclsqlite.c:895:12: */ 37239 var p uintptr = pCtx 37240 var pCmd uintptr 37241 37242 pCmd = tcl.XTcl_NewStringObj(tls, (*SqlCollate)(unsafe.Pointer(p)).FzScript, -1) 37243 (*Tcl_Obj)(unsafe.Pointer(pCmd)).FrefCount++ 37244 tcl.XTcl_ListObjAppendElement(tls, (*SqlCollate)(unsafe.Pointer(p)).Finterp, pCmd, tcl.XTcl_NewStringObj(tls, zA, nA)) 37245 tcl.XTcl_ListObjAppendElement(tls, (*SqlCollate)(unsafe.Pointer(p)).Finterp, pCmd, tcl.XTcl_NewStringObj(tls, zB, nB)) 37246 tcl.XTcl_EvalObjEx(tls, (*SqlCollate)(unsafe.Pointer(p)).Finterp, pCmd, TCL_EVAL_DIRECT) 37247 for ok := true; ok; ok = 0 != 0 { 37248 var _objPtr uintptr = pCmd 37249 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 37250 tcl.XTclFreeObj(tls, _objPtr) 37251 } 37252 } 37253 return libc.Xatoi(tls, tcl.XTcl_GetStringResult(tls, (*SqlCollate)(unsafe.Pointer(p)).Finterp)) 37254 } 37255 37256 // This routine is called to evaluate an SQL function implemented 37257 // using TCL script. 37258 func tclSqlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* tclsqlite.c:918:13: */ 37259 bp := tls.Alloc(40) 37260 defer tls.Free(40) 37261 37262 var p uintptr = sqlite3.Xsqlite3_user_data(tls, context) 37263 var pCmd uintptr 37264 var i int32 37265 var rc int32 37266 37267 if argc == 0 { 37268 // If there are no arguments to the function, call Tcl_EvalObjEx on the 37269 // script object directly. This allows the TCL compiler to generate 37270 // bytecode for the command on the first invocation and thus make 37271 // subsequent invocations much faster. 37272 pCmd = (*SqlFunc)(unsafe.Pointer(p)).FpScript 37273 (*Tcl_Obj)(unsafe.Pointer(pCmd)).FrefCount++ 37274 rc = tcl.XTcl_EvalObjEx(tls, (*SqlFunc)(unsafe.Pointer(p)).Finterp, pCmd, 0) 37275 for ok := true; ok; ok = 0 != 0 { 37276 var _objPtr uintptr = pCmd 37277 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 37278 tcl.XTclFreeObj(tls, _objPtr) 37279 } 37280 } 37281 } else { 37282 // If there are arguments to the function, make a shallow copy of the 37283 // script object, lappend the arguments, then evaluate the copy. 37284 // 37285 // By "shallow" copy, we mean only the outer list Tcl_Obj is duplicated. 37286 // The new Tcl_Obj contains pointers to the original list elements. 37287 // That way, when Tcl_EvalObjv() is run and shimmers the first element 37288 // of the list to tclCmdNameType, that alternate representation will 37289 // be preserved and reused on the next invocation. 37290 // var aArg uintptr at bp+8, 8 37291 37292 // var nArg int32 at bp, 4 37293 37294 if tcl.XTcl_ListObjGetElements(tls, (*SqlFunc)(unsafe.Pointer(p)).Finterp, (*SqlFunc)(unsafe.Pointer(p)).FpScript, bp /* &nArg */, bp+8 /* &aArg */) != 0 { 37295 sqlite3.Xsqlite3_result_error(tls, context, tcl.XTcl_GetStringResult(tls, (*SqlFunc)(unsafe.Pointer(p)).Finterp), -1) 37296 return 37297 } 37298 pCmd = tcl.XTcl_NewListObj(tls, *(*int32)(unsafe.Pointer(bp /* nArg */)), *(*uintptr)(unsafe.Pointer(bp + 8 /* aArg */))) 37299 (*Tcl_Obj)(unsafe.Pointer(pCmd)).FrefCount++ 37300 for i = 0; i < argc; i++ { 37301 var pIn uintptr = *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)) 37302 var pVal uintptr 37303 37304 // Set pVal to contain the i'th column of this row. 37305 switch sqlite3.Xsqlite3_value_type(tls, pIn) { 37306 case SQLITE_BLOB: 37307 { 37308 var bytes int32 = sqlite3.Xsqlite3_value_bytes(tls, pIn) 37309 pVal = tcl.XTcl_NewByteArrayObj(tls, sqlite3.Xsqlite3_value_blob(tls, pIn), bytes) 37310 break 37311 37312 } 37313 fallthrough 37314 case SQLITE_INTEGER: 37315 { 37316 var v sqlite_int64 = sqlite3.Xsqlite3_value_int64(tls, pIn) 37317 if (v >= int64(-2147483647)) && (v <= int64(2147483647)) { 37318 pVal = tcl.XTcl_NewIntObj(tls, int32(v)) 37319 } else { 37320 pVal = tcl.XTcl_NewWideIntObj(tls, v) 37321 } 37322 break 37323 37324 } 37325 fallthrough 37326 case SQLITE_FLOAT: 37327 { 37328 var r float64 = sqlite3.Xsqlite3_value_double(tls, pIn) 37329 pVal = tcl.XTcl_NewDoubleObj(tls, r) 37330 break 37331 37332 } 37333 fallthrough 37334 case SQLITE_NULL: 37335 { 37336 pVal = tcl.XTcl_NewStringObj(tls, (*SqliteDb)(unsafe.Pointer((*SqlFunc)(unsafe.Pointer(p)).FpDb)).FzNull, -1) 37337 break 37338 37339 } 37340 fallthrough 37341 default: 37342 { 37343 var bytes int32 = sqlite3.Xsqlite3_value_bytes(tls, pIn) 37344 pVal = tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, pIn), bytes) 37345 break 37346 37347 } 37348 } 37349 rc = tcl.XTcl_ListObjAppendElement(tls, (*SqlFunc)(unsafe.Pointer(p)).Finterp, pCmd, pVal) 37350 if rc != 0 { 37351 for ok1 := true; ok1; ok1 = 0 != 0 { 37352 var _objPtr uintptr = pCmd 37353 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 37354 tcl.XTclFreeObj(tls, _objPtr) 37355 } 37356 } 37357 sqlite3.Xsqlite3_result_error(tls, context, tcl.XTcl_GetStringResult(tls, (*SqlFunc)(unsafe.Pointer(p)).Finterp), -1) 37358 return 37359 } 37360 } 37361 if !((*SqlFunc)(unsafe.Pointer(p)).FuseEvalObjv != 0) { 37362 // Tcl_EvalObjEx() will automatically call Tcl_EvalObjv() if pCmd 37363 // is a list without a string representation. To prevent this from 37364 // happening, make sure pCmd has a valid string representation 37365 tcl.XTcl_GetString(tls, pCmd) 37366 } 37367 rc = tcl.XTcl_EvalObjEx(tls, (*SqlFunc)(unsafe.Pointer(p)).Finterp, pCmd, TCL_EVAL_DIRECT) 37368 for ok2 := true; ok2; ok2 = 0 != 0 { 37369 var _objPtr uintptr = pCmd 37370 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 37371 tcl.XTclFreeObj(tls, _objPtr) 37372 } 37373 } 37374 } 37375 37376 if (rc != 0) && (rc != TCL_RETURN) { 37377 sqlite3.Xsqlite3_result_error(tls, context, tcl.XTcl_GetStringResult(tls, (*SqlFunc)(unsafe.Pointer(p)).Finterp), -1) 37378 } else { 37379 var pVar uintptr = tcl.XTcl_GetObjResult(tls, (*SqlFunc)(unsafe.Pointer(p)).Finterp) 37380 // var n int32 at bp+16, 4 37381 37382 var data uintptr 37383 var zType uintptr = func() uintptr { 37384 if (*Tcl_Obj)(unsafe.Pointer(pVar)).FtypePtr != 0 { 37385 return (*Tcl_ObjType)(unsafe.Pointer((*Tcl_Obj)(unsafe.Pointer(pVar)).FtypePtr)).Fname 37386 } 37387 return ts + 489 /* "" */ 37388 }() 37389 var c int8 = *(*int8)(unsafe.Pointer(zType)) 37390 var eType int32 = (*SqlFunc)(unsafe.Pointer(p)).FeType 37391 37392 if eType == SQLITE_NULL { 37393 if ((int32(c) == 'b') && (libc.Xstrcmp(tls, zType, ts+2405 /* "bytearray" */) == 0)) && ((*Tcl_Obj)(unsafe.Pointer(pVar)).Fbytes == uintptr(0)) { 37394 // Only return a BLOB type if the Tcl variable is a bytearray and 37395 // has no string representation. 37396 eType = SQLITE_BLOB 37397 } else if (((int32(c) == 'b') && (libc.Xstrcmp(tls, zType, ts+2415 /* "boolean" */) == 0)) || 37398 ((int32(c) == 'w') && (libc.Xstrcmp(tls, zType, ts+2430 /* "wideInt" */) == 0))) || 37399 ((int32(c) == 'i') && (libc.Xstrcmp(tls, zType, ts+2438 /* "int" */) == 0)) { 37400 eType = SQLITE_INTEGER 37401 } else if (int32(c) == 'd') && (libc.Xstrcmp(tls, zType, ts+2423 /* "double" */) == 0) { 37402 eType = SQLITE_FLOAT 37403 } else { 37404 eType = SQLITE_TEXT 37405 } 37406 } 37407 37408 switch eType { 37409 case SQLITE_BLOB: 37410 { 37411 data = tcl.XTcl_GetByteArrayFromObj(tls, pVar, bp+16 /* &n */) 37412 sqlite3.Xsqlite3_result_blob(tls, context, data, *(*int32)(unsafe.Pointer(bp + 16 /* n */)), libc.UintptrFromInt32(-1)) 37413 break 37414 37415 } 37416 fallthrough 37417 case SQLITE_INTEGER: 37418 { 37419 // var v Tcl_WideInt at bp+24, 8 37420 37421 if TCL_OK == tcl.XTcl_GetWideIntFromObj(tls, uintptr(0), pVar, bp+24 /* &v */) { 37422 sqlite3.Xsqlite3_result_int64(tls, context, *(*Tcl_WideInt)(unsafe.Pointer(bp + 24 /* v */))) 37423 break 37424 } 37425 // fall-through 37426 37427 } 37428 fallthrough 37429 case SQLITE_FLOAT: 37430 { 37431 // var r float64 at bp+32, 8 37432 37433 if TCL_OK == tcl.XTcl_GetDoubleFromObj(tls, uintptr(0), pVar, bp+32 /* &r */) { 37434 sqlite3.Xsqlite3_result_double(tls, context, *(*float64)(unsafe.Pointer(bp + 32 /* r */))) 37435 break 37436 } 37437 // fall-through 37438 37439 } 37440 fallthrough 37441 default: 37442 { 37443 data = tcl.XTcl_GetStringFromObj(tls, pVar, bp+16 /* &n */) 37444 sqlite3.Xsqlite3_result_text(tls, context, data, *(*int32)(unsafe.Pointer(bp + 16 /* n */)), libc.UintptrFromInt32(-1)) 37445 break 37446 37447 } 37448 } 37449 37450 } 37451 } 37452 37453 // This is the authentication function. It appends the authentication 37454 // type code and the two arguments to zCmd[] then invokes the result 37455 // on the interpreter. The reply is examined to determine if the 37456 // authentication fails or succeeds. 37457 func auth_callback(tls *libc.TLS, pArg uintptr, code int32, zArg1 uintptr, zArg2 uintptr, zArg3 uintptr, zArg4 uintptr) int32 { /* tclsqlite.c:1069:12: */ 37458 bp := tls.Alloc(216) 37459 defer tls.Free(216) 37460 37461 var zCode uintptr 37462 // var str Tcl_DString at bp, 216 37463 37464 var rc int32 37465 var zReply uintptr 37466 // EVIDENCE-OF: R-38590-62769 The first parameter to the authorizer 37467 // callback is a copy of the third parameter to the 37468 // sqlite3_set_authorizer() interface. 37469 var pDb uintptr = pArg 37470 if (*SqliteDb)(unsafe.Pointer(pDb)).FdisableAuth != 0 { 37471 return SQLITE_OK 37472 } 37473 37474 // EVIDENCE-OF: R-56518-44310 The second parameter to the callback is an 37475 // integer action code that specifies the particular action to be 37476 // authorized. 37477 switch code { 37478 case SQLITE_COPY: 37479 zCode = ts + 10628 /* "SQLITE_COPY" */ 37480 break 37481 case SQLITE_CREATE_INDEX: 37482 zCode = ts + 10640 /* "SQLITE_CREATE_IN..." */ 37483 break 37484 case SQLITE_CREATE_TABLE: 37485 zCode = ts + 10660 /* "SQLITE_CREATE_TA..." */ 37486 break 37487 case SQLITE_CREATE_TEMP_INDEX: 37488 zCode = ts + 10680 /* "SQLITE_CREATE_TE..." */ 37489 break 37490 case SQLITE_CREATE_TEMP_TABLE: 37491 zCode = ts + 10705 /* "SQLITE_CREATE_TE..." */ 37492 break 37493 case SQLITE_CREATE_TEMP_TRIGGER: 37494 zCode = ts + 10730 /* "SQLITE_CREATE_TE..." */ 37495 break 37496 case SQLITE_CREATE_TEMP_VIEW: 37497 zCode = ts + 10757 /* "SQLITE_CREATE_TE..." */ 37498 break 37499 case SQLITE_CREATE_TRIGGER: 37500 zCode = ts + 10781 /* "SQLITE_CREATE_TR..." */ 37501 break 37502 case SQLITE_CREATE_VIEW: 37503 zCode = ts + 10803 /* "SQLITE_CREATE_VI..." */ 37504 break 37505 case SQLITE_DELETE: 37506 zCode = ts + 10822 /* "SQLITE_DELETE" */ 37507 break 37508 case SQLITE_DROP_INDEX: 37509 zCode = ts + 10836 /* "SQLITE_DROP_INDE..." */ 37510 break 37511 case SQLITE_DROP_TABLE: 37512 zCode = ts + 10854 /* "SQLITE_DROP_TABL..." */ 37513 break 37514 case SQLITE_DROP_TEMP_INDEX: 37515 zCode = ts + 10872 /* "SQLITE_DROP_TEMP..." */ 37516 break 37517 case SQLITE_DROP_TEMP_TABLE: 37518 zCode = ts + 10895 /* "SQLITE_DROP_TEMP..." */ 37519 break 37520 case SQLITE_DROP_TEMP_TRIGGER: 37521 zCode = ts + 10918 /* "SQLITE_DROP_TEMP..." */ 37522 break 37523 case SQLITE_DROP_TEMP_VIEW: 37524 zCode = ts + 10943 /* "SQLITE_DROP_TEMP..." */ 37525 break 37526 case SQLITE_DROP_TRIGGER: 37527 zCode = ts + 10965 /* "SQLITE_DROP_TRIG..." */ 37528 break 37529 case SQLITE_DROP_VIEW: 37530 zCode = ts + 10985 /* "SQLITE_DROP_VIEW" */ 37531 break 37532 case SQLITE_INSERT: 37533 zCode = ts + 11002 /* "SQLITE_INSERT" */ 37534 break 37535 case SQLITE_PRAGMA: 37536 zCode = ts + 11016 /* "SQLITE_PRAGMA" */ 37537 break 37538 case SQLITE_READ: 37539 zCode = ts + 11030 /* "SQLITE_READ" */ 37540 break 37541 case SQLITE_SELECT: 37542 zCode = ts + 11042 /* "SQLITE_SELECT" */ 37543 break 37544 case SQLITE_TRANSACTION: 37545 zCode = ts + 11056 /* "SQLITE_TRANSACTI..." */ 37546 break 37547 case SQLITE_UPDATE: 37548 zCode = ts + 11075 /* "SQLITE_UPDATE" */ 37549 break 37550 case SQLITE_ATTACH: 37551 zCode = ts + 11089 /* "SQLITE_ATTACH" */ 37552 break 37553 case SQLITE_DETACH: 37554 zCode = ts + 11103 /* "SQLITE_DETACH" */ 37555 break 37556 case SQLITE_ALTER_TABLE: 37557 zCode = ts + 11117 /* "SQLITE_ALTER_TAB..." */ 37558 break 37559 case SQLITE_REINDEX: 37560 zCode = ts + 11136 /* "SQLITE_REINDEX" */ 37561 break 37562 case SQLITE_ANALYZE: 37563 zCode = ts + 11151 /* "SQLITE_ANALYZE" */ 37564 break 37565 case SQLITE_CREATE_VTABLE: 37566 zCode = ts + 11166 /* "SQLITE_CREATE_VT..." */ 37567 break 37568 case SQLITE_DROP_VTABLE: 37569 zCode = ts + 11187 /* "SQLITE_DROP_VTAB..." */ 37570 break 37571 case SQLITE_FUNCTION: 37572 zCode = ts + 11206 /* "SQLITE_FUNCTION" */ 37573 break 37574 case SQLITE_SAVEPOINT: 37575 zCode = ts + 11222 /* "SQLITE_SAVEPOINT" */ 37576 break 37577 case SQLITE_RECURSIVE: 37578 zCode = ts + 11239 /* "SQLITE_RECURSIVE" */ 37579 break 37580 default: 37581 zCode = ts + 11256 /* "????" */ 37582 break 37583 } 37584 tcl.XTcl_DStringInit(tls, bp /* &str */) 37585 tcl.XTcl_DStringAppend(tls, bp /* &str */, (*SqliteDb)(unsafe.Pointer(pDb)).FzAuth, -1) 37586 tcl.XTcl_DStringAppendElement(tls, bp /* &str */, zCode) 37587 tcl.XTcl_DStringAppendElement(tls, bp /* &str */, func() uintptr { 37588 if zArg1 != 0 { 37589 return zArg1 37590 } 37591 return ts + 489 /* "" */ 37592 }()) 37593 tcl.XTcl_DStringAppendElement(tls, bp /* &str */, func() uintptr { 37594 if zArg2 != 0 { 37595 return zArg2 37596 } 37597 return ts + 489 /* "" */ 37598 }()) 37599 tcl.XTcl_DStringAppendElement(tls, bp /* &str */, func() uintptr { 37600 if zArg3 != 0 { 37601 return zArg3 37602 } 37603 return ts + 489 /* "" */ 37604 }()) 37605 tcl.XTcl_DStringAppendElement(tls, bp /* &str */, func() uintptr { 37606 if zArg4 != 0 { 37607 return zArg4 37608 } 37609 return ts + 489 /* "" */ 37610 }()) 37611 rc = tcl.XTcl_GlobalEval(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, (*Tcl_DString)(unsafe.Pointer(bp /* &str */)).Fstring) 37612 tcl.XTcl_DStringFree(tls, bp /* &str */) 37613 if rc == TCL_OK { 37614 zReply = tcl.XTcl_GetStringResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp) 37615 } else { 37616 zReply = ts + 11261 /* "SQLITE_DENY" */ 37617 } 37618 if libc.Xstrcmp(tls, zReply, ts+1988 /* "SQLITE_OK" */) == 0 { 37619 rc = SQLITE_OK 37620 } else if libc.Xstrcmp(tls, zReply, ts+11261 /* "SQLITE_DENY" */) == 0 { 37621 rc = SQLITE_DENY 37622 } else if libc.Xstrcmp(tls, zReply, ts+11273 /* "SQLITE_IGNORE" */) == 0 { 37623 rc = SQLITE_IGNORE 37624 } else { 37625 rc = 999 37626 } 37627 return rc 37628 } 37629 37630 // This routine reads a line of text from FILE in, stores 37631 // the text in memory obtained from malloc() and returns a pointer 37632 // to the text. NULL is returned at end of file, or if malloc() 37633 // fails. 37634 // 37635 // The interface is like "readline" but no command-line editing 37636 // is done. 37637 // 37638 // copied from shell.c from '.import' command 37639 func local_getline(tls *libc.TLS, zPrompt uintptr, in uintptr) uintptr { /* tclsqlite.c:1168:13: */ 37640 var zLine uintptr 37641 var nLine int32 37642 var n int32 37643 37644 nLine = 100 37645 zLine = libc.Xmalloc(tls, uint64(nLine)) 37646 if zLine == uintptr(0) { 37647 return uintptr(0) 37648 } 37649 n = 0 37650 for 1 != 0 { 37651 if (n + 100) > nLine { 37652 nLine = ((nLine * 2) + 100) 37653 zLine = libc.Xrealloc(tls, zLine, uint64(nLine)) 37654 if zLine == uintptr(0) { 37655 return uintptr(0) 37656 } 37657 } 37658 if libc.Xfgets(tls, (zLine+uintptr(n)), (nLine-n), in) == uintptr(0) { 37659 if n == 0 { 37660 libc.Xfree(tls, zLine) 37661 return uintptr(0) 37662 } 37663 *(*int8)(unsafe.Pointer(zLine + uintptr(n))) = int8(0) 37664 break 37665 } 37666 for *(*int8)(unsafe.Pointer(zLine + uintptr(n))) != 0 { 37667 n++ 37668 } 37669 if (n > 0) && (int32(*(*int8)(unsafe.Pointer(zLine + uintptr((n - 1))))) == '\n') { 37670 n-- 37671 *(*int8)(unsafe.Pointer(zLine + uintptr(n))) = int8(0) 37672 break 37673 } 37674 } 37675 zLine = libc.Xrealloc(tls, zLine, (uint64(n + 1))) 37676 return zLine 37677 } 37678 37679 // This function is part of the implementation of the command: 37680 // 37681 // $db transaction [-deferred|-immediate|-exclusive] SCRIPT 37682 // 37683 // It is invoked after evaluating the script SCRIPT to commit or rollback 37684 // the transaction or savepoint opened by the [transaction] command. 37685 func DbTransPostCmd(tls *libc.TLS, data uintptr, interp uintptr, result int32) int32 { /* tclsqlite.c:1211:26: */ 37686 bp := tls.Alloc(16) 37687 defer tls.Free(16) 37688 37689 var pDb uintptr = *(*ClientData)(unsafe.Pointer(data)) 37690 var rc int32 = result 37691 var zEnd uintptr 37692 37693 (*SqliteDb)(unsafe.Pointer(pDb)).FnTransaction-- 37694 zEnd = azEnd[(((libc.Bool32(rc == TCL_ERROR)) * 2) + (libc.Bool32((*SqliteDb)(unsafe.Pointer(pDb)).FnTransaction == 0)))] 37695 37696 (*SqliteDb)(unsafe.Pointer(pDb)).FdisableAuth++ 37697 if sqlite3.Xsqlite3_exec(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zEnd, uintptr(0), uintptr(0), uintptr(0)) != 0 { 37698 // This is a tricky scenario to handle. The most likely cause of an 37699 // error is that the exec() above was an attempt to commit the 37700 // top-level transaction that returned SQLITE_BUSY. Or, less likely, 37701 // that an IO-error has occurred. In either case, throw a Tcl exception 37702 // and try to rollback the transaction. 37703 // 37704 // But it could also be that the user executed one or more BEGIN, 37705 // COMMIT, SAVEPOINT, RELEASE or ROLLBACK commands that are confusing 37706 // this method's logic. Not clear how this would be best handled. 37707 if rc != TCL_ERROR { 37708 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(0))) 37709 rc = TCL_ERROR 37710 } 37711 sqlite3.Xsqlite3_exec(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, ts+7272 /* "ROLLBACK" */, uintptr(0), uintptr(0), uintptr(0)) 37712 } 37713 (*SqliteDb)(unsafe.Pointer(pDb)).FdisableAuth-- 37714 37715 return rc 37716 } 37717 37718 var azEnd = [4]uintptr{ 37719 ts + 11287, /* "RELEASE _tcl_tra..." */ // rc==TCL_ERROR, nTransaction!=0 37720 ts + 11312, /* "COMMIT" */ // rc!=TCL_ERROR, nTransaction==0 37721 ts + 11319, /* "ROLLBACK TO _tcl..." */ 37722 ts + 7272, /* "ROLLBACK" */ // rc==TCL_ERROR, nTransaction==0 37723 } /* tclsqlite.c:1216:21 */ 37724 37725 // Unless SQLITE_TEST is defined, this function is a simple wrapper around 37726 // sqlite3_prepare_v2(). If SQLITE_TEST is defined, then it uses either 37727 // sqlite3_prepare_v2() or legacy interface sqlite3_prepare(), depending 37728 // on whether or not the [db_use_legacy_prepare] command has been used to 37729 // configure the connection. 37730 func dbPrepare(tls *libc.TLS, pDb uintptr, zSql uintptr, ppStmt uintptr, pzOut uintptr) int32 { /* tclsqlite.c:1259:12: */ 37731 var prepFlags uint32 = uint32(0) 37732 if (*SqliteDb)(unsafe.Pointer(pDb)).FbLegacyPrepare != 0 { 37733 return sqlite3.Xsqlite3_prepare(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zSql, -1, ppStmt, pzOut) 37734 } 37735 // If the statement cache is large, use the SQLITE_PREPARE_PERSISTENT 37736 // flags, which uses less lookaside memory. But if the cache is small, 37737 // omit that flag to make full use of lookaside 37738 if (*SqliteDb)(unsafe.Pointer(pDb)).FmaxStmt > 5 { 37739 prepFlags = uint32(SQLITE_PREPARE_PERSISTENT) 37740 } 37741 37742 return sqlite3.Xsqlite3_prepare_v3(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zSql, -1, prepFlags, ppStmt, pzOut) 37743 } 37744 37745 // Search the cache for a prepared-statement object that implements the 37746 // first SQL statement in the buffer pointed to by parameter zIn. If 37747 // no such prepared-statement can be found, allocate and prepare a new 37748 // one. In either case, bind the current values of the relevant Tcl 37749 // variables to any $var, :var or @var variables in the statement. Before 37750 // returning, set *ppPreStmt to point to the prepared-statement object. 37751 // 37752 // Output parameter *pzOut is set to point to the next SQL statement in 37753 // buffer zIn, or to the '\0' byte at the end of zIn if there is no 37754 // next statement. 37755 // 37756 // If successful, TCL_OK is returned. Otherwise, TCL_ERROR is returned 37757 // and an error message loaded into interpreter pDb->interp. 37758 func dbPrepareAndBind(tls *libc.TLS, pDb uintptr, zIn uintptr, pzOut uintptr, ppPreStmt uintptr) int32 { /* tclsqlite.c:1294:12: */ 37759 bp := tls.Alloc(32) 37760 defer tls.Free(32) 37761 37762 var zSql uintptr = zIn // Pointer to first SQL statement in zIn 37763 *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) // Prepared statement object 37764 var pPreStmt uintptr // Pointer to cached statement 37765 var nSql int32 // Length of zSql in bytes 37766 var nVar int32 = 0 // Number of variables in statement 37767 var iParm int32 = 0 // Next free entry in apParm 37768 var c int8 37769 var i int32 37770 var needResultReset int32 = 0 // Need to invoke Tcl_ResetResult() 37771 var rc int32 = SQLITE_OK // Value to return 37772 var interp uintptr = (*SqliteDb)(unsafe.Pointer(pDb)).Finterp 37773 37774 *(*uintptr)(unsafe.Pointer(ppPreStmt)) = uintptr(0) 37775 37776 // Trim spaces from the start of zSql and calculate the remaining length. 37777 for ((((int32(libc.AssignInt8(&c, *(*int8)(unsafe.Pointer(zSql))))) == ' ') || (int32(c) == '\t')) || (int32(c) == '\r')) || (int32(c) == '\n') { 37778 zSql++ 37779 } 37780 nSql = strlen30(tls, zSql) 37781 37782 for pPreStmt = (*SqliteDb)(unsafe.Pointer(pDb)).FstmtList; pPreStmt != 0; pPreStmt = (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FpNext { 37783 var n int32 = (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FnSql 37784 if ((nSql >= n) && 37785 (libc.Xmemcmp(tls, (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FzSql, zSql, uint64(n)) == 0)) && 37786 ((int32(*(*int8)(unsafe.Pointer(zSql + uintptr(n)))) == 0) || (int32(*(*int8)(unsafe.Pointer(zSql + uintptr((n - 1))))) == ';')) { 37787 *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FpStmt 37788 *(*uintptr)(unsafe.Pointer(pzOut)) = (zSql + uintptr((*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FnSql)) 37789 37790 // When a prepared statement is found, unlink it from the 37791 // cache list. It will later be added back to the beginning 37792 // of the cache list in order to implement LRU replacement. 37793 if (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FpPrev != 0 { 37794 (*SqlPreparedStmt)(unsafe.Pointer((*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FpPrev)).FpNext = (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FpNext 37795 } else { 37796 (*SqliteDb)(unsafe.Pointer(pDb)).FstmtList = (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FpNext 37797 } 37798 if (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FpNext != 0 { 37799 (*SqlPreparedStmt)(unsafe.Pointer((*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FpNext)).FpPrev = (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FpPrev 37800 } else { 37801 (*SqliteDb)(unsafe.Pointer(pDb)).FstmtLast = (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FpPrev 37802 } 37803 (*SqliteDb)(unsafe.Pointer(pDb)).FnStmt-- 37804 nVar = sqlite3.Xsqlite3_bind_parameter_count(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) 37805 break 37806 } 37807 } 37808 37809 // If no prepared statement was found. Compile the SQL text. Also allocate 37810 // a new SqlPreparedStmt structure. 37811 if pPreStmt == uintptr(0) { 37812 var nByte int32 37813 37814 if SQLITE_OK != dbPrepare(tls, pDb, zSql, bp /* &pStmt */, pzOut) { 37815 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), -1)) 37816 return TCL_ERROR 37817 } 37818 if *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) == uintptr(0) { 37819 if SQLITE_OK != sqlite3.Xsqlite3_errcode(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb) { 37820 // A compile-time error in the statement. 37821 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), -1)) 37822 return TCL_ERROR 37823 } else { 37824 // The statement was a no-op. Continue to the next statement 37825 // in the SQL string. 37826 return TCL_OK 37827 } 37828 } 37829 37830 nVar = sqlite3.Xsqlite3_bind_parameter_count(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) 37831 nByte = (int32(uint64(unsafe.Sizeof(SqlPreparedStmt{})) + (uint64(nVar) * uint64(unsafe.Sizeof(uintptr(0)))))) 37832 pPreStmt = tcl.XTcl_Alloc(tls, uint32(nByte)) 37833 libc.Xmemset(tls, pPreStmt, 0, uint64(nByte)) 37834 37835 (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FpStmt = *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) 37836 (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FnSql = (int32((int64(*(*uintptr)(unsafe.Pointer(pzOut))) - int64(zSql)) / 1)) 37837 (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FzSql = sqlite3.Xsqlite3_sql(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) 37838 (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FapParm = (pPreStmt + 1*56) 37839 if (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FzSql == uintptr(0) { 37840 var zCopy uintptr = tcl.XTcl_Alloc(tls, (uint32((*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FnSql + 1))) 37841 libc.Xmemcpy(tls, zCopy, zSql, uint64((*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FnSql)) 37842 *(*int8)(unsafe.Pointer(zCopy + uintptr((*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FnSql))) = int8(0) 37843 (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FzSql = zCopy 37844 } 37845 } 37846 37847 // Bind values to parameters that begin with $ or : 37848 for i = 1; i <= nVar; i++ { 37849 var zVar uintptr = sqlite3.Xsqlite3_bind_parameter_name(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), i) 37850 if (zVar != uintptr(0)) && (((int32(*(*int8)(unsafe.Pointer(zVar))) == '$') || (int32(*(*int8)(unsafe.Pointer(zVar))) == ':')) || (int32(*(*int8)(unsafe.Pointer(zVar))) == '@')) { 37851 var pVar uintptr = tcl.XTcl_GetVar2Ex(tls, interp, (zVar + 1), uintptr(0), 0) 37852 if (pVar == uintptr(0)) && ((*SqliteDb)(unsafe.Pointer(pDb)).FzBindFallback != uintptr(0)) { 37853 var pCmd uintptr 37854 var rx int32 37855 pCmd = tcl.XTcl_NewStringObj(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzBindFallback, -1) 37856 (*Tcl_Obj)(unsafe.Pointer(pCmd)).FrefCount++ 37857 tcl.XTcl_ListObjAppendElement(tls, interp, pCmd, tcl.XTcl_NewStringObj(tls, zVar, -1)) 37858 if needResultReset != 0 { 37859 tcl.XTcl_ResetResult(tls, interp) 37860 } 37861 needResultReset = 1 37862 rx = tcl.XTcl_EvalObjEx(tls, interp, pCmd, TCL_EVAL_DIRECT) 37863 for ok := true; ok; ok = 0 != 0 { 37864 var _objPtr uintptr = pCmd 37865 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 37866 tcl.XTclFreeObj(tls, _objPtr) 37867 } 37868 } 37869 if rx == TCL_OK { 37870 pVar = tcl.XTcl_GetObjResult(tls, interp) 37871 } else if rx == TCL_ERROR { 37872 rc = TCL_ERROR 37873 break 37874 } else { 37875 pVar = uintptr(0) 37876 } 37877 } 37878 if pVar != 0 { 37879 // var n int32 at bp+8, 4 37880 37881 var data uintptr 37882 var zType uintptr = func() uintptr { 37883 if (*Tcl_Obj)(unsafe.Pointer(pVar)).FtypePtr != 0 { 37884 return (*Tcl_ObjType)(unsafe.Pointer((*Tcl_Obj)(unsafe.Pointer(pVar)).FtypePtr)).Fname 37885 } 37886 return ts + 489 /* "" */ 37887 }() 37888 c = *(*int8)(unsafe.Pointer(zType)) 37889 if (int32(*(*int8)(unsafe.Pointer(zVar))) == '@') || (((int32(c) == 'b') && (libc.Xstrcmp(tls, zType, ts+2405 /* "bytearray" */) == 0)) && ((*Tcl_Obj)(unsafe.Pointer(pVar)).Fbytes == uintptr(0))) { 37890 // Load a BLOB type if the Tcl variable is a bytearray and 37891 // it has no string representation or the host 37892 // parameter name begins with "@". 37893 data = tcl.XTcl_GetByteArrayFromObj(tls, pVar, bp+8 /* &n */) 37894 sqlite3.Xsqlite3_bind_blob(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), i, data, *(*int32)(unsafe.Pointer(bp + 8 /* n */)), uintptr(0)) 37895 (*Tcl_Obj)(unsafe.Pointer(pVar)).FrefCount++ 37896 *(*uintptr)(unsafe.Pointer((*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FapParm + uintptr(libc.PostIncInt32(&iParm, 1))*8)) = pVar 37897 } else if (int32(c) == 'b') && (libc.Xstrcmp(tls, zType, ts+2415 /* "boolean" */) == 0) { 37898 tcl.XTcl_GetIntFromObj(tls, interp, pVar, bp+8 /* &n */) 37899 sqlite3.Xsqlite3_bind_int(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), i, *(*int32)(unsafe.Pointer(bp + 8 /* n */))) 37900 } else if (int32(c) == 'd') && (libc.Xstrcmp(tls, zType, ts+2423 /* "double" */) == 0) { 37901 // var r float64 at bp+16, 8 37902 37903 tcl.XTcl_GetDoubleFromObj(tls, interp, pVar, bp+16 /* &r */) 37904 sqlite3.Xsqlite3_bind_double(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), i, *(*float64)(unsafe.Pointer(bp + 16 /* r */))) 37905 } else if ((int32(c) == 'w') && (libc.Xstrcmp(tls, zType, ts+2430 /* "wideInt" */) == 0)) || ((int32(c) == 'i') && (libc.Xstrcmp(tls, zType, ts+2438 /* "int" */) == 0)) { 37906 // var v Tcl_WideInt at bp+24, 8 37907 37908 tcl.XTcl_GetWideIntFromObj(tls, interp, pVar, bp+24 /* &v */) 37909 sqlite3.Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), i, *(*Tcl_WideInt)(unsafe.Pointer(bp + 24 /* v */))) 37910 } else { 37911 data = tcl.XTcl_GetStringFromObj(tls, pVar, bp+8 /* &n */) 37912 sqlite3.Xsqlite3_bind_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), i, data, *(*int32)(unsafe.Pointer(bp + 8 /* n */)), uintptr(0)) 37913 (*Tcl_Obj)(unsafe.Pointer(pVar)).FrefCount++ 37914 *(*uintptr)(unsafe.Pointer((*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FapParm + uintptr(libc.PostIncInt32(&iParm, 1))*8)) = pVar 37915 } 37916 } else { 37917 sqlite3.Xsqlite3_bind_null(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), i) 37918 } 37919 if needResultReset != 0 { 37920 tcl.XTcl_ResetResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp) 37921 } 37922 } 37923 } 37924 (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FnParm = iParm 37925 *(*uintptr)(unsafe.Pointer(ppPreStmt)) = pPreStmt 37926 if (needResultReset != 0) && (rc == TCL_OK) { 37927 tcl.XTcl_ResetResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp) 37928 } 37929 37930 return rc 37931 } 37932 37933 // Release a statement reference obtained by calling dbPrepareAndBind(). 37934 // There should be exactly one call to this function for each call to 37935 // dbPrepareAndBind(). 37936 // 37937 // If the discard parameter is non-zero, then the statement is deleted 37938 // immediately. Otherwise it is added to the LRU list and may be returned 37939 // by a subsequent call to dbPrepareAndBind(). 37940 func dbReleaseStmt(tls *libc.TLS, pDb uintptr, pPreStmt uintptr, discard int32) { /* tclsqlite.c:1470:13: */ 37941 var i int32 37942 37943 // Free the bound string and blob parameters 37944 for i = 0; i < (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FnParm; i++ { 37945 for ok := true; ok; ok = 0 != 0 { 37946 var _objPtr uintptr = *(*uintptr)(unsafe.Pointer((*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FapParm + uintptr(i)*8)) 37947 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 37948 tcl.XTclFreeObj(tls, _objPtr) 37949 } 37950 } 37951 } 37952 (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FnParm = 0 37953 37954 if ((*SqliteDb)(unsafe.Pointer(pDb)).FmaxStmt <= 0) || (discard != 0) { 37955 // If the cache is turned off, deallocated the statement 37956 dbFreeStmt(tls, pPreStmt) 37957 } else { 37958 // Add the prepared statement to the beginning of the cache list. 37959 (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FpNext = (*SqliteDb)(unsafe.Pointer(pDb)).FstmtList 37960 (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FpPrev = uintptr(0) 37961 if (*SqliteDb)(unsafe.Pointer(pDb)).FstmtList != 0 { 37962 (*SqlPreparedStmt)(unsafe.Pointer((*SqliteDb)(unsafe.Pointer(pDb)).FstmtList)).FpPrev = pPreStmt 37963 } 37964 (*SqliteDb)(unsafe.Pointer(pDb)).FstmtList = pPreStmt 37965 if (*SqliteDb)(unsafe.Pointer(pDb)).FstmtLast == uintptr(0) { 37966 37967 (*SqliteDb)(unsafe.Pointer(pDb)).FstmtLast = pPreStmt 37968 } else { 37969 37970 } 37971 (*SqliteDb)(unsafe.Pointer(pDb)).FnStmt++ 37972 37973 // If we have too many statement in cache, remove the surplus from 37974 // the end of the cache list. 37975 for (*SqliteDb)(unsafe.Pointer(pDb)).FnStmt > (*SqliteDb)(unsafe.Pointer(pDb)).FmaxStmt { 37976 var pLast uintptr = (*SqliteDb)(unsafe.Pointer(pDb)).FstmtLast 37977 (*SqliteDb)(unsafe.Pointer(pDb)).FstmtLast = (*SqlPreparedStmt)(unsafe.Pointer(pLast)).FpPrev 37978 (*SqlPreparedStmt)(unsafe.Pointer((*SqliteDb)(unsafe.Pointer(pDb)).FstmtLast)).FpNext = uintptr(0) 37979 (*SqliteDb)(unsafe.Pointer(pDb)).FnStmt-- 37980 dbFreeStmt(tls, pLast) 37981 } 37982 } 37983 } 37984 37985 // Structure used with dbEvalXXX() functions: 37986 // 37987 // dbEvalInit() 37988 // dbEvalStep() 37989 // dbEvalFinalize() 37990 // dbEvalRowInfo() 37991 // dbEvalColumnValue() 37992 type DbEvalContext1 = struct { 37993 FpDb uintptr 37994 FpSql uintptr 37995 FzSql uintptr 37996 FpPreStmt uintptr 37997 FnCol int32 37998 FevalFlags int32 37999 FpArray uintptr 38000 FapColName uintptr 38001 } /* tclsqlite.c:1523:9 */ 38002 38003 // Structure used with dbEvalXXX() functions: 38004 // 38005 // dbEvalInit() 38006 // dbEvalStep() 38007 // dbEvalFinalize() 38008 // dbEvalRowInfo() 38009 // dbEvalColumnValue() 38010 type DbEvalContext = DbEvalContext1 /* tclsqlite.c:1523:30 */ 38011 38012 // Release any cache of column names currently held as part of 38013 // the DbEvalContext structure passed as the first argument. 38014 func dbReleaseColumnNames(tls *libc.TLS, p uintptr) { /* tclsqlite.c:1541:13: */ 38015 if (*DbEvalContext)(unsafe.Pointer(p)).FapColName != 0 { 38016 var i int32 38017 for i = 0; i < (*DbEvalContext)(unsafe.Pointer(p)).FnCol; i++ { 38018 for ok := true; ok; ok = 0 != 0 { 38019 var _objPtr uintptr = *(*uintptr)(unsafe.Pointer((*DbEvalContext)(unsafe.Pointer(p)).FapColName + uintptr(i)*8)) 38020 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 38021 tcl.XTclFreeObj(tls, _objPtr) 38022 } 38023 } 38024 } 38025 tcl.XTcl_Free(tls, (*DbEvalContext)(unsafe.Pointer(p)).FapColName) 38026 (*DbEvalContext)(unsafe.Pointer(p)).FapColName = uintptr(0) 38027 } 38028 (*DbEvalContext)(unsafe.Pointer(p)).FnCol = 0 38029 } 38030 38031 // Initialize a DbEvalContext structure. 38032 // 38033 // If pArray is not NULL, then it contains the name of a Tcl array 38034 // variable. The "*" member of this array is set to a list containing 38035 // the names of the columns returned by the statement as part of each 38036 // call to dbEvalStep(), in order from left to right. e.g. if the names 38037 // of the returned columns are a, b and c, it does the equivalent of the 38038 // tcl command: 38039 // 38040 // set ${pArray}(*) {a b c} 38041 func dbEvalInit(tls *libc.TLS, p uintptr, pDb uintptr, pSql uintptr, pArray uintptr, evalFlags int32) { /* tclsqlite.c:1565:13: */ 38042 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(DbEvalContext{}))) 38043 (*DbEvalContext)(unsafe.Pointer(p)).FpDb = pDb 38044 (*DbEvalContext)(unsafe.Pointer(p)).FzSql = tcl.XTcl_GetString(tls, pSql) 38045 (*DbEvalContext)(unsafe.Pointer(p)).FpSql = pSql 38046 (*Tcl_Obj)(unsafe.Pointer(pSql)).FrefCount++ 38047 if pArray != 0 { 38048 (*DbEvalContext)(unsafe.Pointer(p)).FpArray = pArray 38049 (*Tcl_Obj)(unsafe.Pointer(pArray)).FrefCount++ 38050 } 38051 (*DbEvalContext)(unsafe.Pointer(p)).FevalFlags = evalFlags 38052 } 38053 38054 // Obtain information about the row that the DbEvalContext passed as the 38055 // first argument currently points to. 38056 func dbEvalRowInfo(tls *libc.TLS, p uintptr, pnCol uintptr, papColName uintptr) { /* tclsqlite.c:1588:13: */ 38057 // Compute column names 38058 if uintptr(0) == (*DbEvalContext)(unsafe.Pointer(p)).FapColName { 38059 var pStmt uintptr = (*SqlPreparedStmt)(unsafe.Pointer((*DbEvalContext)(unsafe.Pointer(p)).FpPreStmt)).FpStmt 38060 var i int32 // Iterator variable 38061 var nCol int32 // Number of columns returned by pStmt 38062 var apColName uintptr = uintptr(0) // Array of column names 38063 38064 (*DbEvalContext)(unsafe.Pointer(p)).FnCol = libc.AssignInt32(&nCol, sqlite3.Xsqlite3_column_count(tls, pStmt)) 38065 if (nCol > 0) && ((papColName != 0) || ((*DbEvalContext)(unsafe.Pointer(p)).FpArray != 0)) { 38066 apColName = tcl.XTcl_Alloc(tls, (uint32(uint64(unsafe.Sizeof(uintptr(0))) * uint64(nCol)))) 38067 for i = 0; i < nCol; i++ { 38068 *(*uintptr)(unsafe.Pointer(apColName + uintptr(i)*8)) = tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_column_name(tls, pStmt, i), -1) 38069 (*Tcl_Obj)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(apColName + uintptr(i)*8)))).FrefCount++ 38070 } 38071 (*DbEvalContext)(unsafe.Pointer(p)).FapColName = apColName 38072 } 38073 38074 // If results are being stored in an array variable, then create 38075 // the array(*) entry for that array 38076 if (*DbEvalContext)(unsafe.Pointer(p)).FpArray != 0 { 38077 var interp uintptr = (*SqliteDb)(unsafe.Pointer((*DbEvalContext)(unsafe.Pointer(p)).FpDb)).Finterp 38078 var pColList uintptr = tcl.XTcl_NewObj(tls) 38079 var pStar uintptr = tcl.XTcl_NewStringObj(tls, ts+3711 /* "*" */, -1) 38080 38081 for i = 0; i < nCol; i++ { 38082 tcl.XTcl_ListObjAppendElement(tls, interp, pColList, *(*uintptr)(unsafe.Pointer(apColName + uintptr(i)*8))) 38083 } 38084 (*Tcl_Obj)(unsafe.Pointer(pStar)).FrefCount++ 38085 tcl.XTcl_ObjSetVar2(tls, interp, (*DbEvalContext)(unsafe.Pointer(p)).FpArray, pStar, pColList, 0) 38086 for ok := true; ok; ok = 0 != 0 { 38087 var _objPtr uintptr = pStar 38088 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 38089 tcl.XTclFreeObj(tls, _objPtr) 38090 } 38091 } 38092 } 38093 } 38094 38095 if papColName != 0 { 38096 *(*uintptr)(unsafe.Pointer(papColName)) = (*DbEvalContext)(unsafe.Pointer(p)).FapColName 38097 } 38098 if pnCol != 0 { 38099 *(*int32)(unsafe.Pointer(pnCol)) = (*DbEvalContext)(unsafe.Pointer(p)).FnCol 38100 } 38101 } 38102 38103 // Return one of TCL_OK, TCL_BREAK or TCL_ERROR. If TCL_ERROR is 38104 // returned, then an error message is stored in the interpreter before 38105 // returning. 38106 // 38107 // A return value of TCL_OK means there is a row of data available. The 38108 // data may be accessed using dbEvalRowInfo() and dbEvalColumnValue(). This 38109 // is analogous to a return of SQLITE_ROW from sqlite3_step(). If TCL_BREAK 38110 // is returned, then the SQL script has finished executing and there are 38111 // no further rows available. This is similar to SQLITE_DONE. 38112 func dbEvalStep(tls *libc.TLS, p uintptr) int32 { /* tclsqlite.c:1646:12: */ 38113 var zPrevSql uintptr = uintptr(0) // Previous value of p->zSql 38114 38115 for (*(*int8)(unsafe.Pointer((*DbEvalContext)(unsafe.Pointer(p)).FzSql)) != 0) || ((*DbEvalContext)(unsafe.Pointer(p)).FpPreStmt != 0) { 38116 var rc int32 38117 if (*DbEvalContext)(unsafe.Pointer(p)).FpPreStmt == uintptr(0) { 38118 zPrevSql = func() uintptr { 38119 if (*DbEvalContext)(unsafe.Pointer(p)).FzSql == zPrevSql { 38120 return uintptr(0) 38121 } 38122 return (*DbEvalContext)(unsafe.Pointer(p)).FzSql 38123 }() 38124 rc = dbPrepareAndBind(tls, (*DbEvalContext)(unsafe.Pointer(p)).FpDb, (*DbEvalContext)(unsafe.Pointer(p)).FzSql, (p + 16 /* &.zSql */), (p + 24 /* &.pPreStmt */)) 38125 if rc != TCL_OK { 38126 return rc 38127 } 38128 } else { 38129 var rcs int32 38130 var pDb uintptr = (*DbEvalContext)(unsafe.Pointer(p)).FpDb 38131 var pPreStmt uintptr = (*DbEvalContext)(unsafe.Pointer(p)).FpPreStmt 38132 var pStmt uintptr = (*SqlPreparedStmt)(unsafe.Pointer(pPreStmt)).FpStmt 38133 38134 rcs = sqlite3.Xsqlite3_step(tls, pStmt) 38135 if rcs == SQLITE_ROW { 38136 return TCL_OK 38137 } 38138 if (*DbEvalContext)(unsafe.Pointer(p)).FpArray != 0 { 38139 dbEvalRowInfo(tls, p, uintptr(0), uintptr(0)) 38140 } 38141 rcs = sqlite3.Xsqlite3_reset(tls, pStmt) 38142 38143 (*SqliteDb)(unsafe.Pointer(pDb)).FnStep = sqlite3.Xsqlite3_stmt_status(tls, pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP, 1) 38144 (*SqliteDb)(unsafe.Pointer(pDb)).FnSort = sqlite3.Xsqlite3_stmt_status(tls, pStmt, SQLITE_STMTSTATUS_SORT, 1) 38145 (*SqliteDb)(unsafe.Pointer(pDb)).FnIndex = sqlite3.Xsqlite3_stmt_status(tls, pStmt, SQLITE_STMTSTATUS_AUTOINDEX, 1) 38146 (*SqliteDb)(unsafe.Pointer(pDb)).FnVMStep = sqlite3.Xsqlite3_stmt_status(tls, pStmt, SQLITE_STMTSTATUS_VM_STEP, 1) 38147 dbReleaseColumnNames(tls, p) 38148 (*DbEvalContext)(unsafe.Pointer(p)).FpPreStmt = uintptr(0) 38149 38150 if rcs != SQLITE_OK { 38151 // If a run-time error occurs, report the error and stop reading 38152 // the SQL. 38153 dbReleaseStmt(tls, pDb, pPreStmt, 1) 38154 if (((*SqliteDb)(unsafe.Pointer((*DbEvalContext)(unsafe.Pointer(p)).FpDb)).FbLegacyPrepare != 0) && (rcs == SQLITE_SCHEMA)) && (zPrevSql != 0) { 38155 // If the runtime error was an SQLITE_SCHEMA, and the database 38156 // handle is configured to use the legacy sqlite3_prepare() 38157 // interface, retry prepare()/step() on the same SQL statement. 38158 // This only happens once. If there is a second SQLITE_SCHEMA 38159 // error, the error will be returned to the caller. 38160 (*DbEvalContext)(unsafe.Pointer(p)).FzSql = zPrevSql 38161 continue 38162 } 38163 tcl.XTcl_SetObjResult(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Finterp, 38164 tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), -1)) 38165 return TCL_ERROR 38166 } else { 38167 dbReleaseStmt(tls, pDb, pPreStmt, 0) 38168 } 38169 } 38170 } 38171 38172 // Finished 38173 return TCL_BREAK 38174 } 38175 38176 // Free all resources currently held by the DbEvalContext structure passed 38177 // as the first argument. There should be exactly one call to this function 38178 // for each call to dbEvalInit(). 38179 func dbEvalFinalize(tls *libc.TLS, p uintptr) { /* tclsqlite.c:1710:13: */ 38180 if (*DbEvalContext)(unsafe.Pointer(p)).FpPreStmt != 0 { 38181 sqlite3.Xsqlite3_reset(tls, (*SqlPreparedStmt)(unsafe.Pointer((*DbEvalContext)(unsafe.Pointer(p)).FpPreStmt)).FpStmt) 38182 dbReleaseStmt(tls, (*DbEvalContext)(unsafe.Pointer(p)).FpDb, (*DbEvalContext)(unsafe.Pointer(p)).FpPreStmt, 0) 38183 (*DbEvalContext)(unsafe.Pointer(p)).FpPreStmt = uintptr(0) 38184 } 38185 if (*DbEvalContext)(unsafe.Pointer(p)).FpArray != 0 { 38186 for ok := true; ok; ok = 0 != 0 { 38187 var _objPtr uintptr = (*DbEvalContext)(unsafe.Pointer(p)).FpArray 38188 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 38189 tcl.XTclFreeObj(tls, _objPtr) 38190 } 38191 } 38192 (*DbEvalContext)(unsafe.Pointer(p)).FpArray = uintptr(0) 38193 } 38194 for ok1 := true; ok1; ok1 = 0 != 0 { 38195 var _objPtr uintptr = (*DbEvalContext)(unsafe.Pointer(p)).FpSql 38196 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 38197 tcl.XTclFreeObj(tls, _objPtr) 38198 } 38199 } 38200 dbReleaseColumnNames(tls, p) 38201 } 38202 38203 // Return a pointer to a Tcl_Obj structure with ref-count 0 that contains 38204 // the value for the iCol'th column of the row currently pointed to by 38205 // the DbEvalContext structure passed as the first argument. 38206 func dbEvalColumnValue(tls *libc.TLS, p uintptr, iCol int32) uintptr { /* tclsqlite.c:1729:16: */ 38207 var pStmt uintptr = (*SqlPreparedStmt)(unsafe.Pointer((*DbEvalContext)(unsafe.Pointer(p)).FpPreStmt)).FpStmt 38208 switch sqlite3.Xsqlite3_column_type(tls, pStmt, iCol) { 38209 case SQLITE_BLOB: 38210 { 38211 var bytes int32 = sqlite3.Xsqlite3_column_bytes(tls, pStmt, iCol) 38212 var zBlob uintptr = sqlite3.Xsqlite3_column_blob(tls, pStmt, iCol) 38213 if !(zBlob != 0) { 38214 bytes = 0 38215 } 38216 return tcl.XTcl_NewByteArrayObj(tls, zBlob, bytes) 38217 38218 } 38219 case SQLITE_INTEGER: 38220 { 38221 var v sqlite_int64 = sqlite3.Xsqlite3_column_int64(tls, pStmt, iCol) 38222 if (v >= int64(-2147483647)) && (v <= int64(2147483647)) { 38223 return tcl.XTcl_NewIntObj(tls, int32(v)) 38224 } else { 38225 return tcl.XTcl_NewWideIntObj(tls, v) 38226 } 38227 38228 } 38229 fallthrough 38230 case SQLITE_FLOAT: 38231 { 38232 return tcl.XTcl_NewDoubleObj(tls, sqlite3.Xsqlite3_column_double(tls, pStmt, iCol)) 38233 38234 } 38235 case SQLITE_NULL: 38236 { 38237 return tcl.XTcl_NewStringObj(tls, (*SqliteDb)(unsafe.Pointer((*DbEvalContext)(unsafe.Pointer(p)).FpDb)).FzNull, -1) 38238 38239 } 38240 } 38241 38242 return tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_column_text(tls, pStmt, iCol), -1) 38243 } 38244 38245 // If using Tcl version 8.6 or greater, use the NR functions to avoid 38246 // recursive evalution of scripts by the [db eval] and [db trans] 38247 // commands. Even if the headers used while compiling the extension 38248 // are 8.6 or newer, the code still tests the Tcl version at runtime. 38249 // This allows stubs-enabled builds to be used with older Tcl libraries. 38250 func DbUseNre(tls *libc.TLS) int32 { /* tclsqlite.c:1766:12: */ 38251 bp := tls.Alloc(8) 38252 defer tls.Free(8) 38253 38254 // var major int32 at bp, 4 38255 38256 // var minor int32 at bp+4, 4 38257 38258 tcl.XTcl_GetVersion(tls, bp /* &major */, bp+4 /* &minor */, uintptr(0), uintptr(0)) 38259 return (libc.Bool32(((*(*int32)(unsafe.Pointer(bp /* major */)) == 8) && (*(*int32)(unsafe.Pointer(bp + 4 /* minor */)) >= 6)) || (*(*int32)(unsafe.Pointer(bp /* major */)) > 8))) 38260 } 38261 38262 // This function is part of the implementation of the command: 38263 // 38264 // $db eval SQL ?ARRAYNAME? SCRIPT 38265 func DbEvalNextCmd(tls *libc.TLS, data uintptr, interp uintptr, result int32) int32 { /* tclsqlite.c:1793:26: */ 38266 bp := tls.Alloc(16) 38267 defer tls.Free(16) 38268 38269 var rc int32 = result // Return code 38270 38271 // The first element of the data[] array is a pointer to a DbEvalContext 38272 // structure allocated using Tcl_Alloc(). The second element of data[] 38273 // is a pointer to a Tcl_Obj containing the script to run for each row 38274 // returned by the queries encapsulated in data[0]. 38275 var p uintptr = *(*ClientData)(unsafe.Pointer(data)) 38276 var pScript uintptr = *(*ClientData)(unsafe.Pointer(data + 1*8)) 38277 var pArray uintptr = (*DbEvalContext)(unsafe.Pointer(p)).FpArray 38278 38279 for ((rc == TCL_OK) || (rc == TCL_CONTINUE)) && (TCL_OK == (libc.AssignInt32(&rc, dbEvalStep(tls, p)))) { 38280 var i int32 38281 // var nCol int32 at bp, 4 38282 38283 // var apColName uintptr at bp+8, 8 38284 38285 dbEvalRowInfo(tls, p, bp /* &nCol */, bp+8 /* &apColName */) 38286 for i = 0; i < *(*int32)(unsafe.Pointer(bp /* nCol */)); i++ { 38287 if pArray == uintptr(0) { 38288 tcl.XTcl_ObjSetVar2(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* apColName */)) + uintptr(i)*8)), uintptr(0), dbEvalColumnValue(tls, p, i), 0) 38289 } else if (((*DbEvalContext)(unsafe.Pointer(p)).FevalFlags & SQLITE_EVAL_WITHOUTNULLS) != 0) && 38290 (sqlite3.Xsqlite3_column_type(tls, (*SqlPreparedStmt)(unsafe.Pointer((*DbEvalContext)(unsafe.Pointer(p)).FpPreStmt)).FpStmt, i) == SQLITE_NULL) { 38291 tcl.XTcl_UnsetVar2(tls, interp, tcl.XTcl_GetString(tls, pArray), 38292 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* apColName */)) + uintptr(i)*8))), 0) 38293 } else { 38294 tcl.XTcl_ObjSetVar2(tls, interp, pArray, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* apColName */)) + uintptr(i)*8)), dbEvalColumnValue(tls, p, i), 0) 38295 } 38296 } 38297 38298 // The required interpreter variables are now populated with the data 38299 // from the current row. If using NRE, schedule callbacks to evaluate 38300 // script pScript, then to invoke this function again to fetch the next 38301 // row (or clean up if there is no next row or the script throws an 38302 // exception). After scheduling the callbacks, return control to the 38303 // caller. 38304 // 38305 // If not using NRE, evaluate pScript directly and continue with the 38306 // next iteration of this while(...) loop. 38307 if DbUseNre(tls) != 0 { 38308 tcl.XTcl_NRAddCallback(tls, interp, *(*uintptr)(unsafe.Pointer(&struct { 38309 f func(*libc.TLS, uintptr, uintptr, int32) int32 38310 }{DbEvalNextCmd})), p, pScript, uintptr(0), uintptr(0)) 38311 return tcl.XTcl_NREvalObj(tls, interp, pScript, 0) 38312 } else { 38313 rc = tcl.XTcl_EvalObjEx(tls, interp, pScript, 0) 38314 } 38315 } 38316 38317 for ok := true; ok; ok = 0 != 0 { 38318 var _objPtr uintptr = pScript 38319 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 38320 tcl.XTclFreeObj(tls, _objPtr) 38321 } 38322 } 38323 dbEvalFinalize(tls, p) 38324 tcl.XTcl_Free(tls, p) 38325 38326 if (rc == TCL_OK) || (rc == TCL_BREAK) { 38327 tcl.XTcl_ResetResult(tls, interp) 38328 rc = TCL_OK 38329 } 38330 return rc 38331 } 38332 38333 // This function is used by the implementations of the following database 38334 // handle sub-commands: 38335 // 38336 // $db update_hook ?SCRIPT? 38337 // $db wal_hook ?SCRIPT? 38338 // $db commit_hook ?SCRIPT? 38339 // $db preupdate hook ?SCRIPT? 38340 func DbHookCmd(tls *libc.TLS, interp uintptr, pDb uintptr, pArg uintptr, ppHook uintptr) { /* tclsqlite.c:1863:13: */ 38341 var db uintptr = (*SqliteDb)(unsafe.Pointer(pDb)).Fdb 38342 38343 if *(*uintptr)(unsafe.Pointer(ppHook)) != 0 { 38344 tcl.XTcl_SetObjResult(tls, interp, *(*uintptr)(unsafe.Pointer(ppHook))) 38345 if pArg != 0 { 38346 for ok := true; ok; ok = 0 != 0 { 38347 var _objPtr uintptr = *(*uintptr)(unsafe.Pointer(ppHook)) 38348 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 38349 tcl.XTclFreeObj(tls, _objPtr) 38350 } 38351 } 38352 *(*uintptr)(unsafe.Pointer(ppHook)) = uintptr(0) 38353 } 38354 } 38355 if pArg != 0 { 38356 38357 if tcl.XTcl_GetCharLength(tls, pArg) > 0 { 38358 *(*uintptr)(unsafe.Pointer(ppHook)) = pArg 38359 (*Tcl_Obj)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppHook)))).FrefCount++ 38360 } 38361 } 38362 38363 sqlite3.Xsqlite3_preupdate_hook(tls, db, func() uintptr { 38364 if (*SqliteDb)(unsafe.Pointer(pDb)).FpPreUpdateHook != 0 { 38365 return *(*uintptr)(unsafe.Pointer(&struct { 38366 f func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, sqlite_int64, sqlite_int64) 38367 }{DbPreUpdateHandler})) 38368 } 38369 return uintptr(0) 38370 }(), pDb) 38371 sqlite3.Xsqlite3_update_hook(tls, db, func() uintptr { 38372 if (*SqliteDb)(unsafe.Pointer(pDb)).FpUpdateHook != 0 { 38373 return *(*uintptr)(unsafe.Pointer(&struct { 38374 f func(*libc.TLS, uintptr, int32, uintptr, uintptr, sqlite_int64) 38375 }{DbUpdateHandler})) 38376 } 38377 return uintptr(0) 38378 }(), pDb) 38379 sqlite3.Xsqlite3_rollback_hook(tls, db, func() uintptr { 38380 if (*SqliteDb)(unsafe.Pointer(pDb)).FpRollbackHook != 0 { 38381 return *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{DbRollbackHandler})) 38382 } 38383 return uintptr(0) 38384 }(), pDb) 38385 sqlite3.Xsqlite3_wal_hook(tls, db, func() uintptr { 38386 if (*SqliteDb)(unsafe.Pointer(pDb)).FpWalHook != 0 { 38387 return *(*uintptr)(unsafe.Pointer(&struct { 38388 f func(*libc.TLS, uintptr, uintptr, uintptr, int32) int32 38389 }{DbWalHandler})) 38390 } 38391 return uintptr(0) 38392 }(), pDb) 38393 } 38394 38395 // The "sqlite" command below creates a new Tcl command for each 38396 // connection it opens to an SQLite database. This routine is invoked 38397 // whenever one of those connection-specific commands is executed 38398 // in Tcl. For example, if you run Tcl code like this: 38399 // 38400 // sqlite3 db1 "my_database" 38401 // db1 close 38402 // 38403 // The first command opens a connection to the "my_database" database 38404 // and calls that connection "db1". The second command causes this 38405 // subroutine to be invoked. 38406 func DbObjCmd(tls *libc.TLS, cd uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* tclsqlite.c:1907:26: */ 38407 bp := tls.Alloc(1580) 38408 defer tls.Free(1580) 38409 *(*uintptr)(unsafe.Pointer(bp + 1456)) = cd 38410 38411 var pDb uintptr 38412 // var choice int32 at bp+1016, 4 38413 38414 var rc int32 38415 var zAuth uintptr 38416 // var len int32 at bp+1020, 4 38417 38418 var zDestFile uintptr 38419 var zSrcDb uintptr 38420 // var pDest uintptr at bp+1024, 8 38421 38422 var pBackup uintptr 38423 var zCallback uintptr 38424 // var len1 int32 at bp+1032, 4 38425 38426 var zBusy uintptr 38427 // var len2 int32 at bp+1036, 4 38428 38429 var subCmd uintptr 38430 // var n int32 at bp+1040, 4 38431 38432 var pResult uintptr 38433 var pCollate uintptr 38434 var zName uintptr 38435 var zScript uintptr 38436 // var nScript int32 at bp+1044, 4 38437 38438 var _objPtr uintptr 38439 var zCommit uintptr 38440 // var len3 int32 at bp+1048, 4 38441 38442 var pResult1 uintptr 38443 var isComplete int32 38444 // var v int32 at bp+1052, 4 38445 38446 var zOpt uintptr 38447 // var onoff int32 at bp+1056, 4 38448 38449 // var v1 int32 at bp+1060, 4 38450 38451 var pResult2 uintptr 38452 var ii int32 38453 var zErr uintptr 38454 var nErr int32 38455 var z uintptr 38456 var zTable uintptr // Insert data into this table 38457 var zFile uintptr // The file from which to extract data 38458 var zConflict uintptr // The conflict algorithm to use 38459 // var pStmt uintptr at bp+1064, 8 38460 // A statement 38461 var nCol int32 // Number of columns in the table 38462 var nByte int32 // Number of bytes in an SQL string 38463 var i int32 38464 var j int32 // Loop counters 38465 var nSep int32 // Number of bytes in zSep[] 38466 var nNull int32 // Number of bytes in zNull[] 38467 var zSql uintptr // An SQL statement 38468 var zLine uintptr // A single line of input from the file 38469 var azCol uintptr // zLine[] broken up into columns 38470 var zCommit1 uintptr // How to commit changes 38471 var in uintptr // The input file 38472 var lineno int32 // Line number of input file 38473 // var zLineNum [80]int8 at bp+1072, 80 38474 // Line number print buffer 38475 var pResult3 uintptr // interp result 38476 38477 var zSep uintptr 38478 var zNull uintptr 38479 var z1 uintptr 38480 var flags int32 38481 var zSchema uintptr 38482 var pValue uintptr 38483 var pBA uintptr 38484 var pData uintptr 38485 // var len4 int32 at bp+1164, 4 38486 38487 var xrc int32 38488 // var mxSize sqlite3_int64 at bp+1152, 8 38489 38490 var i1 int32 38491 // var isReadonly int32 at bp+1160, 4 38492 38493 var pResult4 uintptr 38494 // var sEval DbEvalContext at bp+1168, 56 38495 38496 var i2 int32 38497 // var nCol1 int32 at bp+1280, 4 38498 38499 var _objPtr1 uintptr 38500 // var sEval1 DbEvalContext at bp+1224, 56 38501 38502 var pRet uintptr 38503 // var cd2 [2]ClientData at bp+1288, 16 38504 38505 var p uintptr 38506 var pArray uintptr 38507 var pScript uintptr 38508 var evalFlags int32 38509 var zOpt1 uintptr 38510 // var azType [6]uintptr at bp+1312, 48 38511 38512 var z2 uintptr 38513 var n1 int32 38514 var _objPtr2 uintptr 38515 var flags1 int32 38516 var pFunc uintptr 38517 var pScript1 uintptr 38518 var zName1 uintptr 38519 // var nArg int32 at bp+1304, 4 38520 38521 var i3 int32 38522 // var eType int32 at bp+1360, 4 38523 38524 var isReadonly1 int32 38525 var zDb uintptr 38526 var zTable1 uintptr 38527 var zColumn uintptr 38528 // var iRow Tcl_WideInt at bp+1368, 8 38529 38530 // var len5 int32 at bp+1376, 4 38531 38532 var zNull1 uintptr 38533 var pResult5 uintptr 38534 var rowid Tcl_WideInt 38535 var zProgress uintptr 38536 // var len6 int32 at bp+1384, 4 38537 38538 // var N int32 at bp+1380, 4 38539 38540 var zProfile uintptr 38541 // var len7 int32 at bp+1388, 4 38542 38543 var zSrcFile uintptr 38544 var zDestDb uintptr 38545 // var pSrc uintptr at bp+1392, 8 38546 38547 var pBackup1 uintptr 38548 var nTimeout int32 38549 var needFree int32 38550 var zSchema1 uintptr 38551 // var sz sqlite3_int64 at bp+1400, 8 38552 38553 var pData1 uintptr 38554 var v2 int32 38555 var zOp uintptr 38556 // var ms int32 at bp+1408, 4 38557 38558 var pResult6 uintptr 38559 var zTrace uintptr 38560 // var len8 int32 at bp+1412, 4 38561 38562 var _objPtr3 uintptr 38563 var _objPtr4 uintptr 38564 // var wType Tcl_WideInt at bp+1440, 8 38565 38566 var pError uintptr 38567 // var pObj uintptr at bp+1424, 8 38568 38569 // var ttype int32 at bp+1432, 4 38570 38571 var i4 int32 38572 var zTraceV2 uintptr 38573 // var len9 int32 at bp+1416, 4 38574 38575 var wMask Tcl_WideInt 38576 // var ttype1 int32 at bp+1448, 4 38577 38578 var pScript2 uintptr 38579 var zBegin uintptr 38580 var _objPtr5 uintptr 38581 var xNotify uintptr 38582 var pNotifyArg uintptr 38583 var nCol2 int32 38584 var pRet1 uintptr 38585 var pObj1 uintptr 38586 // var iIdx int32 at bp+1468, 4 38587 38588 // var pValue1 uintptr at bp+1472, 8 38589 38590 // var iSub int32 at bp+1464, 4 38591 38592 // set ppHook to point at pUpdateHook or pRollbackHook, depending on 38593 // whether [$db update_hook] or [$db rollback_hook] was invoked. 38594 var ppHook uintptr 38595 // var zBuf [100]int8 at bp+1480, 100 38596 38597 var zArg uintptr 38598 var i5 int32 38599 pDb = *(*uintptr)(unsafe.Pointer(bp + 1456 /* cd */)) 38600 rc = TCL_OK 38601 // don't leave trailing commas on DB_enum, it confuses the AIX xlc compiler 38602 38603 if !(objc < 2) { 38604 goto __1 38605 } 38606 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1860 /* "SUBCOMMAND ..." */) 38607 return TCL_ERROR 38608 __1: 38609 ; 38610 if !(tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&DB_strs)), int32(unsafe.Sizeof(uintptr(0))), ts+11375 /* "option" */, 0, bp+1016 /* &choice */) != 0) { 38611 goto __2 38612 } 38613 return TCL_ERROR 38614 __2: 38615 ; 38616 38617 switch uint32(*(*int32)(unsafe.Pointer(bp + 1016 /* choice */))) { 38618 38619 // $db authorizer ?CALLBACK? 38620 // 38621 // Invoke the given callback to authorize each SQL operation as it is 38622 // compiled. 5 arguments are appended to the callback before it is 38623 // invoked: 38624 // 38625 // (1) The authorization type (ex: SQLITE_CREATE_TABLE, SQLITE_INSERT, ...) 38626 // (2) First descriptive name (depends on authorization type) 38627 // (3) Second descriptive name 38628 // (4) Name of the database (ex: "main", "temp") 38629 // (5) Name of trigger that is doing the access 38630 // 38631 // The callback should return on of the following strings: SQLITE_OK, 38632 // SQLITE_IGNORE, or SQLITE_DENY. Any other return value is an error. 38633 // 38634 // If this method is invoked with no arguments, the current authorization 38635 // callback string is returned. 38636 case uint32(0) /* DB_AUTHORIZER */ : 38637 goto __4 38638 38639 // $db backup ?DATABASE? FILENAME 38640 // 38641 // Open or create a database file named FILENAME. Transfer the 38642 // content of local database DATABASE (default: "main") into the 38643 // FILENAME database. 38644 case uint32(1) /* DB_BACKUP */ : 38645 goto __5 38646 38647 // $db bind_fallback ?CALLBACK? 38648 // 38649 // When resolving bind parameters in an SQL statement, if the parameter 38650 // cannot be associated with a TCL variable then invoke CALLBACK with a 38651 // single argument that is the name of the parameter and use the return 38652 // value of the CALLBACK as the binding. If CALLBACK returns something 38653 // other than TCL_OK or TCL_ERROR then bind a NULL. 38654 // 38655 // If CALLBACK is an empty string, then revert to the default behavior 38656 // which is to set the binding to NULL. 38657 // 38658 // If CALLBACK returns an error, that causes the statement execution to 38659 // abort. Hence, to configure a connection so that it throws an error 38660 // on an attempt to bind an unknown variable, do something like this: 38661 // 38662 // proc bind_error {name} {error "no such variable: $name"} 38663 // db bind_fallback bind_error 38664 case uint32(2) /* DB_BIND_FALLBACK */ : 38665 goto __6 38666 38667 // $db busy ?CALLBACK? 38668 // 38669 // Invoke the given callback if an SQL statement attempts to open 38670 // a locked database file. 38671 case uint32(3) /* DB_BUSY */ : 38672 goto __7 38673 38674 // $db cache flush 38675 // $db cache size n 38676 // 38677 // Flush the prepared statement cache, or set the maximum number of 38678 // cached statements. 38679 case uint32(4) /* DB_CACHE */ : 38680 goto __8 38681 38682 // $db changes 38683 // 38684 // Return the number of rows that were modified, inserted, or deleted by 38685 // the most recent INSERT, UPDATE or DELETE statement, not including 38686 // any changes made by trigger programs. 38687 case uint32(5) /* DB_CHANGES */ : 38688 goto __9 38689 38690 // $db close 38691 // 38692 // Shutdown the database 38693 case uint32(6) /* DB_CLOSE */ : 38694 goto __10 38695 38696 // $db collate NAME SCRIPT 38697 // 38698 // Create a new SQL collation function called NAME. Whenever 38699 // that function is called, invoke SCRIPT to evaluate the function. 38700 case uint32(7) /* DB_COLLATE */ : 38701 goto __11 38702 38703 // $db collation_needed SCRIPT 38704 // 38705 // Create a new SQL collation function called NAME. Whenever 38706 // that function is called, invoke SCRIPT to evaluate the function. 38707 case uint32(8) /* DB_COLLATION_NEEDED */ : 38708 goto __12 38709 38710 // $db commit_hook ?CALLBACK? 38711 // 38712 // Invoke the given callback just before committing every SQL transaction. 38713 // If the callback throws an exception or returns non-zero, then the 38714 // transaction is aborted. If CALLBACK is an empty string, the callback 38715 // is disabled. 38716 case uint32(9) /* DB_COMMIT_HOOK */ : 38717 goto __13 38718 38719 // $db complete SQL 38720 // 38721 // Return TRUE if SQL is a complete SQL statement. Return FALSE if 38722 // additional lines of input are needed. This is similar to the 38723 // built-in "info complete" command of Tcl. 38724 case uint32(10) /* DB_COMPLETE */ : 38725 goto __14 38726 38727 // $db config ?OPTION? ?BOOLEAN? 38728 // 38729 // Configure the database connection using the sqlite3_db_config() 38730 // interface. 38731 case uint32(11) /* DB_CONFIG */ : 38732 goto __15 38733 38734 // $db copy conflict-algorithm table filename ?SEPARATOR? ?NULLINDICATOR? 38735 // 38736 // Copy data into table from filename, optionally using SEPARATOR 38737 // as column separators. If a column contains a null string, or the 38738 // value of NULLINDICATOR, a NULL is inserted for the column. 38739 // conflict-algorithm is one of the sqlite conflict algorithms: 38740 // rollback, abort, fail, ignore, replace 38741 // On success, return the number of lines processed, not necessarily same 38742 // as 'db changes' due to conflict-algorithm selected. 38743 // 38744 // This code is basically an implementation/enhancement of 38745 // the sqlite3 shell.c ".import" command. 38746 // 38747 // This command usage is equivalent to the sqlite2.x COPY statement, 38748 // which imports file data into a table using the PostgreSQL COPY file format: 38749 // $db copy $conflit_algo $table_name $filename \t \\N 38750 case uint32(12) /* DB_COPY */ : 38751 goto __16 38752 38753 // $db deserialize ?-maxsize N? ?-readonly BOOL? ?DATABASE? VALUE 38754 // 38755 // Reopen DATABASE (default "main") using the content in $VALUE 38756 case uint32(13) /* DB_DESERIALIZE */ : 38757 goto __17 38758 38759 // $db enable_load_extension BOOLEAN 38760 // 38761 // Turn the extension loading feature on or off. It if off by 38762 // default. 38763 case uint32(14) /* DB_ENABLE_LOAD_EXTENSION */ : 38764 goto __18 38765 38766 // $db errorcode 38767 // 38768 // Return the numeric error code that was returned by the most recent 38769 // call to sqlite3_exec(). 38770 case uint32(15) /* DB_ERRORCODE */ : 38771 goto __19 38772 38773 // $db exists $sql 38774 // $db onecolumn $sql 38775 // 38776 // The onecolumn method is the equivalent of: 38777 // lindex [$db eval $sql] 0 38778 case uint32(17) /* DB_EXISTS */ : 38779 goto __20 38780 case uint32(23) /* DB_ONECOLUMN */ : 38781 goto __21 38782 38783 // $db eval ?options? $sql ?array? ?{ ...code... }? 38784 // 38785 // The SQL statement in $sql is evaluated. For each row, the values are 38786 // placed in elements of the array named "array" and ...code... is executed. 38787 // If "array" and "code" are omitted, then no callback is every invoked. 38788 // If "array" is an empty string, then the values are placed in variables 38789 // that have the same name as the fields extracted by the query. 38790 case uint32(16) /* DB_EVAL */ : 38791 goto __22 38792 38793 // $db function NAME [OPTIONS] SCRIPT 38794 // 38795 // Create a new SQL function called NAME. Whenever that function is 38796 // called, invoke SCRIPT to evaluate the function. 38797 // 38798 // Options: 38799 // --argcount N Function has exactly N arguments 38800 // --deterministic The function is pure 38801 // --directonly Prohibit use inside triggers and views 38802 // --innocuous Has no side effects or information leaks 38803 // --returntype TYPE Specify the return type of the function 38804 case uint32(18) /* DB_FUNCTION */ : 38805 goto __23 38806 38807 // $db incrblob ?-readonly? ?DB? TABLE COLUMN ROWID 38808 case uint32(19) /* DB_INCRBLOB */ : 38809 goto __24 38810 38811 // $db interrupt 38812 // 38813 // Interrupt the execution of the inner-most SQL interpreter. This 38814 // causes the SQL statement to return an error of SQLITE_INTERRUPT. 38815 case uint32(20) /* DB_INTERRUPT */ : 38816 goto __25 38817 38818 // $db nullvalue ?STRING? 38819 // 38820 // Change text used when a NULL comes back from the database. If ?STRING? 38821 // is not present, then the current string used for NULL is returned. 38822 // If STRING is present, then STRING is returned. 38823 // 38824 case uint32(22) /* DB_NULLVALUE */ : 38825 goto __26 38826 38827 // $db last_insert_rowid 38828 // 38829 // Return an integer which is the ROWID for the most recent insert. 38830 case uint32(21) /* DB_LAST_INSERT_ROWID */ : 38831 goto __27 38832 38833 // The DB_ONECOLUMN method is implemented together with DB_EXISTS. 38834 38835 // $db progress ?N CALLBACK? 38836 // 38837 // Invoke the given callback every N virtual machine opcodes while executing 38838 // queries. 38839 case uint32(26) /* DB_PROGRESS */ : 38840 goto __28 38841 38842 // $db profile ?CALLBACK? 38843 // 38844 // Make arrangements to invoke the CALLBACK routine after each SQL statement 38845 // that has run. The text of the SQL and the amount of elapse time are 38846 // appended to CALLBACK before the script is run. 38847 case uint32(25) /* DB_PROFILE */ : 38848 goto __29 38849 38850 // $db rekey KEY 38851 // 38852 // Change the encryption key on the currently open database. 38853 case uint32(27) /* DB_REKEY */ : 38854 goto __30 38855 38856 // $db restore ?DATABASE? FILENAME 38857 // 38858 // Open a database file named FILENAME. Transfer the content 38859 // of FILENAME into the local database DATABASE (default: "main"). 38860 case uint32(28) /* DB_RESTORE */ : 38861 goto __31 38862 38863 // $db serialize ?DATABASE? 38864 // 38865 // Return a serialization of a database. 38866 case uint32(30) /* DB_SERIALIZE */ : 38867 goto __32 38868 38869 // $db status (step|sort|autoindex|vmstep) 38870 // 38871 // Display SQLITE_STMTSTATUS_FULLSCAN_STEP or 38872 // SQLITE_STMTSTATUS_SORT for the most recent eval. 38873 case uint32(31) /* DB_STATUS */ : 38874 goto __33 38875 38876 // $db timeout MILLESECONDS 38877 // 38878 // Delay for the number of milliseconds specified when a file is locked. 38879 case uint32(32) /* DB_TIMEOUT */ : 38880 goto __34 38881 38882 // $db total_changes 38883 // 38884 // Return the number of rows that were modified, inserted, or deleted 38885 // since the database handle was created. 38886 case uint32(33) /* DB_TOTAL_CHANGES */ : 38887 goto __35 38888 38889 // $db trace ?CALLBACK? 38890 // 38891 // Make arrangements to invoke the CALLBACK routine for each SQL statement 38892 // that is executed. The text of the SQL is appended to CALLBACK before 38893 // it is executed. 38894 case uint32(34) /* DB_TRACE */ : 38895 goto __36 38896 38897 // $db trace_v2 ?CALLBACK? ?MASK? 38898 // 38899 // Make arrangements to invoke the CALLBACK routine for each trace event 38900 // matching the mask that is generated. The parameters are appended to 38901 // CALLBACK before it is executed. 38902 case uint32(35) /* DB_TRACE_V2 */ : 38903 goto __37 38904 38905 // $db transaction [-deferred|-immediate|-exclusive] SCRIPT 38906 // 38907 // Start a new transaction (if we are not already in the midst of a 38908 // transaction) and execute the TCL script SCRIPT. After SCRIPT 38909 // completes, either commit the transaction or roll it back if SCRIPT 38910 // throws an exception. Or if no new transation was started, do nothing. 38911 // pass the exception on up the stack. 38912 // 38913 // This command was inspired by Dave Thomas's talk on Ruby at the 38914 // 2005 O'Reilly Open Source Convention (OSCON). 38915 case uint32(36) /* DB_TRANSACTION */ : 38916 goto __38 38917 38918 // $db unlock_notify ?script? 38919 case uint32(37) /* DB_UNLOCK_NOTIFY */ : 38920 goto __39 38921 38922 // $db preupdate_hook count 38923 // $db preupdate_hook hook ?SCRIPT? 38924 // $db preupdate_hook new INDEX 38925 // $db preupdate_hook old INDEX 38926 case uint32(24) /* DB_PREUPDATE */ : 38927 goto __40 38928 38929 // $db wal_hook ?script? 38930 // $db update_hook ?script? 38931 // $db rollback_hook ?script? 38932 case uint32(40) /* DB_WAL_HOOK */ : 38933 goto __41 38934 case uint32(38) /* DB_UPDATE_HOOK */ : 38935 goto __42 38936 case uint32(29) /* DB_ROLLBACK_HOOK */ : 38937 goto __43 38938 38939 // $db version 38940 // 38941 // Return the version string for this database. 38942 case uint32(39) /* DB_VERSION */ : 38943 goto __44 38944 } 38945 goto __3 38946 38947 // $db authorizer ?CALLBACK? 38948 // 38949 // Invoke the given callback to authorize each SQL operation as it is 38950 // compiled. 5 arguments are appended to the callback before it is 38951 // invoked: 38952 // 38953 // (1) The authorization type (ex: SQLITE_CREATE_TABLE, SQLITE_INSERT, ...) 38954 // (2) First descriptive name (depends on authorization type) 38955 // (3) Second descriptive name 38956 // (4) Name of the database (ex: "main", "temp") 38957 // (5) Name of trigger that is doing the access 38958 // 38959 // The callback should return on of the following strings: SQLITE_OK, 38960 // SQLITE_IGNORE, or SQLITE_DENY. Any other return value is an error. 38961 // 38962 // If this method is invoked with no arguments, the current authorization 38963 // callback string is returned. 38964 __4: 38965 if !(objc > 3) { 38966 goto __45 38967 } 38968 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11382 /* "?CALLBACK?" */) 38969 return TCL_ERROR 38970 goto __46 38971 __45: 38972 if !(objc == 2) { 38973 goto __47 38974 } 38975 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzAuth != 0) { 38976 goto __49 38977 } 38978 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, (*SqliteDb)(unsafe.Pointer(pDb)).FzAuth, uintptr(0))) 38979 __49: 38980 ; 38981 goto __48 38982 __47: 38983 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzAuth != 0) { 38984 goto __50 38985 } 38986 tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzAuth) 38987 __50: 38988 ; 38989 zAuth = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1020 /* &len */) 38990 if !((zAuth != 0) && (*(*int32)(unsafe.Pointer(bp + 1020 /* len */)) > 0)) { 38991 goto __51 38992 } 38993 (*SqliteDb)(unsafe.Pointer(pDb)).FzAuth = tcl.XTcl_Alloc(tls, (uint32(*(*int32)(unsafe.Pointer(bp + 1020 /* len */)) + 1))) 38994 libc.Xmemcpy(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzAuth, zAuth, (uint64(*(*int32)(unsafe.Pointer(bp + 1020 /* len */)) + 1))) 38995 goto __52 38996 __51: 38997 (*SqliteDb)(unsafe.Pointer(pDb)).FzAuth = uintptr(0) 38998 __52: 38999 ; 39000 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzAuth != 0) { 39001 goto __53 39002 } 39003 (*SqliteDb)(unsafe.Pointer(pDb)).Finterp = interp 39004 sqlite3.Xsqlite3_set_authorizer(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, *(*uintptr)(unsafe.Pointer(&struct { 39005 f func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr, uintptr) int32 39006 }{auth_callback})), pDb) 39007 goto __54 39008 __53: 39009 sqlite3.Xsqlite3_set_authorizer(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, uintptr(0), uintptr(0)) 39010 __54: 39011 ; 39012 __48: 39013 ; 39014 __46: 39015 ; 39016 goto __3 39017 39018 // $db backup ?DATABASE? FILENAME 39019 // 39020 // Open or create a database file named FILENAME. Transfer the 39021 // content of local database DATABASE (default: "main") into the 39022 // FILENAME database. 39023 __5: 39024 39025 if !(objc == 3) { 39026 goto __55 39027 } 39028 zSrcDb = ts + 85 /* "main" */ 39029 zDestFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 39030 goto __56 39031 __55: 39032 if !(objc == 4) { 39033 goto __57 39034 } 39035 zSrcDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 39036 zDestFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 39037 goto __58 39038 __57: 39039 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11393 /* "?DATABASE? FILEN..." */) 39040 return TCL_ERROR 39041 __58: 39042 ; 39043 __56: 39044 ; 39045 rc = sqlite3.Xsqlite3_open_v2(tls, zDestFile, bp+1024, /* &pDest */ 39046 ((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | (*SqliteDb)(unsafe.Pointer(pDb)).FopenFlags), uintptr(0)) 39047 if !(rc != SQLITE_OK) { 39048 goto __59 39049 } 39050 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, ts+11413, /* "cannot open targ..." */ 39051 sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 1024 /* pDest */))), uintptr(0))) 39052 sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 1024 /* pDest */))) 39053 return TCL_ERROR 39054 __59: 39055 ; 39056 pBackup = sqlite3.Xsqlite3_backup_init(tls, *(*uintptr)(unsafe.Pointer(bp + 1024 /* pDest */)), ts+85 /* "main" */, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zSrcDb) 39057 if !(pBackup == uintptr(0)) { 39058 goto __60 39059 } 39060 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, ts+11443, /* "backup failed: " */ 39061 sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 1024 /* pDest */))), uintptr(0))) 39062 sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 1024 /* pDest */))) 39063 return TCL_ERROR 39064 __60: 39065 ; 39066 __61: 39067 if !((libc.AssignInt32(&rc, sqlite3.Xsqlite3_backup_step(tls, pBackup, 100))) == SQLITE_OK) { 39068 goto __62 39069 } 39070 goto __61 39071 __62: 39072 ; 39073 sqlite3.Xsqlite3_backup_finish(tls, pBackup) 39074 if !(rc == SQLITE_DONE) { 39075 goto __63 39076 } 39077 rc = TCL_OK 39078 goto __64 39079 __63: 39080 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, ts+11443, /* "backup failed: " */ 39081 sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 1024 /* pDest */))), uintptr(0))) 39082 rc = TCL_ERROR 39083 __64: 39084 ; 39085 sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 1024 /* pDest */))) 39086 goto __3 39087 39088 // $db bind_fallback ?CALLBACK? 39089 // 39090 // When resolving bind parameters in an SQL statement, if the parameter 39091 // cannot be associated with a TCL variable then invoke CALLBACK with a 39092 // single argument that is the name of the parameter and use the return 39093 // value of the CALLBACK as the binding. If CALLBACK returns something 39094 // other than TCL_OK or TCL_ERROR then bind a NULL. 39095 // 39096 // If CALLBACK is an empty string, then revert to the default behavior 39097 // which is to set the binding to NULL. 39098 // 39099 // If CALLBACK returns an error, that causes the statement execution to 39100 // abort. Hence, to configure a connection so that it throws an error 39101 // on an attempt to bind an unknown variable, do something like this: 39102 // 39103 // proc bind_error {name} {error "no such variable: $name"} 39104 // db bind_fallback bind_error 39105 __6: 39106 if !(objc > 3) { 39107 goto __65 39108 } 39109 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11382 /* "?CALLBACK?" */) 39110 return TCL_ERROR 39111 goto __66 39112 __65: 39113 if !(objc == 2) { 39114 goto __67 39115 } 39116 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzBindFallback != 0) { 39117 goto __69 39118 } 39119 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+88, (*SqliteDb)(unsafe.Pointer(pDb)).FzBindFallback, uintptr(0))) 39120 __69: 39121 ; 39122 goto __68 39123 __67: 39124 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzBindFallback != 0) { 39125 goto __70 39126 } 39127 tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzBindFallback) 39128 __70: 39129 ; 39130 zCallback = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1032 /* &len1 */) 39131 if !((zCallback != 0) && (*(*int32)(unsafe.Pointer(bp + 1032 /* len1 */)) > 0)) { 39132 goto __71 39133 } 39134 (*SqliteDb)(unsafe.Pointer(pDb)).FzBindFallback = tcl.XTcl_Alloc(tls, (uint32(*(*int32)(unsafe.Pointer(bp + 1032 /* len1 */)) + 1))) 39135 libc.Xmemcpy(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzBindFallback, zCallback, (uint64(*(*int32)(unsafe.Pointer(bp + 1032 /* len1 */)) + 1))) 39136 goto __72 39137 __71: 39138 (*SqliteDb)(unsafe.Pointer(pDb)).FzBindFallback = uintptr(0) 39139 __72: 39140 ; 39141 __68: 39142 ; 39143 __66: 39144 ; 39145 goto __3 39146 39147 // $db busy ?CALLBACK? 39148 // 39149 // Invoke the given callback if an SQL statement attempts to open 39150 // a locked database file. 39151 __7: 39152 if !(objc > 3) { 39153 goto __73 39154 } 39155 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11459 /* "CALLBACK" */) 39156 return TCL_ERROR 39157 goto __74 39158 __73: 39159 if !(objc == 2) { 39160 goto __75 39161 } 39162 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzBusy != 0) { 39163 goto __77 39164 } 39165 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+104, (*SqliteDb)(unsafe.Pointer(pDb)).FzBusy, uintptr(0))) 39166 __77: 39167 ; 39168 goto __76 39169 __75: 39170 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzBusy != 0) { 39171 goto __78 39172 } 39173 tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzBusy) 39174 __78: 39175 ; 39176 zBusy = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1036 /* &len2 */) 39177 if !((zBusy != 0) && (*(*int32)(unsafe.Pointer(bp + 1036 /* len2 */)) > 0)) { 39178 goto __79 39179 } 39180 (*SqliteDb)(unsafe.Pointer(pDb)).FzBusy = tcl.XTcl_Alloc(tls, (uint32(*(*int32)(unsafe.Pointer(bp + 1036 /* len2 */)) + 1))) 39181 libc.Xmemcpy(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzBusy, zBusy, (uint64(*(*int32)(unsafe.Pointer(bp + 1036 /* len2 */)) + 1))) 39182 goto __80 39183 __79: 39184 (*SqliteDb)(unsafe.Pointer(pDb)).FzBusy = uintptr(0) 39185 __80: 39186 ; 39187 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzBusy != 0) { 39188 goto __81 39189 } 39190 (*SqliteDb)(unsafe.Pointer(pDb)).Finterp = interp 39191 sqlite3.Xsqlite3_busy_handler(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, *(*uintptr)(unsafe.Pointer(&struct { 39192 f func(*libc.TLS, uintptr, int32) int32 39193 }{DbBusyHandler})), pDb) 39194 goto __82 39195 __81: 39196 sqlite3.Xsqlite3_busy_handler(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, uintptr(0), uintptr(0)) 39197 __82: 39198 ; 39199 __76: 39200 ; 39201 __74: 39202 ; 39203 goto __3 39204 39205 // $db cache flush 39206 // $db cache size n 39207 // 39208 // Flush the prepared statement cache, or set the maximum number of 39209 // cached statements. 39210 __8: 39211 39212 if !(objc <= 2) { 39213 goto __83 39214 } 39215 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+11468 /* "cache option ?ar..." */) 39216 return TCL_ERROR 39217 __83: 39218 ; 39219 subCmd = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(0)) 39220 if !((int32(*(*int8)(unsafe.Pointer(subCmd))) == 'f') && (libc.Xstrcmp(tls, subCmd, ts+11487 /* "flush" */) == 0)) { 39221 goto __84 39222 } 39223 if !(objc != 3) { 39224 goto __86 39225 } 39226 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11487 /* "flush" */) 39227 return TCL_ERROR 39228 goto __87 39229 __86: 39230 flushStmtCache(tls, pDb) 39231 __87: 39232 ; 39233 goto __85 39234 __84: 39235 if !((int32(*(*int8)(unsafe.Pointer(subCmd))) == 's') && (libc.Xstrcmp(tls, subCmd, ts+11493 /* "size" */) == 0)) { 39236 goto __88 39237 } 39238 if !(objc != 4) { 39239 goto __90 39240 } 39241 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11498 /* "size n" */) 39242 return TCL_ERROR 39243 goto __91 39244 __90: 39245 if !(TCL_ERROR == tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+1040 /* &n */)) { 39246 goto __92 39247 } 39248 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+120, ts+11505, /* "cannot convert \"" */ 39249 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), uintptr(0)), ts+11522 /* "\" to integer" */, uintptr(0))) 39250 return TCL_ERROR 39251 goto __93 39252 __92: 39253 if !(*(*int32)(unsafe.Pointer(bp + 1040 /* n */)) < 0) { 39254 goto __94 39255 } 39256 flushStmtCache(tls, pDb) 39257 *(*int32)(unsafe.Pointer(bp + 1040 /* n */)) = 0 39258 goto __95 39259 __94: 39260 if !(*(*int32)(unsafe.Pointer(bp + 1040 /* n */)) > MAX_PREPARED_STMTS) { 39261 goto __96 39262 } 39263 *(*int32)(unsafe.Pointer(bp + 1040 /* n */)) = MAX_PREPARED_STMTS 39264 __96: 39265 ; 39266 __95: 39267 ; 39268 (*SqliteDb)(unsafe.Pointer(pDb)).FmaxStmt = *(*int32)(unsafe.Pointer(bp + 1040 /* n */)) 39269 __93: 39270 ; 39271 __91: 39272 ; 39273 goto __89 39274 __88: 39275 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+152, ts+11535, /* "bad option \"" */ 39276 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(0)), ts+11548, /* "\": must be flush..." */ 39277 uintptr(0))) 39278 return TCL_ERROR 39279 __89: 39280 ; 39281 __85: 39282 ; 39283 goto __3 39284 39285 // $db changes 39286 // 39287 // Return the number of rows that were modified, inserted, or deleted by 39288 // the most recent INSERT, UPDATE or DELETE statement, not including 39289 // any changes made by trigger programs. 39290 __9: 39291 if !(objc != 2) { 39292 goto __97 39293 } 39294 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+489 /* "" */) 39295 return TCL_ERROR 39296 __97: 39297 ; 39298 pResult = tcl.XTcl_GetObjResult(tls, interp) 39299 tcl.XTcl_SetIntObj(tls, pResult, sqlite3.Xsqlite3_changes(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb)) 39300 goto __3 39301 39302 // $db close 39303 // 39304 // Shutdown the database 39305 __10: 39306 tcl.XTcl_DeleteCommand(tls, interp, tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0))) 39307 goto __3 39308 39309 // $db collate NAME SCRIPT 39310 // 39311 // Create a new SQL collation function called NAME. Whenever 39312 // that function is called, invoke SCRIPT to evaluate the function. 39313 __11: 39314 if !(objc != 4) { 39315 goto __98 39316 } 39317 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11573 /* "NAME SCRIPT" */) 39318 return TCL_ERROR 39319 __98: 39320 ; 39321 zName = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(0)) 39322 zScript = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+1044 /* &nScript */) 39323 pCollate = tcl.XTcl_Alloc(tls, (uint32((uint64(unsafe.Sizeof(SqlCollate{})) + uint64(*(*int32)(unsafe.Pointer(bp + 1044 /* nScript */)))) + uint64(1)))) 39324 if !(pCollate == uintptr(0)) { 39325 goto __99 39326 } 39327 return TCL_ERROR 39328 __99: 39329 ; 39330 (*SqlCollate)(unsafe.Pointer(pCollate)).Finterp = interp 39331 (*SqlCollate)(unsafe.Pointer(pCollate)).FpNext = (*SqliteDb)(unsafe.Pointer(pDb)).FpCollate 39332 (*SqlCollate)(unsafe.Pointer(pCollate)).FzScript = (pCollate + 1*24) 39333 (*SqliteDb)(unsafe.Pointer(pDb)).FpCollate = pCollate 39334 libc.Xmemcpy(tls, (*SqlCollate)(unsafe.Pointer(pCollate)).FzScript, zScript, (uint64(*(*int32)(unsafe.Pointer(bp + 1044 /* nScript */)) + 1))) 39335 if !(sqlite3.Xsqlite3_create_collation(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zName, SQLITE_UTF8, 39336 pCollate, *(*uintptr)(unsafe.Pointer(&struct { 39337 f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 39338 }{tclSqlCollate}))) != 0) { 39339 goto __100 39340 } 39341 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(1)) 39342 return TCL_ERROR 39343 __100: 39344 ; 39345 goto __3 39346 39347 // $db collation_needed SCRIPT 39348 // 39349 // Create a new SQL collation function called NAME. Whenever 39350 // that function is called, invoke SCRIPT to evaluate the function. 39351 __12: 39352 if !(objc != 3) { 39353 goto __101 39354 } 39355 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11585 /* "SCRIPT" */) 39356 return TCL_ERROR 39357 __101: 39358 ; 39359 if !((*SqliteDb)(unsafe.Pointer(pDb)).FpCollateNeeded != 0) { 39360 goto __102 39361 } 39362 __103: 39363 _objPtr = (*SqliteDb)(unsafe.Pointer(pDb)).FpCollateNeeded 39364 if !(libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1) { 39365 goto __106 39366 } 39367 tcl.XTclFreeObj(tls, _objPtr) 39368 __106: 39369 ; 39370 goto __104 39371 __104: 39372 if 0 != 0 { 39373 goto __103 39374 } 39375 goto __105 39376 __105: 39377 ; 39378 __102: 39379 ; 39380 (*SqliteDb)(unsafe.Pointer(pDb)).FpCollateNeeded = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 39381 (*Tcl_Obj)(unsafe.Pointer((*SqliteDb)(unsafe.Pointer(pDb)).FpCollateNeeded)).FrefCount++ 39382 sqlite3.Xsqlite3_collation_needed(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, pDb, *(*uintptr)(unsafe.Pointer(&struct { 39383 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) 39384 }{tclCollateNeeded}))) 39385 goto __3 39386 39387 // $db commit_hook ?CALLBACK? 39388 // 39389 // Invoke the given callback just before committing every SQL transaction. 39390 // If the callback throws an exception or returns non-zero, then the 39391 // transaction is aborted. If CALLBACK is an empty string, the callback 39392 // is disabled. 39393 __13: 39394 if !(objc > 3) { 39395 goto __107 39396 } 39397 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11382 /* "?CALLBACK?" */) 39398 return TCL_ERROR 39399 goto __108 39400 __107: 39401 if !(objc == 2) { 39402 goto __109 39403 } 39404 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzCommit != 0) { 39405 goto __111 39406 } 39407 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+184, (*SqliteDb)(unsafe.Pointer(pDb)).FzCommit, uintptr(0))) 39408 __111: 39409 ; 39410 goto __110 39411 __109: 39412 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzCommit != 0) { 39413 goto __112 39414 } 39415 tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzCommit) 39416 __112: 39417 ; 39418 zCommit = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1048 /* &len3 */) 39419 if !((zCommit != 0) && (*(*int32)(unsafe.Pointer(bp + 1048 /* len3 */)) > 0)) { 39420 goto __113 39421 } 39422 (*SqliteDb)(unsafe.Pointer(pDb)).FzCommit = tcl.XTcl_Alloc(tls, (uint32(*(*int32)(unsafe.Pointer(bp + 1048 /* len3 */)) + 1))) 39423 libc.Xmemcpy(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzCommit, zCommit, (uint64(*(*int32)(unsafe.Pointer(bp + 1048 /* len3 */)) + 1))) 39424 goto __114 39425 __113: 39426 (*SqliteDb)(unsafe.Pointer(pDb)).FzCommit = uintptr(0) 39427 __114: 39428 ; 39429 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzCommit != 0) { 39430 goto __115 39431 } 39432 (*SqliteDb)(unsafe.Pointer(pDb)).Finterp = interp 39433 sqlite3.Xsqlite3_commit_hook(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, *(*uintptr)(unsafe.Pointer(&struct { 39434 f func(*libc.TLS, uintptr) int32 39435 }{DbCommitHandler})), pDb) 39436 goto __116 39437 __115: 39438 sqlite3.Xsqlite3_commit_hook(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, uintptr(0), uintptr(0)) 39439 __116: 39440 ; 39441 __110: 39442 ; 39443 __108: 39444 ; 39445 goto __3 39446 39447 // $db complete SQL 39448 // 39449 // Return TRUE if SQL is a complete SQL statement. Return FALSE if 39450 // additional lines of input are needed. This is similar to the 39451 // built-in "info complete" command of Tcl. 39452 __14: 39453 if !(objc != 3) { 39454 goto __117 39455 } 39456 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+10172 /* "SQL" */) 39457 return TCL_ERROR 39458 __117: 39459 ; 39460 isComplete = sqlite3.Xsqlite3_complete(tls, tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(0))) 39461 pResult1 = tcl.XTcl_GetObjResult(tls, interp) 39462 tcl.XTcl_SetIntObj(tls, pResult1, (libc.Bool32((isComplete) != 0))) 39463 goto __3 39464 39465 // $db config ?OPTION? ?BOOLEAN? 39466 // 39467 // Configure the database connection using the sqlite3_db_config() 39468 // interface. 39469 __15: 39470 if !(objc > 4) { 39471 goto __118 39472 } 39473 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11592 /* "?OPTION? ?BOOLEA..." */) 39474 return TCL_ERROR 39475 __118: 39476 ; 39477 if !(objc == 2) { 39478 goto __119 39479 } 39480 // With no arguments, list all configuration options and with the 39481 // current value 39482 pResult2 = tcl.XTcl_NewListObj(tls, 0, uintptr(0)) 39483 ii = 0 39484 __121: 39485 if !(uint64(ii) < (uint64(unsafe.Sizeof(aDbConfig)) / uint64(unsafe.Sizeof(DbConfigChoices{})))) { 39486 goto __123 39487 } 39488 *(*int32)(unsafe.Pointer(bp + 1052 /* v */)) = 0 39489 sqlite3.Xsqlite3_db_config(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, aDbConfig[ii].Fop, libc.VaList(bp+200, -1, bp+1052 /* &v */)) 39490 tcl.XTcl_ListObjAppendElement(tls, interp, pResult2, 39491 tcl.XTcl_NewStringObj(tls, aDbConfig[ii].FzName, -1)) 39492 tcl.XTcl_ListObjAppendElement(tls, interp, pResult2, 39493 tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 1052 /* v */)))) 39494 goto __122 39495 __122: 39496 ii++ 39497 goto __121 39498 goto __123 39499 __123: 39500 ; 39501 goto __120 39502 __119: 39503 zOpt = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 39504 *(*int32)(unsafe.Pointer(bp + 1056 /* onoff */)) = -1 39505 *(*int32)(unsafe.Pointer(bp + 1060 /* v1 */)) = 0 39506 if !(int32(*(*int8)(unsafe.Pointer(zOpt))) == '-') { 39507 goto __124 39508 } 39509 zOpt++ 39510 __124: 39511 ; 39512 ii = 0 39513 __125: 39514 if !(uint64(ii) < (uint64(unsafe.Sizeof(aDbConfig)) / uint64(unsafe.Sizeof(DbConfigChoices{})))) { 39515 goto __127 39516 } 39517 if !(libc.Xstrcmp(tls, aDbConfig[ii].FzName, zOpt) == 0) { 39518 goto __128 39519 } 39520 goto __127 39521 __128: 39522 ; 39523 goto __126 39524 __126: 39525 ii++ 39526 goto __125 39527 goto __127 39528 __127: 39529 ; 39530 if !(uint64(ii) >= (uint64(unsafe.Sizeof(aDbConfig)) / uint64(unsafe.Sizeof(DbConfigChoices{})))) { 39531 goto __129 39532 } 39533 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+216, ts+11611 /* "unknown config o..." */, zOpt, 39534 ts+11636 /* "\"" */, uintptr(0))) 39535 return TCL_ERROR 39536 __129: 39537 ; 39538 if !(objc == 4) { 39539 goto __130 39540 } 39541 if !(tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+1056 /* &onoff */) != 0) { 39542 goto __131 39543 } 39544 return TCL_ERROR 39545 __131: 39546 ; 39547 __130: 39548 ; 39549 sqlite3.Xsqlite3_db_config(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, aDbConfig[ii].Fop, libc.VaList(bp+248, *(*int32)(unsafe.Pointer(bp + 1056 /* onoff */)), bp+1060 /* &v1 */)) 39550 pResult2 = tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 1060 /* v1 */))) 39551 __120: 39552 ; 39553 tcl.XTcl_SetObjResult(tls, interp, pResult2) 39554 goto __3 39555 39556 // $db copy conflict-algorithm table filename ?SEPARATOR? ?NULLINDICATOR? 39557 // 39558 // Copy data into table from filename, optionally using SEPARATOR 39559 // as column separators. If a column contains a null string, or the 39560 // value of NULLINDICATOR, a NULL is inserted for the column. 39561 // conflict-algorithm is one of the sqlite conflict algorithms: 39562 // rollback, abort, fail, ignore, replace 39563 // On success, return the number of lines processed, not necessarily same 39564 // as 'db changes' due to conflict-algorithm selected. 39565 // 39566 // This code is basically an implementation/enhancement of 39567 // the sqlite3 shell.c ".import" command. 39568 // 39569 // This command usage is equivalent to the sqlite2.x COPY statement, 39570 // which imports file data into a table using the PostgreSQL COPY file format: 39571 // $db copy $conflit_algo $table_name $filename \t \\N 39572 __16: // The input file 39573 lineno = 0 39574 if !((objc < 5) || (objc > 7)) { 39575 goto __132 39576 } 39577 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, 39578 ts+11638 /* "CONFLICT-ALGORIT..." */) 39579 return TCL_ERROR 39580 __132: 39581 ; 39582 if !(objc >= 6) { 39583 goto __133 39584 } 39585 zSep = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 5*8)), uintptr(0)) 39586 goto __134 39587 __133: 39588 zSep = ts + 11700 /* "\t" */ 39589 __134: 39590 ; 39591 if !(objc >= 7) { 39592 goto __135 39593 } 39594 zNull = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 6*8)), uintptr(0)) 39595 goto __136 39596 __135: 39597 zNull = ts + 489 /* "" */ 39598 __136: 39599 ; 39600 zConflict = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(0)) 39601 zTable = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), uintptr(0)) 39602 zFile = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8)), uintptr(0)) 39603 nSep = strlen30(tls, zSep) 39604 nNull = strlen30(tls, zNull) 39605 if !(nSep == 0) { 39606 goto __137 39607 } 39608 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+264, ts+11702, /* "Error: non-null ..." */ 39609 uintptr(0))) 39610 return TCL_ERROR 39611 __137: 39612 ; 39613 if !(((((libc.Xstrcmp(tls, zConflict, ts+11746 /* "rollback" */) != 0) && (libc.Xstrcmp(tls, zConflict, ts+11755 /* "abort" */) != 0)) && (libc.Xstrcmp(tls, zConflict, ts+11761 /* "fail" */) != 0)) && (libc.Xstrcmp(tls, zConflict, ts+11766 /* "ignore" */) != 0)) && (libc.Xstrcmp(tls, zConflict, ts+11773 /* "replace" */) != 0)) { 39614 goto __138 39615 } 39616 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+280, ts+11781 /* "Error: \"" */, zConflict, 39617 39618 ts+11790 /* "\", conflict-algo..." */, uintptr(0))) 39619 return TCL_ERROR 39620 __138: 39621 ; 39622 zSql = sqlite3.Xsqlite3_mprintf(tls, ts+11870 /* "SELECT * FROM '%..." */, libc.VaList(bp+312, zTable)) 39623 if !(zSql == uintptr(0)) { 39624 goto __139 39625 } 39626 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+320, ts+11889 /* "Error: no such t..." */, zTable, uintptr(0))) 39627 return TCL_ERROR 39628 __139: 39629 ; 39630 nByte = strlen30(tls, zSql) 39631 rc = sqlite3.Xsqlite3_prepare(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zSql, -1, bp+1064 /* &pStmt */, uintptr(0)) 39632 sqlite3.Xsqlite3_free(tls, zSql) 39633 if !(rc != 0) { 39634 goto __140 39635 } 39636 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+344, ts+11912 /* "Error: " */, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(0))) 39637 nCol = 0 39638 goto __141 39639 __140: 39640 nCol = sqlite3.Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 1064 /* pStmt */))) 39641 __141: 39642 ; 39643 sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 1064 /* pStmt */))) 39644 if !(nCol == 0) { 39645 goto __142 39646 } 39647 return TCL_ERROR 39648 __142: 39649 ; 39650 zSql = libc.Xmalloc(tls, (uint64((nByte + 50) + (nCol * 2)))) 39651 if !(zSql == uintptr(0)) { 39652 goto __143 39653 } 39654 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+368, ts+11920 /* "Error: can't mal..." */, uintptr(0))) 39655 return TCL_ERROR 39656 __143: 39657 ; 39658 sqlite3.Xsqlite3_snprintf(tls, (nByte + 50), zSql, ts+11942, /* "INSERT OR %q INT..." */ 39659 libc.VaList(bp+384, zConflict, zTable)) 39660 j = strlen30(tls, zSql) 39661 i = 1 39662 __144: 39663 if !(i < nCol) { 39664 goto __146 39665 } 39666 *(*int8)(unsafe.Pointer(zSql + uintptr(libc.PostIncInt32(&j, 1)))) = int8(',') 39667 *(*int8)(unsafe.Pointer(zSql + uintptr(libc.PostIncInt32(&j, 1)))) = int8('?') 39668 goto __145 39669 __145: 39670 i++ 39671 goto __144 39672 goto __146 39673 __146: 39674 ; 39675 *(*int8)(unsafe.Pointer(zSql + uintptr(libc.PostIncInt32(&j, 1)))) = int8(')') 39676 *(*int8)(unsafe.Pointer(zSql + uintptr(j))) = int8(0) 39677 rc = sqlite3.Xsqlite3_prepare(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zSql, -1, bp+1064 /* &pStmt */, uintptr(0)) 39678 libc.Xfree(tls, zSql) 39679 if !(rc != 0) { 39680 goto __147 39681 } 39682 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+400, ts+11912 /* "Error: " */, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(0))) 39683 sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 1064 /* pStmt */))) 39684 return TCL_ERROR 39685 __147: 39686 ; 39687 in = libc.Xfopen(tls, zFile, ts+4273 /* "rb" */) 39688 if !(in == uintptr(0)) { 39689 goto __148 39690 } 39691 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+424, ts+11974 /* "Error: cannot op..." */, zFile, uintptr(0))) 39692 sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 1064 /* pStmt */))) 39693 return TCL_ERROR 39694 __148: 39695 ; 39696 azCol = libc.Xmalloc(tls, (uint64(unsafe.Sizeof(uintptr(0))) * (uint64(nCol + 1)))) 39697 if !(azCol == uintptr(0)) { 39698 goto __149 39699 } 39700 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+448, ts+11920 /* "Error: can't mal..." */, uintptr(0))) 39701 libc.Xfclose(tls, in) 39702 return TCL_ERROR 39703 __149: 39704 ; 39705 sqlite3.Xsqlite3_exec(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, ts+12000 /* "BEGIN" */, uintptr(0), uintptr(0), uintptr(0)) 39706 zCommit1 = ts + 11312 /* "COMMIT" */ 39707 __150: 39708 if !((libc.AssignUintptr(&zLine, local_getline(tls, uintptr(0), in))) != uintptr(0)) { 39709 goto __151 39710 } 39711 lineno++ 39712 *(*uintptr)(unsafe.Pointer(azCol)) = zLine 39713 i = 0 39714 z = zLine 39715 __152: 39716 if !(*(*int8)(unsafe.Pointer(z)) != 0) { 39717 goto __154 39718 } 39719 if !((int32(*(*int8)(unsafe.Pointer(z))) == int32(*(*int8)(unsafe.Pointer(zSep)))) && (libc.Xstrncmp(tls, z, zSep, uint64(nSep)) == 0)) { 39720 goto __155 39721 } 39722 *(*int8)(unsafe.Pointer(z)) = int8(0) 39723 i++ 39724 if !(i < nCol) { 39725 goto __156 39726 } 39727 *(*uintptr)(unsafe.Pointer(azCol + uintptr(i)*8)) = (z + uintptr(nSep)) 39728 z += (uintptr(nSep - 1)) 39729 __156: 39730 ; 39731 __155: 39732 ; 39733 goto __153 39734 __153: 39735 z++ 39736 goto __152 39737 goto __154 39738 __154: 39739 ; 39740 if !((i + 1) != nCol) { 39741 goto __157 39742 } 39743 nErr = (strlen30(tls, zFile) + 200) 39744 zErr = libc.Xmalloc(tls, uint64(nErr)) 39745 if !(zErr != 0) { 39746 goto __158 39747 } 39748 sqlite3.Xsqlite3_snprintf(tls, nErr, zErr, 39749 ts+12006, /* "Error: %s line %..." */ 39750 libc.VaList(bp+464, zFile, lineno, nCol, (i+1))) 39751 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+496, zErr, uintptr(0))) 39752 libc.Xfree(tls, zErr) 39753 __158: 39754 ; 39755 zCommit1 = ts + 7272 /* "ROLLBACK" */ 39756 goto __151 39757 __157: 39758 ; 39759 i = 0 39760 __159: 39761 if !(i < nCol) { 39762 goto __161 39763 } 39764 // check for null data, if so, bind as null 39765 if !(((nNull > 0) && (libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(azCol + uintptr(i)*8)), zNull) == 0)) || 39766 (strlen30(tls, *(*uintptr)(unsafe.Pointer(azCol + uintptr(i)*8))) == 0)) { 39767 goto __162 39768 } 39769 sqlite3.Xsqlite3_bind_null(tls, *(*uintptr)(unsafe.Pointer(bp + 1064 /* pStmt */)), (i + 1)) 39770 goto __163 39771 __162: 39772 sqlite3.Xsqlite3_bind_text(tls, *(*uintptr)(unsafe.Pointer(bp + 1064 /* pStmt */)), (i + 1), *(*uintptr)(unsafe.Pointer(azCol + uintptr(i)*8)), -1, uintptr(0)) 39773 __163: 39774 ; 39775 goto __160 39776 __160: 39777 i++ 39778 goto __159 39779 goto __161 39780 __161: 39781 ; 39782 sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 1064 /* pStmt */))) 39783 rc = sqlite3.Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 1064 /* pStmt */))) 39784 libc.Xfree(tls, zLine) 39785 if !(rc != SQLITE_OK) { 39786 goto __164 39787 } 39788 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+512, ts+11912 /* "Error: " */, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(0))) 39789 zCommit1 = ts + 7272 /* "ROLLBACK" */ 39790 goto __151 39791 __164: 39792 ; 39793 goto __150 39794 __151: 39795 ; 39796 libc.Xfree(tls, azCol) 39797 libc.Xfclose(tls, in) 39798 sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 1064 /* pStmt */))) 39799 sqlite3.Xsqlite3_exec(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zCommit1, uintptr(0), uintptr(0), uintptr(0)) 39800 39801 if !(int32(*(*int8)(unsafe.Pointer(zCommit1))) == 'C') { 39802 goto __165 39803 } 39804 // success, set result as number of lines processed 39805 pResult3 = tcl.XTcl_GetObjResult(tls, interp) 39806 tcl.XTcl_SetIntObj(tls, pResult3, lineno) 39807 rc = TCL_OK 39808 goto __166 39809 __165: 39810 // failure, append lineno where failed 39811 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([80]int8{})), bp+1072 /* &zLineNum[0] */, ts+1238 /* "%d" */, libc.VaList(bp+536, lineno)) 39812 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+544, ts+12066 /* ", failed while p..." */, bp+1072, /* &zLineNum[0] */ 39813 uintptr(0))) 39814 rc = TCL_ERROR 39815 __166: 39816 ; 39817 goto __3 39818 39819 // $db deserialize ?-maxsize N? ?-readonly BOOL? ?DATABASE? VALUE 39820 // 39821 // Reopen DATABASE (default "main") using the content in $VALUE 39822 __17: 39823 zSchema = uintptr(0) 39824 pValue = uintptr(0) 39825 *(*sqlite3_int64)(unsafe.Pointer(bp + 1152 /* mxSize */)) = int64(0) 39826 *(*int32)(unsafe.Pointer(bp + 1160 /* isReadonly */)) = 0 39827 39828 if !(objc < 3) { 39829 goto __167 39830 } 39831 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12099 /* "?DATABASE? VALUE" */) 39832 rc = TCL_ERROR 39833 goto __3 39834 __167: 39835 ; 39836 i1 = 2 39837 __168: 39838 if !(i1 < (objc - 1)) { 39839 goto __170 39840 } 39841 z1 = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i1)*8))) 39842 if !((libc.Xstrcmp(tls, z1, ts+12116 /* "-maxsize" */) == 0) && (i1 < (objc - 2))) { 39843 goto __171 39844 } 39845 rc = tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(libc.PreIncInt32(&i1, 1))*8)), bp+1152 /* &mxSize */) 39846 if !(rc != 0) { 39847 goto __172 39848 } 39849 goto deserialize_error 39850 __172: 39851 ; 39852 goto __169 39853 __171: 39854 ; 39855 if !((libc.Xstrcmp(tls, z1, ts+12125 /* "-readonly" */) == 0) && (i1 < (objc - 2))) { 39856 goto __173 39857 } 39858 rc = tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(libc.PreIncInt32(&i1, 1))*8)), bp+1160 /* &isReadonly */) 39859 if !(rc != 0) { 39860 goto __174 39861 } 39862 goto deserialize_error 39863 __174: 39864 ; 39865 goto __169 39866 __173: 39867 ; 39868 if !(((zSchema == uintptr(0)) && (i1 == (objc - 2))) && (int32(*(*int8)(unsafe.Pointer(z1))) != '-')) { 39869 goto __175 39870 } 39871 zSchema = z1 39872 goto __169 39873 __175: 39874 ; 39875 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+568, ts+12135 /* "unknown option: " */, z1, uintptr(0))) 39876 rc = TCL_ERROR 39877 goto deserialize_error 39878 goto __169 39879 __169: 39880 i1++ 39881 goto __168 39882 goto __170 39883 __170: 39884 ; 39885 pValue = *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-1))*8)) 39886 pBA = tcl.XTcl_GetByteArrayFromObj(tls, pValue, bp+1164 /* &len4 */) 39887 pData = sqlite3.Xsqlite3_malloc64(tls, uint64(*(*int32)(unsafe.Pointer(bp + 1164 /* len4 */)))) 39888 if !((pData == uintptr(0)) && (*(*int32)(unsafe.Pointer(bp + 1164 /* len4 */)) > 0)) { 39889 goto __176 39890 } 39891 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+592, ts+1930 /* "out of memory" */, uintptr(0))) 39892 rc = TCL_ERROR 39893 goto __177 39894 __176: 39895 if !(*(*int32)(unsafe.Pointer(bp + 1164 /* len4 */)) > 0) { 39896 goto __178 39897 } 39898 libc.Xmemcpy(tls, pData, pBA, uint64(*(*int32)(unsafe.Pointer(bp + 1164 /* len4 */)))) 39899 __178: 39900 ; 39901 if !(*(*int32)(unsafe.Pointer(bp + 1160 /* isReadonly */)) != 0) { 39902 goto __179 39903 } 39904 flags = (SQLITE_DESERIALIZE_FREEONCLOSE | SQLITE_DESERIALIZE_READONLY) 39905 goto __180 39906 __179: 39907 flags = (SQLITE_DESERIALIZE_FREEONCLOSE | SQLITE_DESERIALIZE_RESIZEABLE) 39908 __180: 39909 ; 39910 xrc = sqlite3.Xsqlite3_deserialize(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zSchema, pData, int64(*(*int32)(unsafe.Pointer(bp + 1164 /* len4 */))), int64(*(*int32)(unsafe.Pointer(bp + 1164 /* len4 */))), uint32(flags)) 39911 if !(xrc != 0) { 39912 goto __181 39913 } 39914 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+608, ts+12152 /* "unable to set ME..." */, uintptr(0))) 39915 rc = TCL_ERROR 39916 __181: 39917 ; 39918 if !(*(*sqlite3_int64)(unsafe.Pointer(bp + 1152 /* mxSize */)) > int64(0)) { 39919 goto __182 39920 } 39921 sqlite3.Xsqlite3_file_control(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zSchema, SQLITE_FCNTL_SIZE_LIMIT, bp+1152 /* &mxSize */) 39922 __182: 39923 ; 39924 __177: 39925 ; 39926 deserialize_error: 39927 goto __3 39928 39929 // $db enable_load_extension BOOLEAN 39930 // 39931 // Turn the extension loading feature on or off. It if off by 39932 // default. 39933 __18: 39934 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+624, ts+12180, /* "extension loadin..." */ 39935 uintptr(0))) 39936 return TCL_ERROR 39937 39938 // $db errorcode 39939 // 39940 // Return the numeric error code that was returned by the most recent 39941 // call to sqlite3_exec(). 39942 __19: 39943 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_errcode(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb))) 39944 goto __3 39945 39946 // $db exists $sql 39947 // $db onecolumn $sql 39948 // 39949 // The onecolumn method is the equivalent of: 39950 // lindex [$db eval $sql] 0 39951 __20: 39952 __21: 39953 pResult4 = uintptr(0) 39954 if !(objc != 3) { 39955 goto __183 39956 } 39957 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+10172 /* "SQL" */) 39958 return TCL_ERROR 39959 __183: 39960 ; 39961 39962 dbEvalInit(tls, bp+1168 /* &sEval */, pDb, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(0), 0) 39963 rc = dbEvalStep(tls, bp+1168 /* &sEval */) 39964 if !(*(*int32)(unsafe.Pointer(bp + 1016 /* choice */)) == 23 /* DB_ONECOLUMN */) { 39965 goto __184 39966 } 39967 if !(rc == TCL_OK) { 39968 goto __186 39969 } 39970 pResult4 = dbEvalColumnValue(tls, bp+1168 /* &sEval */, 0) 39971 goto __187 39972 __186: 39973 if !(rc == TCL_BREAK) { 39974 goto __188 39975 } 39976 tcl.XTcl_ResetResult(tls, interp) 39977 __188: 39978 ; 39979 __187: 39980 ; 39981 goto __185 39982 __184: 39983 if !((rc == TCL_BREAK) || (rc == TCL_OK)) { 39984 goto __189 39985 } 39986 pResult4 = tcl.XTcl_NewIntObj(tls, (libc.Bool32((libc.Bool32(rc == TCL_OK)) != 0))) 39987 __189: 39988 ; 39989 __185: 39990 ; 39991 dbEvalFinalize(tls, bp+1168 /* &sEval */) 39992 if !(pResult4 != 0) { 39993 goto __190 39994 } 39995 tcl.XTcl_SetObjResult(tls, interp, pResult4) 39996 __190: 39997 ; 39998 39999 if !(rc == TCL_BREAK) { 40000 goto __191 40001 } 40002 rc = TCL_OK 40003 __191: 40004 ; 40005 goto __3 40006 40007 // $db eval ?options? $sql ?array? ?{ ...code... }? 40008 // 40009 // The SQL statement in $sql is evaluated. For each row, the values are 40010 // placed in elements of the array named "array" and ...code... is executed. 40011 // If "array" and "code" are omitted, then no callback is every invoked. 40012 // If "array" is an empty string, then the values are placed in variables 40013 // that have the same name as the fields extracted by the query. 40014 __22: 40015 evalFlags = 0 40016 __192: 40017 if !(((objc > 3) && ((libc.AssignUintptr(&zOpt1, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))))) != uintptr(0))) && (int32(*(*int8)(unsafe.Pointer(zOpt1))) == '-')) { 40018 goto __193 40019 } 40020 if !(libc.Xstrcmp(tls, zOpt1, ts+12228 /* "-withoutnulls" */) == 0) { 40021 goto __194 40022 } 40023 evalFlags = evalFlags | (SQLITE_EVAL_WITHOUTNULLS) 40024 goto __195 40025 __194: 40026 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+640, ts+12242 /* "unknown option: ..." */, zOpt1, ts+11636 /* "\"" */, uintptr(0))) 40027 return TCL_ERROR 40028 __195: 40029 ; 40030 objc-- 40031 objv += 8 40032 goto __192 40033 __193: 40034 ; 40035 if !((objc < 3) || (objc > 5)) { 40036 goto __196 40037 } 40038 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, 40039 ts+12260 /* "?OPTIONS? SQL ?A..." */) 40040 return TCL_ERROR 40041 __196: 40042 ; 40043 40044 if !(objc == 3) { 40045 goto __197 40046 } 40047 pRet = tcl.XTcl_NewObj(tls) 40048 (*Tcl_Obj)(unsafe.Pointer(pRet)).FrefCount++ 40049 dbEvalInit(tls, bp+1224 /* &sEval1 */, pDb, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(0), 0) 40050 __199: 40051 if !(TCL_OK == (libc.AssignInt32(&rc, dbEvalStep(tls, bp+1224 /* &sEval1 */)))) { 40052 goto __200 40053 } 40054 dbEvalRowInfo(tls, bp+1224 /* &sEval1 */, bp+1280 /* &nCol1 */, uintptr(0)) 40055 i2 = 0 40056 __201: 40057 if !(i2 < *(*int32)(unsafe.Pointer(bp + 1280 /* nCol1 */))) { 40058 goto __203 40059 } 40060 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, dbEvalColumnValue(tls, bp+1224 /* &sEval1 */, i2)) 40061 goto __202 40062 __202: 40063 i2++ 40064 goto __201 40065 goto __203 40066 __203: 40067 ; 40068 goto __199 40069 __200: 40070 ; 40071 dbEvalFinalize(tls, bp+1224 /* &sEval1 */) 40072 if !(rc == TCL_BREAK) { 40073 goto __204 40074 } 40075 tcl.XTcl_SetObjResult(tls, interp, pRet) 40076 rc = TCL_OK 40077 __204: 40078 ; 40079 __205: 40080 _objPtr1 = pRet 40081 if !(libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr1))).FrefCount, 1) <= 1) { 40082 goto __208 40083 } 40084 tcl.XTclFreeObj(tls, _objPtr1) 40085 __208: 40086 ; 40087 goto __206 40088 __206: 40089 if 0 != 0 { 40090 goto __205 40091 } 40092 goto __207 40093 __207: 40094 ; 40095 goto __198 40096 __197: 40097 pArray = uintptr(0) 40098 40099 if !((objc >= 5) && (*(*int8)(unsafe.Pointer(tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))))) != 0)) { 40100 goto __209 40101 } 40102 pArray = *(*uintptr)(unsafe.Pointer(objv + 3*8)) 40103 __209: 40104 ; 40105 pScript = *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-1))*8)) 40106 (*Tcl_Obj)(unsafe.Pointer(pScript)).FrefCount++ 40107 40108 p = tcl.XTcl_Alloc(tls, uint32(unsafe.Sizeof(DbEvalContext{}))) 40109 dbEvalInit(tls, p, pDb, *(*uintptr)(unsafe.Pointer(objv + 2*8)), pArray, evalFlags) 40110 40111 *(*ClientData)(unsafe.Pointer(bp + 1288 /* &cd2[0] */)) = p 40112 *(*ClientData)(unsafe.Pointer(bp + 1288 /* &cd2[0] */ + 1*8)) = pScript 40113 rc = DbEvalNextCmd(tls, bp+1288 /* &cd2[0] */, interp, TCL_OK) 40114 __198: 40115 ; 40116 goto __3 40117 40118 // $db function NAME [OPTIONS] SCRIPT 40119 // 40120 // Create a new SQL function called NAME. Whenever that function is 40121 // called, invoke SCRIPT to evaluate the function. 40122 // 40123 // Options: 40124 // --argcount N Function has exactly N arguments 40125 // --deterministic The function is pure 40126 // --directonly Prohibit use inside triggers and views 40127 // --innocuous Has no side effects or information leaks 40128 // --returntype TYPE Specify the return type of the function 40129 __23: 40130 flags1 = SQLITE_UTF8 40131 *(*int32)(unsafe.Pointer(bp + 1304 /* nArg */)) = -1 40132 *(*int32)(unsafe.Pointer(bp + 1360 /* eType */)) = SQLITE_NULL 40133 if !(objc < 4) { 40134 goto __210 40135 } 40136 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12296 /* "NAME ?SWITCHES? ..." */) 40137 return TCL_ERROR 40138 __210: 40139 ; 40140 i3 = 3 40141 __211: 40142 if !(i3 < (objc - 1)) { 40143 goto __213 40144 } 40145 z2 = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i3)*8))) 40146 n1 = strlen30(tls, z2) 40147 if !((n1 > 1) && (libc.Xstrncmp(tls, z2, ts+12319 /* "-argcount" */, uint64(n1)) == 0)) { 40148 goto __214 40149 } 40150 if !(i3 == (objc - 2)) { 40151 goto __216 40152 } 40153 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+672, ts+12329 /* "option requires ..." */, z2, uintptr(0))) 40154 return TCL_ERROR 40155 __216: 40156 ; 40157 if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i3+1))*8)), bp+1304 /* &nArg */) != 0) { 40158 goto __217 40159 } 40160 return TCL_ERROR 40161 __217: 40162 ; 40163 if !(*(*int32)(unsafe.Pointer(bp + 1304 /* nArg */)) < 0) { 40164 goto __218 40165 } 40166 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+696, ts+12359, /* "number of argume..." */ 40167 uintptr(0))) 40168 return TCL_ERROR 40169 __218: 40170 ; 40171 i3++ 40172 goto __215 40173 __214: 40174 if !((n1 > 1) && (libc.Xstrncmp(tls, z2, ts+12400 /* "-deterministic" */, uint64(n1)) == 0)) { 40175 goto __219 40176 } 40177 flags1 = flags1 | (SQLITE_DETERMINISTIC) 40178 goto __220 40179 __219: 40180 if !((n1 > 1) && (libc.Xstrncmp(tls, z2, ts+12415 /* "-directonly" */, uint64(n1)) == 0)) { 40181 goto __221 40182 } 40183 flags1 = flags1 | (SQLITE_DIRECTONLY) 40184 goto __222 40185 __221: 40186 if !((n1 > 1) && (libc.Xstrncmp(tls, z2, ts+12427 /* "-innocuous" */, uint64(n1)) == 0)) { 40187 goto __223 40188 } 40189 flags1 = flags1 | (SQLITE_INNOCUOUS) 40190 goto __224 40191 __223: 40192 if !((n1 > 1) && (libc.Xstrncmp(tls, z2, ts+12438 /* "-returntype" */, uint64(n1)) == 0)) { 40193 goto __225 40194 } 40195 *(*[6]uintptr)(unsafe.Pointer(bp + 1312 /* azType */)) = [6]uintptr{ts + 7918 /* "integer" */, ts + 12450 /* "real" */, ts + 12455 /* "text" */, ts + 12460 /* "blob" */, ts + 12465 /* "any" */, uintptr(0)} 40196 40197 if !(i3 == (objc - 2)) { 40198 goto __227 40199 } 40200 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+712, ts+12329 /* "option requires ..." */, z2, uintptr(0))) 40201 return TCL_ERROR 40202 __227: 40203 ; 40204 i3++ 40205 if !(tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i3)*8)), bp+1312 /* &azType[0] */, int32(unsafe.Sizeof(uintptr(0))), ts+12469 /* "type" */, 0, bp+1360 /* &eType */) != 0) { 40206 goto __228 40207 } 40208 return TCL_ERROR 40209 __228: 40210 ; 40211 *(*int32)(unsafe.Pointer(bp + 1360 /* eType */))++ 40212 goto __226 40213 __225: 40214 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+736, ts+11535 /* "bad option \"" */, z2, 40215 40216 ts+12474 /* "\": must be -argc..." */, uintptr(0))) 40217 return TCL_ERROR 40218 __226: 40219 ; 40220 __224: 40221 ; 40222 __222: 40223 ; 40224 __220: 40225 ; 40226 __215: 40227 ; 40228 goto __212 40229 __212: 40230 i3++ 40231 goto __211 40232 goto __213 40233 __213: 40234 ; 40235 40236 pScript1 = *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-1))*8)) 40237 zName1 = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(0)) 40238 pFunc = findSqlFunc(tls, pDb, zName1) 40239 if !(pFunc == uintptr(0)) { 40240 goto __229 40241 } 40242 return TCL_ERROR 40243 __229: 40244 ; 40245 if !((*SqlFunc)(unsafe.Pointer(pFunc)).FpScript != 0) { 40246 goto __230 40247 } 40248 __231: 40249 _objPtr2 = (*SqlFunc)(unsafe.Pointer(pFunc)).FpScript 40250 if !(libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr2))).FrefCount, 1) <= 1) { 40251 goto __234 40252 } 40253 tcl.XTclFreeObj(tls, _objPtr2) 40254 __234: 40255 ; 40256 goto __232 40257 __232: 40258 if 0 != 0 { 40259 goto __231 40260 } 40261 goto __233 40262 __233: 40263 ; 40264 __230: 40265 ; 40266 (*SqlFunc)(unsafe.Pointer(pFunc)).FpScript = pScript1 40267 (*Tcl_Obj)(unsafe.Pointer(pScript1)).FrefCount++ 40268 (*SqlFunc)(unsafe.Pointer(pFunc)).FuseEvalObjv = safeToUseEvalObjv(tls, interp, pScript1) 40269 (*SqlFunc)(unsafe.Pointer(pFunc)).FeType = *(*int32)(unsafe.Pointer(bp + 1360 /* eType */)) 40270 rc = sqlite3.Xsqlite3_create_function(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zName1, *(*int32)(unsafe.Pointer(bp + 1304 /* nArg */)), flags1, 40271 pFunc, *(*uintptr)(unsafe.Pointer(&struct { 40272 f func(*libc.TLS, uintptr, int32, uintptr) 40273 }{tclSqlFunc})), uintptr(0), uintptr(0)) 40274 if !(rc != SQLITE_OK) { 40275 goto __235 40276 } 40277 rc = TCL_ERROR 40278 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(1)) 40279 __235: 40280 ; 40281 goto __3 40282 40283 // $db incrblob ?-readonly? ?DB? TABLE COLUMN ROWID 40284 __24: 40285 isReadonly1 = 0 40286 zDb = ts + 85 /* "main" */ 40287 40288 // Check for the -readonly option 40289 if !((objc > 3) && (libc.Xstrcmp(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), ts+12125 /* "-readonly" */) == 0)) { 40290 goto __236 40291 } 40292 isReadonly1 = 1 40293 __236: 40294 ; 40295 40296 if !((objc != (5 + isReadonly1)) && (objc != (6 + isReadonly1))) { 40297 goto __237 40298 } 40299 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12552 /* "?-readonly? ?DB?..." */) 40300 return TCL_ERROR 40301 __237: 40302 ; 40303 40304 if !(objc == (6 + isReadonly1)) { 40305 goto __238 40306 } 40307 zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 40308 __238: 40309 ; 40310 zTable1 = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-3))*8))) 40311 zColumn = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-2))*8))) 40312 rc = tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-1))*8)), bp+1368 /* &iRow */) 40313 40314 if !(rc == TCL_OK) { 40315 goto __239 40316 } 40317 rc = createIncrblobChannel(tls, 40318 interp, pDb, zDb, zTable1, zColumn, *(*Tcl_WideInt)(unsafe.Pointer(bp + 1368 /* iRow */)), isReadonly1) 40319 __239: 40320 ; 40321 goto __3 40322 40323 // $db interrupt 40324 // 40325 // Interrupt the execution of the inner-most SQL interpreter. This 40326 // causes the SQL statement to return an error of SQLITE_INTERRUPT. 40327 __25: 40328 sqlite3.Xsqlite3_interrupt(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb) 40329 goto __3 40330 40331 // $db nullvalue ?STRING? 40332 // 40333 // Change text used when a NULL comes back from the database. If ?STRING? 40334 // is not present, then the current string used for NULL is returned. 40335 // If STRING is present, then STRING is returned. 40336 // 40337 __26: 40338 if !((objc != 2) && (objc != 3)) { 40339 goto __240 40340 } 40341 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12588 /* "NULLVALUE" */) 40342 return TCL_ERROR 40343 __240: 40344 ; 40345 if !(objc == 3) { 40346 goto __241 40347 } 40348 zNull1 = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1376 /* &len5 */) 40349 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzNull != 0) { 40350 goto __242 40351 } 40352 tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzNull) 40353 __242: 40354 ; 40355 if !((zNull1 != 0) && (*(*int32)(unsafe.Pointer(bp + 1376 /* len5 */)) > 0)) { 40356 goto __243 40357 } 40358 (*SqliteDb)(unsafe.Pointer(pDb)).FzNull = tcl.XTcl_Alloc(tls, (uint32(*(*int32)(unsafe.Pointer(bp + 1376 /* len5 */)) + 1))) 40359 libc.Xmemcpy(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzNull, zNull1, uint64(*(*int32)(unsafe.Pointer(bp + 1376 /* len5 */)))) 40360 *(*int8)(unsafe.Pointer((*SqliteDb)(unsafe.Pointer(pDb)).FzNull + uintptr(*(*int32)(unsafe.Pointer(bp + 1376 /* len5 */))))) = int8(0) 40361 goto __244 40362 __243: 40363 (*SqliteDb)(unsafe.Pointer(pDb)).FzNull = uintptr(0) 40364 __244: 40365 ; 40366 __241: 40367 ; 40368 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzNull, -1)) 40369 goto __3 40370 40371 // $db last_insert_rowid 40372 // 40373 // Return an integer which is the ROWID for the most recent insert. 40374 __27: 40375 if !(objc != 2) { 40376 goto __245 40377 } 40378 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+489 /* "" */) 40379 return TCL_ERROR 40380 __245: 40381 ; 40382 rowid = sqlite3.Xsqlite3_last_insert_rowid(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb) 40383 pResult5 = tcl.XTcl_GetObjResult(tls, interp) 40384 tcl.XTcl_SetWideIntObj(tls, pResult5, rowid) 40385 goto __3 40386 40387 // The DB_ONECOLUMN method is implemented together with DB_EXISTS. 40388 40389 // $db progress ?N CALLBACK? 40390 // 40391 // Invoke the given callback every N virtual machine opcodes while executing 40392 // queries. 40393 __28: 40394 if !(objc == 2) { 40395 goto __246 40396 } 40397 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzProgress != 0) { 40398 goto __248 40399 } 40400 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+768, (*SqliteDb)(unsafe.Pointer(pDb)).FzProgress, uintptr(0))) 40401 __248: 40402 ; 40403 goto __247 40404 __246: 40405 if !(objc == 4) { 40406 goto __249 40407 } 40408 if !(TCL_OK != tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1380 /* &N */)) { 40409 goto __251 40410 } 40411 return TCL_ERROR 40412 __251: 40413 ; 40414 40415 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzProgress != 0) { 40416 goto __252 40417 } 40418 tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzProgress) 40419 __252: 40420 ; 40421 zProgress = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+1384 /* &len6 */) 40422 if !((zProgress != 0) && (*(*int32)(unsafe.Pointer(bp + 1384 /* len6 */)) > 0)) { 40423 goto __253 40424 } 40425 (*SqliteDb)(unsafe.Pointer(pDb)).FzProgress = tcl.XTcl_Alloc(tls, (uint32(*(*int32)(unsafe.Pointer(bp + 1384 /* len6 */)) + 1))) 40426 libc.Xmemcpy(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzProgress, zProgress, (uint64(*(*int32)(unsafe.Pointer(bp + 1384 /* len6 */)) + 1))) 40427 goto __254 40428 __253: 40429 (*SqliteDb)(unsafe.Pointer(pDb)).FzProgress = uintptr(0) 40430 __254: 40431 ; 40432 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzProgress != 0) { 40433 goto __255 40434 } 40435 (*SqliteDb)(unsafe.Pointer(pDb)).Finterp = interp 40436 sqlite3.Xsqlite3_progress_handler(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, *(*int32)(unsafe.Pointer(bp + 1380 /* N */)), *(*uintptr)(unsafe.Pointer(&struct { 40437 f func(*libc.TLS, uintptr) int32 40438 }{DbProgressHandler})), pDb) 40439 goto __256 40440 __255: 40441 sqlite3.Xsqlite3_progress_handler(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, 0, uintptr(0), uintptr(0)) 40442 __256: 40443 ; 40444 goto __250 40445 __249: 40446 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12598 /* "N CALLBACK" */) 40447 return TCL_ERROR 40448 __250: 40449 ; 40450 __247: 40451 ; 40452 goto __3 40453 40454 // $db profile ?CALLBACK? 40455 // 40456 // Make arrangements to invoke the CALLBACK routine after each SQL statement 40457 // that has run. The text of the SQL and the amount of elapse time are 40458 // appended to CALLBACK before the script is run. 40459 __29: 40460 if !(objc > 3) { 40461 goto __257 40462 } 40463 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11382 /* "?CALLBACK?" */) 40464 return TCL_ERROR 40465 goto __258 40466 __257: 40467 if !(objc == 2) { 40468 goto __259 40469 } 40470 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzProfile != 0) { 40471 goto __261 40472 } 40473 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+784, (*SqliteDb)(unsafe.Pointer(pDb)).FzProfile, uintptr(0))) 40474 __261: 40475 ; 40476 goto __260 40477 __259: 40478 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzProfile != 0) { 40479 goto __262 40480 } 40481 tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzProfile) 40482 __262: 40483 ; 40484 zProfile = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1388 /* &len7 */) 40485 if !((zProfile != 0) && (*(*int32)(unsafe.Pointer(bp + 1388 /* len7 */)) > 0)) { 40486 goto __263 40487 } 40488 (*SqliteDb)(unsafe.Pointer(pDb)).FzProfile = tcl.XTcl_Alloc(tls, (uint32(*(*int32)(unsafe.Pointer(bp + 1388 /* len7 */)) + 1))) 40489 libc.Xmemcpy(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzProfile, zProfile, (uint64(*(*int32)(unsafe.Pointer(bp + 1388 /* len7 */)) + 1))) 40490 goto __264 40491 __263: 40492 (*SqliteDb)(unsafe.Pointer(pDb)).FzProfile = uintptr(0) 40493 __264: 40494 ; 40495 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzProfile != 0) { 40496 goto __265 40497 } 40498 (*SqliteDb)(unsafe.Pointer(pDb)).Finterp = interp 40499 sqlite3.Xsqlite3_profile(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, *(*uintptr)(unsafe.Pointer(&struct { 40500 f func(*libc.TLS, uintptr, uintptr, sqlite_uint64) 40501 }{DbProfileHandler})), pDb) 40502 goto __266 40503 __265: 40504 sqlite3.Xsqlite3_profile(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, uintptr(0), uintptr(0)) 40505 __266: 40506 ; 40507 __260: 40508 ; 40509 __258: 40510 ; 40511 goto __3 40512 40513 // $db rekey KEY 40514 // 40515 // Change the encryption key on the currently open database. 40516 __30: 40517 if !(objc != 3) { 40518 goto __267 40519 } 40520 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12609 /* "KEY" */) 40521 return TCL_ERROR 40522 __267: 40523 ; 40524 goto __3 40525 40526 // $db restore ?DATABASE? FILENAME 40527 // 40528 // Open a database file named FILENAME. Transfer the content 40529 // of FILENAME into the local database DATABASE (default: "main"). 40530 __31: 40531 nTimeout = 0 40532 40533 if !(objc == 3) { 40534 goto __268 40535 } 40536 zDestDb = ts + 85 /* "main" */ 40537 zSrcFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 40538 goto __269 40539 __268: 40540 if !(objc == 4) { 40541 goto __270 40542 } 40543 zDestDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 40544 zSrcFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 40545 goto __271 40546 __270: 40547 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11393 /* "?DATABASE? FILEN..." */) 40548 return TCL_ERROR 40549 __271: 40550 ; 40551 __269: 40552 ; 40553 rc = sqlite3.Xsqlite3_open_v2(tls, zSrcFile, bp+1392, /* &pSrc */ 40554 (SQLITE_OPEN_READONLY | (*SqliteDb)(unsafe.Pointer(pDb)).FopenFlags), uintptr(0)) 40555 if !(rc != SQLITE_OK) { 40556 goto __272 40557 } 40558 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+800, ts+12613, /* "cannot open sour..." */ 40559 sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 1392 /* pSrc */))), uintptr(0))) 40560 sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 1392 /* pSrc */))) 40561 return TCL_ERROR 40562 __272: 40563 ; 40564 pBackup1 = sqlite3.Xsqlite3_backup_init(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zDestDb, *(*uintptr)(unsafe.Pointer(bp + 1392 /* pSrc */)), ts+85 /* "main" */) 40565 if !(pBackup1 == uintptr(0)) { 40566 goto __273 40567 } 40568 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+824, ts+12643, /* "restore failed: " */ 40569 sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(0))) 40570 sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 1392 /* pSrc */))) 40571 return TCL_ERROR 40572 __273: 40573 ; 40574 __274: 40575 if !(((libc.AssignInt32(&rc, sqlite3.Xsqlite3_backup_step(tls, pBackup1, 100))) == SQLITE_OK) || 40576 (rc == SQLITE_BUSY)) { 40577 goto __275 40578 } 40579 if !(rc == SQLITE_BUSY) { 40580 goto __276 40581 } 40582 if !(libc.PostIncInt32(&nTimeout, 1) >= 3) { 40583 goto __277 40584 } 40585 goto __275 40586 __277: 40587 ; 40588 sqlite3.Xsqlite3_sleep(tls, 100) 40589 __276: 40590 ; 40591 goto __274 40592 __275: 40593 ; 40594 sqlite3.Xsqlite3_backup_finish(tls, pBackup1) 40595 if !(rc == SQLITE_DONE) { 40596 goto __278 40597 } 40598 rc = TCL_OK 40599 goto __279 40600 __278: 40601 if !((rc == SQLITE_BUSY) || (rc == SQLITE_LOCKED)) { 40602 goto __280 40603 } 40604 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+848, ts+12660, /* "restore failed: ..." */ 40605 uintptr(0))) 40606 rc = TCL_ERROR 40607 goto __281 40608 __280: 40609 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+864, ts+12643, /* "restore failed: " */ 40610 sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(0))) 40611 rc = TCL_ERROR 40612 __281: 40613 ; 40614 __279: 40615 ; 40616 sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 1392 /* pSrc */))) 40617 goto __3 40618 40619 // $db serialize ?DATABASE? 40620 // 40621 // Return a serialization of a database. 40622 __32: 40623 if objc >= 3 { 40624 zSchema1 = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 40625 } else { 40626 zSchema1 = ts + 85 /* "main" */ 40627 } 40628 *(*sqlite3_int64)(unsafe.Pointer(bp + 1400 /* sz */)) = int64(0) 40629 if !((objc != 2) && (objc != 3)) { 40630 goto __282 40631 } 40632 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12697 /* "?DATABASE?" */) 40633 rc = TCL_ERROR 40634 goto __283 40635 __282: 40636 pData1 = sqlite3.Xsqlite3_serialize(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zSchema1, bp+1400 /* &sz */, uint32(SQLITE_SERIALIZE_NOCOPY)) 40637 if !(pData1 != 0) { 40638 goto __284 40639 } 40640 needFree = 0 40641 goto __285 40642 __284: 40643 pData1 = sqlite3.Xsqlite3_serialize(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zSchema1, bp+1400 /* &sz */, uint32(0)) 40644 needFree = 1 40645 __285: 40646 ; 40647 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewByteArrayObj(tls, pData1, int32(*(*sqlite3_int64)(unsafe.Pointer(bp + 1400 /* sz */))))) 40648 if !(needFree != 0) { 40649 goto __286 40650 } 40651 sqlite3.Xsqlite3_free(tls, pData1) 40652 __286: 40653 ; 40654 __283: 40655 ; 40656 goto __3 40657 40658 // $db status (step|sort|autoindex|vmstep) 40659 // 40660 // Display SQLITE_STMTSTATUS_FULLSCAN_STEP or 40661 // SQLITE_STMTSTATUS_SORT for the most recent eval. 40662 __33: 40663 if !(objc != 3) { 40664 goto __287 40665 } 40666 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12708 /* "(step|sort|autoi..." */) 40667 return TCL_ERROR 40668 __287: 40669 ; 40670 zOp = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 40671 if !(libc.Xstrcmp(tls, zOp, ts+10122 /* "step" */) == 0) { 40672 goto __288 40673 } 40674 v2 = (*SqliteDb)(unsafe.Pointer(pDb)).FnStep 40675 goto __289 40676 __288: 40677 if !(libc.Xstrcmp(tls, zOp, ts+12730 /* "sort" */) == 0) { 40678 goto __290 40679 } 40680 v2 = (*SqliteDb)(unsafe.Pointer(pDb)).FnSort 40681 goto __291 40682 __290: 40683 if !(libc.Xstrcmp(tls, zOp, ts+12735 /* "autoindex" */) == 0) { 40684 goto __292 40685 } 40686 v2 = (*SqliteDb)(unsafe.Pointer(pDb)).FnIndex 40687 goto __293 40688 __292: 40689 if !(libc.Xstrcmp(tls, zOp, ts+12745 /* "vmstep" */) == 0) { 40690 goto __294 40691 } 40692 v2 = (*SqliteDb)(unsafe.Pointer(pDb)).FnVMStep 40693 goto __295 40694 __294: 40695 tcl.XTcl_AppendResult(tls, interp, 40696 libc.VaList(bp+888, ts+12752, /* "bad argument: sh..." */ 40697 uintptr(0))) 40698 return TCL_ERROR 40699 __295: 40700 ; 40701 __293: 40702 ; 40703 __291: 40704 ; 40705 __289: 40706 ; 40707 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, v2)) 40708 goto __3 40709 40710 // $db timeout MILLESECONDS 40711 // 40712 // Delay for the number of milliseconds specified when a file is locked. 40713 __34: 40714 if !(objc != 3) { 40715 goto __296 40716 } 40717 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12808 /* "MILLISECONDS" */) 40718 return TCL_ERROR 40719 __296: 40720 ; 40721 if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1408 /* &ms */) != 0) { 40722 goto __297 40723 } 40724 return TCL_ERROR 40725 __297: 40726 ; 40727 sqlite3.Xsqlite3_busy_timeout(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, *(*int32)(unsafe.Pointer(bp + 1408 /* ms */))) 40728 goto __3 40729 40730 // $db total_changes 40731 // 40732 // Return the number of rows that were modified, inserted, or deleted 40733 // since the database handle was created. 40734 __35: 40735 if !(objc != 2) { 40736 goto __298 40737 } 40738 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+489 /* "" */) 40739 return TCL_ERROR 40740 __298: 40741 ; 40742 pResult6 = tcl.XTcl_GetObjResult(tls, interp) 40743 tcl.XTcl_SetIntObj(tls, pResult6, sqlite3.Xsqlite3_total_changes(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb)) 40744 goto __3 40745 40746 // $db trace ?CALLBACK? 40747 // 40748 // Make arrangements to invoke the CALLBACK routine for each SQL statement 40749 // that is executed. The text of the SQL is appended to CALLBACK before 40750 // it is executed. 40751 __36: 40752 if !(objc > 3) { 40753 goto __299 40754 } 40755 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+11382 /* "?CALLBACK?" */) 40756 return TCL_ERROR 40757 goto __300 40758 __299: 40759 if !(objc == 2) { 40760 goto __301 40761 } 40762 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzTrace != 0) { 40763 goto __303 40764 } 40765 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+904, (*SqliteDb)(unsafe.Pointer(pDb)).FzTrace, uintptr(0))) 40766 __303: 40767 ; 40768 goto __302 40769 __301: 40770 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzTrace != 0) { 40771 goto __304 40772 } 40773 tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzTrace) 40774 __304: 40775 ; 40776 zTrace = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1412 /* &len8 */) 40777 if !((zTrace != 0) && (*(*int32)(unsafe.Pointer(bp + 1412 /* len8 */)) > 0)) { 40778 goto __305 40779 } 40780 (*SqliteDb)(unsafe.Pointer(pDb)).FzTrace = tcl.XTcl_Alloc(tls, (uint32(*(*int32)(unsafe.Pointer(bp + 1412 /* len8 */)) + 1))) 40781 libc.Xmemcpy(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzTrace, zTrace, (uint64(*(*int32)(unsafe.Pointer(bp + 1412 /* len8 */)) + 1))) 40782 goto __306 40783 __305: 40784 (*SqliteDb)(unsafe.Pointer(pDb)).FzTrace = uintptr(0) 40785 __306: 40786 ; 40787 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzTrace != 0) { 40788 goto __307 40789 } 40790 (*SqliteDb)(unsafe.Pointer(pDb)).Finterp = interp 40791 sqlite3.Xsqlite3_trace(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, *(*uintptr)(unsafe.Pointer(&struct { 40792 f func(*libc.TLS, uintptr, uintptr) 40793 }{DbTraceHandler})), pDb) 40794 goto __308 40795 __307: 40796 sqlite3.Xsqlite3_trace(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, uintptr(0), uintptr(0)) 40797 __308: 40798 ; 40799 __302: 40800 ; 40801 __300: 40802 ; 40803 goto __3 40804 40805 // $db trace_v2 ?CALLBACK? ?MASK? 40806 // 40807 // Make arrangements to invoke the CALLBACK routine for each trace event 40808 // matching the mask that is generated. The parameters are appended to 40809 // CALLBACK before it is executed. 40810 __37: 40811 if !(objc > 4) { 40812 goto __309 40813 } 40814 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12821 /* "?CALLBACK? ?MASK..." */) 40815 return TCL_ERROR 40816 goto __310 40817 __309: 40818 if !(objc == 2) { 40819 goto __311 40820 } 40821 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzTraceV2 != 0) { 40822 goto __313 40823 } 40824 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+920, (*SqliteDb)(unsafe.Pointer(pDb)).FzTraceV2, uintptr(0))) 40825 __313: 40826 ; 40827 goto __312 40828 __311: 40829 wMask = int64(0) 40830 if !(objc == 4) { 40831 goto __314 40832 } 40833 if !(TCL_OK != tcl.XTcl_ListObjLength(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+1416 /* &len9 */)) { 40834 goto __316 40835 } 40836 return TCL_ERROR 40837 __316: 40838 ; 40839 i4 = 0 40840 __317: 40841 if !(i4 < *(*int32)(unsafe.Pointer(bp + 1416 /* len9 */))) { 40842 goto __319 40843 } 40844 if !(TCL_OK != tcl.XTcl_ListObjIndex(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), i4, bp+1424 /* &pObj */)) { 40845 goto __320 40846 } 40847 return TCL_ERROR 40848 __320: 40849 ; 40850 if !(tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 1424 /* pObj */)), uintptr(unsafe.Pointer(&TTYPE_strs)), int32(unsafe.Sizeof(uintptr(0))), ts+12839 /* "trace type" */, 0, bp+1432 /* &ttype */) != TCL_OK) { 40851 goto __321 40852 } 40853 pError = tcl.XTcl_DuplicateObj(tls, tcl.XTcl_GetObjResult(tls, interp)) 40854 (*Tcl_Obj)(unsafe.Pointer(pError)).FrefCount++ 40855 if !(TCL_OK == tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 1424 /* pObj */)), bp+1440 /* &wType */)) { 40856 goto __323 40857 } 40858 __325: 40859 _objPtr3 = pError 40860 if !(libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr3))).FrefCount, 1) <= 1) { 40861 goto __328 40862 } 40863 tcl.XTclFreeObj(tls, _objPtr3) 40864 __328: 40865 ; 40866 goto __326 40867 __326: 40868 if 0 != 0 { 40869 goto __325 40870 } 40871 goto __327 40872 __327: 40873 ; 40874 wMask = wMask | (*(*Tcl_WideInt)(unsafe.Pointer(bp + 1440 /* wType */))) 40875 goto __324 40876 __323: 40877 tcl.XTcl_SetObjResult(tls, interp, pError) 40878 __329: 40879 _objPtr4 = pError 40880 if !(libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr4))).FrefCount, 1) <= 1) { 40881 goto __332 40882 } 40883 tcl.XTclFreeObj(tls, _objPtr4) 40884 __332: 40885 ; 40886 goto __330 40887 __330: 40888 if 0 != 0 { 40889 goto __329 40890 } 40891 goto __331 40892 __331: 40893 ; 40894 return TCL_ERROR 40895 __324: 40896 ; 40897 goto __322 40898 __321: 40899 switch uint32(*(*int32)(unsafe.Pointer(bp + 1432 /* ttype */))) { 40900 case uint32(0) /* TTYPE_STMT */ : 40901 goto __334 40902 case uint32(1) /* TTYPE_PROFILE */ : 40903 goto __335 40904 case uint32(2) /* TTYPE_ROW */ : 40905 goto __336 40906 case uint32(3) /* TTYPE_CLOSE */ : 40907 goto __337 40908 } 40909 goto __333 40910 __334: 40911 wMask = wMask | (int64(SQLITE_TRACE_STMT)) 40912 goto __333 40913 __335: 40914 wMask = wMask | (int64(SQLITE_TRACE_PROFILE)) 40915 goto __333 40916 __336: 40917 wMask = wMask | (int64(SQLITE_TRACE_ROW)) 40918 goto __333 40919 __337: 40920 wMask = wMask | (int64(SQLITE_TRACE_CLOSE)) 40921 goto __333 40922 __333: 40923 ; 40924 __322: 40925 ; 40926 goto __318 40927 __318: 40928 i4++ 40929 goto __317 40930 goto __319 40931 __319: 40932 ; 40933 goto __315 40934 __314: 40935 wMask = int64(SQLITE_TRACE_STMT) // use the "legacy" default 40936 __315: 40937 ; 40938 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzTraceV2 != 0) { 40939 goto __338 40940 } 40941 tcl.XTcl_Free(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzTraceV2) 40942 __338: 40943 ; 40944 zTraceV2 = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+1416 /* &len9 */) 40945 if !((zTraceV2 != 0) && (*(*int32)(unsafe.Pointer(bp + 1416 /* len9 */)) > 0)) { 40946 goto __339 40947 } 40948 (*SqliteDb)(unsafe.Pointer(pDb)).FzTraceV2 = tcl.XTcl_Alloc(tls, (uint32(*(*int32)(unsafe.Pointer(bp + 1416 /* len9 */)) + 1))) 40949 libc.Xmemcpy(tls, (*SqliteDb)(unsafe.Pointer(pDb)).FzTraceV2, zTraceV2, (uint64(*(*int32)(unsafe.Pointer(bp + 1416 /* len9 */)) + 1))) 40950 goto __340 40951 __339: 40952 (*SqliteDb)(unsafe.Pointer(pDb)).FzTraceV2 = uintptr(0) 40953 __340: 40954 ; 40955 if !((*SqliteDb)(unsafe.Pointer(pDb)).FzTraceV2 != 0) { 40956 goto __341 40957 } 40958 (*SqliteDb)(unsafe.Pointer(pDb)).Finterp = interp 40959 sqlite3.Xsqlite3_trace_v2(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, uint32(wMask), *(*uintptr)(unsafe.Pointer(&struct { 40960 f func(*libc.TLS, uint32, uintptr, uintptr, uintptr) int32 40961 }{DbTraceV2Handler})), pDb) 40962 goto __342 40963 __341: 40964 sqlite3.Xsqlite3_trace_v2(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, uint32(0), uintptr(0), uintptr(0)) 40965 __342: 40966 ; 40967 __312: 40968 ; 40969 __310: 40970 ; 40971 goto __3 40972 40973 // $db transaction [-deferred|-immediate|-exclusive] SCRIPT 40974 // 40975 // Start a new transaction (if we are not already in the midst of a 40976 // transaction) and execute the TCL script SCRIPT. After SCRIPT 40977 // completes, either commit the transaction or roll it back if SCRIPT 40978 // throws an exception. Or if no new transation was started, do nothing. 40979 // pass the exception on up the stack. 40980 // 40981 // This command was inspired by Dave Thomas's talk on Ruby at the 40982 // 2005 O'Reilly Open Source Convention (OSCON). 40983 __38: 40984 zBegin = ts + 12850 /* "SAVEPOINT _tcl_t..." */ 40985 if !((objc != 3) && (objc != 4)) { 40986 goto __343 40987 } 40988 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12877 /* "[TYPE] SCRIPT" */) 40989 return TCL_ERROR 40990 __343: 40991 ; 40992 40993 if !(((*SqliteDb)(unsafe.Pointer(pDb)).FnTransaction == 0) && (objc == 4)) { 40994 goto __344 40995 } 40996 if !(tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&TTYPE_strs1)), int32(unsafe.Sizeof(uintptr(0))), ts+12891 /* "transaction type" */, 0, bp+1448 /* &ttype1 */) != 0) { 40997 goto __345 40998 } 40999 return TCL_ERROR 41000 __345: 41001 ; 41002 switch uint32(*(*int32)(unsafe.Pointer(bp + 1448 /* ttype1 */))) { 41003 case uint32(0) /* TTYPE_DEFERRED */ : 41004 goto __347 41005 case uint32(1) /* TTYPE_EXCLUSIVE */ : 41006 goto __348 41007 case uint32(2) /* TTYPE_IMMEDIATE */ : 41008 goto __349 41009 } 41010 goto __346 41011 __347: /* no-op */ 41012 ; 41013 goto __346 41014 __348: 41015 zBegin = ts + 12908 /* "BEGIN EXCLUSIVE" */ 41016 goto __346 41017 __349: 41018 zBegin = ts + 12924 /* "BEGIN IMMEDIATE" */ 41019 goto __346 41020 __346: 41021 ; 41022 __344: 41023 ; 41024 pScript2 = *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-1))*8)) 41025 41026 // Run the SQLite BEGIN command to open a transaction or savepoint. 41027 (*SqliteDb)(unsafe.Pointer(pDb)).FdisableAuth++ 41028 rc = sqlite3.Xsqlite3_exec(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, zBegin, uintptr(0), uintptr(0), uintptr(0)) 41029 (*SqliteDb)(unsafe.Pointer(pDb)).FdisableAuth-- 41030 if !(rc != SQLITE_OK) { 41031 goto __350 41032 } 41033 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+936, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(0))) 41034 return TCL_ERROR 41035 __350: 41036 ; 41037 (*SqliteDb)(unsafe.Pointer(pDb)).FnTransaction++ 41038 41039 // If using NRE, schedule a callback to invoke the script pScript, then 41040 // a second callback to commit (or rollback) the transaction or savepoint 41041 // opened above. If not using NRE, evaluate the script directly, then 41042 // call function DbTransPostCmd() to commit (or rollback) the transaction 41043 // or savepoint. 41044 if !(DbUseNre(tls) != 0) { 41045 goto __351 41046 } 41047 tcl.XTcl_NRAddCallback(tls, interp, *(*uintptr)(unsafe.Pointer(&struct { 41048 f func(*libc.TLS, uintptr, uintptr, int32) int32 41049 }{DbTransPostCmd})), *(*uintptr)(unsafe.Pointer(bp + 1456 /* cd */)), uintptr(0), uintptr(0), uintptr(0)) 41050 tcl.XTcl_NREvalObj(tls, interp, pScript2, 0) 41051 goto __352 41052 __351: 41053 rc = DbTransPostCmd(tls, bp+1456 /* &cd */, interp, tcl.XTcl_EvalObjEx(tls, interp, pScript2, 0)) 41054 __352: 41055 ; 41056 goto __3 41057 41058 // $db unlock_notify ?script? 41059 __39: 41060 if !((objc != 2) && (objc != 3)) { 41061 goto __353 41062 } 41063 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12940 /* "?SCRIPT?" */) 41064 rc = TCL_ERROR 41065 goto __354 41066 __353: 41067 xNotify = uintptr(0) 41068 pNotifyArg = uintptr(0) 41069 41070 if !((*SqliteDb)(unsafe.Pointer(pDb)).FpUnlockNotify != 0) { 41071 goto __355 41072 } 41073 __356: 41074 _objPtr5 = (*SqliteDb)(unsafe.Pointer(pDb)).FpUnlockNotify 41075 if !(libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr5))).FrefCount, 1) <= 1) { 41076 goto __359 41077 } 41078 tcl.XTclFreeObj(tls, _objPtr5) 41079 __359: 41080 ; 41081 goto __357 41082 __357: 41083 if 0 != 0 { 41084 goto __356 41085 } 41086 goto __358 41087 __358: 41088 ; 41089 (*SqliteDb)(unsafe.Pointer(pDb)).FpUnlockNotify = uintptr(0) 41090 __355: 41091 ; 41092 41093 if !(objc == 3) { 41094 goto __360 41095 } 41096 xNotify = *(*uintptr)(unsafe.Pointer(&struct { 41097 f func(*libc.TLS, uintptr, int32) 41098 }{DbUnlockNotify})) 41099 pNotifyArg = pDb 41100 (*SqliteDb)(unsafe.Pointer(pDb)).FpUnlockNotify = *(*uintptr)(unsafe.Pointer(objv + 2*8)) 41101 (*Tcl_Obj)(unsafe.Pointer((*SqliteDb)(unsafe.Pointer(pDb)).FpUnlockNotify)).FrefCount++ 41102 __360: 41103 ; 41104 41105 if !(sqlite3.Xsqlite3_unlock_notify(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, xNotify, pNotifyArg) != 0) { 41106 goto __361 41107 } 41108 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+952, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(0))) 41109 rc = TCL_ERROR 41110 __361: 41111 ; 41112 __354: 41113 ; 41114 goto __3 41115 41116 // $db preupdate_hook count 41117 // $db preupdate_hook hook ?SCRIPT? 41118 // $db preupdate_hook new INDEX 41119 // $db preupdate_hook old INDEX 41120 __40: 41121 41122 if !(objc < 3) { 41123 goto __362 41124 } 41125 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12949 /* "SUB-COMMAND ?ARG..." */) 41126 __362: 41127 ; 41128 if !(tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&azSub)), int32(unsafe.Sizeof(uintptr(0))), ts+1875 /* "sub-command" */, 0, bp+1464 /* &iSub */) != 0) { 41129 goto __363 41130 } 41131 return TCL_ERROR 41132 __363: 41133 ; 41134 41135 switch uint32(*(*int32)(unsafe.Pointer(bp + 1464 /* iSub */))) { 41136 case uint32(0) /* PRE_COUNT */ : 41137 goto __365 41138 41139 case uint32(2) /* PRE_HOOK */ : 41140 goto __366 41141 41142 case uint32(1) /* PRE_DEPTH */ : 41143 goto __367 41144 41145 case uint32(3) /* PRE_NEW */ : 41146 goto __368 41147 case uint32(4) /* PRE_OLD */ : 41148 goto __369 41149 } 41150 goto __364 41151 __365: 41152 nCol2 = sqlite3.Xsqlite3_preupdate_count(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb) 41153 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, nCol2)) 41154 goto __364 41155 41156 __366: 41157 if !(objc > 4) { 41158 goto __370 41159 } 41160 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12968 /* "hook ?SCRIPT?" */) 41161 return TCL_ERROR 41162 __370: 41163 ; 41164 DbHookCmd(tls, interp, pDb, func() uintptr { 41165 if objc == 4 { 41166 return *(*uintptr)(unsafe.Pointer(objv + 3*8)) 41167 } 41168 return uintptr(0) 41169 }(), (pDb + 112 /* &.pPreUpdateHook */)) 41170 goto __364 41171 41172 __367: 41173 if !(objc != 3) { 41174 goto __371 41175 } 41176 tcl.XTcl_WrongNumArgs(tls, interp, 3, objv, ts+489 /* "" */) 41177 return TCL_ERROR 41178 __371: 41179 ; 41180 pRet1 = tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_preupdate_depth(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb)) 41181 tcl.XTcl_SetObjResult(tls, interp, pRet1) 41182 goto __364 41183 41184 __368: 41185 __369: 41186 if !(objc != 4) { 41187 goto __372 41188 } 41189 tcl.XTcl_WrongNumArgs(tls, interp, 3, objv, ts+12982 /* "INDEX" */) 41190 return TCL_ERROR 41191 __372: 41192 ; 41193 if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+1468 /* &iIdx */) != 0) { 41194 goto __373 41195 } 41196 return TCL_ERROR 41197 __373: 41198 ; 41199 41200 if !(*(*int32)(unsafe.Pointer(bp + 1464 /* iSub */)) == 4 /* PRE_OLD */) { 41201 goto __374 41202 } 41203 rc = sqlite3.Xsqlite3_preupdate_old(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, *(*int32)(unsafe.Pointer(bp + 1468 /* iIdx */)), bp+1472 /* &pValue1 */) 41204 goto __375 41205 __374: 41206 ; 41207 rc = sqlite3.Xsqlite3_preupdate_new(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb, *(*int32)(unsafe.Pointer(bp + 1468 /* iIdx */)), bp+1472 /* &pValue1 */) 41208 __375: 41209 ; 41210 41211 if !(rc == SQLITE_OK) { 41212 goto __376 41213 } 41214 pObj1 = tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(bp + 1472 /* pValue1 */))), -1) 41215 tcl.XTcl_SetObjResult(tls, interp, pObj1) 41216 goto __377 41217 __376: 41218 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+968, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(pDb)).Fdb), uintptr(0))) 41219 return TCL_ERROR 41220 __377: 41221 ; 41222 41223 __364: 41224 ; 41225 goto __3 41226 41227 // $db wal_hook ?script? 41228 // $db update_hook ?script? 41229 // $db rollback_hook ?script? 41230 __41: 41231 __42: 41232 __43: 41233 // set ppHook to point at pUpdateHook or pRollbackHook, depending on 41234 // whether [$db update_hook] or [$db rollback_hook] was invoked. 41235 ppHook = uintptr(0) 41236 if !(*(*int32)(unsafe.Pointer(bp + 1016 /* choice */)) == 40 /* DB_WAL_HOOK */) { 41237 goto __378 41238 } 41239 ppHook = (pDb + 128 /* &.pWalHook */) 41240 __378: 41241 ; 41242 if !(*(*int32)(unsafe.Pointer(bp + 1016 /* choice */)) == 38 /* DB_UPDATE_HOOK */) { 41243 goto __379 41244 } 41245 ppHook = (pDb + 104 /* &.pUpdateHook */) 41246 __379: 41247 ; 41248 if !(*(*int32)(unsafe.Pointer(bp + 1016 /* choice */)) == 29 /* DB_ROLLBACK_HOOK */) { 41249 goto __380 41250 } 41251 ppHook = (pDb + 120 /* &.pRollbackHook */) 41252 __380: 41253 ; 41254 if !(objc > 3) { 41255 goto __381 41256 } 41257 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12940 /* "?SCRIPT?" */) 41258 return TCL_ERROR 41259 __381: 41260 ; 41261 41262 DbHookCmd(tls, interp, pDb, func() uintptr { 41263 if objc == 3 { 41264 return *(*uintptr)(unsafe.Pointer(objv + 2*8)) 41265 } 41266 return uintptr(0) 41267 }(), ppHook) 41268 goto __3 41269 41270 // $db version 41271 // 41272 // Return the version string for this database. 41273 __44: 41274 i5 = 2 41275 __382: 41276 if !(i5 < objc) { 41277 goto __384 41278 } 41279 zArg = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i5)*8))) 41280 // Optional arguments to $db version are used for testing purpose 41281 // $db version -use-legacy-prepare BOOLEAN 41282 // 41283 // Turn the use of legacy sqlite3_prepare() on or off. 41284 if !((libc.Xstrcmp(tls, zArg, ts+12988 /* "-use-legacy-prep..." */) == 0) && ((i5 + 1) < objc)) { 41285 goto __385 41286 } 41287 i5++ 41288 if !(tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i5)*8)), (pDb+224 /* &.bLegacyPrepare */)) != 0) { 41289 goto __387 41290 } 41291 return TCL_ERROR 41292 __387: 41293 ; 41294 goto __386 41295 __385: 41296 41297 // $db version -last-stmt-ptr 41298 // 41299 // Return a string which is a hex encoding of the pointer to the 41300 // most recent sqlite3_stmt in the statement cache. 41301 if !(libc.Xstrcmp(tls, zArg, ts+13008 /* "-last-stmt-ptr" */) == 0) { 41302 goto __388 41303 } 41304 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+1480 /* &zBuf[0] */, ts+13023, /* "%p" */ 41305 libc.VaList(bp+984, func() uintptr { 41306 if (*SqliteDb)(unsafe.Pointer(pDb)).FstmtList != 0 { 41307 return (*SqlPreparedStmt)(unsafe.Pointer((*SqliteDb)(unsafe.Pointer(pDb)).FstmtList)).FpStmt 41308 } 41309 return uintptr(0) 41310 }())) 41311 tcl.XTcl_SetResult(tls, interp, bp+1480 /* &zBuf[0] */, uintptr(1)) 41312 goto __389 41313 __388: 41314 41315 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+992, ts+13026 /* "unknown argument..." */, zArg, uintptr(0))) 41316 return TCL_ERROR 41317 __389: 41318 ; 41319 __386: 41320 ; 41321 goto __383 41322 __383: 41323 i5++ 41324 goto __382 41325 goto __384 41326 __384: 41327 ; 41328 if !(i5 == 2) { 41329 goto __390 41330 } 41331 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3_libversion(tls), uintptr(0)) 41332 __390: 41333 ; 41334 goto __3 41335 41336 __3: 41337 ; // End of the SWITCH statement 41338 return rc 41339 } 41340 41341 type DbConfigChoices = struct { 41342 FzName uintptr 41343 Fop int32 41344 _ [4]byte 41345 } /* tclsqlite.c:2340:18 */ 41346 41347 var DB_strs = [42]uintptr{ 41348 ts + 13045 /* "authorizer" */, ts + 13056 /* "backup" */, ts + 13063, /* "bind_fallback" */ 41349 ts + 13077 /* "busy" */, ts + 13082 /* "cache" */, ts + 13088, /* "changes" */ 41350 ts + 10127 /* "close" */, ts + 13096 /* "collate" */, ts + 13104, /* "collation_needed" */ 41351 ts + 13121 /* "commit_hook" */, ts + 13133 /* "complete" */, ts + 13142, /* "config" */ 41352 ts + 13149 /* "copy" */, ts + 13154 /* "deserialize" */, ts + 13166, /* "enable_load_exte..." */ 41353 ts + 13188 /* "errorcode" */, ts + 4767 /* "eval" */, ts + 13198, /* "exists" */ 41354 ts + 13205 /* "function" */, ts + 10526 /* "incrblob" */, ts + 13214, /* "interrupt" */ 41355 ts + 13224 /* "last_insert_rowi..." */, ts + 13242 /* "nullvalue" */, ts + 13252, /* "onecolumn" */ 41356 ts + 13262 /* "preupdate" */, ts + 13272 /* "profile" */, ts + 10201, /* "progress" */ 41357 ts + 13280 /* "rekey" */, ts + 13286 /* "restore" */, ts + 13294, /* "rollback_hook" */ 41358 ts + 13308 /* "serialize" */, ts + 13318 /* "status" */, ts + 13325, /* "timeout" */ 41359 ts + 13333 /* "total_changes" */, ts + 13347 /* "trace" */, ts + 13353, /* "trace_v2" */ 41360 ts + 13362 /* "transaction" */, ts + 13374 /* "unlock_notify" */, ts + 13388, /* "update_hook" */ 41361 ts + 13400 /* "version" */, ts + 13408 /* "wal_hook" */, uintptr(0), 41362 } /* tclsqlite.c:1916:21 */ 41363 var aDbConfig = [16]DbConfigChoices{ 41364 {FzName: ts + 13417 /* "defensive" */, Fop: SQLITE_DBCONFIG_DEFENSIVE}, 41365 {FzName: ts + 13427 /* "dqs_ddl" */, Fop: SQLITE_DBCONFIG_DQS_DDL}, 41366 {FzName: ts + 13435 /* "dqs_dml" */, Fop: SQLITE_DBCONFIG_DQS_DML}, 41367 {FzName: ts + 13443 /* "enable_fkey" */, Fop: SQLITE_DBCONFIG_ENABLE_FKEY}, 41368 {FzName: ts + 13455 /* "enable_qpsg" */, Fop: SQLITE_DBCONFIG_ENABLE_QPSG}, 41369 {FzName: ts + 13467 /* "enable_trigger" */, Fop: SQLITE_DBCONFIG_ENABLE_TRIGGER}, 41370 {FzName: ts + 13482 /* "enable_view" */, Fop: SQLITE_DBCONFIG_ENABLE_VIEW}, 41371 {FzName: ts + 13494 /* "fts3_tokenizer" */, Fop: SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER}, 41372 {FzName: ts + 13509 /* "legacy_alter_tab..." */, Fop: SQLITE_DBCONFIG_LEGACY_ALTER_TABLE}, 41373 {FzName: ts + 13528 /* "legacy_file_form..." */, Fop: SQLITE_DBCONFIG_LEGACY_FILE_FORMAT}, 41374 {FzName: ts + 13547 /* "load_extension" */, Fop: SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION}, 41375 {FzName: ts + 13562 /* "no_ckpt_on_close" */, Fop: SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE}, 41376 {FzName: ts + 13579 /* "reset_database" */, Fop: SQLITE_DBCONFIG_RESET_DATABASE}, 41377 {FzName: ts + 13594 /* "trigger_eqp" */, Fop: SQLITE_DBCONFIG_TRIGGER_EQP}, 41378 {FzName: ts + 13606 /* "trusted_schema" */, Fop: SQLITE_DBCONFIG_TRUSTED_SCHEMA}, 41379 {FzName: ts + 13621 /* "writable_schema" */, Fop: SQLITE_DBCONFIG_WRITABLE_SCHEMA}, 41380 } /* tclsqlite.c:2343:7 */ 41381 var TTYPE_strs = [5]uintptr{ 41382 ts + 13637 /* "statement" */, ts + 13272 /* "profile" */, ts + 13647 /* "row" */, ts + 10127 /* "close" */, uintptr(0), 41383 } /* tclsqlite.c:3321:27 */ 41384 var TTYPE_strs1 = [4]uintptr{ 41385 ts + 13651 /* "deferred" */, ts + 13660 /* "exclusive" */, ts + 13670 /* "immediate" */, uintptr(0), 41386 } /* tclsqlite.c:3404:25 */ 41387 var azSub = [6]uintptr{ts + 1826 /* "count" */, ts + 13680 /* "depth" */, ts + 13686 /* "hook" */, ts + 13691 /* "new" */, ts + 13695 /* "old" */, uintptr(0)} /* tclsqlite.c:3496:23 */ 41388 41389 // Adaptor that provides an objCmd interface to the NRE-enabled 41390 // interface implementation. 41391 func DbObjCmdAdaptor(tls *libc.TLS, cd uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* tclsqlite.c:3647:26: */ 41392 return tcl.XTcl_NRCallObjProc(tls, interp, *(*uintptr)(unsafe.Pointer(&struct { 41393 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 41394 }{DbObjCmd})), cd, objc, objv) 41395 } 41396 41397 // Issue the usage message when the "sqlite3" command arguments are 41398 // incorrect. 41399 func sqliteCmdUsage(tls *libc.TLS, interp uintptr, objv uintptr) int32 { /* tclsqlite.c:3661:12: */ 41400 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, 41401 41402 ts+13699 /* "HANDLE ?FILENAME..." */) 41403 return TCL_ERROR 41404 } 41405 41406 // sqlite3 DBNAME FILENAME ?-vfs VFSNAME? ?-key KEY? ?-readonly BOOLEAN? 41407 // ?-create BOOLEAN? ?-nomutex BOOLEAN? 41408 // ?-nofollow BOOLEAN? 41409 // 41410 // This is the main Tcl command. When the "sqlite" Tcl command is 41411 // invoked, this routine runs to process that command. 41412 // 41413 // The first argument, DBNAME, is an arbitrary name for a new 41414 // database connection. This command creates a new command named 41415 // DBNAME that is used to control that connection. The database 41416 // connection is deleted when the DBNAME command is deleted. 41417 // 41418 // The second argument is the name of the database file. 41419 // 41420 func DbMain(tls *libc.TLS, cd uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* tclsqlite.c:3689:26: */ 41421 bp := tls.Alloc(336) 41422 defer tls.Free(336) 41423 41424 var p uintptr 41425 var zArg uintptr 41426 var zErrMsg uintptr 41427 var i int32 41428 var zFile uintptr = uintptr(0) 41429 var zVfs uintptr = uintptr(0) 41430 var flags int32 41431 *(*int32)(unsafe.Pointer(bp + 112 /* bTranslateFileName */)) = 1 41432 // var translatedFilename Tcl_DString at bp+120, 216 41433 41434 var rc int32 41435 41436 // In normal use, each TCL interpreter runs in a single thread. So 41437 // by default, we can turn off mutexing on SQLite database connections. 41438 // However, for testing purposes it is useful to have mutexes turned 41439 // on. So, by default, mutexes default off. But if compiled with 41440 // SQLITE_TCL_DEFAULT_FULLMUTEX then mutexes default on. 41441 flags = ((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_NOMUTEX) 41442 41443 if objc == 1 { 41444 return sqliteCmdUsage(tls, interp, objv) 41445 } 41446 if objc == 2 { 41447 zArg = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(0)) 41448 if libc.Xstrcmp(tls, zArg, ts+13845 /* "-version" */) == 0 { 41449 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3_libversion(tls), uintptr(0))) 41450 return TCL_OK 41451 } 41452 if libc.Xstrcmp(tls, zArg, ts+13854 /* "-sourceid" */) == 0 { 41453 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, sqlite3.Xsqlite3_sourceid(tls), uintptr(0))) 41454 return TCL_OK 41455 } 41456 if libc.Xstrcmp(tls, zArg, ts+13864 /* "-has-codec" */) == 0 { 41457 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+13875 /* "0" */, uintptr(0))) 41458 return TCL_OK 41459 } 41460 if int32(*(*int8)(unsafe.Pointer(zArg))) == '-' { 41461 return sqliteCmdUsage(tls, interp, objv) 41462 } 41463 } 41464 for i = 2; i < objc; i++ { 41465 zArg = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8))) 41466 if int32(*(*int8)(unsafe.Pointer(zArg))) != '-' { 41467 if zFile != uintptr(0) { 41468 return sqliteCmdUsage(tls, interp, objv) 41469 } 41470 zFile = zArg 41471 continue 41472 } 41473 if i == (objc - 1) { 41474 return sqliteCmdUsage(tls, interp, objv) 41475 } 41476 i++ 41477 if libc.Xstrcmp(tls, zArg, ts+13877 /* "-key" */) == 0 { 41478 // no-op 41479 } else if libc.Xstrcmp(tls, zArg, ts+13882 /* "-vfs" */) == 0 { 41480 zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8))) 41481 } else if libc.Xstrcmp(tls, zArg, ts+12125 /* "-readonly" */) == 0 { 41482 // var b int32 at bp+88, 4 41483 41484 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+88 /* &b */) != 0 { 41485 return TCL_ERROR 41486 } 41487 if *(*int32)(unsafe.Pointer(bp + 88 /* b */)) != 0 { 41488 flags = flags & (libc.CplInt32((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE))) 41489 flags = flags | (SQLITE_OPEN_READONLY) 41490 } else { 41491 flags = flags & (libc.CplInt32(SQLITE_OPEN_READONLY)) 41492 flags = flags | (SQLITE_OPEN_READWRITE) 41493 } 41494 } else if libc.Xstrcmp(tls, zArg, ts+13887 /* "-create" */) == 0 { 41495 // var b int32 at bp+92, 4 41496 41497 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+92 /* &b */) != 0 { 41498 return TCL_ERROR 41499 } 41500 if (*(*int32)(unsafe.Pointer(bp + 92 /* b */)) != 0) && ((flags & SQLITE_OPEN_READONLY) == 0) { 41501 flags = flags | (SQLITE_OPEN_CREATE) 41502 } else { 41503 flags = flags & (libc.CplInt32(SQLITE_OPEN_CREATE)) 41504 } 41505 } else if libc.Xstrcmp(tls, zArg, ts+13895 /* "-nofollow" */) == 0 { 41506 // var b int32 at bp+96, 4 41507 41508 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+96 /* &b */) != 0 { 41509 return TCL_ERROR 41510 } 41511 if *(*int32)(unsafe.Pointer(bp + 96 /* b */)) != 0 { 41512 flags = flags | (SQLITE_OPEN_NOFOLLOW) 41513 } else { 41514 flags = flags & (libc.CplInt32(SQLITE_OPEN_NOFOLLOW)) 41515 } 41516 } else if libc.Xstrcmp(tls, zArg, ts+13905 /* "-nomutex" */) == 0 { 41517 // var b int32 at bp+100, 4 41518 41519 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+100 /* &b */) != 0 { 41520 return TCL_ERROR 41521 } 41522 if *(*int32)(unsafe.Pointer(bp + 100 /* b */)) != 0 { 41523 flags = flags | (SQLITE_OPEN_NOMUTEX) 41524 flags = flags & (libc.CplInt32(SQLITE_OPEN_FULLMUTEX)) 41525 } else { 41526 flags = flags & (libc.CplInt32(SQLITE_OPEN_NOMUTEX)) 41527 } 41528 } else if libc.Xstrcmp(tls, zArg, ts+13914 /* "-fullmutex" */) == 0 { 41529 // var b int32 at bp+104, 4 41530 41531 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+104 /* &b */) != 0 { 41532 return TCL_ERROR 41533 } 41534 if *(*int32)(unsafe.Pointer(bp + 104 /* b */)) != 0 { 41535 flags = flags | (SQLITE_OPEN_FULLMUTEX) 41536 flags = flags & (libc.CplInt32(SQLITE_OPEN_NOMUTEX)) 41537 } else { 41538 flags = flags & (libc.CplInt32(SQLITE_OPEN_FULLMUTEX)) 41539 } 41540 } else if libc.Xstrcmp(tls, zArg, ts+13925 /* "-uri" */) == 0 { 41541 // var b int32 at bp+108, 4 41542 41543 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+108 /* &b */) != 0 { 41544 return TCL_ERROR 41545 } 41546 if *(*int32)(unsafe.Pointer(bp + 108 /* b */)) != 0 { 41547 flags = flags | (SQLITE_OPEN_URI) 41548 } else { 41549 flags = flags & (libc.CplInt32(SQLITE_OPEN_URI)) 41550 } 41551 } else if libc.Xstrcmp(tls, zArg, ts+13930 /* "-translatefilena..." */) == 0 { 41552 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+112 /* &bTranslateFileName */) != 0 { 41553 return TCL_ERROR 41554 } 41555 } else { 41556 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+12135 /* "unknown option: " */, zArg, uintptr(0))) 41557 return TCL_ERROR 41558 } 41559 } 41560 zErrMsg = uintptr(0) 41561 p = tcl.XTcl_Alloc(tls, uint32(unsafe.Sizeof(SqliteDb{}))) 41562 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(SqliteDb{}))) 41563 if zFile == uintptr(0) { 41564 zFile = ts + 489 /* "" */ 41565 } 41566 if *(*int32)(unsafe.Pointer(bp + 112 /* bTranslateFileName */)) != 0 { 41567 zFile = tcl.XTcl_TranslateFileName(tls, interp, zFile, bp+120 /* &translatedFilename */) 41568 } 41569 rc = sqlite3.Xsqlite3_open_v2(tls, zFile, (p /* &.db */), flags, zVfs) 41570 if *(*int32)(unsafe.Pointer(bp + 112 /* bTranslateFileName */)) != 0 { 41571 tcl.XTcl_DStringFree(tls, bp+120 /* &translatedFilename */) 41572 } 41573 if (*SqliteDb)(unsafe.Pointer(p)).Fdb != 0 { 41574 if SQLITE_OK != sqlite3.Xsqlite3_errcode(tls, (*SqliteDb)(unsafe.Pointer(p)).Fdb) { 41575 zErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+72, sqlite3.Xsqlite3_errmsg(tls, (*SqliteDb)(unsafe.Pointer(p)).Fdb))) 41576 sqlite3.Xsqlite3_close(tls, (*SqliteDb)(unsafe.Pointer(p)).Fdb) 41577 (*SqliteDb)(unsafe.Pointer(p)).Fdb = uintptr(0) 41578 } 41579 } else { 41580 zErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+80, sqlite3.Xsqlite3_errstr(tls, rc))) 41581 } 41582 if (*SqliteDb)(unsafe.Pointer(p)).Fdb == uintptr(0) { 41583 tcl.XTcl_SetResult(tls, interp, zErrMsg, uintptr(1)) 41584 tcl.XTcl_Free(tls, p) 41585 sqlite3.Xsqlite3_free(tls, zErrMsg) 41586 return TCL_ERROR 41587 } 41588 (*SqliteDb)(unsafe.Pointer(p)).FmaxStmt = NUM_PREPARED_STMTS 41589 (*SqliteDb)(unsafe.Pointer(p)).FopenFlags = (flags & SQLITE_OPEN_URI) 41590 (*SqliteDb)(unsafe.Pointer(p)).Finterp = interp 41591 zArg = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(0)) 41592 if DbUseNre(tls) != 0 { 41593 tcl.XTcl_NRCreateCommand(tls, interp, zArg, *(*uintptr)(unsafe.Pointer(&struct { 41594 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 41595 }{DbObjCmdAdaptor})), *(*uintptr)(unsafe.Pointer(&struct { 41596 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 41597 }{DbObjCmd})), 41598 p, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{DbDeleteCmd}))) 41599 } else { 41600 tcl.XTcl_CreateObjCommand(tls, interp, zArg, *(*uintptr)(unsafe.Pointer(&struct { 41601 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 41602 }{DbObjCmd})), p, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{DbDeleteCmd}))) 41603 } 41604 return TCL_OK 41605 } 41606 41607 // Provide a dummy Tcl_InitStubs if we are using this as a static 41608 // library. 41609 41610 // Make sure we have a PACKAGE_VERSION macro defined. This will be 41611 // defined automatically by the TEA makefile. But other makefiles 41612 // do not define it. 41613 41614 // Initialize this module. 41615 // 41616 // This Tcl module contains only a single new Tcl command named "sqlite". 41617 // (Hence there is no namespace. There is no point in using a namespace 41618 // if the extension only supplies one new name!) The "sqlite" command is 41619 // used to open a new SQLite database. See the DbMain() routine above 41620 // for additional information. 41621 // 41622 // The EXTERN macros are required by TCL in order to work on windows. 41623 func Sqlite3_Init(tls *libc.TLS, interp uintptr) int32 { /* tclsqlite.c:3877:12: */ 41624 var rc int32 41625 if 1 != 0 { 41626 rc = TCL_OK 41627 } else { 41628 rc = TCL_ERROR 41629 } 41630 if rc == TCL_OK { 41631 tcl.XTcl_CreateObjCommand(tls, interp, ts+13949 /* "sqlite3" */, *(*uintptr)(unsafe.Pointer(&struct { 41632 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 41633 }{DbMain})), uintptr(0), uintptr(0)) 41634 // The "sqlite" alias is undocumented. It is here only to support 41635 // legacy scripts. All new scripts should use only the "sqlite3" 41636 // command. 41637 tcl.XTcl_CreateObjCommand(tls, interp, ts+13957 /* "sqlite" */, *(*uintptr)(unsafe.Pointer(&struct { 41638 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 41639 }{DbMain})), uintptr(0), uintptr(0)) 41640 rc = tcl.XTcl_PkgProvideEx(tls, interp, ts+13949 /* "sqlite3" */, ts+13964 /* "3.35.5" */, uintptr(0)) 41641 } 41642 return rc 41643 } 41644 41645 func Tclsqlite3_Init(tls *libc.TLS, interp uintptr) int32 { /* tclsqlite.c:3891:12: */ 41646 return Sqlite3_Init(tls, interp) 41647 } 41648 41649 func Sqlite3_Unload(tls *libc.TLS, interp uintptr, flags int32) int32 { /* tclsqlite.c:3892:12: */ 41650 return TCL_OK 41651 } 41652 41653 func Tclsqlite3_Unload(tls *libc.TLS, interp uintptr, flags int32) int32 { /* tclsqlite.c:3893:12: */ 41654 return TCL_OK 41655 } 41656 41657 // Because it accesses the file-system and uses persistent state, SQLite 41658 // is not considered appropriate for safe interpreters. Hence, we cause 41659 // the _SafeInit() interfaces return TCL_ERROR. 41660 func Sqlite3_SafeInit(tls *libc.TLS, interp uintptr) int32 { /* tclsqlite.c:3899:12: */ 41661 return TCL_ERROR 41662 } 41663 41664 func Sqlite3_SafeUnload(tls *libc.TLS, interp uintptr, flags int32) int32 { /* tclsqlite.c:3900:12: */ 41665 return TCL_ERROR 41666 } 41667 41668 func Sqlite_Init(tls *libc.TLS, interp uintptr) int32 { /* tclsqlite.c:3905:5: */ 41669 return Sqlite3_Init(tls, interp) 41670 } 41671 41672 func Tclsqlite_Init(tls *libc.TLS, interp uintptr) int32 { /* tclsqlite.c:3906:5: */ 41673 return Sqlite3_Init(tls, interp) 41674 } 41675 41676 func Sqlite_Unload(tls *libc.TLS, interp uintptr, flags int32) int32 { /* tclsqlite.c:3907:5: */ 41677 return TCL_OK 41678 } 41679 41680 func Tclsqlite_Unload(tls *libc.TLS, interp uintptr, flags int32) int32 { /* tclsqlite.c:3908:5: */ 41681 return TCL_OK 41682 } 41683 41684 // If the TCLSH macro is defined, add code to make a stand-alone program. 41685 41686 // This is the main routine for an ordinary TCL shell. If there are 41687 // are arguments, run the first argument as a script. Otherwise, 41688 // read TCL commands from standard input 41689 func tclsh_main_loop(tls *libc.TLS) uintptr { /* tclsqlite.c:3920:19: */ 41690 return uintptr(unsafe.Pointer(&zMainloop)) 41691 } 41692 41693 var zMainloop = *(*[431]int8)(unsafe.Pointer(ts + 13971 /* "if {[llength $ar..." */)) /* tclsqlite.c:3921:21 */ 41694 41695 func main1(tls *libc.TLS, argc int32, argv uintptr) int32 { /* tclsqlite.c:3953:18: */ 41696 bp := tls.Alloc(64) 41697 defer tls.Free(64) 41698 41699 var interp uintptr 41700 var i int32 41701 var zScript uintptr = uintptr(0) 41702 // var zArgc [32]int8 at bp+32, 32 41703 41704 if libc.Xgetenv(tls, ts+14402 /* "SQLITE_DEBUG_BRE..." */) != 0 { 41705 if (libc.Xisatty(tls, 0) != 0) && (libc.Xisatty(tls, 2) != 0) { 41706 libc.Xfprintf(tls, libc.Xstderr, 41707 ts+14421, /* "attach debugger ..." */ 41708 libc.VaList(bp, libc.Xgetpid(tls))) 41709 libc.Xfgetc(tls, libc.Xstdin) 41710 } else { 41711 libc.Xraise(tls, SIGTRAP) 41712 } 41713 } 41714 41715 // Call sqlite3_shutdown() once before doing anything else. This is to 41716 // test that sqlite3_shutdown() can be safely called by a process before 41717 // sqlite3_initialize() is. 41718 sqlite3.Xsqlite3_shutdown(tls) 41719 41720 tcl.XTcl_FindExecutable(tls, *(*uintptr)(unsafe.Pointer(argv))) 41721 tcl.XTcl_SetSystemEncoding(tls, uintptr(0), ts+14483 /* "utf-8" */) 41722 interp = tcl.XTcl_CreateInterp(tls) 41723 Sqlite3_Init(tls, interp) 41724 41725 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([32]int8{})), bp+32 /* &zArgc[0] */, ts+1238 /* "%d" */, libc.VaList(bp+8, (argc-1))) 41726 tcl.XTcl_SetVar2(tls, interp, ts+14489 /* "argc" */, uintptr(0), bp+32 /* &zArgc[0] */, TCL_GLOBAL_ONLY) 41727 tcl.XTcl_SetVar2(tls, interp, ts+14494 /* "argv0" */, uintptr(0), *(*uintptr)(unsafe.Pointer(argv)), TCL_GLOBAL_ONLY) 41728 tcl.XTcl_SetVar2(tls, interp, ts+14500 /* "argv" */, uintptr(0), ts+489 /* "" */, TCL_GLOBAL_ONLY) 41729 for i = 1; i < argc; i++ { 41730 tcl.XTcl_SetVar2(tls, interp, ts+14500 /* "argv" */, uintptr(0), *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), ((TCL_GLOBAL_ONLY | TCL_LIST_ELEMENT) | TCL_APPEND_VALUE)) 41731 } 41732 zScript = sqlite3TestInit(tls, interp) 41733 if zScript == uintptr(0) { 41734 zScript = tclsh_main_loop(tls) 41735 } 41736 if tcl.XTcl_GlobalEval(tls, interp, zScript) != TCL_OK { 41737 var zInfo uintptr = tcl.XTcl_GetVar2(tls, interp, ts+14505 /* "errorInfo" */, uintptr(0), TCL_GLOBAL_ONLY) 41738 if zInfo == uintptr(0) { 41739 zInfo = tcl.XTcl_GetStringResult(tls, interp) 41740 } 41741 libc.Xfprintf(tls, libc.Xstderr, ts+14515 /* "%s: %s\n" */, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(argv)), zInfo)) 41742 return 1 41743 } 41744 return 0 41745 } 41746 41747 // CAPI3REF: Database Connection Handle 41748 // KEYWORDS: {database connection} {database connections} 41749 // 41750 // Each open SQLite database is represented by a pointer to an instance of 41751 // the opaque structure named "sqlite3". It is useful to think of an sqlite3 41752 // pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and 41753 // [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] 41754 // and [sqlite3_close_v2()] are its destructors. There are many other 41755 // interfaces (such as 41756 // [sqlite3_prepare_v2()], [sqlite3_create_function()], and 41757 // [sqlite3_busy_timeout()] to name but three) that are methods on an 41758 // sqlite3 object. 41759 type sqlite31 = sqlite32 /* sqlite3.h:249:24 */ 41760 41761 // CAPI3REF: Dynamically Typed Value Object 41762 // KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} 41763 // 41764 // SQLite uses the sqlite3_value object to represent all values 41765 // that can be stored in a database table. SQLite uses dynamic typing 41766 // for the values it stores. ^Values stored in sqlite3_value objects 41767 // can be integers, floating point values, strings, BLOBs, or NULL. 41768 // 41769 // An sqlite3_value object may be either "protected" or "unprotected". 41770 // Some interfaces require a protected sqlite3_value. Other interfaces 41771 // will accept either a protected or an unprotected sqlite3_value. 41772 // Every interface that accepts sqlite3_value arguments specifies 41773 // whether or not it requires a protected sqlite3_value. The 41774 // [sqlite3_value_dup()] interface can be used to construct a new 41775 // protected sqlite3_value from an unprotected sqlite3_value. 41776 // 41777 // The terms "protected" and "unprotected" refer to whether or not 41778 // a mutex is held. An internal mutex is held for a protected 41779 // sqlite3_value object but no mutex is held for an unprotected 41780 // sqlite3_value object. If SQLite is compiled to be single-threaded 41781 // (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0) 41782 // or if SQLite is run in one of reduced mutex modes 41783 // [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD] 41784 // then there is no distinction between protected and unprotected 41785 // sqlite3_value objects and they can be used interchangeably. However, 41786 // for maximum code portability it is recommended that applications 41787 // still make the distinction between protected and unprotected 41788 // sqlite3_value objects even when not strictly required. 41789 // 41790 // ^The sqlite3_value objects that are passed as parameters into the 41791 // implementation of [application-defined SQL functions] are protected. 41792 // ^The sqlite3_value object returned by 41793 // [sqlite3_column_value()] is unprotected. 41794 // Unprotected sqlite3_value objects may only be used as arguments 41795 // to [sqlite3_result_value()], [sqlite3_bind_value()], and 41796 // [sqlite3_value_dup()]. 41797 // The [sqlite3_value_blob | sqlite3_value_type()] family of 41798 // interfaces require protected sqlite3_value objects. 41799 type sqlite3_value = sqlite3_value1 /* sqlite3.h:4258:30 */ 41800 41801 // CAPI3REF: SQL Function Context Object 41802 // 41803 // The context in which an SQL function executes is stored in an 41804 // sqlite3_context object. ^A pointer to an sqlite3_context object 41805 // is always first parameter to [application-defined SQL functions]. 41806 // The application-defined SQL function implementation will pass this 41807 // pointer through into calls to [sqlite3_result_int | sqlite3_result()], 41808 // [sqlite3_aggregate_context()], [sqlite3_user_data()], 41809 // [sqlite3_context_db_handle()], [sqlite3_get_auxdata()], 41810 // and/or [sqlite3_set_auxdata()]. 41811 type sqlite3_context = sqlite3_context1 /* sqlite3.h:4272:32 */ 41812 41813 // CAPI3REF: Dynamic String Object 41814 // KEYWORDS: {dynamic string} 41815 // 41816 // An instance of the sqlite3_str object contains a dynamically-sized 41817 // string under construction. 41818 // 41819 // The lifecycle of an sqlite3_str object is as follows: 41820 // <ol> 41821 // <li> ^The sqlite3_str object is created using [sqlite3_str_new()]. 41822 // <li> ^Text is appended to the sqlite3_str object using various 41823 // methods, such as [sqlite3_str_appendf()]. 41824 // <li> ^The sqlite3_str object is destroyed and the string it created 41825 // is returned using the [sqlite3_str_finish()] interface. 41826 // </ol> 41827 type sqlite3_str = sqlite3_str1 /* sqlite3.h:7851:28 */ 41828 41829 // Unsigned. 41830 // Define uintN_t types. 41831 // Copyright (C) 2017-2018 Free Software Foundation, Inc. 41832 // This file is part of the GNU C Library. 41833 // 41834 // The GNU C Library is free software; you can redistribute it and/or 41835 // modify it under the terms of the GNU Lesser General Public 41836 // License as published by the Free Software Foundation; either 41837 // version 2.1 of the License, or (at your option) any later version. 41838 // 41839 // The GNU C Library is distributed in the hope that it will be useful, 41840 // but WITHOUT ANY WARRANTY; without even the implied warranty of 41841 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 41842 // Lesser General Public License for more details. 41843 // 41844 // You should have received a copy of the GNU Lesser General Public 41845 // License along with the GNU C Library; if not, see 41846 // <http://www.gnu.org/licenses/>. 41847 41848 // bits/types.h -- definitions of __*_t types underlying *_t types. 41849 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 41850 // This file is part of the GNU C Library. 41851 // 41852 // The GNU C Library is free software; you can redistribute it and/or 41853 // modify it under the terms of the GNU Lesser General Public 41854 // License as published by the Free Software Foundation; either 41855 // version 2.1 of the License, or (at your option) any later version. 41856 // 41857 // The GNU C Library is distributed in the hope that it will be useful, 41858 // but WITHOUT ANY WARRANTY; without even the implied warranty of 41859 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 41860 // Lesser General Public License for more details. 41861 // 41862 // You should have received a copy of the GNU Lesser General Public 41863 // License along with the GNU C Library; if not, see 41864 // <http://www.gnu.org/licenses/>. 41865 41866 // Never include this file directly; use <sys/types.h> instead. 41867 41868 type uint8_t = uint8 /* stdint-uintn.h:24:19 */ 41869 type uint16_t = uint16 /* stdint-uintn.h:25:20 */ 41870 type uint32_t = uint32 /* stdint-uintn.h:26:20 */ 41871 type uint64_t = uint64 /* stdint-uintn.h:27:20 */ 41872 41873 // Small types. 41874 41875 // Signed. 41876 type int_least8_t = int8 /* stdint.h:43:24 */ 41877 type int_least16_t = int16 /* stdint.h:44:25 */ 41878 type int_least32_t = int32 /* stdint.h:45:25 */ 41879 type int_least64_t = int64 /* stdint.h:46:25 */ 41880 41881 // Unsigned. 41882 type uint_least8_t = uint8 /* stdint.h:49:25 */ 41883 type uint_least16_t = uint16 /* stdint.h:50:26 */ 41884 type uint_least32_t = uint32 /* stdint.h:51:26 */ 41885 type uint_least64_t = uint64 /* stdint.h:52:26 */ 41886 41887 // Fast types. 41888 41889 // Signed. 41890 type int_fast8_t = int8 /* stdint.h:58:22 */ 41891 type int_fast16_t = int64 /* stdint.h:60:19 */ 41892 type int_fast32_t = int64 /* stdint.h:61:19 */ 41893 type int_fast64_t = int64 /* stdint.h:62:19 */ 41894 41895 // Unsigned. 41896 type uint_fast8_t = uint8 /* stdint.h:71:24 */ 41897 type uint_fast16_t = uint64 /* stdint.h:73:27 */ 41898 type uint_fast32_t = uint64 /* stdint.h:74:27 */ 41899 type uint_fast64_t = uint64 /* stdint.h:75:27 */ 41900 type uintptr_t = uint64 /* stdint.h:90:27 */ 41901 41902 // Largest integral types. 41903 type intmax_t = int64 /* stdint.h:101:21 */ 41904 type uintmax_t = uint64 /* stdint.h:102:22 */ 41905 41906 // Macros for printing format specifiers. 41907 41908 // Decimal notation. 41909 41910 // Octal notation. 41911 41912 // Unsigned integers. 41913 41914 // lowercase hexadecimal notation. 41915 41916 // UPPERCASE hexadecimal notation. 41917 41918 // Macros for printing `intmax_t' and `uintmax_t'. 41919 41920 // Macros for printing `intptr_t' and `uintptr_t'. 41921 41922 // Macros for scanning format specifiers. 41923 41924 // Signed decimal notation. 41925 41926 // Signed decimal notation. 41927 41928 // Unsigned decimal notation. 41929 41930 // Octal notation. 41931 41932 // Hexadecimal notation. 41933 41934 // Macros for scanning `intmax_t' and `uintmax_t'. 41935 41936 // Macros for scaning `intptr_t' and `uintptr_t'. 41937 41938 // We have to define the `uintmax_t' type using `ldiv_t'. 41939 type imaxdiv_t = struct { 41940 Fquot int64 41941 Frem int64 41942 } /* inttypes.h:275:5 */ 41943 41944 // Is the sqlite3ErrName() function needed in the build? Currently, 41945 // it is needed by "mutex_w32.c" (when debugging), "os_win.c" (when 41946 // OSTRACE is enabled), and by several "test*.c" files (which are 41947 // compiled using SQLITE_TEST). 41948 41949 // SQLITE_ENABLE_EXPLAIN_COMMENTS is incompatible with SQLITE_OMIT_EXPLAIN 41950 41951 // Return true (non-zero) if the input is an integer that is too large 41952 // to fit in 32-bits. This macro is used inside of various testcase() 41953 // macros to verify that we have tested SQLite for large-file support. 41954 41955 // The macro unlikely() is a hint that surrounds a boolean 41956 // expression that is usually false. Macro likely() surrounds 41957 // a boolean expression that is usually true. These hints could, 41958 // in theory, be used by the compiler to generate better code, but 41959 // currently they are just comments for human readers. 41960 41961 // 2001 September 22 41962 // 41963 // The author disclaims copyright to this source code. In place of 41964 // a legal notice, here is a blessing: 41965 // 41966 // May you do good and not evil. 41967 // May you find forgiveness for yourself and forgive others. 41968 // May you share freely, never taking more than you give. 41969 // 41970 // 41971 // This is the header file for the generic hash-table implementation 41972 // used in SQLite. 41973 41974 // Forward declarations of structures. 41975 type Hash1 = struct { 41976 Fhtsize uint32 41977 Fcount uint32 41978 Ffirst uintptr 41979 Fht uintptr 41980 } /* sqlite3.h:249:9 */ 41981 41982 // Is the sqlite3ErrName() function needed in the build? Currently, 41983 // it is needed by "mutex_w32.c" (when debugging), "os_win.c" (when 41984 // OSTRACE is enabled), and by several "test*.c" files (which are 41985 // compiled using SQLITE_TEST). 41986 41987 // SQLITE_ENABLE_EXPLAIN_COMMENTS is incompatible with SQLITE_OMIT_EXPLAIN 41988 41989 // Return true (non-zero) if the input is an integer that is too large 41990 // to fit in 32-bits. This macro is used inside of various testcase() 41991 // macros to verify that we have tested SQLite for large-file support. 41992 41993 // The macro unlikely() is a hint that surrounds a boolean 41994 // expression that is usually false. Macro likely() surrounds 41995 // a boolean expression that is usually true. These hints could, 41996 // in theory, be used by the compiler to generate better code, but 41997 // currently they are just comments for human readers. 41998 41999 // 2001 September 22 42000 // 42001 // The author disclaims copyright to this source code. In place of 42002 // a legal notice, here is a blessing: 42003 // 42004 // May you do good and not evil. 42005 // May you find forgiveness for yourself and forgive others. 42006 // May you share freely, never taking more than you give. 42007 // 42008 // 42009 // This is the header file for the generic hash-table implementation 42010 // used in SQLite. 42011 42012 // Forward declarations of structures. 42013 type Hash = Hash1 /* hash.h:19:21 */ 42014 type HashElem1 = struct { 42015 Fnext uintptr 42016 Fprev uintptr 42017 Fdata uintptr 42018 FpKey uintptr 42019 } /* sqlite3.h:249:9 */ 42020 42021 type HashElem = HashElem1 /* hash.h:20:25 */ 42022 42023 // A complete hash table is an instance of the following structure. 42024 // The internals of this structure are intended to be opaque -- client 42025 // code should not attempt to access or modify the fields of this structure 42026 // directly. Change this structure only by using the routines below. 42027 // However, some of the "procedures" and "functions" for modifying and 42028 // accessing this structure are really macros, so we can't really make 42029 // this structure opaque. 42030 // 42031 // All elements of the hash table are on a single doubly-linked list. 42032 // Hash.first points to the head of this list. 42033 // 42034 // There are Hash.htsize buckets. Each bucket points to a spot in 42035 // the global doubly-linked list. The contents of the bucket are the 42036 // element pointed to plus the next _ht.count-1 elements in the list. 42037 // 42038 // Hash.htsize and Hash.ht may be zero. In that case lookup is done 42039 // by a linear search of the global list. For small tables, the 42040 // Hash.ht table is never allocated because if there are few elements 42041 // in the table, it is faster to do a linear search than to manage 42042 // the hash table. 42043 type _ht = struct { 42044 Fcount uint32 42045 _ [4]byte 42046 Fchain uintptr 42047 } /* sqlite3.h:249:9 */ 42048 42049 // The structure with the cookie function pointers. 42050 // The tag name of this struct is _IO_cookie_io_functions_t to 42051 // preserve historic C++ mangled names for functions taking 42052 // cookie_io_functions_t arguments. That name should not be used in 42053 // new code. 42054 type _IO_cookie_io_functions_t = struct { 42055 Fread uintptr 42056 Fwrite uintptr 42057 Fseek uintptr 42058 Fclose uintptr 42059 } /* cookie_io_functions_t.h:55:9 */ 42060 42061 // The structure with the cookie function pointers. 42062 // The tag name of this struct is _IO_cookie_io_functions_t to 42063 // preserve historic C++ mangled names for functions taking 42064 // cookie_io_functions_t arguments. That name should not be used in 42065 // new code. 42066 type cookie_io_functions_t = _IO_cookie_io_functions_t /* cookie_io_functions_t.h:61:3 */ 42067 type off64_t = int64 /* stdio.h:70:19 */ 42068 type fpos64_t = _G_fpos64_t /* stdio.h:89:20 */ 42069 type ino64_t = uint64 /* types.h:54:19 */ 42070 42071 // Some versions of <linux/posix_types.h> define this macros. 42072 // It's easier to assume 8-bit bytes than to get CHAR_BIT. 42073 42074 // fd_set for select and pselect. 42075 type fd_set1 = struct{ Ffds_bits [16]int64 } /* select.h:70:5 */ // Type to count file system inodes. 42076 42077 type blkcnt64_t = int64 /* types.h:236:22 */ // Type to count number of disk blocks. 42078 type fsblkcnt64_t = uint64 /* types.h:237:24 */ // Type to count file system blocks. 42079 type fsfilcnt64_t = uint64 /* types.h:238:24 */ 42080 42081 type comparison_fn_t = uintptr /* stdlib.h:808:23 */ // 8-byte unsigned integer 42082 type u322 = uint32_t /* sqliteInt.h:793:21 */ // 2-byte unsigned integer 42083 type i16 = int16_t /* sqliteInt.h:795:20 */ // 1-byte unsigned integer 42084 type i8 = int8_t /* sqliteInt.h:797:19 */ // 1-byte signed integer 42085 42086 // SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value 42087 // that can be stored in a u32 without loss of data. The value 42088 // is 0x00000000ffffffff. But because of quirks of some compilers, we 42089 // have to specify the value in the less intuitive manner shown: 42090 42091 // The datatype used to store estimates of the number of rows in a 42092 // table or index. This is an unsigned integer type. For 99.9% of 42093 // the world, a 32-bit integer is sufficient. But a 64-bit integer 42094 // can be used at compile-time if desired. 42095 type tRowcnt = u322 /* sqliteInt.h:816:14 */ // 32-bit is the default 42096 42097 // Estimated quantities used for query planning are stored as 16-bit 42098 // logarithms. For quantity X, the value stored is 10*log2(X). This 42099 // gives a possible range of values of approximately 1.0e986 to 1e-986. 42100 // But the allowed values are "grainy". Not every value is representable. 42101 // For example, quantities 16 and 17 are both represented by a LogEst 42102 // of 40. However, since LogEst quantities are suppose to be estimates, 42103 // not exact values, this imprecision is not a problem. 42104 // 42105 // "LogEst" is short for "Logarithmic Estimate". 42106 // 42107 // Examples: 42108 // 1 -> 0 20 -> 43 10000 -> 132 42109 // 2 -> 10 25 -> 46 25000 -> 146 42110 // 3 -> 16 100 -> 66 1000000 -> 199 42111 // 4 -> 20 1000 -> 99 1048576 -> 200 42112 // 10 -> 33 1024 -> 100 4294967296 -> 320 42113 // 42114 // The LogEst can be negative to indicate fractional values. 42115 // Examples: 42116 // 42117 // 0.5 -> -10 0.1 -> -33 0.0625 -> -40 42118 type LogEst = int16_t /* sqliteInt.h:842:20 */ 42119 42120 // Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer 42121 42122 // The uptr type is an unsigned integer large enough to hold a pointer 42123 type uptr = uintptr_t /* sqliteInt.h:862:21 */ 42124 42125 // An instance of the following structure is used to store the busy-handler 42126 // callback for a given sqlite handle. 42127 // 42128 // The sqlite.busyHandler member of the sqlite struct contains the busy 42129 // callback for the database handle. Each pager opened via the sqlite 42130 // handle is passed a pointer to sqlite.busyHandler. The busy-handler 42131 // callback is currently invoked only from within pager.c. 42132 type BusyHandler1 = struct { 42133 FxBusyHandler uintptr 42134 FpBusyArg uintptr 42135 FnBusy int32 42136 _ [4]byte 42137 } /* sqlite3.h:249:9 */ 42138 42139 // An instance of the following structure is used to store the busy-handler 42140 // callback for a given sqlite handle. 42141 // 42142 // The sqlite.busyHandler member of the sqlite struct contains the busy 42143 // callback for the database handle. Each pager opened via the sqlite 42144 // handle is passed a pointer to sqlite.busyHandler. The busy-handler 42145 // callback is currently invoked only from within pager.c. 42146 type BusyHandler = BusyHandler1 /* sqliteInt.h:1037:28 */ 42147 42148 // Name of table that holds the database schema. 42149 42150 // The root-page of the schema table. 42151 42152 // The name of the schema table. The name is different for TEMP. 42153 42154 // A convenience macro that returns the number of elements in 42155 // an array. 42156 42157 // Determine if the argument is a power of two 42158 42159 // The following value as a destructor means to use sqlite3DbFree(). 42160 // The sqlite3DbFree() routine requires two parameters instead of the 42161 // one parameter that destructors normally want. So we have to introduce 42162 // this magic value that the code knows to handle differently. Any 42163 // pointer will work here as long as it is distinct from SQLITE_STATIC 42164 // and SQLITE_TRANSIENT. 42165 42166 // When SQLITE_OMIT_WSD is defined, it means that the target platform does 42167 // not support Writable Static Data (WSD) such as global and static variables. 42168 // All variables must either be on the stack or dynamically allocated from 42169 // the heap. When WSD is unsupported, the variable declarations scattered 42170 // throughout the SQLite code must become constants instead. The SQLITE_WSD 42171 // macro is used for this purpose. And instead of referencing the variable 42172 // directly, we use its constant as a key to lookup the run-time allocated 42173 // buffer that holds real variable. The constant is also the initializer 42174 // for the run-time allocated buffer. 42175 // 42176 // In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL 42177 // macros become no-ops and have zero performance impact. 42178 42179 // The following macros are used to suppress compiler warnings and to 42180 // make it clear to human readers when a function parameter is deliberately 42181 // left unused within the body of a function. This usually happens when 42182 // a function is called via a function pointer. For example the 42183 // implementation of an SQL aggregate step callback may not use the 42184 // parameter indicating the number of arguments passed to the aggregate, 42185 // if it knows that this is enforced elsewhere. 42186 // 42187 // When a function parameter is not used at all within the body of a function, 42188 // it is generally named "NotUsed" or "NotUsed2" to make things even clearer. 42189 // However, these macros may also be used to suppress warnings related to 42190 // parameters that may or may not be used depending on compilation options. 42191 // For example those parameters only used in assert() statements. In these 42192 // cases the parameters are named as per the usual conventions. 42193 42194 // Forward references to structures 42195 type AggInfo1 = struct { 42196 FdirectMode u8 42197 FuseSortingIdx u8 42198 _ [2]byte 42199 FsortingIdx int32 42200 FsortingIdxPTab int32 42201 FnSortingColumn int32 42202 FmnReg int32 42203 FmxReg int32 42204 FpGroupBy uintptr 42205 FaCol uintptr 42206 FnColumn int32 42207 FnAccumulator int32 42208 FaFunc uintptr 42209 FnFunc int32 42210 FselId u322 42211 } /* sqlite3.h:249:9 */ 42212 42213 // Name of table that holds the database schema. 42214 42215 // The root-page of the schema table. 42216 42217 // The name of the schema table. The name is different for TEMP. 42218 42219 // A convenience macro that returns the number of elements in 42220 // an array. 42221 42222 // Determine if the argument is a power of two 42223 42224 // The following value as a destructor means to use sqlite3DbFree(). 42225 // The sqlite3DbFree() routine requires two parameters instead of the 42226 // one parameter that destructors normally want. So we have to introduce 42227 // this magic value that the code knows to handle differently. Any 42228 // pointer will work here as long as it is distinct from SQLITE_STATIC 42229 // and SQLITE_TRANSIENT. 42230 42231 // When SQLITE_OMIT_WSD is defined, it means that the target platform does 42232 // not support Writable Static Data (WSD) such as global and static variables. 42233 // All variables must either be on the stack or dynamically allocated from 42234 // the heap. When WSD is unsupported, the variable declarations scattered 42235 // throughout the SQLite code must become constants instead. The SQLITE_WSD 42236 // macro is used for this purpose. And instead of referencing the variable 42237 // directly, we use its constant as a key to lookup the run-time allocated 42238 // buffer that holds real variable. The constant is also the initializer 42239 // for the run-time allocated buffer. 42240 // 42241 // In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL 42242 // macros become no-ops and have zero performance impact. 42243 42244 // The following macros are used to suppress compiler warnings and to 42245 // make it clear to human readers when a function parameter is deliberately 42246 // left unused within the body of a function. This usually happens when 42247 // a function is called via a function pointer. For example the 42248 // implementation of an SQL aggregate step callback may not use the 42249 // parameter indicating the number of arguments passed to the aggregate, 42250 // if it knows that this is enforced elsewhere. 42251 // 42252 // When a function parameter is not used at all within the body of a function, 42253 // it is generally named "NotUsed" or "NotUsed2" to make things even clearer. 42254 // However, these macros may also be used to suppress warnings related to 42255 // parameters that may or may not be used depending on compilation options. 42256 // For example those parameters only used in assert() statements. In these 42257 // cases the parameters are named as per the usual conventions. 42258 42259 // Forward references to structures 42260 type AggInfo = AggInfo1 /* sqliteInt.h:1133:24 */ 42261 type AuthContext1 = struct { 42262 FzAuthContext uintptr 42263 FpParse uintptr 42264 } /* sqliteInt.h:1134:9 */ 42265 42266 type AuthContext = AuthContext1 /* sqliteInt.h:1134:28 */ 42267 type AutoincInfo1 = struct { 42268 FpNext uintptr 42269 FpTab uintptr 42270 FiDb int32 42271 FregCtr int32 42272 } /* sqlite3.h:249:9 */ 42273 42274 type AutoincInfo = AutoincInfo1 /* sqliteInt.h:1135:28 */ 42275 type CollSeq1 = struct { 42276 FzName uintptr 42277 Fenc u8 42278 _ [7]byte 42279 FpUser uintptr 42280 FxCmp uintptr 42281 FxDel uintptr 42282 } /* sqlite3.h:249:9 */ 42283 42284 type CollSeq = CollSeq1 /* sqliteInt.h:1137:24 */ 42285 type Column1 = struct { 42286 FzName uintptr 42287 FpDflt uintptr 42288 FzColl uintptr 42289 FnotNull u8 42290 Faffinity int8 42291 FszEst u8 42292 FhName u8 42293 FcolFlags u16 42294 _ [2]byte 42295 } /* sqlite3.h:249:9 */ 42296 42297 type Column = Column1 /* sqliteInt.h:1138:23 */ 42298 type Cte1 = struct { 42299 FzName uintptr 42300 FpCols uintptr 42301 FpSelect uintptr 42302 FzCteErr uintptr 42303 FpUse uintptr 42304 FeM10d u8 42305 _ [7]byte 42306 } /* sqlite3.h:249:9 */ 42307 42308 type Cte = Cte1 /* sqliteInt.h:1139:20 */ 42309 type CteUse1 = struct { 42310 FnUse int32 42311 FaddrM9e int32 42312 FregRtn int32 42313 FiCur int32 42314 FnRowEst LogEst 42315 FeM10d u8 42316 _ [1]byte 42317 } /* sqlite3.h:249:9 */ 42318 42319 type CteUse = CteUse1 /* sqliteInt.h:1140:23 */ 42320 type Db1 = struct { 42321 FzDbSName uintptr 42322 FpBt uintptr 42323 Fsafety_level u8 42324 FbSyncSet u8 42325 _ [6]byte 42326 FpSchema uintptr 42327 } /* sqlite3.h:249:9 */ 42328 42329 type Db = Db1 /* sqliteInt.h:1141:19 */ 42330 type DbFixer1 = struct { 42331 FpParse uintptr 42332 Fw Walker 42333 FpSchema uintptr 42334 FbTemp u8 42335 _ [7]byte 42336 FzDb uintptr 42337 FzType uintptr 42338 FpName uintptr 42339 } /* sqliteInt.h:1142:9 */ 42340 42341 type DbFixer = DbFixer1 /* sqliteInt.h:1142:24 */ 42342 type Schema1 = struct { 42343 Fschema_cookie int32 42344 FiGeneration int32 42345 FtblHash Hash 42346 FidxHash Hash 42347 FtrigHash Hash 42348 FfkeyHash Hash 42349 FpSeqTab uintptr 42350 Ffile_format u8 42351 Fenc u8 42352 FschemaFlags u16 42353 Fcache_size int32 42354 } /* sqlite3.h:249:9 */ 42355 42356 type Schema = Schema1 /* sqliteInt.h:1143:23 */ 42357 type Expr1 = struct { 42358 Fop u8 42359 FaffExpr int8 42360 Fop2 u8 42361 _ [1]byte 42362 Fflags u322 42363 Fu struct{ FzToken uintptr } 42364 FpLeft uintptr 42365 FpRight uintptr 42366 Fx struct{ FpList uintptr } 42367 FnHeight int32 42368 FiTable int32 42369 FiColumn ynVar 42370 FiAgg i16 42371 FiRightJoinTable int32 42372 FpAggInfo uintptr 42373 Fy struct{ FpTab uintptr } 42374 } /* sqlite3.h:249:9 */ 42375 42376 type Expr = Expr1 /* sqliteInt.h:1144:21 */ 42377 type ExprList1 = struct { 42378 FnExpr int32 42379 _ [4]byte 42380 Fa [1]struct { 42381 FpExpr uintptr 42382 FzEName uintptr 42383 FsortFlags u8 42384 _ [3]byte 42385 FeEName uint8 /* unsigned eEName: 2, unsigned done: 1, unsigned reusable: 1, unsigned bSorterRef: 1, unsigned bNulls: 1 */ 42386 _ [3]byte 42387 Fu struct { 42388 _ [0]uint32 42389 Fx struct { 42390 FiOrderByCol u16 42391 FiAlias u16 42392 } 42393 } 42394 _ [4]byte 42395 } 42396 } /* sqlite3.h:249:9 */ 42397 42398 type ExprList = ExprList1 /* sqliteInt.h:1145:25 */ 42399 type FKey1 = struct { 42400 FpFrom uintptr 42401 FpNextFrom uintptr 42402 FzTo uintptr 42403 FpNextTo uintptr 42404 FpPrevTo uintptr 42405 FnCol int32 42406 FisDeferred u8 42407 FaAction [2]u8 42408 _ [1]byte 42409 FapTrigger [2]uintptr 42410 FaCol [1]struct { 42411 FiFrom int32 42412 _ [4]byte 42413 FzCol uintptr 42414 } 42415 } /* sqlite3.h:249:9 */ 42416 42417 type FKey = FKey1 /* sqliteInt.h:1146:21 */ 42418 type FuncDestructor1 = struct { 42419 FnRef int32 42420 _ [4]byte 42421 FxDestroy uintptr 42422 FpUserData uintptr 42423 } /* sqliteInt.h:1147:9 */ 42424 42425 type FuncDestructor = FuncDestructor1 /* sqliteInt.h:1147:31 */ 42426 type FuncDef1 = struct { 42427 FnArg i8 42428 _ [3]byte 42429 FfuncFlags u322 42430 FpUserData uintptr 42431 FpNext uintptr 42432 FxSFunc uintptr 42433 FxFinalize uintptr 42434 FxValue uintptr 42435 FxInverse uintptr 42436 FzName uintptr 42437 Fu struct{ FpHash uintptr } 42438 } /* sqlite3.h:249:9 */ 42439 42440 type FuncDef = FuncDef1 /* sqliteInt.h:1148:24 */ 42441 type FuncDefHash1 = struct{ Fa [23]uintptr } /* sqliteInt.h:1149:9 */ 42442 42443 type FuncDefHash = FuncDefHash1 /* sqliteInt.h:1149:28 */ 42444 type IdList1 = struct { 42445 Fa uintptr 42446 FnId int32 42447 _ [4]byte 42448 } /* sqlite3.h:249:9 */ 42449 42450 type IdList = IdList1 /* sqliteInt.h:1150:23 */ 42451 type Index1 = struct { 42452 FzName uintptr 42453 FaiColumn uintptr 42454 FaiRowLogEst uintptr 42455 FpTable uintptr 42456 FzColAff uintptr 42457 FpNext uintptr 42458 FpSchema uintptr 42459 FaSortOrder uintptr 42460 FazColl uintptr 42461 FpPartIdxWhere uintptr 42462 FaColExpr uintptr 42463 Ftnum Pgno 42464 FszIdxRow LogEst 42465 FnKeyCol u16 42466 FnColumn u16 42467 FonError u8 42468 _ [1]byte 42469 FidxType uint16 /* unsigned idxType: 2, unsigned bUnordered: 1, unsigned uniqNotNull: 1, unsigned isResized: 1, unsigned isCovering: 1, unsigned noSkipScan: 1, unsigned hasStat1: 1, unsigned bNoQuery: 1, unsigned bAscKeyBug: 1, unsigned bHasVCol: 1 */ 42470 _ [2]byte 42471 FnSample int32 42472 FnSampleCol int32 42473 FaAvgEq uintptr 42474 FaSample uintptr 42475 FaiRowEst uintptr 42476 FnRowEst0 tRowcnt 42477 _ [4]byte 42478 FcolNotIdxed Bitmask 42479 } /* sqlite3.h:249:9 */ 42480 42481 type Index = Index1 /* sqliteInt.h:1151:22 */ 42482 type IndexSample1 = struct { 42483 Fp uintptr 42484 Fn int32 42485 _ [4]byte 42486 FanEq uintptr 42487 FanLt uintptr 42488 FanDLt uintptr 42489 } /* sqlite3.h:249:9 */ 42490 42491 type IndexSample = IndexSample1 /* sqliteInt.h:1152:28 */ 42492 type KeyInfo1 = struct { 42493 FnRef u322 42494 Fenc u8 42495 _ [1]byte 42496 FnKeyField u16 42497 FnAllField u16 42498 _ [6]byte 42499 Fdb uintptr 42500 FaSortFlags uintptr 42501 FaColl [1]uintptr 42502 } /* sqlite3.h:249:9 */ 42503 42504 type KeyInfo = KeyInfo1 /* sqliteInt.h:1154:24 */ 42505 type Lookaside1 = struct { 42506 FbDisable u322 42507 Fsz u16 42508 FszTrue u16 42509 FbMalloced u8 42510 _ [3]byte 42511 FnSlot u322 42512 FanStat [3]u322 42513 _ [4]byte 42514 FpInit uintptr 42515 FpFree uintptr 42516 FpSmallInit uintptr 42517 FpSmallFree uintptr 42518 FpMiddle uintptr 42519 FpStart uintptr 42520 FpEnd uintptr 42521 } /* sqlite3.h:249:9 */ 42522 42523 type Lookaside = Lookaside1 /* sqliteInt.h:1155:26 */ 42524 type LookasideSlot1 = struct{ FpNext uintptr } /* sqlite3.h:249:9 */ 42525 42526 type LookasideSlot = LookasideSlot1 /* sqliteInt.h:1156:30 */ 42527 type Module1 = struct { 42528 FpModule uintptr 42529 FzName uintptr 42530 FnRefModule int32 42531 _ [4]byte 42532 FpAux uintptr 42533 FxDestroy uintptr 42534 FpEpoTab uintptr 42535 } /* sqlite3.h:249:9 */ 42536 42537 type Module = Module1 /* sqliteInt.h:1157:23 */ 42538 type NameContext1 = struct { 42539 FpParse uintptr 42540 FpSrcList uintptr 42541 FuNC struct{ FpEList uintptr } 42542 FpNext uintptr 42543 FnRef int32 42544 FnErr int32 42545 FncFlags int32 42546 _ [4]byte 42547 FpWinSelect uintptr 42548 } /* sqliteInt.h:1158:9 */ 42549 42550 type NameContext = NameContext1 /* sqliteInt.h:1158:28 */ 42551 type Parse1 = struct { 42552 Fdb uintptr 42553 FzErrMsg uintptr 42554 FpVdbe uintptr 42555 Frc int32 42556 FcolNamesSet u8 42557 FcheckSchema u8 42558 Fnested u8 42559 FnTempReg u8 42560 FisMultiWrite u8 42561 FmayAbort u8 42562 FhasCompound u8 42563 FokConstFactor u8 42564 FdisableLookaside u8 42565 FdisableVtab u8 42566 _ [2]byte 42567 FnRangeReg int32 42568 FiRangeReg int32 42569 FnErr int32 42570 FnTab int32 42571 FnMem int32 42572 FszOpAlloc int32 42573 FiSelfTab int32 42574 FnLabel int32 42575 FnLabelAlloc int32 42576 _ [4]byte 42577 FaLabel uintptr 42578 FpConstExpr uintptr 42579 FconstraintName Token 42580 FwriteMask yDbMask 42581 FcookieMask yDbMask 42582 FregRowid int32 42583 FregRoot int32 42584 FnMaxArg int32 42585 FnSelect int32 42586 FnTableLock int32 42587 _ [4]byte 42588 FaTableLock uintptr 42589 FpAinc uintptr 42590 FpToplevel uintptr 42591 FpTriggerTab uintptr 42592 FpParentParse uintptr 42593 Fu1 struct { 42594 _ [0]uint64 42595 FaddrCrTab int32 42596 _ [4]byte 42597 } 42598 FnQueryLoop u322 42599 Foldmask u322 42600 Fnewmask u322 42601 FeTriggerOp u8 42602 FbReturning u8 42603 FeOrconf u8 42604 FdisableTriggers u8 42605 FaTempReg [8]int32 42606 FsNameToken Token 42607 FsLastToken Token 42608 FnVar ynVar 42609 FiPkSortOrder u8 42610 Fexplain u8 42611 FeParseMode u8 42612 _ [3]byte 42613 FnVtabLock int32 42614 FnHeight int32 42615 FaddrExplain int32 42616 _ [4]byte 42617 FpVList uintptr 42618 FpReprepare uintptr 42619 FzTail uintptr 42620 FpNewTable uintptr 42621 FpNewIndex uintptr 42622 FpNewTrigger uintptr 42623 FzAuthContext uintptr 42624 FsArg Token 42625 FapVtabLock uintptr 42626 FpTriggerPrg uintptr 42627 FpWith uintptr 42628 FpCleanup uintptr 42629 FpRename uintptr 42630 } /* sqlite3.h:249:9 */ 42631 42632 type Parse = Parse1 /* sqliteInt.h:1159:22 */ 42633 type ParseCleanup1 = struct { 42634 FpNext uintptr 42635 FpPtr uintptr 42636 FxCleanup uintptr 42637 } /* sqlite3.h:249:9 */ 42638 42639 type ParseCleanup = ParseCleanup1 /* sqliteInt.h:1160:29 */ 42640 type PreUpdate1 = struct { 42641 Fv uintptr 42642 FpCsr uintptr 42643 Fop int32 42644 _ [4]byte 42645 FaRecord uintptr 42646 Fkeyinfo KeyInfo 42647 FpUnpacked uintptr 42648 FpNewUnpacked uintptr 42649 FiNewReg int32 42650 _ [4]byte 42651 FiKey1 i64 42652 FiKey2 i64 42653 FaNew uintptr 42654 FpTab uintptr 42655 FpPk uintptr 42656 } /* sqlite3.h:249:9 */ 42657 42658 type PreUpdate = PreUpdate1 /* sqliteInt.h:1161:26 */ 42659 type PrintfArguments1 = struct { 42660 FnArg int32 42661 FnUsed int32 42662 FapArg uintptr 42663 } /* sqliteInt.h:1162:9 */ 42664 42665 type PrintfArguments = PrintfArguments1 /* sqliteInt.h:1162:32 */ 42666 type Returning1 = struct { 42667 FpParse uintptr 42668 FpReturnEL uintptr 42669 FretTrig Trigger 42670 FretTStep TriggerStep 42671 FiRetCur int32 42672 FnRetCol int32 42673 FiRetReg int32 42674 _ [4]byte 42675 } /* sqliteInt.h:1164:9 */ 42676 42677 type Returning = Returning1 /* sqliteInt.h:1164:26 */ 42678 type Savepoint1 = struct { 42679 FzName uintptr 42680 FnDeferredCons i64 42681 FnDeferredImmCons i64 42682 FpNext uintptr 42683 } /* sqlite3.h:249:9 */ 42684 42685 type Savepoint = Savepoint1 /* sqliteInt.h:1166:26 */ 42686 type Select1 = struct { 42687 Fop u8 42688 _ [1]byte 42689 FnSelectRow LogEst 42690 FselFlags u322 42691 FiLimit int32 42692 FiOffset int32 42693 FselId u322 42694 FaddrOpenEphm [2]int32 42695 _ [4]byte 42696 FpEList uintptr 42697 FpSrc uintptr 42698 FpWhere uintptr 42699 FpGroupBy uintptr 42700 FpHaving uintptr 42701 FpOrderBy uintptr 42702 FpPrior uintptr 42703 FpNext uintptr 42704 FpLimit uintptr 42705 FpWith uintptr 42706 FpWin uintptr 42707 FpWinDefn uintptr 42708 } /* sqlite3.h:249:9 */ 42709 42710 type Select = Select1 /* sqliteInt.h:1167:23 */ 42711 type SelectDest1 = struct { 42712 FeDest u8 42713 _ [3]byte 42714 FiSDParm int32 42715 FiSDParm2 int32 42716 FiSdst int32 42717 FnSdst int32 42718 _ [4]byte 42719 FzAffSdst uintptr 42720 FpOrderBy uintptr 42721 } /* sqliteInt.h:1169:9 */ 42722 42723 type SelectDest = SelectDest1 /* sqliteInt.h:1169:27 */ 42724 type SrcItem1 = struct { 42725 FpSchema uintptr 42726 FzDatabase uintptr 42727 FzName uintptr 42728 FzAlias uintptr 42729 FpTab uintptr 42730 FpSelect uintptr 42731 FaddrFillSub int32 42732 FregReturn int32 42733 FregResult int32 42734 Ffg struct { 42735 _ [0]uint32 42736 Fjointype u8 42737 _ [3]byte 42738 FnotIndexed uint8 /* unsigned notIndexed: 1, unsigned isIndexedBy: 1, unsigned isTabFunc: 1, unsigned isCorrelated: 1, unsigned viaCoroutine: 1, unsigned isRecursive: 1, unsigned fromDDL: 1, unsigned isCte: 1 */ 42739 _ [3]byte 42740 } 42741 FiCursor int32 42742 FpOn uintptr 42743 FpUsing uintptr 42744 FcolUsed Bitmask 42745 Fu1 struct{ FzIndexedBy uintptr } 42746 Fu2 struct{ FpIBIndex uintptr } 42747 } /* sqlite3.h:249:9 */ 42748 42749 type SrcItem = SrcItem1 /* sqliteInt.h:1170:24 */ 42750 type SrcList1 = struct { 42751 FnSrc int32 42752 FnAlloc u322 42753 Fa [1]SrcItem 42754 } /* sqlite3.h:249:9 */ 42755 42756 type SrcList = SrcList1 /* sqliteInt.h:1171:24 */ 42757 type StrAccum = sqlite3_str1 /* sqliteInt.h:1172:28 */ // Internal alias for sqlite3_str 42758 type Table1 = struct { 42759 FzName uintptr 42760 FaCol uintptr 42761 FpIndex uintptr 42762 FpSelect uintptr 42763 FpFKey uintptr 42764 FzColAff uintptr 42765 FpCheck uintptr 42766 Ftnum Pgno 42767 FnTabRef u322 42768 FtabFlags u322 42769 FiPKey i16 42770 FnCol i16 42771 FnNVCol i16 42772 FnRowLogEst LogEst 42773 FszTabRow LogEst 42774 FkeyConf u8 42775 _ [1]byte 42776 FaddColOffset int32 42777 FnModuleArg int32 42778 FazModuleArg uintptr 42779 FpVTable uintptr 42780 FpTrigger uintptr 42781 FpSchema uintptr 42782 } /* sqlite3.h:249:9 */ 42783 42784 // Internal alias for sqlite3_str 42785 type Table = Table1 /* sqliteInt.h:1173:22 */ 42786 type Token1 = struct { 42787 Fz uintptr 42788 Fn uint32 42789 _ [4]byte 42790 } /* sqlite3.h:249:9 */ 42791 42792 type Token = Token1 /* sqliteInt.h:1175:22 */ 42793 type Trigger1 = struct { 42794 FzName uintptr 42795 Ftable uintptr 42796 Fop u8 42797 Ftr_tm u8 42798 FbReturning u8 42799 _ [5]byte 42800 FpWhen uintptr 42801 FpColumns uintptr 42802 FpSchema uintptr 42803 FpTabSchema uintptr 42804 Fstep_list uintptr 42805 FpNext uintptr 42806 } /* sqlite3.h:249:9 */ 42807 42808 type Trigger = Trigger1 /* sqliteInt.h:1177:24 */ 42809 type TriggerPrg1 = struct { 42810 FpTrigger uintptr 42811 FpNext uintptr 42812 FpProgram uintptr 42813 Forconf int32 42814 FaColmask [2]u322 42815 _ [4]byte 42816 } /* sqlite3.h:249:9 */ 42817 42818 type TriggerPrg = TriggerPrg1 /* sqliteInt.h:1178:27 */ 42819 type TriggerStep1 = struct { 42820 Fop u8 42821 Forconf u8 42822 _ [6]byte 42823 FpTrig uintptr 42824 FpSelect uintptr 42825 FzTarget uintptr 42826 FpFrom uintptr 42827 FpWhere uintptr 42828 FpExprList uintptr 42829 FpIdList uintptr 42830 FpUpsert uintptr 42831 FzSpan uintptr 42832 FpNext uintptr 42833 FpLast uintptr 42834 } /* sqlite3.h:249:9 */ 42835 42836 type TriggerStep = TriggerStep1 /* sqliteInt.h:1179:28 */ 42837 type UnpackedRecord1 = struct { 42838 FpKeyInfo uintptr 42839 FaMem uintptr 42840 FnField u16 42841 Fdefault_rc i8 42842 FerrCode u8 42843 Fr1 i8 42844 Fr2 i8 42845 FeqSeen u8 42846 _ [1]byte 42847 } /* sqlite3.h:249:9 */ 42848 42849 type UnpackedRecord = UnpackedRecord1 /* sqliteInt.h:1180:31 */ 42850 type Upsert1 = struct { 42851 FpUpsertTarget uintptr 42852 FpUpsertTargetWhere uintptr 42853 FpUpsertSet uintptr 42854 FpUpsertWhere uintptr 42855 FpNextUpsert uintptr 42856 FisDoUpdate u8 42857 _ [7]byte 42858 FpToFree uintptr 42859 FpUpsertIdx uintptr 42860 FpUpsertSrc uintptr 42861 FregData int32 42862 FiDataCur int32 42863 FiIdxCur int32 42864 _ [4]byte 42865 } /* sqlite3.h:249:9 */ 42866 42867 type Upsert = Upsert1 /* sqliteInt.h:1181:23 */ 42868 type VTable1 = struct { 42869 Fdb uintptr 42870 FpMod uintptr 42871 FpVtab uintptr 42872 FnRef int32 42873 FbConstraint u8 42874 FeVtabRisk u8 42875 _ [2]byte 42876 FiSavepoint int32 42877 _ [4]byte 42878 FpNext uintptr 42879 } /* sqlite3.h:249:9 */ 42880 42881 type VTable = VTable1 /* sqliteInt.h:1182:23 */ 42882 type Walker1 = struct { 42883 FpParse uintptr 42884 FxExprCallback uintptr 42885 FxSelectCallback uintptr 42886 FxSelectCallback2 uintptr 42887 FwalkerDepth int32 42888 FeCode u16 42889 _ [2]byte 42890 Fu struct{ FpNC uintptr } 42891 } /* sqliteInt.h:1142:9 */ 42892 42893 type Walker = Walker1 /* sqliteInt.h:1184:23 */ 42894 type Window1 = struct { 42895 FzName uintptr 42896 FzBase uintptr 42897 FpPartition uintptr 42898 FpOrderBy uintptr 42899 FeFrmType u8 42900 FeStart u8 42901 FeEnd u8 42902 FbImplicitFrame u8 42903 FeExclude u8 42904 _ [3]byte 42905 FpStart uintptr 42906 FpEnd uintptr 42907 FppThis uintptr 42908 FpNextWin uintptr 42909 FpFilter uintptr 42910 FpFunc uintptr 42911 FiEphCsr int32 42912 FregAccum int32 42913 FregResult int32 42914 FcsrApp int32 42915 FregApp int32 42916 FregPart int32 42917 FpOwner uintptr 42918 FnBufferCol int32 42919 FiArgCol int32 42920 FregOne int32 42921 FregStartRowid int32 42922 FregEndRowid int32 42923 FbExprArgs u8 42924 _ [3]byte 42925 } /* sqlite3.h:249:9 */ 42926 42927 type Window = Window1 /* sqliteInt.h:1186:23 */ 42928 type With1 = struct { 42929 FnCte int32 42930 _ [4]byte 42931 FpOuter uintptr 42932 Fa [1]Cte 42933 } /* sqlite3.h:249:9 */ 42934 42935 type With = With1 /* sqliteInt.h:1187:21 */ 42936 42937 // The bitmask datatype defined below is used for various optimizations. 42938 // 42939 // Changing this from a 64-bit to a 32-bit type limits the number of 42940 // tables in a join to 32 instead of 64. But it also reduces the size 42941 // of the library by 738 bytes on ix86. 42942 type Bitmask = u64 /* sqliteInt.h:1200:15 */ 42943 42944 // The number of bits in a Bitmask. "BMS" means "BitMask Size". 42945 42946 // A bit in a Bitmask 42947 42948 // A VList object records a mapping between parameters/variables/wildcards 42949 // in the SQL statement (such as $abc, @pqr, or :xyz) and the integer 42950 // variable number associated with that parameter. See the format description 42951 // on the sqlite3VListAdd() routine for more information. A VList is really 42952 // just an array of integers. 42953 type VList = int32 /* sqliteInt.h:1222:13 */ 42954 42955 // Defer sourcing vdbe.h and btree.h until after the "u8" and 42956 // "BusyHandler" typedefs. vdbe.h also requires a few of the opaque 42957 // pointer types (i.e. FuncDef) defined above. 42958 // 2001 September 15 42959 // 42960 // The author disclaims copyright to this source code. In place of 42961 // a legal notice, here is a blessing: 42962 // 42963 // May you do good and not evil. 42964 // May you find forgiveness for yourself and forgive others. 42965 // May you share freely, never taking more than you give. 42966 // 42967 // 42968 // This header file defines the interface that the sqlite page cache 42969 // subsystem. The page cache subsystem reads and writes a file a page 42970 // at a time and provides a journal for rollback. 42971 42972 // Default maximum size for persistent journal files. A negative 42973 // value means no limit. This value may be overridden using the 42974 // sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit". 42975 42976 // The type used to represent a page number. The first page in a file 42977 // is called page 1. 0 is used to represent "not a page". 42978 type Pgno = u322 /* pager.h:33:13 */ 42979 42980 // Handle type for pages. 42981 type PgHdr1 = struct { 42982 FpPage uintptr 42983 FpData uintptr 42984 FpExtra uintptr 42985 FpCache uintptr 42986 FpDirty uintptr 42987 FpPager uintptr 42988 Fpgno Pgno 42989 Fflags u16 42990 FnRef i16 42991 FpDirtyNext uintptr 42992 FpDirtyPrev uintptr 42993 } /* pager.h:43:9 */ 42994 42995 // Handle type for pages. 42996 type DbPage = PgHdr1 /* pager.h:43:22 */ 42997 42998 // 2001 September 15 42999 // 43000 // The author disclaims copyright to this source code. In place of 43001 // a legal notice, here is a blessing: 43002 // 43003 // May you do good and not evil. 43004 // May you find forgiveness for yourself and forgive others. 43005 // May you share freely, never taking more than you give. 43006 // 43007 // 43008 // This header file defines the interface that the sqlite B-Tree file 43009 // subsystem. See comments in the source code for a detailed description 43010 // of what each interface routine does. 43011 43012 // TODO: This definition is just included so other modules compile. It 43013 // needs to be revisited. 43014 43015 // If defined as non-zero, auto-vacuum is enabled by default. Otherwise 43016 // it must be turned on for each database using "PRAGMA auto_vacuum = 1". 43017 43018 // Forward declarations of structure 43019 type Btree1 = struct { 43020 Fdb uintptr 43021 FpBt uintptr 43022 FinTrans u8 43023 Fsharable u8 43024 Flocked u8 43025 FhasIncrblobCur u8 43026 FwantToLock int32 43027 FnBackup int32 43028 FiBDataVersion u322 43029 FpNext uintptr 43030 FpPrev uintptr 43031 Flock BtLock 43032 } /* btree.h:39:9 */ 43033 43034 type BtCursor1 = struct { 43035 FeState u8 43036 FcurFlags u8 43037 FcurPagerFlags u8 43038 Fhints u8 43039 FskipNext int32 43040 FpBtree uintptr 43041 FaOverflow uintptr 43042 FpKey uintptr 43043 FpBt uintptr 43044 FpNext uintptr 43045 Finfo CellInfo 43046 FnKey i64 43047 FpgnoRoot Pgno 43048 FiPage i8 43049 FcurIntKey u8 43050 Fix u16 43051 FaiIdx [19]u16 43052 _ [2]byte 43053 FpKeyInfo uintptr 43054 FpPage uintptr 43055 FapPage [19]uintptr 43056 } /* btree.h:39:9 */ 43057 43058 type BtShared1 = struct { 43059 FpPager uintptr 43060 Fdb uintptr 43061 FpCursor uintptr 43062 FpPage1 uintptr 43063 FopenFlags u8 43064 FautoVacuum u8 43065 FincrVacuum u8 43066 FbDoTruncate u8 43067 FinTransaction u8 43068 Fmax1bytePayload u8 43069 FnReserveWanted u8 43070 _ [1]byte 43071 FbtsFlags u16 43072 FmaxLocal u16 43073 FminLocal u16 43074 FmaxLeaf u16 43075 FminLeaf u16 43076 _ [2]byte 43077 FpageSize u322 43078 FusableSize u322 43079 FnTransaction int32 43080 FnPage u322 43081 _ [4]byte 43082 FpSchema uintptr 43083 FxFreeSchema uintptr 43084 Fmutex uintptr 43085 FpHasContent uintptr 43086 FnRef int32 43087 _ [4]byte 43088 FpNext uintptr 43089 FpLock uintptr 43090 FpWriter uintptr 43091 FpTmpSpace uintptr 43092 FnPreformatSize int32 43093 _ [4]byte 43094 } /* btree.h:39:9 */ 43095 43096 type BtreePayload1 = struct { 43097 FpKey uintptr 43098 FnKey sqlite3_int64 43099 FpData uintptr 43100 FaMem uintptr 43101 FnMem u16 43102 _ [2]byte 43103 FnData int32 43104 FnZero int32 43105 _ [4]byte 43106 } /* btree.h:42:9 */ 43107 43108 type BtreePayload = BtreePayload1 /* btree.h:42:29 */ 43109 43110 // 2001 September 15 43111 // 43112 // The author disclaims copyright to this source code. In place of 43113 // a legal notice, here is a blessing: 43114 // 43115 // May you do good and not evil. 43116 // May you find forgiveness for yourself and forgive others. 43117 // May you share freely, never taking more than you give. 43118 // 43119 // 43120 // Header file for the Virtual DataBase Engine (VDBE) 43121 // 43122 // This header defines the interface to the virtual database engine 43123 // or VDBE. The VDBE implements an abstract machine that runs a 43124 // simple program to access and modify the underlying database. 43125 // Define ISO C stdio on top of C++ iostreams. 43126 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 43127 // This file is part of the GNU C Library. 43128 // 43129 // The GNU C Library is free software; you can redistribute it and/or 43130 // modify it under the terms of the GNU Lesser General Public 43131 // License as published by the Free Software Foundation; either 43132 // version 2.1 of the License, or (at your option) any later version. 43133 // 43134 // The GNU C Library is distributed in the hope that it will be useful, 43135 // but WITHOUT ANY WARRANTY; without even the implied warranty of 43136 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 43137 // Lesser General Public License for more details. 43138 // 43139 // You should have received a copy of the GNU Lesser General Public 43140 // License along with the GNU C Library; if not, see 43141 // <http://www.gnu.org/licenses/>. 43142 43143 // ISO C99 Standard: 7.19 Input/output <stdio.h> 43144 43145 // A single VDBE is an opaque structure named "Vdbe". Only routines 43146 // in the source file sqliteVdbe.c are allowed to see the insides 43147 // of this structure. 43148 type Vdbe1 = struct { 43149 Fdb uintptr 43150 FpPrev uintptr 43151 FpNext uintptr 43152 FpParse uintptr 43153 FnVar ynVar 43154 _ [2]byte 43155 FiVdbeMagic u322 43156 FnMem int32 43157 FnCursor int32 43158 FcacheCtr u322 43159 Fpc int32 43160 Frc int32 43161 FnChange int32 43162 FiStatement int32 43163 _ [4]byte 43164 FiCurrentTime i64 43165 FnFkConstraint i64 43166 FnStmtDefCons i64 43167 FnStmtDefImmCons i64 43168 FaMem uintptr 43169 FapArg uintptr 43170 FapCsr uintptr 43171 FaVar uintptr 43172 FaOp uintptr 43173 FnOp int32 43174 FnOpAlloc int32 43175 FaColName uintptr 43176 FpResultSet uintptr 43177 FzErrMsg uintptr 43178 FpVList uintptr 43179 FstartTime i64 43180 FnResColumn u16 43181 FerrorAction u8 43182 FminWriteFileFormat u8 43183 FprepFlags u8 43184 FdoingRerun u8 43185 _ [2]byte 43186 Fexpired uint16 /* bft expired: 2, bft explain: 2, bft changeCntOn: 1, bft runOnlyOnce: 1, bft usesStmtJournal: 1, bft readOnly: 1, bft bIsReader: 1 */ 43187 _ [2]byte 43188 FbtreeMask yDbMask 43189 FlockMask yDbMask 43190 FaCounter [7]u322 43191 FzSql uintptr 43192 FpFree uintptr 43193 FpFrame uintptr 43194 FpDelFrame uintptr 43195 FnFrame int32 43196 Fexpmask u322 43197 FpProgram uintptr 43198 FpAuxData uintptr 43199 } /* sqlite3.h:249:9 */ 43200 43201 // 2001 September 15 43202 // 43203 // The author disclaims copyright to this source code. In place of 43204 // a legal notice, here is a blessing: 43205 // 43206 // May you do good and not evil. 43207 // May you find forgiveness for yourself and forgive others. 43208 // May you share freely, never taking more than you give. 43209 // 43210 // 43211 // Header file for the Virtual DataBase Engine (VDBE) 43212 // 43213 // This header defines the interface to the virtual database engine 43214 // or VDBE. The VDBE implements an abstract machine that runs a 43215 // simple program to access and modify the underlying database. 43216 // Define ISO C stdio on top of C++ iostreams. 43217 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 43218 // This file is part of the GNU C Library. 43219 // 43220 // The GNU C Library is free software; you can redistribute it and/or 43221 // modify it under the terms of the GNU Lesser General Public 43222 // License as published by the Free Software Foundation; either 43223 // version 2.1 of the License, or (at your option) any later version. 43224 // 43225 // The GNU C Library is distributed in the hope that it will be useful, 43226 // but WITHOUT ANY WARRANTY; without even the implied warranty of 43227 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 43228 // Lesser General Public License for more details. 43229 // 43230 // You should have received a copy of the GNU Lesser General Public 43231 // License along with the GNU C Library; if not, see 43232 // <http://www.gnu.org/licenses/>. 43233 43234 // ISO C99 Standard: 7.19 Input/output <stdio.h> 43235 43236 // A single VDBE is an opaque structure named "Vdbe". Only routines 43237 // in the source file sqliteVdbe.c are allowed to see the insides 43238 // of this structure. 43239 type Vdbe = Vdbe1 /* vdbe.h:27:21 */ 43240 43241 // The names of the following types declared in vdbeInt.h are required 43242 // for the VdbeOp definition. 43243 type Mem = sqlite3_value1 /* vdbe.h:33:30 */ 43244 type SubProgram1 = struct { 43245 FaOp uintptr 43246 FnOp int32 43247 FnMem int32 43248 FnCsr int32 43249 _ [4]byte 43250 FaOnce uintptr 43251 Ftoken uintptr 43252 FpNext uintptr 43253 } /* sqlite3.h:249:9 */ 43254 43255 type SubProgram = SubProgram1 /* vdbe.h:34:27 */ 43256 43257 // A single instruction of the virtual machine has an opcode 43258 // and as many as three operands. The instruction is recorded 43259 // as an instance of the following structure: 43260 type VdbeOp1 = struct { 43261 Fopcode u8 43262 Fp4type int8 43263 Fp5 u16 43264 Fp1 int32 43265 Fp2 int32 43266 Fp3 int32 43267 Fp4 struct { 43268 _ [0]uint64 43269 Fi int32 43270 _ [4]byte 43271 } 43272 FzComment uintptr 43273 } /* sqlite3.h:249:9 */ 43274 43275 // A single instruction of the virtual machine has an opcode 43276 // and as many as three operands. The instruction is recorded 43277 // as an instance of the following structure: 43278 type p4union = struct { 43279 _ [0]uint64 43280 Fi int32 43281 _ [4]byte 43282 } /* sqlite3.h:249:9 */ 43283 43284 type VdbeOp = VdbeOp1 /* vdbe.h:80:23 */ 43285 43286 // A smaller version of VdbeOp used for the VdbeAddOpList() function because 43287 // it takes up less space. 43288 type VdbeOpList1 = struct { 43289 Fopcode u8 43290 Fp1 int8 43291 Fp2 int8 43292 Fp3 int8 43293 } /* vdbe.h:100:1 */ 43294 43295 type VdbeOpList = VdbeOpList1 /* vdbe.h:106:27 */ 43296 43297 type RecordCompare = uintptr /* vdbe.h:286:13 */ 43298 43299 // The VdbeCoverage macros are used to set a coverage testing point 43300 // for VDBE branch instructions. The coverage testing points are line 43301 // numbers in the sqlite3.c source file. VDBE branch coverage testing 43302 // only works with an amalagmation build. That's ok since a VDBE branch 43303 // coverage build designed for testing the test suite only. No application 43304 // should ever ship with VDBE branch coverage measuring turned on. 43305 // 43306 // VdbeCoverage(v) // Mark the previously coded instruction 43307 // // as a branch 43308 // 43309 // VdbeCoverageIf(v, conditional) // Mark previous if conditional true 43310 // 43311 // VdbeCoverageAlwaysTaken(v) // Previous branch is always taken 43312 // 43313 // VdbeCoverageNeverTaken(v) // Previous branch is never taken 43314 // 43315 // VdbeCoverageNeverNull(v) // Previous three-way branch is only 43316 // // taken on the first two ways. The 43317 // // NULL option is not possible 43318 // 43319 // VdbeCoverageEqNe(v) // Previous OP_Jump is only interested 43320 // // in distingishing equal and not-equal. 43321 // 43322 // Every VDBE branch operation must be tagged with one of the macros above. 43323 // If not, then when "make test" is run with -DSQLITE_VDBE_COVERAGE and 43324 // -DSQLITE_DEBUG then an ALWAYS() will fail in the vdbeTakeBranch() 43325 // routine in vdbe.c, alerting the developer to the missed tag. 43326 // 43327 // During testing, the test application will invoke 43328 // sqlite3_test_control(SQLITE_TESTCTRL_VDBE_COVERAGE,...) to set a callback 43329 // routine that is invoked as each bytecode branch is taken. The callback 43330 // contains the sqlite3.c source line number ov the VdbeCoverage macro and 43331 // flags to indicate whether or not the branch was taken. The test application 43332 // is responsible for keeping track of this and reporting byte-code branches 43333 // that are never taken. 43334 // 43335 // See the VdbeBranchTaken() macro and vdbeTakeBranch() function in the 43336 // vdbe.c source file for additional information. 43337 43338 // 2008 August 05 43339 // 43340 // The author disclaims copyright to this source code. In place of 43341 // a legal notice, here is a blessing: 43342 // 43343 // May you do good and not evil. 43344 // May you find forgiveness for yourself and forgive others. 43345 // May you share freely, never taking more than you give. 43346 // 43347 // 43348 // This header file defines the interface that the sqlite page cache 43349 // subsystem. 43350 43351 type PgHdr = PgHdr1 /* pcache.h:18:22 */ 43352 43353 // typedef for the authorization callback function. 43354 type sqlite3_xauth = uintptr /* sqliteInt.h:1468:15 */ 43355 43356 // This is an extra SQLITE_TRACE macro that indicates "legacy" tracing 43357 // in the style of sqlite3_trace() 43358 43359 // Maximum number of sqlite3.aDb[] entries. This is the number of attached 43360 // databases plus 2 for "main" and "temp". 43361 43362 // Each database connection is an instance of the following structure. 43363 type sqlite3InitInfo = struct { 43364 FnewTnum Pgno 43365 FiDb u8 43366 Fbusy u8 43367 _ [2]byte 43368 ForphanTrigger uint8 /* unsigned orphanTrigger: 1, unsigned imposterTable: 1, unsigned reopenMemdb: 1, unsigned bDropColumn: 1 */ 43369 _ [7]byte 43370 FazInit uintptr 43371 } /* sqlite3.h:249:9 */ 43372 43373 // Allowed values for Table.tabFlags. 43374 // 43375 // TF_OOOHidden applies to tables or view that have hidden columns that are 43376 // followed by non-hidden columns. Example: "CREATE VIRTUAL TABLE x USING 43377 // vtab1(a HIDDEN, b);". Since "b" is a non-hidden column but "a" is hidden, 43378 // the TF_OOOHidden attribute would apply in this case. Such tables require 43379 // special handling during INSERT processing. The "OOO" means "Out Of Order". 43380 // 43381 // Constraints: 43382 // 43383 // TF_HasVirtual == COLFLAG_VIRTUAL 43384 // TF_HasStored == COLFLAG_STORED 43385 // TF_HasHidden == COLFLAG_HIDDEN 43386 43387 // Test to see whether or not a table is a virtual table. This is 43388 // done as a macro so that it will be optimized out when virtual 43389 // table support is omitted from the build. 43390 43391 // Macros to determine if a column is hidden. IsOrdinaryHiddenColumn() 43392 // only works for non-virtual tables (ordinary tables and views) and is 43393 // always false unless SQLITE_ENABLE_HIDDEN_COLUMNS is defined. The 43394 // IsHiddenColumn() macro is general purpose. 43395 43396 // Does the table have a rowid 43397 43398 // Each foreign key constraint is an instance of the following structure. 43399 // 43400 // A foreign key is associated with two tables. The "from" table is 43401 // the table that contains the REFERENCES clause that creates the foreign 43402 // key. The "to" table is the table that is named in the REFERENCES clause. 43403 // Consider this example: 43404 // 43405 // CREATE TABLE ex1( 43406 // a INTEGER PRIMARY KEY, 43407 // b INTEGER CONSTRAINT fk1 REFERENCES ex2(x) 43408 // ); 43409 // 43410 // For foreign key "fk1", the from-table is "ex1" and the to-table is "ex2". 43411 // Equivalent names: 43412 // 43413 // from-table == child-table 43414 // to-table == parent-table 43415 // 43416 // Each REFERENCES clause generates an instance of the following structure 43417 // which is attached to the from-table. The to-table need not exist when 43418 // the from-table is created. The existence of the to-table is not checked. 43419 // 43420 // The list of all parents for child Table X is held at X.pFKey. 43421 // 43422 // A list of all children for a table named Z (which might not even exist) 43423 // is held in Schema.fkeyHash with a hash key of Z. 43424 type sColMap = struct { 43425 FiFrom int32 43426 _ [4]byte 43427 FzCol uintptr 43428 } /* sqlite3.h:249:9 */ 43429 43430 // An instance of this structure contains information needed to generate 43431 // code for a SELECT that contains aggregate functions. 43432 // 43433 // If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a 43434 // pointer to this structure. The Expr.iAgg field is the index in 43435 // AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate 43436 // code for that node. 43437 // 43438 // AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the 43439 // original Select structure that describes the SELECT statement. These 43440 // fields do not need to be freed when deallocating the AggInfo structure. 43441 type AggInfo_col = struct { 43442 FpTab uintptr 43443 FpCExpr uintptr 43444 FiTable int32 43445 FiMem int32 43446 FiColumn i16 43447 FiSorterColumn i16 43448 _ [4]byte 43449 } /* sqlite3.h:249:9 */ 43450 43451 // An instance of this structure contains information needed to generate 43452 // code for a SELECT that contains aggregate functions. 43453 // 43454 // If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a 43455 // pointer to this structure. The Expr.iAgg field is the index in 43456 // AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate 43457 // code for that node. 43458 // 43459 // AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the 43460 // original Select structure that describes the SELECT statement. These 43461 // fields do not need to be freed when deallocating the AggInfo structure. 43462 type AggInfo_func = struct { 43463 FpFExpr uintptr 43464 FpFunc uintptr 43465 FiMem int32 43466 FiDistinct int32 43467 } /* sqlite3.h:249:9 */ 43468 43469 // The datatype ynVar is a signed integer, either 16-bit or 32-bit. 43470 // Usually it is 16-bits. But if SQLITE_MAX_VARIABLE_NUMBER is greater 43471 // than 32767 we have to make it 32-bit. 16-bit is preferred because 43472 // it uses less memory in the Expr object, which is a big memory user 43473 // in systems with lots of prepared statements. And few applications 43474 // need more than about 10 or 20 variables. But some extreme users want 43475 // to have prepared statements with over 32766 variables, and for them 43476 // the option is available (at compile-time). 43477 type ynVar = i16 /* sqliteInt.h:2625:13 */ 43478 43479 // The following are the meanings of bits in the Expr.flags field. 43480 // Value restrictions: 43481 // 43482 // EP_Agg == NC_HasAgg == SF_HasAgg 43483 // EP_Win == NC_HasWin 43484 // 0x400000 // Available 43485 // 0x80000000 // Available 43486 43487 // The EP_Propagate mask is a set of properties that automatically propagate 43488 // upwards into parent nodes. 43489 43490 // These macros can be used to test, set, or clear bits in the 43491 // Expr.flags field. 43492 43493 // Flags for use with Expr.vvaFlags 43494 43495 // The ExprSetVVAProperty() macro is used for Verification, Validation, 43496 // and Accreditation only. It works like ExprSetProperty() during VVA 43497 // processes but is a no-op for delivery. 43498 43499 // Macros to determine the number of bytes required by a normal Expr 43500 // struct, an Expr struct with the EP_Reduced flag set in Expr.flags 43501 // and an Expr struct with the EP_TokenOnly flag set. 43502 43503 // Flags passed to the sqlite3ExprDup() function. See the header comment 43504 // above sqlite3ExprDup() for details. 43505 43506 // True if the expression passed as an argument was a function with 43507 // an OVER() clause (a window function). 43508 43509 // A list of expressions. Each expression may optionally have a 43510 // name. An expr/name combination can be used in several ways, such 43511 // as the list of "expr AS ID" fields following a "SELECT" or in the 43512 // list of "ID = expr" items in an UPDATE. A list of expressions can 43513 // also be used as the argument to a function, in which case the a.zName 43514 // field is not used. 43515 // 43516 // In order to try to keep memory usage down, the Expr.a.zEName field 43517 // is used for multiple purposes: 43518 // 43519 // eEName Usage 43520 // ---------- ------------------------- 43521 // ENAME_NAME (1) the AS of result set column 43522 // (2) COLUMN= of an UPDATE 43523 // 43524 // ENAME_TAB DB.TABLE.NAME used to resolve names 43525 // of subqueries 43526 // 43527 // ENAME_SPAN Text of the original result set 43528 // expression. 43529 type ExprList_item = struct { 43530 FpExpr uintptr 43531 FzEName uintptr 43532 FsortFlags u8 43533 _ [3]byte 43534 FeEName uint8 /* unsigned eEName: 2, unsigned done: 1, unsigned reusable: 1, unsigned bSorterRef: 1, unsigned bNulls: 1 */ 43535 _ [3]byte 43536 Fu struct { 43537 _ [0]uint32 43538 Fx struct { 43539 FiOrderByCol u16 43540 FiAlias u16 43541 } 43542 } 43543 _ [4]byte 43544 } /* sqlite3.h:249:9 */ 43545 43546 // Allowed values for Expr.a.eEName 43547 43548 // An instance of this structure can hold a simple list of identifiers, 43549 // such as the list "a,b,c" in the following statements: 43550 // 43551 // INSERT INTO t(a,b,c) VALUES ...; 43552 // CREATE INDEX idx ON t(a,b,c); 43553 // CREATE TRIGGER trig BEFORE UPDATE ON t(a,b,c) ...; 43554 // 43555 // The IdList.a.idx field is used when the IdList represents the list of 43556 // column names after a table name in an INSERT statement. In the statement 43557 // 43558 // INSERT INTO t(a,b,c) ... 43559 // 43560 // If "a" is the k-th column of table "t", then IdList.a[0].idx==k. 43561 type IdList_item = struct { 43562 FzName uintptr 43563 Fidx int32 43564 _ [4]byte 43565 } /* sqlite3.h:249:9 */ 43566 43567 // The yDbMask datatype for the bitmask of all attached databases. 43568 type yDbMask = uint32 /* sqliteInt.h:3378:24 */ 43569 43570 // A pointer to this structure is used to communicate information 43571 // from sqlite3Init and OP_ParseSchema into the sqlite3InitCallback. 43572 type InitData = struct { 43573 Fdb uintptr 43574 FpzErrMsg uintptr 43575 FiDb int32 43576 Frc int32 43577 FmInitFlags u322 43578 FnInitRow u322 43579 FmxPage Pgno 43580 _ [4]byte 43581 } /* sqliteInt.h:3736:3 */ 43582 43583 // Allowed values for mInitFlags 43584 43585 // Structure containing global configuration data for the SQLite library. 43586 // 43587 // This structure also contains some state information. 43588 type Sqlite3Config = struct { 43589 FbMemstat int32 43590 FbCoreMutex u8 43591 FbFullMutex u8 43592 FbOpenUri u8 43593 FbUseCis u8 43594 FbSmallMalloc u8 43595 FbExtraSchemaChecks u8 43596 _ [2]byte 43597 FmxStrlen int32 43598 FneverCorrupt int32 43599 FszLookaside int32 43600 FnLookaside int32 43601 FnStmtSpill int32 43602 Fm sqlite3_mem_methods 43603 Fmutex sqlite3_mutex_methods 43604 Fpcache2 sqlite3_pcache_methods2 43605 FpHeap uintptr 43606 FnHeap int32 43607 FmnReq int32 43608 FmxReq int32 43609 _ [4]byte 43610 FszMmap sqlite3_int64 43611 FmxMmap sqlite3_int64 43612 FpPage uintptr 43613 FszPage int32 43614 FnPage int32 43615 FmxParserStack int32 43616 FsharedCacheEnabled int32 43617 FszPma u322 43618 FisInit int32 43619 FinProgress int32 43620 FisMutexInit int32 43621 FisMallocInit int32 43622 FisPCacheInit int32 43623 FnRefInitMutex int32 43624 _ [4]byte 43625 FpInitMutex uintptr 43626 FxLog uintptr 43627 FpLogArg uintptr 43628 FmxMemdbSize sqlite3_int64 43629 FxTestCallback uintptr 43630 FbLocaltimeFault int32 43631 FiOnceResetThreshold int32 43632 FszSorterRef u322 43633 FiPrngSeed uint32 43634 } /* sqliteInt.h:3749:1 */ 43635 43636 // 2003 September 6 43637 // 43638 // The author disclaims copyright to this source code. In place of 43639 // a legal notice, here is a blessing: 43640 // 43641 // May you do good and not evil. 43642 // May you find forgiveness for yourself and forgive others. 43643 // May you share freely, never taking more than you give. 43644 // 43645 // 43646 // This is the header file for information that is private to the 43647 // VDBE. This information used to all be at the top of the single 43648 // source code file "vdbe.c". When that file became too big (over 43649 // 6000 lines long) it was split up into several smaller files and 43650 // this header information was factored out. 43651 43652 // The maximum number of times that a statement will try to reparse 43653 // itself before giving up and returning SQLITE_SCHEMA. 43654 43655 // VDBE_DISPLAY_P4 is true or false depending on whether or not the 43656 // "explain" P4 display logic is enabled. 43657 43658 // SQL is translated into a sequence of instructions to be 43659 // executed by a virtual machine. Each instruction is an instance 43660 // of the following structure. 43661 type Op = VdbeOp1 /* vdbeInt.h:46:23 */ 43662 43663 // Boolean values 43664 type Bool = uint32 /* vdbeInt.h:51:18 */ 43665 43666 // Elements of the linked list at Vdbe.pAuxData 43667 type AuxData1 = struct { 43668 FiAuxOp int32 43669 FiAuxArg int32 43670 FpAux uintptr 43671 FxDeleteAux uintptr 43672 FpNextAux uintptr 43673 } /* sqlite3.h:249:9 */ 43674 43675 // Elements of the linked list at Vdbe.pAuxData 43676 type AuxData = AuxData1 /* vdbeInt.h:57:24 */ 43677 43678 // Types of VDBE cursors 43679 43680 // A VdbeCursor is an superclass (a wrapper) for various cursor objects: 43681 // 43682 // * A b-tree cursor 43683 // - In the main database or in an ephemeral database 43684 // - On either an index or a table 43685 // * A sorter 43686 // * A virtual table 43687 // * A one-row "pseudotable" stored in a single register 43688 type VdbeCursor1 = struct { 43689 FeCurType u8 43690 FiDb i8 43691 FnullRow u8 43692 FdeferredMoveto u8 43693 FisTable u8 43694 _ [3]byte 43695 FisEphemeral uint8 /* Bool isEphemeral: 1, Bool useRandomRowid: 1, Bool isOrdered: 1, Bool hasBeenDuped: 1 */ 43696 _ [1]byte 43697 FseekHit u16 43698 _ [4]byte 43699 FpBtx uintptr 43700 FseqCount i64 43701 FaAltMap uintptr 43702 FcacheStatus u322 43703 FseekResult int32 43704 FpAltCursor uintptr 43705 Fuc struct{ FpCursor uintptr } 43706 FpKeyInfo uintptr 43707 FiHdrOffset u322 43708 FpgnoRoot Pgno 43709 FnField i16 43710 FnHdrParsed u16 43711 _ [4]byte 43712 FmovetoTarget i64 43713 FaOffset uintptr 43714 FaRow uintptr 43715 FpayloadSize u322 43716 FszRow u322 43717 FaType [1]u322 43718 _ [4]byte 43719 } /* sqlite3.h:249:9 */ 43720 43721 // Types of VDBE cursors 43722 43723 // A VdbeCursor is an superclass (a wrapper) for various cursor objects: 43724 // 43725 // * A b-tree cursor 43726 // - In the main database or in an ephemeral database 43727 // - On either an index or a table 43728 // * A sorter 43729 // * A virtual table 43730 // * A one-row "pseudotable" stored in a single register 43731 type VdbeCursor = VdbeCursor1 /* vdbeInt.h:75:27 */ 43732 43733 // A value for VdbeCursor.cacheStatus that means the cache is always invalid. 43734 43735 // When a sub-program is executed (OP_Program), a structure of this type 43736 // is allocated to store the current value of the program counter, as 43737 // well as the current memory cell array and various other frame specific 43738 // values stored in the Vdbe struct. When the sub-program is finished, 43739 // these values are copied back to the Vdbe from the VdbeFrame structure, 43740 // restoring the state of the VM to as it was before the sub-program 43741 // began executing. 43742 // 43743 // The memory for a VdbeFrame object is allocated and managed by a memory 43744 // cell in the parent (calling) frame. When the memory cell is deleted or 43745 // overwritten, the VdbeFrame object is not freed immediately. Instead, it 43746 // is linked into the Vdbe.pDelFrame list. The contents of the Vdbe.pDelFrame 43747 // list is deleted when the VM is reset in VdbeHalt(). The reason for doing 43748 // this instead of deleting the VdbeFrame immediately is to avoid recursive 43749 // calls to sqlite3VdbeMemRelease() when the memory cells belonging to the 43750 // child frame are released. 43751 // 43752 // The currently executing frame is stored in Vdbe.pFrame. Vdbe.pFrame is 43753 // set to NULL if the currently executing frame is the main program. 43754 type VdbeFrame1 = struct { 43755 Fv uintptr 43756 FpParent uintptr 43757 FaOp uintptr 43758 FanExec uintptr 43759 FaMem uintptr 43760 FapCsr uintptr 43761 FaOnce uintptr 43762 Ftoken uintptr 43763 FlastRowid i64 43764 FpAuxData uintptr 43765 FnCursor int32 43766 Fpc int32 43767 FnOp int32 43768 FnMem int32 43769 FnChildMem int32 43770 FnChildCsr int32 43771 FnChange int32 43772 FnDbChange int32 43773 } /* sqlite3.h:249:9 */ 43774 43775 // A value for VdbeCursor.cacheStatus that means the cache is always invalid. 43776 43777 // When a sub-program is executed (OP_Program), a structure of this type 43778 // is allocated to store the current value of the program counter, as 43779 // well as the current memory cell array and various other frame specific 43780 // values stored in the Vdbe struct. When the sub-program is finished, 43781 // these values are copied back to the Vdbe from the VdbeFrame structure, 43782 // restoring the state of the VM to as it was before the sub-program 43783 // began executing. 43784 // 43785 // The memory for a VdbeFrame object is allocated and managed by a memory 43786 // cell in the parent (calling) frame. When the memory cell is deleted or 43787 // overwritten, the VdbeFrame object is not freed immediately. Instead, it 43788 // is linked into the Vdbe.pDelFrame list. The contents of the Vdbe.pDelFrame 43789 // list is deleted when the VM is reset in VdbeHalt(). The reason for doing 43790 // this instead of deleting the VdbeFrame immediately is to avoid recursive 43791 // calls to sqlite3VdbeMemRelease() when the memory cells belonging to the 43792 // child frame are released. 43793 // 43794 // The currently executing frame is stored in Vdbe.pFrame. Vdbe.pFrame is 43795 // set to NULL if the currently executing frame is the main program. 43796 type VdbeFrame = VdbeFrame1 /* vdbeInt.h:162:26 */ 43797 43798 // Magic number for sanity checking on VdbeFrame objects 43799 43800 // Return a pointer to the array of registers allocated for use 43801 // by a VdbeFrame. 43802 43803 // Internally, the vdbe manipulates nearly all SQL values as Mem 43804 // structures. Each Mem struct may cache multiple representations (string, 43805 // integer etc.) of the same value. 43806 type MemValue = struct{ Fr float64 } /* sqlite3.h:249:9 */ 43807 43808 // A bitfield type for use inside of structures. Always follow with :N where 43809 // N is the number of bits. 43810 type bft = uint32 /* vdbeInt.h:345:18 */ // Bit Field Type 43811 43812 // The ScanStatus object holds a single value for the 43813 // sqlite3_stmt_scanstatus() interface. 43814 type ScanStatus1 = struct { 43815 FaddrExplain int32 43816 FaddrLoop int32 43817 FaddrVisit int32 43818 FiSelectID int32 43819 FnEst LogEst 43820 _ [6]byte 43821 FzName uintptr 43822 } /* vdbeInt.h:350:9 */ 43823 43824 // Bit Field Type 43825 43826 // The ScanStatus object holds a single value for the 43827 // sqlite3_stmt_scanstatus() interface. 43828 type ScanStatus = ScanStatus1 /* vdbeInt.h:350:27 */ 43829 43830 // The DblquoteStr object holds the text of a double-quoted 43831 // string for a prepared statement. A linked list of these objects 43832 // is constructed during statement parsing and is held on Vdbe.pDblStr. 43833 // When computing a normalized SQL statement for an SQL statement, that 43834 // list is consulted for each double-quoted identifier to see if the 43835 // identifier should really be a string literal. 43836 type DblquoteStr1 = struct { 43837 FpNextStr uintptr 43838 Fz [8]int8 43839 } /* vdbeInt.h:367:9 */ 43840 43841 // The DblquoteStr object holds the text of a double-quoted 43842 // string for a prepared statement. A linked list of these objects 43843 // is constructed during statement parsing and is held on Vdbe.pDblStr. 43844 // When computing a normalized SQL statement for an SQL statement, that 43845 // list is consulted for each double-quoted identifier to see if the 43846 // identifier should really be a string literal. 43847 type DblquoteStr = DblquoteStr1 /* vdbeInt.h:367:28 */ 43848 43849 // Convert text generated by the "%p" conversion format back into 43850 // a pointer. 43851 func testHexToInt(tls *libc.TLS, h int32) int32 { /* test1.c:44:12: */ 43852 if (h >= '0') && (h <= '9') { 43853 return (h - '0') 43854 } else if (h >= 'a') && (h <= 'f') { 43855 return ((h - 'a') + 10) 43856 } else { 43857 43858 return ((h - 'A') + 10) 43859 } 43860 return int32(0) 43861 } 43862 43863 func sqlite3TestTextToPtr(tls *libc.TLS, z uintptr) uintptr { /* test1.c:54:6: */ 43864 bp := tls.Alloc(20) 43865 defer tls.Free(20) 43866 43867 // var p uintptr at bp, 8 43868 43869 // var v u64 at bp+8, 8 43870 43871 // var v2 u322 at bp+16, 4 43872 43873 if (int32(*(*int8)(unsafe.Pointer(z))) == '0') && (int32(*(*int8)(unsafe.Pointer(z + 1))) == 'x') { 43874 z += uintptr(2) 43875 } 43876 *(*u64)(unsafe.Pointer(bp + 8 /* v */)) = uint64(0) 43877 for *(*int8)(unsafe.Pointer(z)) != 0 { 43878 *(*u64)(unsafe.Pointer(bp + 8 /* v */)) = ((*(*u64)(unsafe.Pointer(bp + 8 /* v */)) << 4) + u64(testHexToInt(tls, int32(*(*int8)(unsafe.Pointer(z)))))) 43879 z++ 43880 } 43881 if uint64(unsafe.Sizeof(uintptr(0))) == uint64(unsafe.Sizeof(u64(0))) { 43882 libc.Xmemcpy(tls, bp /* &p */, bp+8 /* &v */, uint64(unsafe.Sizeof(uintptr(0)))) 43883 } else { 43884 43885 *(*u322)(unsafe.Pointer(bp + 16 /* v2 */)) = u322(*(*u64)(unsafe.Pointer(bp + 8 /* v */))) 43886 libc.Xmemcpy(tls, bp /* &p */, bp+16 /* &v2 */, uint64(unsafe.Sizeof(uintptr(0)))) 43887 } 43888 return *(*uintptr)(unsafe.Pointer(bp /* p */)) 43889 } 43890 43891 // A TCL command that returns the address of the sqlite* pointer 43892 // for an sqlite connection instance. Bad things happen if the 43893 // input is not an sqlite connection. 43894 func get_sqlite_pointer(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:82:26: */ 43895 bp := tls.Alloc(212) 43896 defer tls.Free(212) 43897 43898 var p uintptr 43899 // var cmdInfo Tcl_CmdInfo at bp+48, 64 43900 43901 // var zBuf [100]int8 at bp+112, 100 43902 43903 if objc != 2 { 43904 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+14523 /* "SQLITE-CONNECTIO..." */) 43905 return TCL_ERROR 43906 } 43907 if !(tcl.XTcl_GetCommandInfo(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &cmdInfo */) != 0) { 43908 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14541, /* "command not foun..." */ 43909 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), uintptr(0))) 43910 return TCL_ERROR 43911 } 43912 p = (*Tcl_CmdInfo)(unsafe.Pointer(bp + 48 /* &cmdInfo */)).FobjClientData 43913 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+112 /* &zBuf[0] */, ts+13023 /* "%p" */, libc.VaList(bp+24, (*struct{ Fdb uintptr })(unsafe.Pointer(p)).Fdb)) 43914 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, bp+112 /* &zBuf[0] */, 0)) 43915 return TCL_OK 43916 } 43917 43918 // Decode a pointer to an sqlite3 object. 43919 func getDbPointer(tls *libc.TLS, interp uintptr, zA uintptr, ppDb uintptr) int32 { /* test1.c:109:5: */ 43920 bp := tls.Alloc(64) 43921 defer tls.Free(64) 43922 43923 var p uintptr 43924 // var cmdInfo Tcl_CmdInfo at bp, 64 43925 43926 if tcl.XTcl_GetCommandInfo(tls, interp, zA, bp /* &cmdInfo */) != 0 { 43927 p = (*Tcl_CmdInfo)(unsafe.Pointer(bp /* &cmdInfo */)).FobjClientData 43928 *(*uintptr)(unsafe.Pointer(ppDb)) = (*struct{ Fdb uintptr })(unsafe.Pointer(p)).Fdb 43929 } else { 43930 *(*uintptr)(unsafe.Pointer(ppDb)) = sqlite3TestTextToPtr(tls, zA) 43931 } 43932 return TCL_OK 43933 } 43934 43935 // Convert an sqlite3_stmt* into an sqlite3*. This depends on the 43936 // fact that the sqlite3* is the first field in the Vdbe structure. 43937 43938 // Check a return value to make sure it agrees with the results 43939 // from sqlite3_errcode. 43940 func sqlite3TestErrCode(tls *libc.TLS, interp uintptr, db uintptr, rc int32) int32 { /* test1.c:144:5: */ 43941 bp := tls.Alloc(248) 43942 defer tls.Free(248) 43943 43944 if (((sqlite3.Xsqlite3_threadsafe(tls) == 0) && (rc != SQLITE_MISUSE)) && (rc != SQLITE_OK)) && 43945 (sqlite3.Xsqlite3_errcode(tls, db) != rc) { 43946 // var zBuf [200]int8 at bp+48, 200 43947 43948 var r2 int32 = sqlite3.Xsqlite3_errcode(tls, db) 43949 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([200]int8{})), bp+48, /* &zBuf[0] */ 43950 ts+14561, /* "error code %s (%..." */ 43951 libc.VaList(bp, sqlite3.Xsqlite3ErrName(tls, rc), rc, sqlite3.Xsqlite3ErrName(tls, r2), r2)) 43952 tcl.XTcl_ResetResult(tls, interp) 43953 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, bp+48 /* &zBuf[0] */, 0)) 43954 return 1 43955 } 43956 return 0 43957 } 43958 43959 // Decode a pointer to an sqlite3_stmt object. 43960 func getStmtPointer(tls *libc.TLS, interp uintptr, zArg uintptr, ppStmt uintptr) int32 { /* test1.c:162:12: */ 43961 *(*uintptr)(unsafe.Pointer(ppStmt)) = sqlite3TestTextToPtr(tls, zArg) 43962 return TCL_OK 43963 } 43964 43965 // Generate a text representation of a pointer that can be understood 43966 // by the getDbPointer and getVmPointer routines above. 43967 // 43968 // The problem is, on some machines (Solaris) if you do a printf with 43969 // "%p" you cannot turn around and do a scanf with the same "%p" and 43970 // get your pointer back. You have to prepend a "0x" before it will 43971 // work. Or at least that is what is reported to me (drh). But this 43972 // behavior varies from machine to machine. The solution used her is 43973 // to test the string right after it is generated to see if it can be 43974 // understood by scanf, and if not, try prepending an "0x" to see if 43975 // that helps. If nothing works, a fatal error is generated. 43976 func sqlite3TestMakePointerStr(tls *libc.TLS, interp uintptr, zPtr uintptr, p uintptr) int32 { /* test1.c:184:5: */ 43977 bp := tls.Alloc(8) 43978 defer tls.Free(8) 43979 43980 sqlite3.Xsqlite3_snprintf(tls, 100, zPtr, ts+13023 /* "%p" */, libc.VaList(bp, p)) 43981 return TCL_OK 43982 } 43983 43984 // The callback routine for sqlite3_exec_printf(). 43985 func exec_printf_cb(tls *libc.TLS, pArg uintptr, argc int32, argv uintptr, name uintptr) int32 { /* test1.c:192:12: */ 43986 var str uintptr = pArg 43987 var i int32 43988 43989 if ((*Tcl_DString)(unsafe.Pointer(str)).Flength) == 0 { 43990 for i = 0; i < argc; i++ { 43991 tcl.XTcl_DStringAppendElement(tls, str, func() uintptr { 43992 if *(*uintptr)(unsafe.Pointer(name + uintptr(i)*8)) != 0 { 43993 return *(*uintptr)(unsafe.Pointer(name + uintptr(i)*8)) 43994 } 43995 return ts + 5717 /* "NULL" */ 43996 }()) 43997 } 43998 } 43999 for i = 0; i < argc; i++ { 44000 tcl.XTcl_DStringAppendElement(tls, str, func() uintptr { 44001 if *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)) != 0 { 44002 return *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)) 44003 } 44004 return ts + 5717 /* "NULL" */ 44005 }()) 44006 } 44007 return 0 44008 } 44009 44010 // The I/O tracing callback. 44011 44012 // Usage: io_trace FILENAME 44013 // 44014 // Turn I/O tracing on or off. If FILENAME is not an empty string, 44015 // I/O tracing begins going into FILENAME. If FILENAME is an empty 44016 // string, I/O tracing is turned off. 44017 func test_io_trace(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:228:26: */ 44018 return TCL_OK 44019 } 44020 44021 // Usage: clang_sanitize_address 44022 // 44023 // Returns true if the program was compiled using clang with the 44024 // -fsanitize=address switch on the command line. False otherwise. 44025 // 44026 // Also return true if the OMIT_MISUSE environment variable exists. 44027 func clang_sanitize_address(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:269:26: */ 44028 var res int32 = 0 44029 if (res == 0) && (libc.Xgetenv(tls, ts+14619 /* "OMIT_MISUSE" */) != uintptr(0)) { 44030 res = 1 44031 } 44032 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, res)) 44033 return TCL_OK 44034 } 44035 44036 // Usage: sqlite3_exec_printf DB FORMAT STRING 44037 // 44038 // Invoke the sqlite3_exec_printf() interface using the open database 44039 // DB. The SQL is the string FORMAT. The format string should contain 44040 // one %s or %q. STRING is the value inserted into %s or %q. 44041 func test_exec_printf(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:296:26: */ 44042 bp := tls.Alloc(310) 44043 defer tls.Free(310) 44044 44045 // var db uintptr at bp+48, 8 44046 44047 // var str Tcl_DString at bp+56, 216 44048 44049 var rc int32 44050 *(*uintptr)(unsafe.Pointer(bp + 272 /* zErr */)) = uintptr(0) 44051 var zSql uintptr 44052 // var zBuf [30]int8 at bp+280, 30 44053 44054 if argc != 4 { 44055 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 44056 ts+14657 /* " DB FORMAT STRIN..." */, 0)) 44057 return TCL_ERROR 44058 } 44059 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+48 /* &db */) != 0 { 44060 return TCL_ERROR 44061 } 44062 tcl.XTcl_DStringInit(tls, bp+56 /* &str */) 44063 zSql = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)), libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(argv + 3*8)))) 44064 rc = sqlite3.Xsqlite3_exec(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), zSql, *(*uintptr)(unsafe.Pointer(&struct { 44065 f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 44066 }{exec_printf_cb})), bp+56 /* &str */, bp+272 /* &zErr */) 44067 sqlite3.Xsqlite3_free(tls, zSql) 44068 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+280 /* &zBuf[0] */, ts+1238 /* "%d" */, libc.VaList(bp+40, rc)) 44069 tcl.XTcl_AppendElement(tls, interp, bp+280 /* &zBuf[0] */) 44070 tcl.XTcl_AppendElement(tls, interp, func() uintptr { 44071 if rc == SQLITE_OK { 44072 return (*Tcl_DString)(unsafe.Pointer(bp + 56 /* &str */)).Fstring 44073 } 44074 return *(*uintptr)(unsafe.Pointer(bp + 272 /* zErr */)) 44075 }()) 44076 tcl.XTcl_DStringFree(tls, bp+56 /* &str */) 44077 if *(*uintptr)(unsafe.Pointer(bp + 272 /* zErr */)) != 0 { 44078 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 272 /* zErr */))) 44079 } 44080 if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), rc) != 0 { 44081 return TCL_ERROR 44082 } 44083 return TCL_OK 44084 } 44085 44086 // Usage: sqlite3_exec_hex DB HEX 44087 // 44088 // Invoke the sqlite3_exec() on a string that is obtained by translating 44089 // HEX into ASCII. Most characters are translated as is. %HH becomes 44090 // a hex character. 44091 func test_exec_hex(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:334:26: */ 44092 bp := tls.Alloc(806) 44093 defer tls.Free(806) 44094 44095 // var db uintptr at bp+40, 8 44096 44097 // var str Tcl_DString at bp+552, 216 44098 44099 var rc int32 44100 var i int32 44101 var j int32 44102 *(*uintptr)(unsafe.Pointer(bp + 768 /* zErr */)) = uintptr(0) 44103 var zHex uintptr 44104 // var zSql [501]int8 at bp+48, 501 44105 44106 // var zBuf [30]int8 at bp+776, 30 44107 44108 if argc != 3 { 44109 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 44110 ts+14675 /* " DB HEX" */, 0)) 44111 return TCL_ERROR 44112 } 44113 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+40 /* &db */) != 0 { 44114 return TCL_ERROR 44115 } 44116 zHex = *(*uintptr)(unsafe.Pointer(argv + 2*8)) 44117 i = libc.AssignInt32(&j, 0) 44118 __1: 44119 if !((uint64(i) < (uint64(unsafe.Sizeof([501]int8{})) - uint64(1))) && (*(*int8)(unsafe.Pointer(zHex + uintptr(j))) != 0)) { 44120 goto __3 44121 } 44122 { 44123 if ((int32(*(*int8)(unsafe.Pointer(zHex + uintptr(j)))) == '%') && (*(*int8)(unsafe.Pointer(zHex + uintptr((j + 2)))) != 0)) && (*(*int8)(unsafe.Pointer(zHex + uintptr((j + 2)))) != 0) { 44124 *(*int8)(unsafe.Pointer(bp + 48 /* &zSql[0] */ + uintptr(i))) = (int8((testHexToInt(tls, int32(*(*int8)(unsafe.Pointer(zHex + uintptr((j + 1)))))) << 4) + testHexToInt(tls, int32(*(*int8)(unsafe.Pointer(zHex + uintptr((j + 2)))))))) 44125 j = j + (2) 44126 } else { 44127 *(*int8)(unsafe.Pointer(bp + 48 /* &zSql[0] */ + uintptr(i))) = *(*int8)(unsafe.Pointer(zHex + uintptr(j))) 44128 } 44129 44130 } 44131 goto __2 44132 __2: 44133 i++ 44134 j++ 44135 goto __1 44136 goto __3 44137 __3: 44138 ; 44139 *(*int8)(unsafe.Pointer(bp + 48 /* &zSql[0] */ + uintptr(i))) = int8(0) 44140 tcl.XTcl_DStringInit(tls, bp+552 /* &str */) 44141 rc = sqlite3.Xsqlite3_exec(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* db */)), bp+48 /* &zSql[0] */, *(*uintptr)(unsafe.Pointer(&struct { 44142 f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 44143 }{exec_printf_cb})), bp+552 /* &str */, bp+768 /* &zErr */) 44144 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+776 /* &zBuf[0] */, ts+1238 /* "%d" */, libc.VaList(bp+32, rc)) 44145 tcl.XTcl_AppendElement(tls, interp, bp+776 /* &zBuf[0] */) 44146 tcl.XTcl_AppendElement(tls, interp, func() uintptr { 44147 if rc == SQLITE_OK { 44148 return (*Tcl_DString)(unsafe.Pointer(bp + 552 /* &str */)).Fstring 44149 } 44150 return *(*uintptr)(unsafe.Pointer(bp + 768 /* zErr */)) 44151 }()) 44152 tcl.XTcl_DStringFree(tls, bp+552 /* &str */) 44153 if *(*uintptr)(unsafe.Pointer(bp + 768 /* zErr */)) != 0 { 44154 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 768 /* zErr */))) 44155 } 44156 if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 40 /* db */)), rc) != 0 { 44157 return TCL_ERROR 44158 } 44159 return TCL_OK 44160 } 44161 44162 // Usage: db_enter DB 44163 // db_leave DB 44164 // 44165 // Enter or leave the mutex on a database connection. 44166 func db_enter(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:380:26: */ 44167 bp := tls.Alloc(40) 44168 defer tls.Free(40) 44169 44170 // var db uintptr at bp+32, 8 44171 44172 if argc != 2 { 44173 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 44174 ts+14683 /* " DB" */, 0)) 44175 return TCL_ERROR 44176 } 44177 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { 44178 return TCL_ERROR 44179 } 44180 sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmutex) 44181 return TCL_OK 44182 } 44183 44184 func db_leave(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:396:26: */ 44185 bp := tls.Alloc(40) 44186 defer tls.Free(40) 44187 44188 // var db uintptr at bp+32, 8 44189 44190 if argc != 2 { 44191 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 44192 ts+14683 /* " DB" */, 0)) 44193 return TCL_ERROR 44194 } 44195 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { 44196 return TCL_ERROR 44197 } 44198 sqlite3.Xsqlite3_mutex_leave(tls, (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmutex) 44199 return TCL_OK 44200 } 44201 44202 // Usage: sqlite3_exec DB SQL 44203 // 44204 // Invoke the sqlite3_exec interface using the open database DB 44205 func test_exec(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:418:26: */ 44206 bp := tls.Alloc(310) 44207 defer tls.Free(310) 44208 44209 // var db uintptr at bp+48, 8 44210 44211 // var str Tcl_DString at bp+56, 216 44212 44213 var rc int32 44214 *(*uintptr)(unsafe.Pointer(bp + 272 /* zErr */)) = uintptr(0) 44215 var zSql uintptr 44216 var i int32 44217 var j int32 44218 // var zBuf [30]int8 at bp+280, 30 44219 44220 if argc != 3 { 44221 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 44222 ts+14687 /* " DB SQL" */, 0)) 44223 return TCL_ERROR 44224 } 44225 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+48 /* &db */) != 0 { 44226 return TCL_ERROR 44227 } 44228 tcl.XTcl_DStringInit(tls, bp+56 /* &str */) 44229 zSql = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) 44230 for i = libc.AssignInt32(&j, 0); *(*int8)(unsafe.Pointer(zSql + uintptr(i))) != 0; { 44231 if int32(*(*int8)(unsafe.Pointer(zSql + uintptr(i)))) == '%' { 44232 *(*int8)(unsafe.Pointer(zSql + uintptr(libc.PostIncInt32(&j, 1)))) = (int8((testHexToInt(tls, int32(*(*int8)(unsafe.Pointer(zSql + uintptr((i + 1)))))) << 4) + testHexToInt(tls, int32(*(*int8)(unsafe.Pointer(zSql + uintptr((i + 2)))))))) 44233 i = i + (3) 44234 } else { 44235 *(*int8)(unsafe.Pointer(zSql + uintptr(libc.PostIncInt32(&j, 1)))) = *(*int8)(unsafe.Pointer(zSql + uintptr(libc.PostIncInt32(&i, 1)))) 44236 } 44237 } 44238 *(*int8)(unsafe.Pointer(zSql + uintptr(j))) = int8(0) 44239 rc = sqlite3.Xsqlite3_exec(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), zSql, *(*uintptr)(unsafe.Pointer(&struct { 44240 f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 44241 }{exec_printf_cb})), bp+56 /* &str */, bp+272 /* &zErr */) 44242 sqlite3.Xsqlite3_free(tls, zSql) 44243 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+280 /* &zBuf[0] */, ts+1238 /* "%d" */, libc.VaList(bp+40, rc)) 44244 tcl.XTcl_AppendElement(tls, interp, bp+280 /* &zBuf[0] */) 44245 tcl.XTcl_AppendElement(tls, interp, func() uintptr { 44246 if rc == SQLITE_OK { 44247 return (*Tcl_DString)(unsafe.Pointer(bp + 56 /* &str */)).Fstring 44248 } 44249 return *(*uintptr)(unsafe.Pointer(bp + 272 /* zErr */)) 44250 }()) 44251 tcl.XTcl_DStringFree(tls, bp+56 /* &str */) 44252 if *(*uintptr)(unsafe.Pointer(bp + 272 /* zErr */)) != 0 { 44253 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 272 /* zErr */))) 44254 } 44255 if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), rc) != 0 { 44256 return TCL_ERROR 44257 } 44258 return TCL_OK 44259 } 44260 44261 // Usage: sqlite3_exec_nr DB SQL 44262 // 44263 // Invoke the sqlite3_exec interface using the open database DB. Discard 44264 // all results 44265 func test_exec_nr(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:465:26: */ 44266 bp := tls.Alloc(48) 44267 defer tls.Free(48) 44268 44269 // var db uintptr at bp+32, 8 44270 44271 var rc int32 44272 *(*uintptr)(unsafe.Pointer(bp + 40 /* zErr */)) = uintptr(0) 44273 if argc != 3 { 44274 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 44275 ts+14687 /* " DB SQL" */, 0)) 44276 return TCL_ERROR 44277 } 44278 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { 44279 return TCL_ERROR 44280 } 44281 rc = sqlite3.Xsqlite3_exec(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), *(*uintptr)(unsafe.Pointer(argv + 2*8)), uintptr(0), uintptr(0), bp+40 /* &zErr */) 44282 if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), rc) != 0 { 44283 return TCL_ERROR 44284 } 44285 return TCL_OK 44286 } 44287 44288 // Usage: sqlite3_mprintf_z_test SEPARATOR ARG0 ARG1 ... 44289 // 44290 // Test the %z format of sqlite_mprintf(). Use multiple mprintf() calls to 44291 // concatenate arg0 through argn using separator as the separator. 44292 // Return the result. 44293 func test_mprintf_z(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:492:26: */ 44294 bp := tls.Alloc(40) 44295 defer tls.Free(40) 44296 44297 var zResult uintptr = uintptr(0) 44298 var i int32 44299 44300 for i = 2; (i < argc) && ((i == 2) || (zResult != 0)); i++ { 44301 zResult = sqlite3.Xsqlite3_mprintf(tls, ts+14695 /* "%z%s%s" */, libc.VaList(bp, zResult, *(*uintptr)(unsafe.Pointer(argv + 1*8)), *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)))) 44302 } 44303 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, zResult, 0)) 44304 sqlite3.Xsqlite3_free(tls, zResult) 44305 return TCL_OK 44306 } 44307 44308 // Usage: sqlite3_mprintf_n_test STRING 44309 // 44310 // Test the %n format of sqlite_mprintf(). Return the length of the 44311 // input string. 44312 func test_mprintf_n(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:515:26: */ 44313 bp := tls.Alloc(20) 44314 defer tls.Free(20) 44315 44316 var zStr uintptr 44317 *(*int32)(unsafe.Pointer(bp + 16 /* n */)) = 0 44318 zStr = sqlite3.Xsqlite3_mprintf(tls, ts+14702 /* "%s%n" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+16 /* &n */)) 44319 sqlite3.Xsqlite3_free(tls, zStr) 44320 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 16 /* n */)))) 44321 return TCL_OK 44322 } 44323 44324 // Usage: sqlite3_snprintf_int SIZE FORMAT INT 44325 // 44326 // Test the of sqlite3_snprintf() routine. SIZE is the size of the 44327 // output buffer in bytes. The maximum size is 100. FORMAT is the 44328 // format string. INT is a single integer argument. The FORMAT 44329 // string must require no more than this one integer argument. If 44330 // You pass in a format string that requires more than one argument, 44331 // bad things will happen. 44332 func test_snprintf_int(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:539:26: */ 44333 bp := tls.Alloc(124) 44334 defer tls.Free(124) 44335 44336 // var zStr [100]int8 at bp+24, 100 44337 44338 var n int32 = libc.Xatoi(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 44339 var zFormat uintptr = *(*uintptr)(unsafe.Pointer(argv + 2*8)) 44340 var a1 int32 = libc.Xatoi(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) 44341 if uint64(n) > uint64(unsafe.Sizeof([100]int8{})) { 44342 n = int32(unsafe.Sizeof([100]int8{})) 44343 } 44344 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+24 /* &zStr[0] */, ts+14707 /* "abcdefghijklmnop..." */, 0) 44345 sqlite3.Xsqlite3_snprintf(tls, n, bp+24 /* &zStr[0] */, zFormat, libc.VaList(bp, a1)) 44346 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+8, bp+24 /* &zStr[0] */, 0)) 44347 return TCL_OK 44348 } 44349 44350 // Usage: sqlite3_get_table_printf DB FORMAT STRING ?--no-counts? 44351 // 44352 // Invoke the sqlite3_get_table_printf() interface using the open database 44353 // DB. The SQL is the string FORMAT. The format string should contain 44354 // one %s or %q. STRING is the value inserted into %s or %q. 44355 func test_get_table_printf(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:565:26: */ 44356 bp := tls.Alloc(350) 44357 defer tls.Free(350) 44358 44359 // var db uintptr at bp+72, 8 44360 44361 // var str Tcl_DString at bp+80, 216 44362 44363 var rc int32 44364 *(*uintptr)(unsafe.Pointer(bp + 304 /* zErr */)) = uintptr(0) 44365 *(*int32)(unsafe.Pointer(bp + 312 /* nRow */)) = 0 44366 *(*int32)(unsafe.Pointer(bp + 316 /* nCol */)) = 0 44367 // var aResult uintptr at bp+296, 8 44368 44369 var i int32 44370 // var zBuf [30]int8 at bp+320, 30 44371 44372 var zSql uintptr 44373 *(*int32)(unsafe.Pointer(bp + 64 /* resCount */)) = -1 44374 if argc == 5 { 44375 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 4*8)), bp+64 /* &resCount */) != 0 { 44376 return TCL_ERROR 44377 } 44378 } 44379 if (argc != 4) && (argc != 5) { 44380 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 44381 ts+14734 /* " DB FORMAT STRIN..." */, 0)) 44382 return TCL_ERROR 44383 } 44384 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+72 /* &db */) != 0 { 44385 return TCL_ERROR 44386 } 44387 tcl.XTcl_DStringInit(tls, bp+80 /* &str */) 44388 zSql = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)), libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(argv + 3*8)))) 44389 if argc == 5 { 44390 rc = sqlite3.Xsqlite3_get_table(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* db */)), zSql, bp+296 /* &aResult */, uintptr(0), uintptr(0), bp+304 /* &zErr */) 44391 } else { 44392 rc = sqlite3.Xsqlite3_get_table(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* db */)), zSql, bp+296 /* &aResult */, bp+312 /* &nRow */, bp+316 /* &nCol */, bp+304 /* &zErr */) 44393 *(*int32)(unsafe.Pointer(bp + 64 /* resCount */)) = ((*(*int32)(unsafe.Pointer(bp + 312 /* nRow */)) + 1) * *(*int32)(unsafe.Pointer(bp + 316 /* nCol */))) 44394 } 44395 sqlite3.Xsqlite3_free(tls, zSql) 44396 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+320 /* &zBuf[0] */, ts+1238 /* "%d" */, libc.VaList(bp+40, rc)) 44397 tcl.XTcl_AppendElement(tls, interp, bp+320 /* &zBuf[0] */) 44398 if rc == SQLITE_OK { 44399 if argc == 4 { 44400 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+320 /* &zBuf[0] */, ts+1238 /* "%d" */, libc.VaList(bp+48, *(*int32)(unsafe.Pointer(bp + 312 /* nRow */)))) 44401 tcl.XTcl_AppendElement(tls, interp, bp+320 /* &zBuf[0] */) 44402 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+320 /* &zBuf[0] */, ts+1238 /* "%d" */, libc.VaList(bp+56, *(*int32)(unsafe.Pointer(bp + 316 /* nCol */)))) 44403 tcl.XTcl_AppendElement(tls, interp, bp+320 /* &zBuf[0] */) 44404 } 44405 for i = 0; i < *(*int32)(unsafe.Pointer(bp + 64 /* resCount */)); i++ { 44406 tcl.XTcl_AppendElement(tls, interp, func() uintptr { 44407 if *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 296 /* aResult */)) + uintptr(i)*8)) != 0 { 44408 return *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 296 /* aResult */)) + uintptr(i)*8)) 44409 } 44410 return ts + 5717 /* "NULL" */ 44411 }()) 44412 } 44413 } else { 44414 tcl.XTcl_AppendElement(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 304 /* zErr */))) 44415 } 44416 sqlite3.Xsqlite3_free_table(tls, *(*uintptr)(unsafe.Pointer(bp + 296 /* aResult */))) 44417 if *(*uintptr)(unsafe.Pointer(bp + 304 /* zErr */)) != 0 { 44418 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 304 /* zErr */))) 44419 } 44420 if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 72 /* db */)), rc) != 0 { 44421 return TCL_ERROR 44422 } 44423 return TCL_OK 44424 } 44425 44426 // Usage: sqlite3_last_insert_rowid DB 44427 // 44428 // Returns the integer ROWID of the most recent insert. 44429 func test_last_rowid(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:628:26: */ 44430 bp := tls.Alloc(94) 44431 defer tls.Free(94) 44432 44433 // var db uintptr at bp+56, 8 44434 44435 // var zBuf [30]int8 at bp+64, 30 44436 44437 if argc != 2 { 44438 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14760 /* " DB\"" */, 0)) 44439 return TCL_ERROR 44440 } 44441 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+56 /* &db */) != 0 { 44442 return TCL_ERROR 44443 } 44444 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+64 /* &zBuf[0] */, ts+10547 /* "%lld" */, libc.VaList(bp+32, sqlite3.Xsqlite3_last_insert_rowid(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* db */))))) 44445 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+64 /* &zBuf[0] */, 0)) 44446 return SQLITE_OK 44447 } 44448 44449 // Usage: sqlite3_key DB KEY 44450 // 44451 // Set the codec key. 44452 func test_key(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:652:26: */ 44453 return TCL_OK 44454 } 44455 44456 // Usage: sqlite3_rekey DB KEY 44457 // 44458 // Change the codec key. 44459 func test_rekey(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:666:26: */ 44460 return TCL_OK 44461 } 44462 44463 // Usage: sqlite3_close DB 44464 // 44465 // Closes the database opened by sqlite3_open. 44466 func sqlite_test_close(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:680:26: */ 44467 bp := tls.Alloc(40) 44468 defer tls.Free(40) 44469 44470 // var db uintptr at bp+32, 8 44471 44472 var rc int32 44473 if argc != 2 { 44474 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 44475 ts+14765 /* " FILENAME\"" */, 0)) 44476 return TCL_ERROR 44477 } 44478 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { 44479 return TCL_ERROR 44480 } 44481 rc = sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */))) 44482 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 44483 return TCL_OK 44484 } 44485 44486 // Usage: sqlite3_close_v2 DB 44487 // 44488 // Closes the database opened by sqlite3_open. 44489 func sqlite_test_close_v2(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:704:26: */ 44490 bp := tls.Alloc(40) 44491 defer tls.Free(40) 44492 44493 // var db uintptr at bp+32, 8 44494 44495 var rc int32 44496 if argc != 2 { 44497 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 44498 ts+14765 /* " FILENAME\"" */, 0)) 44499 return TCL_ERROR 44500 } 44501 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { 44502 return TCL_ERROR 44503 } 44504 rc = sqlite3.Xsqlite3_close_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */))) 44505 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 44506 return TCL_OK 44507 } 44508 44509 // Implementation of the x_coalesce() function. 44510 // Return the first argument non-NULL argument. 44511 func t1_ifnullFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test1.c:727:13: */ 44512 var i int32 44513 for i = 0; i < argc; i++ { 44514 if SQLITE_NULL != sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) { 44515 var n int32 = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) 44516 sqlite3.Xsqlite3_result_text(tls, context, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))), 44517 n, libc.UintptrFromInt32(-1)) 44518 break 44519 } 44520 } 44521 } 44522 44523 // These are test functions. hex8() interprets its argument as 44524 // UTF8 and returns a hex encoding. hex16le() interprets its argument 44525 // as UTF16le and returns a hex encoding. 44526 func hex8Func(tls *libc.TLS, p uintptr, argc int32, argv uintptr) { /* test1.c:748:13: */ 44527 bp := tls.Alloc(208) 44528 defer tls.Free(208) 44529 44530 var z uintptr 44531 var i int32 44532 // var zBuf [200]int8 at bp+8, 200 44533 44534 z = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 44535 for i = 0; (uint64(i) < ((uint64(unsafe.Sizeof([200]int8{})) / uint64(2)) - uint64(2))) && (*(*uint8)(unsafe.Pointer(z + uintptr(i))) != 0); i++ { 44536 sqlite3.Xsqlite3_snprintf(tls, (int32(uint64(unsafe.Sizeof([200]int8{})) - (uint64(i * 2)))), (bp + 8 /* &zBuf */ + uintptr((i * 2))), ts+14776 /* "%02x" */, libc.VaList(bp, int32(*(*uint8)(unsafe.Pointer(z + uintptr(i)))))) 44537 } 44538 *(*int8)(unsafe.Pointer(bp + 8 /* &zBuf[0] */ + uintptr((i * 2)))) = int8(0) 44539 sqlite3.Xsqlite3_result_text(tls, p, bp+8 /* zBuf */, -1, libc.UintptrFromInt32(-1)) 44540 } 44541 44542 func hex16Func(tls *libc.TLS, p uintptr, argc int32, argv uintptr) { /* test1.c:760:13: */ 44543 bp := tls.Alloc(408) 44544 defer tls.Free(408) 44545 44546 var z uintptr 44547 var i int32 44548 // var zBuf [400]int8 at bp+8, 400 44549 44550 z = sqlite3.Xsqlite3_value_text16(tls, *(*uintptr)(unsafe.Pointer(argv))) 44551 for i = 0; (uint64(i) < ((uint64(unsafe.Sizeof([400]int8{})) / uint64(4)) - uint64(4))) && (*(*uint16)(unsafe.Pointer(z + uintptr(i)*2)) != 0); i++ { 44552 sqlite3.Xsqlite3_snprintf(tls, (int32(uint64(unsafe.Sizeof([400]int8{})) - (uint64(i * 4)))), (bp + 8 /* &zBuf */ + uintptr((i * 4))), ts+14781 /* "%04x" */, libc.VaList(bp, (int32(*(*uint16)(unsafe.Pointer(z + uintptr(i)*2)))&0xff))) 44553 } 44554 *(*int8)(unsafe.Pointer(bp + 8 /* &zBuf[0] */ + uintptr((i * 4)))) = int8(0) 44555 sqlite3.Xsqlite3_result_text(tls, p, bp+8 /* zBuf */, -1, libc.UintptrFromInt32(-1)) 44556 } 44557 44558 // A structure into which to accumulate text. 44559 type dstr = struct { 44560 FnAlloc int32 44561 FnUsed int32 44562 Fz uintptr 44563 } /* test1.c:776:1 */ 44564 44565 // Append text to a dstr 44566 func dstrAppend(tls *libc.TLS, p uintptr, z uintptr, divider int32) { /* test1.c:785:13: */ 44567 var n int32 = int32(libc.Xstrlen(tls, z)) 44568 if (((*dstr)(unsafe.Pointer(p)).FnUsed + n) + 2) > (*dstr)(unsafe.Pointer(p)).FnAlloc { 44569 var zNew uintptr 44570 (*dstr)(unsafe.Pointer(p)).FnAlloc = ((((*dstr)(unsafe.Pointer(p)).FnAlloc * 2) + n) + 200) 44571 zNew = sqlite3.Xsqlite3_realloc(tls, (*dstr)(unsafe.Pointer(p)).Fz, (*dstr)(unsafe.Pointer(p)).FnAlloc) 44572 if zNew == uintptr(0) { 44573 sqlite3.Xsqlite3_free(tls, (*dstr)(unsafe.Pointer(p)).Fz) 44574 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(dstr{}))) 44575 return 44576 } 44577 (*dstr)(unsafe.Pointer(p)).Fz = zNew 44578 } 44579 if (divider != 0) && ((*dstr)(unsafe.Pointer(p)).FnUsed > 0) { 44580 *(*int8)(unsafe.Pointer((*dstr)(unsafe.Pointer(p)).Fz + uintptr(libc.PostIncInt32(&(*dstr)(unsafe.Pointer(p)).FnUsed, 1)))) = int8(divider) 44581 } 44582 libc.Xmemcpy(tls, ((*dstr)(unsafe.Pointer(p)).Fz + uintptr((*dstr)(unsafe.Pointer(p)).FnUsed)), z, (uint64(n + 1))) 44583 *(*int32)(unsafe.Pointer(p + 4 /* &.nUsed */)) += (n) 44584 } 44585 44586 // Invoked for each callback from sqlite3ExecFunc 44587 func execFuncCallback(tls *libc.TLS, pData uintptr, argc int32, argv uintptr, NotUsed uintptr) int32 { /* test1.c:808:12: */ 44588 var p uintptr = pData 44589 var i int32 44590 for i = 0; i < argc; i++ { 44591 if *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)) == uintptr(0) { 44592 dstrAppend(tls, p, ts+5717 /* "NULL" */, ' ') 44593 } else { 44594 dstrAppend(tls, p, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), ' ') 44595 } 44596 } 44597 return 0 44598 } 44599 44600 // Implementation of the x_sqlite_exec() function. This function takes 44601 // a single argument and attempts to execute that argument as SQL code. 44602 // This is illegal and should set the SQLITE_MISUSE flag on the database. 44603 // 44604 // 2004-Jan-07: We have changed this to make it legal to call sqlite3_exec() 44605 // from within a function call. 44606 // 44607 // This routine simulates the effect of having two threads attempt to 44608 // use the same database at the same time. 44609 func sqlite3ExecFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test1.c:832:13: */ 44610 bp := tls.Alloc(16) 44611 defer tls.Free(16) 44612 44613 // var x dstr at bp, 16 44614 44615 libc.Xmemset(tls, bp /* &x */, 0, uint64(unsafe.Sizeof(dstr{}))) 44616 sqlite3.Xsqlite3_exec(tls, sqlite3.Xsqlite3_user_data(tls, context), 44617 sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))), 44618 *(*uintptr)(unsafe.Pointer(&struct { 44619 f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 44620 }{execFuncCallback})), bp /* &x */, uintptr(0)) 44621 sqlite3.Xsqlite3_result_text(tls, context, (*dstr)(unsafe.Pointer(bp /* &x */)).Fz, (*dstr)(unsafe.Pointer(bp /* &x */)).FnUsed, libc.UintptrFromInt32(-1)) 44622 sqlite3.Xsqlite3_free(tls, (*dstr)(unsafe.Pointer(bp /* &x */)).Fz) 44623 } 44624 44625 // Implementation of tkt2213func(), a scalar function that takes exactly 44626 // one argument. It has two interesting features: 44627 // 44628 // * It calls sqlite3_value_text() 3 times on the argument sqlite3_value*. 44629 // If the three pointers returned are not the same an SQL error is raised. 44630 // 44631 // * Otherwise it returns a copy of the text representation of its 44632 // argument in such a way as the VDBE representation is a Mem* cell 44633 // with the MEM_Term flag clear. 44634 // 44635 // Ticket #2213 can therefore be tested by evaluating the following 44636 // SQL expression: 44637 // 44638 // tkt2213func(tkt2213func('a string')); 44639 func tkt2213Function(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test1.c:862:13: */ 44640 var nText int32 44641 var zText1 uintptr 44642 var zText2 uintptr 44643 var zText3 uintptr 44644 44645 nText = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) 44646 zText1 = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 44647 zText2 = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 44648 zText3 = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 44649 44650 if (zText1 != zText2) || (zText2 != zText3) { 44651 sqlite3.Xsqlite3_result_error(tls, context, ts+14786 /* "tkt2213 is not f..." */, -1) 44652 } else { 44653 var zCopy uintptr = sqlite3.Xsqlite3_malloc(tls, nText) 44654 libc.Xmemcpy(tls, zCopy, zText1, uint64(nText)) 44655 sqlite3.Xsqlite3_result_text(tls, context, zCopy, nText, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) 44656 } 44657 } 44658 44659 // The following SQL function takes 4 arguments. The 2nd and 44660 // 4th argument must be one of these strings: 'text', 'text16', 44661 // or 'blob' corresponding to API functions 44662 // 44663 // sqlite3_value_text() 44664 // sqlite3_value_text16() 44665 // sqlite3_value_blob() 44666 // 44667 // The third argument is a string, either 'bytes' or 'bytes16' or 'noop', 44668 // corresponding to APIs: 44669 // 44670 // sqlite3_value_bytes() 44671 // sqlite3_value_bytes16() 44672 // noop 44673 // 44674 // The APIs designated by the 2nd through 4th arguments are applied 44675 // to the first argument in order. If the pointers returned by the 44676 // second and fourth are different, this routine returns 1. Otherwise, 44677 // this routine returns 0. 44678 // 44679 // This function is used to test to see when returned pointers from 44680 // the _text(), _text16() and _blob() APIs become invalidated. 44681 func ptrChngFunction(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test1.c:910:13: */ 44682 var p1 uintptr 44683 var p2 uintptr 44684 var zCmd uintptr 44685 if argc != 4 { 44686 return 44687 } 44688 zCmd = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 44689 if zCmd == uintptr(0) { 44690 return 44691 } 44692 if libc.Xstrcmp(tls, zCmd, ts+12455 /* "text" */) == 0 { 44693 p1 = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 44694 } else if libc.Xstrcmp(tls, zCmd, ts+14807 /* "text16" */) == 0 { 44695 p1 = sqlite3.Xsqlite3_value_text16(tls, *(*uintptr)(unsafe.Pointer(argv))) 44696 } else if libc.Xstrcmp(tls, zCmd, ts+12460 /* "blob" */) == 0 { 44697 p1 = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) 44698 } else { 44699 return 44700 } 44701 zCmd = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) 44702 if zCmd == uintptr(0) { 44703 return 44704 } 44705 if libc.Xstrcmp(tls, zCmd, ts+14814 /* "bytes" */) == 0 { 44706 sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) 44707 } else if libc.Xstrcmp(tls, zCmd, ts+14820 /* "bytes16" */) == 0 { 44708 sqlite3.Xsqlite3_value_bytes16(tls, *(*uintptr)(unsafe.Pointer(argv))) 44709 } else if libc.Xstrcmp(tls, zCmd, ts+14828 /* "noop" */) == 0 { 44710 // do nothing 44711 } else { 44712 return 44713 } 44714 zCmd = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) 44715 if zCmd == uintptr(0) { 44716 return 44717 } 44718 if libc.Xstrcmp(tls, zCmd, ts+12455 /* "text" */) == 0 { 44719 p2 = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 44720 } else if libc.Xstrcmp(tls, zCmd, ts+14807 /* "text16" */) == 0 { 44721 p2 = sqlite3.Xsqlite3_value_text16(tls, *(*uintptr)(unsafe.Pointer(argv))) 44722 } else if libc.Xstrcmp(tls, zCmd, ts+12460 /* "blob" */) == 0 { 44723 p2 = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) 44724 } else { 44725 return 44726 } 44727 sqlite3.Xsqlite3_result_int(tls, context, (libc.Bool32(p1 != p2))) 44728 } 44729 44730 // This SQL function returns a different answer each time it is called, even if 44731 // the arguments are the same. 44732 func nondeterministicFunction(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test1.c:964:13: */ 44733 sqlite3.Xsqlite3_result_int(tls, context, libc.PostIncInt32(&cnt, 1)) 44734 } 44735 44736 var cnt int32 = 0 /* test1.c:969:14 */ 44737 44738 // This SQL function returns the integer value of its argument as a MEM_IntReal 44739 // value. 44740 func intrealFunction(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test1.c:977:13: */ 44741 bp := tls.Alloc(8) 44742 defer tls.Free(8) 44743 44744 var v sqlite3_int64 = sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv))) 44745 sqlite3.Xsqlite3_result_int64(tls, context, v) 44746 sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_RESULT_INTREAL, libc.VaList(bp, context)) 44747 } 44748 44749 // Usage: sqlite3_create_function DB 44750 // 44751 // Call the sqlite3_create_function API on the given database in order 44752 // to create a function named "x_coalesce". This function does the same thing 44753 // as the "coalesce" function. This function also registers an SQL function 44754 // named "x_sqlite_exec" that invokes sqlite3_exec(). Invoking sqlite3_exec() 44755 // in this way is illegal recursion and should raise an SQLITE_MISUSE error. 44756 // The effect is similar to trying to use the same database connection from 44757 // two threads at the same time. 44758 // 44759 // The original motivation for this routine was to be able to call the 44760 // sqlite3_create_function function while a query is in progress in order 44761 // to test the SQLITE_MISUSE detection logic. 44762 func test_create_function(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:1002:26: */ 44763 bp := tls.Alloc(40) 44764 defer tls.Free(40) 44765 44766 var rc int32 44767 // var db uintptr at bp+32, 8 44768 44769 if argc != 2 { 44770 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 44771 ts+14760 /* " DB\"" */, 0)) 44772 return TCL_ERROR 44773 } 44774 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { 44775 return TCL_ERROR 44776 } 44777 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14833 /* "x_coalesce" */, -1, SQLITE_UTF8, uintptr(0), 44778 *(*uintptr)(unsafe.Pointer(&struct { 44779 f func(*libc.TLS, uintptr, int32, uintptr) 44780 }{t1_ifnullFunc})), uintptr(0), uintptr(0)) 44781 if rc == SQLITE_OK { 44782 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14844 /* "hex8" */, 1, (SQLITE_UTF8 | SQLITE_DETERMINISTIC), 44783 uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 44784 f func(*libc.TLS, uintptr, int32, uintptr) 44785 }{hex8Func})), uintptr(0), uintptr(0)) 44786 } 44787 if rc == SQLITE_OK { 44788 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14849 /* "hex16" */, 1, (SQLITE_UTF16 | SQLITE_DETERMINISTIC), 44789 uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 44790 f func(*libc.TLS, uintptr, int32, uintptr) 44791 }{hex16Func})), uintptr(0), uintptr(0)) 44792 } 44793 if rc == SQLITE_OK { 44794 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14855 /* "tkt2213func" */, 1, SQLITE_ANY, uintptr(0), 44795 *(*uintptr)(unsafe.Pointer(&struct { 44796 f func(*libc.TLS, uintptr, int32, uintptr) 44797 }{tkt2213Function})), uintptr(0), uintptr(0)) 44798 } 44799 if rc == SQLITE_OK { 44800 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14867 /* "pointer_change" */, 4, SQLITE_ANY, uintptr(0), 44801 *(*uintptr)(unsafe.Pointer(&struct { 44802 f func(*libc.TLS, uintptr, int32, uintptr) 44803 }{ptrChngFunction})), uintptr(0), uintptr(0)) 44804 } 44805 44806 // Functions counter1() and counter2() have the same implementation - they 44807 // both return an ascending integer with each call. But counter1() is marked 44808 // as non-deterministic and counter2() is marked as deterministic. 44809 if rc == SQLITE_OK { 44810 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14882 /* "counter1" */, -1, SQLITE_UTF8, 44811 uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 44812 f func(*libc.TLS, uintptr, int32, uintptr) 44813 }{nondeterministicFunction})), uintptr(0), uintptr(0)) 44814 } 44815 if rc == SQLITE_OK { 44816 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14891 /* "counter2" */, -1, (SQLITE_UTF8 | SQLITE_DETERMINISTIC), 44817 uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 44818 f func(*libc.TLS, uintptr, int32, uintptr) 44819 }{nondeterministicFunction})), uintptr(0), uintptr(0)) 44820 } 44821 44822 // The intreal() function converts its argument to an integer and returns 44823 // it as a MEM_IntReal. 44824 if rc == SQLITE_OK { 44825 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14900 /* "intreal" */, 1, SQLITE_UTF8, 44826 uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 44827 f func(*libc.TLS, uintptr, int32, uintptr) 44828 }{intrealFunction})), uintptr(0), uintptr(0)) 44829 } 44830 44831 // Use the sqlite3_create_function16() API here. Mainly for fun, but also 44832 // because it is not tested anywhere else. 44833 if rc == SQLITE_OK { 44834 var zUtf16 uintptr 44835 var pVal uintptr 44836 sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmutex) 44837 pVal = sqlite3.Xsqlite3ValueNew(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */))) 44838 sqlite3.Xsqlite3ValueSetStr(tls, pVal, -1, ts+14908 /* "x_sqlite_exec" */, uint8(SQLITE_UTF8), uintptr(0)) 44839 zUtf16 = sqlite3.Xsqlite3ValueText(tls, pVal, func() uint8 { 44840 if int32(*(*int8)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3.Xsqlite3one))))) == 0 { 44841 return uint8(SQLITE_UTF16BE) 44842 } 44843 return uint8(SQLITE_UTF16LE) 44844 }()) 44845 if (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).FmallocFailed != 0 { 44846 rc = SQLITE_NOMEM 44847 } else { 44848 rc = sqlite3.Xsqlite3_create_function16(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), zUtf16, 44849 1, SQLITE_UTF16, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), *(*uintptr)(unsafe.Pointer(&struct { 44850 f func(*libc.TLS, uintptr, int32, uintptr) 44851 }{sqlite3ExecFunc})), uintptr(0), uintptr(0)) 44852 } 44853 sqlite3.Xsqlite3ValueFree(tls, pVal) 44854 sqlite3.Xsqlite3_mutex_leave(tls, (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmutex) 44855 } 44856 44857 if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), rc) != 0 { 44858 return TCL_ERROR 44859 } 44860 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 44861 return TCL_OK 44862 } 44863 44864 // Usage: sqlite3_drop_modules DB ?NAME ...? 44865 // 44866 // Invoke the sqlite3_drop_modules(D,L) interface on database 44867 // connection DB, in order to drop all modules except those named in 44868 // the argument. 44869 func test_drop_modules(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:1092:26: */ 44870 bp := tls.Alloc(40) 44871 defer tls.Free(40) 44872 44873 // var db uintptr at bp+32, 8 44874 44875 if argc != 2 { 44876 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 44877 ts+14760 /* " DB\"" */, 0)) 44878 return TCL_ERROR 44879 } 44880 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { 44881 return TCL_ERROR 44882 } 44883 sqlite3.Xsqlite3_drop_modules(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), func() uintptr { 44884 if argc > 2 { 44885 return (argv + uintptr(2)*8) 44886 } 44887 return uintptr(0) 44888 }()) 44889 return TCL_OK 44890 } 44891 44892 // Routines to implement the x_count() aggregate function. 44893 // 44894 // x_count() counts the number of non-null arguments. But there are 44895 // some twists for testing purposes. 44896 // 44897 // If the argument to x_count() is 40 then a UTF-8 error is reported 44898 // on the step function. If x_count(41) is seen, then a UTF-16 error 44899 // is reported on the step function. If the total count is 42, then 44900 // a UTF-8 error is reported on the finalize function. 44901 type t1CountCtx1 = struct{ Fn int32 } /* test1.c:1123:9 */ 44902 44903 // Routines to implement the x_count() aggregate function. 44904 // 44905 // x_count() counts the number of non-null arguments. But there are 44906 // some twists for testing purposes. 44907 // 44908 // If the argument to x_count() is 40 then a UTF-8 error is reported 44909 // on the step function. If x_count(41) is seen, then a UTF-16 error 44910 // is reported on the step function. If the total count is 42, then 44911 // a UTF-8 error is reported on the finalize function. 44912 type t1CountCtx = t1CountCtx1 /* test1.c:1123:27 */ 44913 44914 func t1CountStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test1.c:1127:13: */ 44915 bp := tls.Alloc(9) 44916 defer tls.Free(9) 44917 44918 var p uintptr 44919 p = sqlite3.Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(t1CountCtx{}))) 44920 if ((argc == 0) || (SQLITE_NULL != sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))))) && (p != 0) { 44921 (*t1CountCtx)(unsafe.Pointer(p)).Fn++ 44922 } 44923 if argc > 0 { 44924 var v int32 = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))) 44925 if v == 40 { 44926 sqlite3.Xsqlite3_result_error(tls, context, ts+14922 /* "value of 40 hand..." */, -1) 44927 } else if v == 41 { 44928 *(*[9]int8)(unsafe.Pointer(bp /* zUtf16ErrMsg */)) = [9]int8{int8(0), int8(0x61), int8(0), int8(0x62), int8(0), int8(0x63), int8(0), int8(0), int8(0)} 44929 sqlite3.Xsqlite3_result_error16(tls, context, (bp /* &zUtf16ErrMsg */ + uintptr((1 - (libc.Bool32(int32(*(*int8)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3.Xsqlite3one))))) == 0))))), -1) 44930 } 44931 } 44932 } 44933 44934 func t1CountFinalize(tls *libc.TLS, context uintptr) { /* test1.c:1149:13: */ 44935 var p uintptr 44936 p = sqlite3.Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(t1CountCtx{}))) 44937 if p != 0 { 44938 if (*t1CountCtx)(unsafe.Pointer(p)).Fn == 42 { 44939 sqlite3.Xsqlite3_result_error(tls, context, ts+14952 /* "x_count totals t..." */, -1) 44940 } else { 44941 sqlite3.Xsqlite3_result_int(tls, context, func() int32 { 44942 if p != 0 { 44943 return (*t1CountCtx)(unsafe.Pointer(p)).Fn 44944 } 44945 return 0 44946 }()) 44947 } 44948 } 44949 } 44950 44951 func legacyCountStep(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test1.c:1162:13: */ 44952 // no-op 44953 } 44954 44955 func legacyCountFinalize(tls *libc.TLS, context uintptr) { /* test1.c:1170:13: */ 44956 sqlite3.Xsqlite3_result_int(tls, context, sqlite3.Xsqlite3_aggregate_count(tls, context)) 44957 } 44958 44959 // Usage: sqlite3_create_aggregate DB 44960 // 44961 // Call the sqlite3_create_function API on the given database in order 44962 // to create a function named "x_count". This function is similar 44963 // to the built-in count() function, with a few special quirks 44964 // for testing the sqlite3_result_error() APIs. 44965 // 44966 // The original motivation for this routine was to be able to call the 44967 // sqlite3_create_aggregate function while a query is in progress in order 44968 // to test the SQLITE_MISUSE detection logic. See misuse.test. 44969 // 44970 // This routine was later extended to test the use of sqlite3_result_error() 44971 // within aggregate functions. 44972 // 44973 // Later: It is now also extended to register the aggregate function 44974 // "legacy_count()" with the supplied database handle. This is used 44975 // to test the deprecated sqlite3_aggregate_count() API. 44976 func test_create_aggregate(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:1194:26: */ 44977 bp := tls.Alloc(40) 44978 defer tls.Free(40) 44979 44980 // var db uintptr at bp+32, 8 44981 44982 var rc int32 44983 if argc != 2 { 44984 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 44985 ts+14765 /* " FILENAME\"" */, 0)) 44986 return TCL_ERROR 44987 } 44988 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { 44989 return TCL_ERROR 44990 } 44991 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14973 /* "x_count" */, 0, SQLITE_UTF8, uintptr(0), uintptr(0), 44992 *(*uintptr)(unsafe.Pointer(&struct { 44993 f func(*libc.TLS, uintptr, int32, uintptr) 44994 }{t1CountStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{t1CountFinalize}))) 44995 if rc == SQLITE_OK { 44996 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14973 /* "x_count" */, 1, SQLITE_UTF8, uintptr(0), uintptr(0), 44997 *(*uintptr)(unsafe.Pointer(&struct { 44998 f func(*libc.TLS, uintptr, int32, uintptr) 44999 }{t1CountStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{t1CountFinalize}))) 45000 } 45001 if rc == SQLITE_OK { 45002 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+14981 /* "legacy_count" */, 0, SQLITE_ANY, uintptr(0), uintptr(0), 45003 *(*uintptr)(unsafe.Pointer(&struct { 45004 f func(*libc.TLS, uintptr, int32, uintptr) 45005 }{legacyCountStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{legacyCountFinalize}))) 45006 } 45007 if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), rc) != 0 { 45008 return TCL_ERROR 45009 } 45010 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 45011 return TCL_OK 45012 } 45013 45014 // Usage: printf TEXT 45015 // 45016 // Send output to printf. Use this rather than puts to merge the output 45017 // in the correct sequence with debugging printfs inserted into C code. 45018 // Puts uses a separate buffer and debugging statements will be out of 45019 // sequence if it is used. 45020 func test_printf(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:1235:26: */ 45021 bp := tls.Alloc(40) 45022 defer tls.Free(40) 45023 45024 if argc != 2 { 45025 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 45026 ts+14994 /* " TEXT\"" */, 0)) 45027 return TCL_ERROR 45028 } 45029 libc.Xprintf(tls, ts+294 /* "%s\n" */, libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) 45030 return TCL_OK 45031 } 45032 45033 // Usage: sqlite3_mprintf_int FORMAT INTEGER INTEGER INTEGER 45034 // 45035 // Call mprintf with three integer arguments 45036 func sqlite3_mprintf_int(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:1257:26: */ 45037 bp := tls.Alloc(84) 45038 defer tls.Free(84) 45039 45040 // var a [3]int32 at bp+72, 12 45041 45042 var i int32 45043 var z uintptr 45044 if argc != 5 { 45045 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 45046 ts+15001 /* " FORMAT INT INT ..." */, 0)) 45047 return TCL_ERROR 45048 } 45049 for i = 2; i < 5; i++ { 45050 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), (bp+72 /* &a */ +uintptr((i-2))*4)) != 0 { 45051 return TCL_ERROR 45052 } 45053 } 45054 z = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)), libc.VaList(bp+32, *(*int32)(unsafe.Pointer(bp + 72 /* &a[0] */)), *(*int32)(unsafe.Pointer(bp + 72 /* &a[0] */ + 1*4)), *(*int32)(unsafe.Pointer(bp + 72 /* &a[0] */ + 2*4)))) 45055 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, z, 0)) 45056 sqlite3.Xsqlite3_free(tls, z) 45057 return TCL_OK 45058 } 45059 45060 // Usage: sqlite3_mprintf_int64 FORMAT INTEGER INTEGER INTEGER 45061 // 45062 // Call mprintf with three 64-bit integer arguments 45063 func sqlite3_mprintf_int64(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:1284:26: */ 45064 bp := tls.Alloc(112) 45065 defer tls.Free(112) 45066 45067 var i int32 45068 // var a [3]sqlite_int64 at bp+88, 24 45069 45070 var z uintptr 45071 if argc != 5 { 45072 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 45073 ts+15001 /* " FORMAT INT INT ..." */, 0)) 45074 return TCL_ERROR 45075 } 45076 for i = 2; i < 5; i++ { 45077 if sqlite3.Xsqlite3Atoi64(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), (bp+88 /* &a */ +uintptr((i-2))*8), sqlite3.Xsqlite3Strlen30(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))), uint8(SQLITE_UTF8)) != 0 { 45078 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+15022 /* "argument is not ..." */, 0)) 45079 return TCL_ERROR 45080 } 45081 } 45082 z = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)), libc.VaList(bp+48, *(*sqlite_int64)(unsafe.Pointer(bp + 88 /* &a[0] */)), *(*sqlite_int64)(unsafe.Pointer(bp + 88 /* &a[0] */ + 1*8)), *(*sqlite_int64)(unsafe.Pointer(bp + 88 /* &a[0] */ + 2*8)))) 45083 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+72, z, 0)) 45084 sqlite3.Xsqlite3_free(tls, z) 45085 return TCL_OK 45086 } 45087 45088 // Usage: sqlite3_mprintf_long FORMAT INTEGER INTEGER INTEGER 45089 // 45090 // Call mprintf with three long integer arguments. This might be the 45091 // same as sqlite3_mprintf_int or sqlite3_mprintf_int64, depending on 45092 // platform. 45093 func sqlite3_mprintf_long(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:1317:26: */ 45094 bp := tls.Alloc(112) 45095 defer tls.Free(112) 45096 45097 var i int32 45098 // var a [3]int64 at bp+88, 24 45099 45100 // var b [3]int32 at bp+72, 12 45101 45102 var z uintptr 45103 if argc != 5 { 45104 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 45105 ts+15001 /* " FORMAT INT INT ..." */, 0)) 45106 return TCL_ERROR 45107 } 45108 for i = 2; i < 5; i++ { 45109 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), (bp+72 /* &b */ +uintptr((i-2))*4)) != 0 { 45110 return TCL_ERROR 45111 } 45112 *(*int64)(unsafe.Pointer(bp + 88 /* &a[0] */ + uintptr((i-2))*8)) = int64(*(*int32)(unsafe.Pointer(bp + 72 /* &b[0] */ + uintptr((i-2))*4))) 45113 *(*int64)(unsafe.Pointer(bp + 88 /* &a */ + uintptr((i-2))*8)) &= int64(((u64((uint64(1))) << (uint64(unsafe.Sizeof(int32(0))) * uint64(8))) - uint64(1))) 45114 } 45115 z = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)), libc.VaList(bp+32, *(*int64)(unsafe.Pointer(bp + 88 /* &a[0] */)), *(*int64)(unsafe.Pointer(bp + 88 /* &a[0] */ + 1*8)), *(*int64)(unsafe.Pointer(bp + 88 /* &a[0] */ + 2*8)))) 45116 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, z, 0)) 45117 sqlite3.Xsqlite3_free(tls, z) 45118 return TCL_OK 45119 } 45120 45121 // Usage: sqlite3_mprintf_str FORMAT INTEGER INTEGER STRING 45122 // 45123 // Call mprintf with two integer arguments and one string argument 45124 func sqlite3_mprintf_str(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:1348:26: */ 45125 bp := tls.Alloc(84) 45126 defer tls.Free(84) 45127 45128 // var a [3]int32 at bp+72, 12 45129 45130 var i int32 45131 var z uintptr 45132 if (argc < 4) || (argc > 5) { 45133 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 45134 ts+15061 /* " FORMAT INT INT ..." */, 0)) 45135 return TCL_ERROR 45136 } 45137 for i = 2; i < 4; i++ { 45138 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), (bp+72 /* &a */ +uintptr((i-2))*4)) != 0 { 45139 return TCL_ERROR 45140 } 45141 } 45142 z = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)), libc.VaList(bp+32, *(*int32)(unsafe.Pointer(bp + 72 /* &a[0] */)), *(*int32)(unsafe.Pointer(bp + 72 /* &a[0] */ + 1*4)), func() uintptr { 45143 if argc > 4 { 45144 return *(*uintptr)(unsafe.Pointer(argv + 4*8)) 45145 } 45146 return uintptr(0) 45147 }())) 45148 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, z, 0)) 45149 sqlite3.Xsqlite3_free(tls, z) 45150 return TCL_OK 45151 } 45152 45153 // Usage: sqlite3_snprintf_str INTEGER FORMAT INTEGER INTEGER STRING 45154 // 45155 // Call mprintf with two integer arguments and one string argument 45156 func sqlite3_snprintf_str(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:1375:26: */ 45157 bp := tls.Alloc(104) 45158 defer tls.Free(104) 45159 45160 // var a [3]int32 at bp+92, 12 45161 45162 var i int32 45163 // var n int32 at bp+88, 4 45164 45165 var z uintptr 45166 if (argc < 5) || (argc > 6) { 45167 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 45168 ts+15087 /* " INT FORMAT INT ..." */, 0)) 45169 return TCL_ERROR 45170 } 45171 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+88 /* &n */) != 0 { 45172 return TCL_ERROR 45173 } 45174 if *(*int32)(unsafe.Pointer(bp + 88 /* n */)) < 0 { 45175 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+15117 /* "N must be non-ne..." */, 0)) 45176 return TCL_ERROR 45177 } 45178 for i = 3; i < 5; i++ { 45179 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), (bp+92 /* &a */ +uintptr((i-3))*4)) != 0 { 45180 return TCL_ERROR 45181 } 45182 } 45183 z = sqlite3.Xsqlite3_malloc(tls, (*(*int32)(unsafe.Pointer(bp + 88 /* n */)) + 1)) 45184 sqlite3.Xsqlite3_snprintf(tls, *(*int32)(unsafe.Pointer(bp + 88 /* n */)), z, *(*uintptr)(unsafe.Pointer(argv + 2*8)), libc.VaList(bp+48, *(*int32)(unsafe.Pointer(bp + 92 /* &a[0] */)), *(*int32)(unsafe.Pointer(bp + 92 /* &a[0] */ + 1*4)), func() uintptr { 45185 if argc > 4 { 45186 return *(*uintptr)(unsafe.Pointer(argv + 5*8)) 45187 } 45188 return uintptr(0) 45189 }())) 45190 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+72, z, 0)) 45191 sqlite3.Xsqlite3_free(tls, z) 45192 return TCL_OK 45193 } 45194 45195 // Usage: sqlite3_mprintf_double FORMAT INTEGER INTEGER DOUBLE 45196 // 45197 // Call mprintf with two integer arguments and one double argument 45198 func sqlite3_mprintf_double(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:1409:26: */ 45199 bp := tls.Alloc(96) 45200 defer tls.Free(96) 45201 45202 // var a [3]int32 at bp+72, 12 45203 45204 var i int32 45205 // var r float64 at bp+88, 8 45206 45207 var z uintptr 45208 if argc != 5 { 45209 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 45210 ts+15140 /* " FORMAT INT INT ..." */, 0)) 45211 return TCL_ERROR 45212 } 45213 for i = 2; i < 4; i++ { 45214 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), (bp+72 /* &a */ +uintptr((i-2))*4)) != 0 { 45215 return TCL_ERROR 45216 } 45217 } 45218 if tcl.XTcl_GetDouble(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 4*8)), bp+88 /* &r */) != 0 { 45219 return TCL_ERROR 45220 } 45221 z = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)), libc.VaList(bp+32, *(*int32)(unsafe.Pointer(bp + 72 /* &a[0] */)), *(*int32)(unsafe.Pointer(bp + 72 /* &a[0] */ + 1*4)), *(*float64)(unsafe.Pointer(bp + 88 /* r */)))) 45222 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, z, 0)) 45223 sqlite3.Xsqlite3_free(tls, z) 45224 return TCL_OK 45225 } 45226 45227 // Usage: sqlite3_mprintf_scaled FORMAT DOUBLE DOUBLE 45228 // 45229 // Call mprintf with a single double argument which is the product of the 45230 // two arguments given above. This is used to generate overflow and underflow 45231 // doubles to test that they are converted properly. 45232 func sqlite3_mprintf_scaled(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:1440:26: */ 45233 bp := tls.Alloc(72) 45234 defer tls.Free(72) 45235 45236 var i int32 45237 // var r [2]float64 at bp+56, 16 45238 45239 var z uintptr 45240 if argc != 4 { 45241 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 45242 ts+15164 /* " FORMAT DOUBLE D..." */, 0)) 45243 return TCL_ERROR 45244 } 45245 for i = 2; i < 4; i++ { 45246 if tcl.XTcl_GetDouble(tls, interp, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)), (bp+56 /* &r */ +uintptr((i-2))*8)) != 0 { 45247 return TCL_ERROR 45248 } 45249 } 45250 z = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)), libc.VaList(bp+32, (*(*float64)(unsafe.Pointer(bp + 56 /* &r[0] */))**(*float64)(unsafe.Pointer(bp + 56 /* &r[0] */ + 1*8))))) 45251 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, z, 0)) 45252 sqlite3.Xsqlite3_free(tls, z) 45253 return TCL_OK 45254 } 45255 45256 // Usage: sqlite3_mprintf_stronly FORMAT STRING 45257 // 45258 // Call mprintf with a single double argument which is the product of the 45259 // two arguments given above. This is used to generate overflow and underflow 45260 // doubles to test that they are converted properly. 45261 func sqlite3_mprintf_stronly(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:1470:26: */ 45262 bp := tls.Alloc(56) 45263 defer tls.Free(56) 45264 45265 var z uintptr 45266 if argc != 3 { 45267 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 45268 ts+15187 /* " FORMAT STRING\"" */, 0)) 45269 return TCL_ERROR 45270 } 45271 z = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)), libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) 45272 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, z, 0)) 45273 sqlite3.Xsqlite3_free(tls, z) 45274 return TCL_OK 45275 } 45276 45277 // Usage: sqlite3_mprintf_hexdouble FORMAT HEX 45278 // 45279 // Call mprintf with a single double argument which is derived from the 45280 // hexadecimal encoding of an IEEE double. 45281 func sqlite3_mprintf_hexdouble(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:1494:26: */ 45282 bp := tls.Alloc(112) 45283 defer tls.Free(112) 45284 45285 var z uintptr 45286 // var r float64 at bp+96, 8 45287 45288 // var x1 uint32 at bp+92, 4 45289 45290 // var x2 uint32 at bp+88, 4 45291 45292 // var d sqlite_uint64 at bp+104, 8 45293 45294 if argc != 3 { 45295 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 45296 ts+15187 /* " FORMAT STRING\"" */, 0)) 45297 return TCL_ERROR 45298 } 45299 if libc.Xsscanf(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)), ts+15203 /* "%08x%08x" */, libc.VaList(bp+32, bp+88 /* &x2 */, bp+92 /* &x1 */)) != 2 { 45300 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+15212 /* "2nd argument sho..." */, 0)) 45301 return TCL_ERROR 45302 } 45303 *(*sqlite_uint64)(unsafe.Pointer(bp + 104 /* d */)) = sqlite_uint64(*(*uint32)(unsafe.Pointer(bp + 88 /* x2 */))) 45304 *(*sqlite_uint64)(unsafe.Pointer(bp + 104 /* d */)) = ((*(*sqlite_uint64)(unsafe.Pointer(bp + 104 /* d */)) << 32) + sqlite_uint64(*(*uint32)(unsafe.Pointer(bp + 92 /* x1 */)))) 45305 libc.Xmemcpy(tls, bp+96 /* &r */, bp+104 /* &d */, uint64(unsafe.Sizeof(float64(0)))) 45306 z = sqlite3.Xsqlite3_mprintf(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)), libc.VaList(bp+64, *(*float64)(unsafe.Pointer(bp + 96 /* r */)))) 45307 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+72, z, 0)) 45308 sqlite3.Xsqlite3_free(tls, z) 45309 return TCL_OK 45310 } 45311 45312 // Usage: sqlite3_enable_shared_cache ?BOOLEAN? 45313 // 45314 func test_enable_shared(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:1527:26: */ 45315 bp := tls.Alloc(4) 45316 defer tls.Free(4) 45317 45318 var rc int32 45319 // var enable int32 at bp, 4 45320 45321 var ret int32 = 0 45322 45323 if (objc != 2) && (objc != 1) { 45324 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2761 /* "?BOOLEAN?" */) 45325 return TCL_ERROR 45326 } 45327 ret = sqlite3.Xsqlite3Config.FsharedCacheEnabled 45328 45329 if objc == 2 { 45330 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &enable */) != 0 { 45331 return TCL_ERROR 45332 } 45333 rc = sqlite3.Xsqlite3_enable_shared_cache(tls, *(*int32)(unsafe.Pointer(bp /* enable */))) 45334 if rc != SQLITE_OK { 45335 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrStr(tls, rc), uintptr(0)) 45336 return TCL_ERROR 45337 } 45338 } 45339 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, (libc.Bool32((ret) != 0)))) 45340 return TCL_OK 45341 } 45342 45343 // Usage: sqlite3_extended_result_codes DB BOOLEAN 45344 // 45345 func test_extended_result_codes(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:1564:26: */ 45346 bp := tls.Alloc(12) 45347 defer tls.Free(12) 45348 45349 // var enable int32 at bp+8, 4 45350 45351 // var db uintptr at bp, 8 45352 45353 if objc != 3 { 45354 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15256 /* "DB BOOLEAN" */) 45355 return TCL_ERROR 45356 } 45357 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 45358 return TCL_ERROR 45359 } 45360 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &enable */) != 0 { 45361 return TCL_ERROR 45362 } 45363 sqlite3.Xsqlite3_extended_result_codes(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), *(*int32)(unsafe.Pointer(bp + 8 /* enable */))) 45364 return TCL_OK 45365 } 45366 45367 // Usage: sqlite3_libversion_number 45368 // 45369 func test_libversion_number(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:1587:26: */ 45370 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_libversion_number(tls))) 45371 return TCL_OK 45372 } 45373 45374 // Usage: sqlite3_table_column_metadata DB dbname tblname colname 45375 // 45376 func test_table_column_metadata(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:1601:26: */ 45377 bp := tls.Alloc(52) 45378 defer tls.Free(52) 45379 45380 // var db uintptr at bp+16, 8 45381 45382 var zDb uintptr 45383 var zTbl uintptr 45384 var zCol uintptr 45385 var rc int32 45386 var pRet uintptr 45387 // var zDatatype uintptr at bp+24, 8 45388 45389 // var zCollseq uintptr at bp+32, 8 45390 45391 // var notnull int32 at bp+40, 4 45392 45393 // var primarykey int32 at bp+44, 4 45394 45395 // var autoincrement int32 at bp+48, 4 45396 45397 if (objc != 5) && (objc != 4) { 45398 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15267 /* "DB dbname tblnam..." */) 45399 return TCL_ERROR 45400 } 45401 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+16 /* &db */) != 0 { 45402 return TCL_ERROR 45403 } 45404 zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 45405 zTbl = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 45406 if objc == 5 { 45407 zCol = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8))) 45408 } else { 45409 zCol = uintptr(0) 45410 } 45411 45412 if libc.Xstrlen(tls, zDb) == uint64(0) { 45413 zDb = uintptr(0) 45414 } 45415 45416 rc = sqlite3.Xsqlite3_table_column_metadata(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), zDb, zTbl, zCol, 45417 bp+24 /* &zDatatype */, bp+32 /* &zCollseq */, bp+40 /* ¬null */, bp+44 /* &primarykey */, bp+48 /* &autoincrement */) 45418 45419 if rc != SQLITE_OK { 45420 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */))), 0)) 45421 return TCL_ERROR 45422 } 45423 45424 pRet = tcl.XTcl_NewObj(tls) 45425 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pRet, tcl.XTcl_NewStringObj(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* zDatatype */)), -1)) 45426 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pRet, tcl.XTcl_NewStringObj(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* zCollseq */)), -1)) 45427 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pRet, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 40 /* notnull */)))) 45428 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pRet, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 44 /* primarykey */)))) 45429 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pRet, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 48 /* autoincrement */)))) 45430 tcl.XTcl_SetObjResult(tls, interp, pRet) 45431 45432 return TCL_OK 45433 } 45434 45435 func blobHandleFromObj(tls *libc.TLS, interp uintptr, pObj uintptr, ppBlob uintptr) int32 { /* test1.c:1652:26: */ 45436 bp := tls.Alloc(8) 45437 defer tls.Free(8) 45438 45439 var z uintptr 45440 // var n int32 at bp, 4 45441 45442 z = tcl.XTcl_GetStringFromObj(tls, pObj, bp /* &n */) 45443 if *(*int32)(unsafe.Pointer(bp /* n */)) == 0 { 45444 *(*uintptr)(unsafe.Pointer(ppBlob)) = uintptr(0) 45445 } else { 45446 // var notUsed int32 at bp+4, 4 45447 45448 var channel Tcl_Channel 45449 var instanceData ClientData 45450 45451 channel = tcl.XTcl_GetChannel(tls, interp, z, bp+4 /* ¬Used */) 45452 if !(channel != 0) { 45453 return TCL_ERROR 45454 } 45455 45456 tcl.XTcl_Flush(tls, channel) 45457 tcl.XTcl_Seek(tls, channel, int64(0), SEEK_SET) 45458 45459 instanceData = tcl.XTcl_GetChannelInstanceData(tls, channel) 45460 *(*uintptr)(unsafe.Pointer(ppBlob)) = *(*uintptr)(unsafe.Pointer(instanceData)) 45461 } 45462 45463 return TCL_OK 45464 } 45465 45466 func test_blob_reopen(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:1681:26: */ 45467 bp := tls.Alloc(16) 45468 defer tls.Free(16) 45469 45470 // var iRowid Tcl_WideInt at bp+8, 8 45471 45472 // var pBlob uintptr at bp, 8 45473 45474 var rc int32 45475 45476 if objc != 3 { 45477 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15293 /* "CHANNEL ROWID" */) 45478 return TCL_ERROR 45479 } 45480 45481 if blobHandleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &pBlob */) != 0 { 45482 return TCL_ERROR 45483 } 45484 if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &iRowid */) != 0 { 45485 return TCL_ERROR 45486 } 45487 45488 rc = sqlite3.Xsqlite3_blob_reopen(tls, *(*uintptr)(unsafe.Pointer(bp /* pBlob */)), *(*Tcl_WideInt)(unsafe.Pointer(bp + 8 /* iRowid */))) 45489 if rc != SQLITE_OK { 45490 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 45491 } 45492 45493 return func() int32 { 45494 if rc == SQLITE_OK { 45495 return TCL_OK 45496 } 45497 return TCL_ERROR 45498 }() 45499 } 45500 45501 // Usage: sqlite3_create_collation_v2 DB-HANDLE NAME CMP-PROC DEL-PROC 45502 // 45503 // This Tcl proc is used for testing the experimental 45504 // sqlite3_create_collation_v2() interface. 45505 type TestCollationX1 = struct { 45506 Finterp uintptr 45507 FpCmp uintptr 45508 FpDel uintptr 45509 } /* test1.c:1715:1 */ 45510 45511 type TestCollationX = TestCollationX1 /* test1.c:1720:31 */ 45512 45513 func testCreateCollationDel(tls *libc.TLS, pCtx uintptr) { /* test1.c:1721:13: */ 45514 var p uintptr = pCtx 45515 45516 var rc int32 = tcl.XTcl_EvalObjEx(tls, (*TestCollationX)(unsafe.Pointer(p)).Finterp, (*TestCollationX)(unsafe.Pointer(p)).FpDel, (TCL_EVAL_DIRECT | TCL_EVAL_GLOBAL)) 45517 if rc != TCL_OK { 45518 tcl.XTcl_BackgroundError(tls, (*TestCollationX)(unsafe.Pointer(p)).Finterp) 45519 } 45520 45521 for ok := true; ok; ok = 0 != 0 { 45522 var _objPtr uintptr = (*TestCollationX)(unsafe.Pointer(p)).FpCmp 45523 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 45524 tcl.XTclFreeObj(tls, _objPtr) 45525 } 45526 } 45527 for ok1 := true; ok1; ok1 = 0 != 0 { 45528 var _objPtr uintptr = (*TestCollationX)(unsafe.Pointer(p)).FpDel 45529 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 45530 tcl.XTclFreeObj(tls, _objPtr) 45531 } 45532 } 45533 sqlite3.Xsqlite3_free(tls, p) 45534 } 45535 45536 func testCreateCollationCmp(tls *libc.TLS, pCtx uintptr, nLeft int32, zLeft uintptr, nRight int32, zRight uintptr) int32 { /* test1.c:1733:12: */ 45537 bp := tls.Alloc(4) 45538 defer tls.Free(4) 45539 45540 var p uintptr = pCtx 45541 var pScript uintptr = tcl.XTcl_DuplicateObj(tls, (*TestCollationX)(unsafe.Pointer(p)).FpCmp) 45542 *(*int32)(unsafe.Pointer(bp /* iRes */)) = 0 45543 45544 (*Tcl_Obj)(unsafe.Pointer(pScript)).FrefCount++ 45545 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pScript, tcl.XTcl_NewStringObj(tls, zLeft, nLeft)) 45546 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pScript, tcl.XTcl_NewStringObj(tls, zRight, nRight)) 45547 45548 if (TCL_OK != tcl.XTcl_EvalObjEx(tls, (*TestCollationX)(unsafe.Pointer(p)).Finterp, pScript, (TCL_EVAL_DIRECT|TCL_EVAL_GLOBAL))) || 45549 (TCL_OK != tcl.XTcl_GetIntFromObj(tls, (*TestCollationX)(unsafe.Pointer(p)).Finterp, tcl.XTcl_GetObjResult(tls, (*TestCollationX)(unsafe.Pointer(p)).Finterp), bp /* &iRes */)) { 45550 tcl.XTcl_BackgroundError(tls, (*TestCollationX)(unsafe.Pointer(p)).Finterp) 45551 } 45552 for ok := true; ok; ok = 0 != 0 { 45553 var _objPtr uintptr = pScript 45554 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 45555 tcl.XTclFreeObj(tls, _objPtr) 45556 } 45557 } 45558 45559 return *(*int32)(unsafe.Pointer(bp /* iRes */)) 45560 } 45561 45562 func test_create_collation_v2(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:1757:26: */ 45563 bp := tls.Alloc(24) 45564 defer tls.Free(24) 45565 45566 var p uintptr 45567 // var db uintptr at bp+16, 8 45568 45569 var rc int32 45570 45571 if objc != 5 { 45572 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15307 /* "DB-HANDLE NAME C..." */) 45573 return TCL_ERROR 45574 } 45575 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+16 /* &db */) != 0 { 45576 return TCL_ERROR 45577 } 45578 45579 p = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(TestCollationX{}))) 45580 (*TestCollationX)(unsafe.Pointer(p)).FpCmp = *(*uintptr)(unsafe.Pointer(objv + 3*8)) 45581 (*TestCollationX)(unsafe.Pointer(p)).FpDel = *(*uintptr)(unsafe.Pointer(objv + 4*8)) 45582 (*TestCollationX)(unsafe.Pointer(p)).Finterp = interp 45583 (*Tcl_Obj)(unsafe.Pointer((*TestCollationX)(unsafe.Pointer(p)).FpCmp)).FrefCount++ 45584 (*Tcl_Obj)(unsafe.Pointer((*TestCollationX)(unsafe.Pointer(p)).FpDel)).FrefCount++ 45585 45586 rc = sqlite3.Xsqlite3_create_collation_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), 16, 45587 p, *(*uintptr)(unsafe.Pointer(&struct { 45588 f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 45589 }{testCreateCollationCmp})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testCreateCollationDel}))) 45590 if rc != SQLITE_MISUSE { 45591 tcl.XTcl_AppendResult(tls, interp, 45592 libc.VaList(bp, ts+15340 /* "sqlite3_create_c..." */, uintptr(0))) 45593 return TCL_ERROR 45594 } 45595 rc = sqlite3.Xsqlite3_create_collation_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), SQLITE_UTF8, 45596 p, *(*uintptr)(unsafe.Pointer(&struct { 45597 f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 45598 }{testCreateCollationCmp})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testCreateCollationDel}))) 45599 return TCL_OK 45600 } 45601 45602 // USAGE: sqlite3_create_function_v2 DB NAME NARG ENC ?SWITCHES? 45603 // 45604 // Available switches are: 45605 // 45606 // -func SCRIPT 45607 // -step SCRIPT 45608 // -final SCRIPT 45609 // -destroy SCRIPT 45610 type CreateFunctionV21 = struct { 45611 Finterp uintptr 45612 FpFunc uintptr 45613 FpStep uintptr 45614 FpFinal uintptr 45615 FpDestroy uintptr 45616 } /* test1.c:1804:9 */ 45617 45618 // USAGE: sqlite3_create_function_v2 DB NAME NARG ENC ?SWITCHES? 45619 // 45620 // Available switches are: 45621 // 45622 // -func SCRIPT 45623 // -step SCRIPT 45624 // -final SCRIPT 45625 // -destroy SCRIPT 45626 type CreateFunctionV2 = CreateFunctionV21 /* test1.c:1804:33 */ 45627 45628 func cf2Func(tls *libc.TLS, ctx uintptr, nArg int32, aArg uintptr) { /* test1.c:1812:13: */ 45629 } 45630 45631 func cf2Step(tls *libc.TLS, ctx uintptr, nArg int32, aArg uintptr) { /* test1.c:1814:13: */ 45632 } 45633 45634 func cf2Final(tls *libc.TLS, ctx uintptr) { /* test1.c:1816:13: */ 45635 } 45636 45637 func cf2Destroy(tls *libc.TLS, pUser uintptr) { /* test1.c:1818:13: */ 45638 var p uintptr = pUser 45639 45640 if ((*CreateFunctionV2)(unsafe.Pointer(p)).Finterp != 0) && ((*CreateFunctionV2)(unsafe.Pointer(p)).FpDestroy != 0) { 45641 var rc int32 = tcl.XTcl_EvalObjEx(tls, (*CreateFunctionV2)(unsafe.Pointer(p)).Finterp, (*CreateFunctionV2)(unsafe.Pointer(p)).FpDestroy, 0) 45642 if rc != TCL_OK { 45643 tcl.XTcl_BackgroundError(tls, (*CreateFunctionV2)(unsafe.Pointer(p)).Finterp) 45644 } 45645 } 45646 45647 if (*CreateFunctionV2)(unsafe.Pointer(p)).FpFunc != 0 { 45648 for ok := true; ok; ok = 0 != 0 { 45649 var _objPtr uintptr = (*CreateFunctionV2)(unsafe.Pointer(p)).FpFunc 45650 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 45651 tcl.XTclFreeObj(tls, _objPtr) 45652 } 45653 } 45654 } 45655 if (*CreateFunctionV2)(unsafe.Pointer(p)).FpStep != 0 { 45656 for ok1 := true; ok1; ok1 = 0 != 0 { 45657 var _objPtr uintptr = (*CreateFunctionV2)(unsafe.Pointer(p)).FpStep 45658 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 45659 tcl.XTclFreeObj(tls, _objPtr) 45660 } 45661 } 45662 } 45663 if (*CreateFunctionV2)(unsafe.Pointer(p)).FpFinal != 0 { 45664 for ok2 := true; ok2; ok2 = 0 != 0 { 45665 var _objPtr uintptr = (*CreateFunctionV2)(unsafe.Pointer(p)).FpFinal 45666 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 45667 tcl.XTclFreeObj(tls, _objPtr) 45668 } 45669 } 45670 } 45671 if (*CreateFunctionV2)(unsafe.Pointer(p)).FpDestroy != 0 { 45672 for ok3 := true; ok3; ok3 = 0 != 0 { 45673 var _objPtr uintptr = (*CreateFunctionV2)(unsafe.Pointer(p)).FpDestroy 45674 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 45675 tcl.XTclFreeObj(tls, _objPtr) 45676 } 45677 } 45678 } 45679 sqlite3.Xsqlite3_free(tls, p) 45680 } 45681 45682 func test_create_function_v2(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:1832:26: */ 45683 bp := tls.Alloc(180) 45684 defer tls.Free(180) 45685 45686 // var db uintptr at bp+16, 8 45687 45688 var zFunc uintptr 45689 // var nArg int32 at bp+24, 4 45690 45691 // var enc int32 at bp+128, 4 45692 45693 var p uintptr 45694 var i int32 45695 var rc int32 45696 45697 *(*[6]EncTable)(unsafe.Pointer(bp + 32 /* aEnc */)) = [6]EncTable{ 45698 {FzEnc: ts + 15405 /* "utf8" */, Fenc: SQLITE_UTF8}, 45699 {FzEnc: ts + 15410 /* "utf16" */, Fenc: SQLITE_UTF16}, 45700 {FzEnc: ts + 15416 /* "utf16le" */, Fenc: SQLITE_UTF16LE}, 45701 {FzEnc: ts + 15424 /* "utf16be" */, Fenc: SQLITE_UTF16BE}, 45702 {FzEnc: ts + 12465 /* "any" */, Fenc: SQLITE_ANY}, 45703 {FzEnc: ts + 13875 /* "0" */}, 45704 } 45705 45706 if (objc < 5) || ((objc % 2) == 0) { 45707 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15432 /* "DB NAME NARG ENC..." */) 45708 return TCL_ERROR 45709 } 45710 45711 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+16 /* &db */) != 0 { 45712 return TCL_ERROR 45713 } 45714 zFunc = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 45715 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+24 /* &nArg */) != 0 { 45716 return TCL_ERROR 45717 } 45718 if tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+32 /* &aEnc[0] */, int32(unsafe.Sizeof(EncTable{})), 45719 ts+15461 /* "encoding" */, 0, bp+128 /* &enc */) != 0 { 45720 return TCL_ERROR 45721 } 45722 *(*int32)(unsafe.Pointer(bp + 128 /* enc */)) = (*EncTable)(unsafe.Pointer(bp + 32 /* &aEnc */ + uintptr(*(*int32)(unsafe.Pointer(bp + 128 /* enc */)))*16)).Fenc 45723 45724 p = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(CreateFunctionV2{}))) 45725 45726 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(CreateFunctionV2{}))) 45727 (*CreateFunctionV2)(unsafe.Pointer(p)).Finterp = interp 45728 45729 for i = 5; i < objc; i = i + (2) { 45730 // var iSwitch int32 at bp+176, 4 45731 45732 *(*[5]uintptr)(unsafe.Pointer(bp + 136 /* azSwitch */)) = [5]uintptr{ts + 15470 /* "-func" */, ts + 15476 /* "-step" */, ts + 15482 /* "-final" */, ts + 15489 /* "-destroy" */, uintptr(0)} 45733 if tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+136 /* &azSwitch[0] */, int32(unsafe.Sizeof(uintptr(0))), ts+15498 /* "switch" */, 0, bp+176 /* &iSwitch */) != 0 { 45734 sqlite3.Xsqlite3_free(tls, p) 45735 return TCL_ERROR 45736 } 45737 45738 switch *(*int32)(unsafe.Pointer(bp + 176 /* iSwitch */)) { 45739 case 0: 45740 (*CreateFunctionV2)(unsafe.Pointer(p)).FpFunc = *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)) 45741 break 45742 case 1: 45743 (*CreateFunctionV2)(unsafe.Pointer(p)).FpStep = *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)) 45744 break 45745 case 2: 45746 (*CreateFunctionV2)(unsafe.Pointer(p)).FpFinal = *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)) 45747 break 45748 case 3: 45749 (*CreateFunctionV2)(unsafe.Pointer(p)).FpDestroy = *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)) 45750 break 45751 } 45752 } 45753 if (*CreateFunctionV2)(unsafe.Pointer(p)).FpFunc != 0 { 45754 (*CreateFunctionV2)(unsafe.Pointer(p)).FpFunc = tcl.XTcl_DuplicateObj(tls, (*CreateFunctionV2)(unsafe.Pointer(p)).FpFunc) 45755 } 45756 if (*CreateFunctionV2)(unsafe.Pointer(p)).FpStep != 0 { 45757 (*CreateFunctionV2)(unsafe.Pointer(p)).FpStep = tcl.XTcl_DuplicateObj(tls, (*CreateFunctionV2)(unsafe.Pointer(p)).FpStep) 45758 } 45759 if (*CreateFunctionV2)(unsafe.Pointer(p)).FpFinal != 0 { 45760 (*CreateFunctionV2)(unsafe.Pointer(p)).FpFinal = tcl.XTcl_DuplicateObj(tls, (*CreateFunctionV2)(unsafe.Pointer(p)).FpFinal) 45761 } 45762 if (*CreateFunctionV2)(unsafe.Pointer(p)).FpDestroy != 0 { 45763 (*CreateFunctionV2)(unsafe.Pointer(p)).FpDestroy = tcl.XTcl_DuplicateObj(tls, (*CreateFunctionV2)(unsafe.Pointer(p)).FpDestroy) 45764 } 45765 45766 if (*CreateFunctionV2)(unsafe.Pointer(p)).FpFunc != 0 { 45767 (*Tcl_Obj)(unsafe.Pointer((*CreateFunctionV2)(unsafe.Pointer(p)).FpFunc)).FrefCount++ 45768 } 45769 if (*CreateFunctionV2)(unsafe.Pointer(p)).FpStep != 0 { 45770 (*Tcl_Obj)(unsafe.Pointer((*CreateFunctionV2)(unsafe.Pointer(p)).FpStep)).FrefCount++ 45771 } 45772 if (*CreateFunctionV2)(unsafe.Pointer(p)).FpFinal != 0 { 45773 (*Tcl_Obj)(unsafe.Pointer((*CreateFunctionV2)(unsafe.Pointer(p)).FpFinal)).FrefCount++ 45774 } 45775 if (*CreateFunctionV2)(unsafe.Pointer(p)).FpDestroy != 0 { 45776 (*Tcl_Obj)(unsafe.Pointer((*CreateFunctionV2)(unsafe.Pointer(p)).FpDestroy)).FrefCount++ 45777 } 45778 45779 rc = sqlite3.Xsqlite3_create_function_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), zFunc, *(*int32)(unsafe.Pointer(bp + 24 /* nArg */)), *(*int32)(unsafe.Pointer(bp + 128 /* enc */)), p, 45780 func() uintptr { 45781 if (*CreateFunctionV2)(unsafe.Pointer(p)).FpFunc != 0 { 45782 return *(*uintptr)(unsafe.Pointer(&struct { 45783 f func(*libc.TLS, uintptr, int32, uintptr) 45784 }{cf2Func})) 45785 } 45786 return uintptr(0) 45787 }(), 45788 func() uintptr { 45789 if (*CreateFunctionV2)(unsafe.Pointer(p)).FpStep != 0 { 45790 return *(*uintptr)(unsafe.Pointer(&struct { 45791 f func(*libc.TLS, uintptr, int32, uintptr) 45792 }{cf2Step})) 45793 } 45794 return uintptr(0) 45795 }(), 45796 func() uintptr { 45797 if (*CreateFunctionV2)(unsafe.Pointer(p)).FpFinal != 0 { 45798 return *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{cf2Final})) 45799 } 45800 return uintptr(0) 45801 }(), 45802 *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{cf2Destroy}))) 45803 if rc != SQLITE_OK { 45804 tcl.XTcl_ResetResult(tls, interp) 45805 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 45806 return TCL_ERROR 45807 } 45808 return TCL_OK 45809 } 45810 45811 type EncTable = struct { 45812 FzEnc uintptr 45813 Fenc int32 45814 _ [4]byte 45815 } /* test1.c:1846:3 */ 45816 45817 // Usage: sqlite3_load_extension DB-HANDLE FILE ?PROC? 45818 func test_load_extension(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:1920:26: */ 45819 bp := tls.Alloc(88) 45820 defer tls.Free(88) 45821 45822 // var cmdInfo Tcl_CmdInfo at bp+24, 64 45823 45824 var db uintptr 45825 _ = db 45826 var rc int32 45827 var zDb uintptr 45828 var zFile uintptr 45829 _ = zFile 45830 var zProc uintptr = uintptr(0) 45831 _ = zProc 45832 var zErr uintptr = uintptr(0) 45833 45834 if (objc != 4) && (objc != 3) { 45835 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15505 /* "DB-HANDLE FILE ?..." */) 45836 return TCL_ERROR 45837 } 45838 zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 45839 zFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 45840 if objc == 4 { 45841 zProc = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 45842 } 45843 45844 // Extract the C database handle from the Tcl command name 45845 if !(tcl.XTcl_GetCommandInfo(tls, interp, zDb, bp+24 /* &cmdInfo */) != 0) { 45846 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14541 /* "command not foun..." */, zDb, uintptr(0))) 45847 return TCL_ERROR 45848 } 45849 db = (*struct{ Fdb uintptr })(unsafe.Pointer((*Tcl_CmdInfo)(unsafe.Pointer(bp + 24 /* &cmdInfo */)).FobjClientData)).Fdb 45850 45851 // Call the underlying C function. If an error occurs, set rc to 45852 // TCL_ERROR and load any error string into the interpreter. If no 45853 // error occurs, set rc to TCL_OK. 45854 rc = SQLITE_ERROR 45855 zErr = sqlite3.Xsqlite3_mprintf(tls, ts+15527 /* "this build omits..." */, 0) 45856 _ = zProc 45857 _ = zFile 45858 if rc != SQLITE_OK { 45859 tcl.XTcl_SetResult(tls, interp, func() uintptr { 45860 if zErr != 0 { 45861 return zErr 45862 } 45863 return ts + 489 /* "" */ 45864 }(), uintptr(1)) 45865 rc = TCL_ERROR 45866 } else { 45867 rc = TCL_OK 45868 } 45869 sqlite3.Xsqlite3_free(tls, zErr) 45870 45871 return rc 45872 } 45873 45874 // Usage: sqlite3_enable_load_extension DB-HANDLE ONOFF 45875 func test_enable_load(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:1978:26: */ 45876 bp := tls.Alloc(100) 45877 defer tls.Free(100) 45878 45879 // var cmdInfo Tcl_CmdInfo at bp+32, 64 45880 45881 var db uintptr 45882 _ = db 45883 var zDb uintptr 45884 // var onoff int32 at bp+96, 4 45885 45886 if objc != 3 { 45887 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15569 /* "DB-HANDLE ONOFF" */) 45888 return TCL_ERROR 45889 } 45890 zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 45891 45892 // Extract the C database handle from the Tcl command name 45893 if !(tcl.XTcl_GetCommandInfo(tls, interp, zDb, bp+32 /* &cmdInfo */) != 0) { 45894 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14541 /* "command not foun..." */, zDb, uintptr(0))) 45895 return TCL_ERROR 45896 } 45897 db = (*struct{ Fdb uintptr })(unsafe.Pointer((*Tcl_CmdInfo)(unsafe.Pointer(bp + 32 /* &cmdInfo */)).FobjClientData)).Fdb 45898 45899 // Get the onoff parameter 45900 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+96 /* &onoff */) != 0 { 45901 return TCL_ERROR 45902 } 45903 45904 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, ts+15527 /* "this build omits..." */)) 45905 return TCL_ERROR 45906 } 45907 45908 // Usage: sqlite_abort 45909 // 45910 // Shutdown the process immediately. This is not a clean shutdown. 45911 // This command is used to test the recoverability of a database in 45912 // the event of a program crash. 45913 func sqlite_abort(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:2024:26: */ 45914 libc.Xexit(tls, 255) 45915 // This will always fail 45916 return TCL_OK 45917 } 45918 45919 // The following routine is a user-defined SQL function whose purpose 45920 // is to test the sqlite_set_result() API. 45921 func testFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test1.c:2045:13: */ 45922 var zArg0 uintptr 45923 __1: 45924 if !(argc >= 2) { 45925 goto __2 45926 } 45927 zArg0 = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 45928 if !(zArg0 != 0) { 45929 goto __3 45930 } 45931 if !(0 == sqlite3.Xsqlite3StrICmp(tls, zArg0, ts+2438 /* "int" */)) { 45932 goto __5 45933 } 45934 sqlite3.Xsqlite3_result_int(tls, context, sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) 45935 goto __6 45936 __5: 45937 if !(sqlite3.Xsqlite3StrICmp(tls, zArg0, ts+3844 /* "int64" */) == 0) { 45938 goto __7 45939 } 45940 sqlite3.Xsqlite3_result_int64(tls, context, sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) 45941 goto __8 45942 __7: 45943 if !(sqlite3.Xsqlite3StrICmp(tls, zArg0, ts+15585 /* "string" */) == 0) { 45944 goto __9 45945 } 45946 sqlite3.Xsqlite3_result_text(tls, context, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))), -1, 45947 libc.UintptrFromInt32(-1)) 45948 goto __10 45949 __9: 45950 if !(sqlite3.Xsqlite3StrICmp(tls, zArg0, ts+2423 /* "double" */) == 0) { 45951 goto __11 45952 } 45953 sqlite3.Xsqlite3_result_double(tls, context, sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) 45954 goto __12 45955 __11: 45956 if !(sqlite3.Xsqlite3StrICmp(tls, zArg0, ts+7387 /* "null" */) == 0) { 45957 goto __13 45958 } 45959 sqlite3.Xsqlite3_result_null(tls, context) 45960 goto __14 45961 __13: 45962 if !(sqlite3.Xsqlite3StrICmp(tls, zArg0, ts+15592 /* "value" */) == 0) { 45963 goto __15 45964 } 45965 sqlite3.Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv + uintptr(sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))))*8))) 45966 goto __16 45967 __15: 45968 goto error_out 45969 __16: 45970 ; 45971 __14: 45972 ; 45973 __12: 45974 ; 45975 __10: 45976 ; 45977 __8: 45978 ; 45979 __6: 45980 ; 45981 goto __4 45982 __3: 45983 goto error_out 45984 __4: 45985 ; 45986 argc = argc - (2) 45987 argv += 8 * (uintptr(2)) 45988 goto __1 45989 __2: 45990 ; 45991 return 45992 45993 error_out: 45994 sqlite3.Xsqlite3_result_error(tls, context, 45995 ts+15598 /* "first argument s..." */, -1) 45996 } 45997 45998 // Usage: sqlite_register_test_function DB NAME 45999 // 46000 // Register the test SQL function on the database DB under the name NAME. 46001 func test_register_func(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:2083:26: */ 46002 bp := tls.Alloc(56) 46003 defer tls.Free(56) 46004 46005 // var db uintptr at bp+48, 8 46006 46007 var rc int32 46008 if argc != 3 { 46009 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 46010 ts+15666 /* " DB FUNCTION-NAM..." */, 0)) 46011 return TCL_ERROR 46012 } 46013 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+48 /* &db */) != 0 { 46014 return TCL_ERROR 46015 } 46016 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), *(*uintptr)(unsafe.Pointer(argv + 2*8)), -1, SQLITE_UTF8, uintptr(0), 46017 *(*uintptr)(unsafe.Pointer(&struct { 46018 f func(*libc.TLS, uintptr, int32, uintptr) 46019 }{testFunc})), uintptr(0), uintptr(0)) 46020 if rc != 0 { 46021 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrStr(tls, rc), 0)) 46022 return TCL_ERROR 46023 } 46024 if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), rc) != 0 { 46025 return TCL_ERROR 46026 } 46027 return TCL_OK 46028 } 46029 46030 // Usage: sqlite3_finalize STMT 46031 // 46032 // Finalize a statement handle. 46033 func test_finalize(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2112:26: */ 46034 bp := tls.Alloc(40) 46035 defer tls.Free(40) 46036 46037 // var pStmt uintptr at bp+32, 8 46038 46039 var rc int32 46040 var db uintptr = uintptr(0) 46041 46042 if objc != 2 { 46043 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 46044 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+15684 /* " <STMT>" */, 0)) 46045 return TCL_ERROR 46046 } 46047 46048 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 46049 return TCL_ERROR 46050 } 46051 46052 if *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)) != 0 { 46053 db = sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))) 46054 } 46055 rc = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))) 46056 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 46057 if (db != 0) && (sqlite3TestErrCode(tls, interp, db, rc) != 0) { 46058 return TCL_ERROR 46059 } 46060 return TCL_OK 46061 } 46062 46063 // Usage: sqlite3_stmt_status STMT CODE RESETFLAG 46064 // 46065 // Get the value of a status counter from a statement. 46066 func test_stmt_status(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2144:26: */ 46067 bp := tls.Alloc(16) 46068 defer tls.Free(16) 46069 46070 var iValue int32 46071 var i int32 46072 *(*int32)(unsafe.Pointer(bp + 8 /* op */)) = 0 46073 // var resetFlag int32 at bp+12, 4 46074 46075 var zOpName uintptr 46076 // var pStmt uintptr at bp, 8 46077 46078 if objc != 4 { 46079 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15692 /* "STMT PARAMETER R..." */) 46080 return TCL_ERROR 46081 } 46082 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &pStmt */) != 0 { 46083 return TCL_ERROR 46084 } 46085 zOpName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 46086 for i = 0; i < (int32(uint64(unsafe.Sizeof(aOp)) / uint64(unsafe.Sizeof(struct { 46087 FzName uintptr 46088 Fop int32 46089 _ [4]byte 46090 }{})))); i++ { 46091 if libc.Xstrcmp(tls, aOp[i].FzName, zOpName) == 0 { 46092 *(*int32)(unsafe.Pointer(bp + 8 /* op */)) = aOp[i].Fop 46093 break 46094 } 46095 } 46096 if i >= (int32(uint64(unsafe.Sizeof(aOp)) / uint64(unsafe.Sizeof(struct { 46097 FzName uintptr 46098 Fop int32 46099 _ [4]byte 46100 }{})))) { 46101 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &op */) != 0 { 46102 return TCL_ERROR 46103 } 46104 } 46105 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+12 /* &resetFlag */) != 0 { 46106 return TCL_ERROR 46107 } 46108 iValue = sqlite3.Xsqlite3_stmt_status(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 8 /* op */)), *(*int32)(unsafe.Pointer(bp + 12 /* resetFlag */))) 46109 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, iValue)) 46110 return TCL_OK 46111 } 46112 46113 var aOp = [7]struct { 46114 FzName uintptr 46115 Fop int32 46116 _ [4]byte 46117 }{ 46118 {FzName: ts + 15717 /* "SQLITE_STMTSTATU..." */, Fop: SQLITE_STMTSTATUS_FULLSCAN_STEP}, 46119 {FzName: ts + 15749 /* "SQLITE_STMTSTATU..." */, Fop: SQLITE_STMTSTATUS_SORT}, 46120 {FzName: ts + 15772 /* "SQLITE_STMTSTATU..." */, Fop: SQLITE_STMTSTATUS_AUTOINDEX}, 46121 {FzName: ts + 15800 /* "SQLITE_STMTSTATU..." */, Fop: SQLITE_STMTSTATUS_VM_STEP}, 46122 {FzName: ts + 15826 /* "SQLITE_STMTSTATU..." */, Fop: SQLITE_STMTSTATUS_REPREPARE}, 46123 {FzName: ts + 15854 /* "SQLITE_STMTSTATU..." */, Fop: SQLITE_STMTSTATUS_RUN}, 46124 {FzName: ts + 15876 /* "SQLITE_STMTSTATU..." */, Fop: SQLITE_STMTSTATUS_MEMUSED}, 46125 } /* test1.c:2158:5 */ 46126 46127 // Usage: sqlite3_config_sorterref 46128 // 46129 // Set the SQLITE_CONFIG_SORTERREF_SIZE configuration option 46130 func test_config_sorterref(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2285:26: */ 46131 bp := tls.Alloc(12) 46132 defer tls.Free(12) 46133 46134 // var iVal int32 at bp+8, 4 46135 46136 if objc != 2 { 46137 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15902 /* "NBYTE" */) 46138 return TCL_ERROR 46139 } 46140 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+8 /* &iVal */) != 0 { 46141 return TCL_ERROR 46142 } 46143 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_SORTERREF_SIZE, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* iVal */)))) 46144 return TCL_OK 46145 } 46146 46147 // Usage: vfs_current_time_int64 46148 // 46149 // Return the value returned by the default VFS's xCurrentTimeInt64 method. 46150 func vfsCurrentTimeInt64(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2306:26: */ 46151 bp := tls.Alloc(8) 46152 defer tls.Free(8) 46153 46154 // var t i64 at bp, 8 46155 46156 var pVfs uintptr = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 46157 if objc != 1 { 46158 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 46159 return TCL_ERROR 46160 } 46161 (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pVfs + 136 /* &.xCurrentTimeInt64 */))))(tls, pVfs, bp /* &t */) 46162 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, *(*i64)(unsafe.Pointer(bp /* t */)))) 46163 return TCL_OK 46164 } 46165 46166 // Usage: sqlite3_snapshot_get DB DBNAME 46167 func test_snapshot_get(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2327:26: */ 46168 bp := tls.Alloc(116) 46169 defer tls.Free(116) 46170 46171 var rc int32 46172 // var db uintptr at bp, 8 46173 46174 var zName uintptr 46175 *(*uintptr)(unsafe.Pointer(bp + 8 /* pSnapshot */)) = uintptr(0) 46176 46177 if objc != 3 { 46178 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15908 /* "DB DBNAME" */) 46179 return TCL_ERROR 46180 } 46181 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 46182 return TCL_ERROR 46183 } 46184 zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 46185 46186 rc = sqlite3.Xsqlite3_snapshot_get(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zName, bp+8 /* &pSnapshot */) 46187 if rc != SQLITE_OK { 46188 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 46189 return TCL_ERROR 46190 } else { 46191 // var zBuf [100]int8 at bp+16, 100 46192 46193 if sqlite3TestMakePointerStr(tls, interp, bp+16 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 8 /* pSnapshot */))) != 0 { 46194 return TCL_ERROR 46195 } 46196 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, bp+16 /* &zBuf[0] */, -1)) 46197 } 46198 return TCL_OK 46199 } 46200 46201 // Usage: sqlite3_snapshot_recover DB DBNAME 46202 func test_snapshot_recover(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2362:26: */ 46203 bp := tls.Alloc(8) 46204 defer tls.Free(8) 46205 46206 var rc int32 46207 // var db uintptr at bp, 8 46208 46209 var zName uintptr 46210 46211 if objc != 3 { 46212 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15908 /* "DB DBNAME" */) 46213 return TCL_ERROR 46214 } 46215 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 46216 return TCL_ERROR 46217 } 46218 zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 46219 46220 rc = sqlite3.Xsqlite3_snapshot_recover(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zName) 46221 if rc != SQLITE_OK { 46222 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 46223 return TCL_ERROR 46224 } else { 46225 tcl.XTcl_ResetResult(tls, interp) 46226 } 46227 return TCL_OK 46228 } 46229 46230 // Usage: sqlite3_snapshot_open DB DBNAME SNAPSHOT 46231 func test_snapshot_open(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2394:26: */ 46232 bp := tls.Alloc(8) 46233 defer tls.Free(8) 46234 46235 var rc int32 46236 // var db uintptr at bp, 8 46237 46238 var zName uintptr 46239 var pSnapshot uintptr 46240 46241 if objc != 4 { 46242 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15918 /* "DB DBNAME SNAPSH..." */) 46243 return TCL_ERROR 46244 } 46245 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 46246 return TCL_ERROR 46247 } 46248 zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 46249 pSnapshot = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)))) 46250 46251 rc = sqlite3.Xsqlite3_snapshot_open(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zName, pSnapshot) 46252 if rc != SQLITE_OK { 46253 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 46254 return TCL_ERROR 46255 } else { 46256 tcl.XTcl_ResetResult(tls, interp) 46257 } 46258 return TCL_OK 46259 } 46260 46261 // Usage: sqlite3_snapshot_free SNAPSHOT 46262 func test_snapshot_free(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2428:26: */ 46263 var pSnapshot uintptr 46264 if objc != 2 { 46265 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15937 /* "SNAPSHOT" */) 46266 return TCL_ERROR 46267 } 46268 pSnapshot = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 46269 sqlite3.Xsqlite3_snapshot_free(tls, pSnapshot) 46270 return TCL_OK 46271 } 46272 46273 // Usage: sqlite3_snapshot_cmp SNAPSHOT1 SNAPSHOT2 46274 func test_snapshot_cmp(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2449:26: */ 46275 var res int32 46276 var p1 uintptr 46277 var p2 uintptr 46278 if objc != 3 { 46279 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15946 /* "SNAPSHOT1 SNAPSH..." */) 46280 return TCL_ERROR 46281 } 46282 p1 = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 46283 p2 = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)))) 46284 res = sqlite3.Xsqlite3_snapshot_cmp(tls, p1, p2) 46285 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, res)) 46286 return TCL_OK 46287 } 46288 46289 // Usage: sqlite3_snapshot_get_blob DB DBNAME 46290 func test_snapshot_get_blob(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2474:26: */ 46291 bp := tls.Alloc(16) 46292 defer tls.Free(16) 46293 46294 var rc int32 46295 // var db uintptr at bp, 8 46296 46297 var zName uintptr 46298 *(*uintptr)(unsafe.Pointer(bp + 8 /* pSnapshot */)) = uintptr(0) 46299 46300 if objc != 3 { 46301 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15908 /* "DB DBNAME" */) 46302 return TCL_ERROR 46303 } 46304 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 46305 return TCL_ERROR 46306 } 46307 zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 46308 46309 rc = sqlite3.Xsqlite3_snapshot_get(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zName, bp+8 /* &pSnapshot */) 46310 if rc != SQLITE_OK { 46311 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 46312 return TCL_ERROR 46313 } else { 46314 tcl.XTcl_SetObjResult(tls, interp, 46315 tcl.XTcl_NewByteArrayObj(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pSnapshot */)), int32(unsafe.Sizeof(sqlite3_snapshot{})))) 46316 sqlite3.Xsqlite3_snapshot_free(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pSnapshot */))) 46317 } 46318 return TCL_OK 46319 } 46320 46321 // Usage: sqlite3_snapshot_open_blob DB DBNAME SNAPSHOT 46322 func test_snapshot_open_blob(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2510:26: */ 46323 bp := tls.Alloc(28) 46324 defer tls.Free(28) 46325 46326 var rc int32 46327 // var db uintptr at bp+16, 8 46328 46329 var zName uintptr 46330 var pBlob uintptr 46331 // var nBlob int32 at bp+24, 4 46332 46333 if objc != 4 { 46334 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15918 /* "DB DBNAME SNAPSH..." */) 46335 return TCL_ERROR 46336 } 46337 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+16 /* &db */) != 0 { 46338 return TCL_ERROR 46339 } 46340 zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 46341 pBlob = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+24 /* &nBlob */) 46342 if (uint64(*(*int32)(unsafe.Pointer(bp + 24 /* nBlob */))) != uint64(unsafe.Sizeof(sqlite3_snapshot{}))) { 46343 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+15966 /* "bad SNAPSHOT" */, 0)) 46344 return TCL_ERROR 46345 } 46346 rc = sqlite3.Xsqlite3_snapshot_open(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), zName, pBlob) 46347 if rc != SQLITE_OK { 46348 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 46349 return TCL_ERROR 46350 } 46351 return TCL_OK 46352 } 46353 46354 // Usage: sqlite3_snapshot_cmp_blob SNAPSHOT1 SNAPSHOT2 46355 func test_snapshot_cmp_blob(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2546:26: */ 46356 bp := tls.Alloc(24) 46357 defer tls.Free(24) 46358 46359 var res int32 46360 var p1 uintptr 46361 var p2 uintptr 46362 // var n1 int32 at bp+16, 4 46363 46364 // var n2 int32 at bp+20, 4 46365 46366 if objc != 3 { 46367 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15946 /* "SNAPSHOT1 SNAPSH..." */) 46368 return TCL_ERROR 46369 } 46370 46371 p1 = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+16 /* &n1 */) 46372 p2 = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+20 /* &n2 */) 46373 46374 if (uint64(*(*int32)(unsafe.Pointer(bp + 16 /* n1 */))) != uint64(unsafe.Sizeof(sqlite3_snapshot{}))) || (*(*int32)(unsafe.Pointer(bp + 16 /* n1 */)) != *(*int32)(unsafe.Pointer(bp + 20 /* n2 */))) { 46375 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+15966 /* "bad SNAPSHOT" */, 0)) 46376 return TCL_ERROR 46377 } 46378 46379 res = sqlite3.Xsqlite3_snapshot_cmp(tls, p1, p2) 46380 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, res)) 46381 return TCL_OK 46382 } 46383 46384 // in test_delete.c 46385 func test_delete_database(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2581:26: */ 46386 var rc int32 46387 var zFile uintptr 46388 if objc != 2 { 46389 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15979 /* "FILE" */) 46390 return TCL_ERROR 46391 } 46392 zFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 46393 rc = sqlite3_delete_database(tls, zFile) 46394 46395 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 46396 return TCL_OK 46397 } 46398 46399 // Usage: atomic_batch_write PATH 46400 func test_atomic_batch_write(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2603:26: */ 46401 bp := tls.Alloc(32) 46402 defer tls.Free(32) 46403 46404 var zFile uintptr = uintptr(0) // Path to file to test 46405 *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)) = uintptr(0) // Database handle 46406 *(*uintptr)(unsafe.Pointer(bp + 24 /* pFd */)) = uintptr(0) // SQLite fd open on zFile 46407 var bRes int32 = 0 // Integer result of this command 46408 var dc int32 = 0 // Device-characteristics mask 46409 var rc int32 // sqlite3_open() return code 46410 46411 if objc != 2 { 46412 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15984 /* "PATH" */) 46413 return TCL_ERROR 46414 } 46415 zFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 46416 46417 rc = sqlite3.Xsqlite3_open(tls, zFile, bp+16 /* &db */) 46418 if rc != SQLITE_OK { 46419 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */))), 0)) 46420 sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */))) 46421 return TCL_ERROR 46422 } 46423 46424 rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+85 /* "main" */, SQLITE_FCNTL_FILE_POINTER, bp+24 /* &pFd */) 46425 dc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pFd */)))).FpMethods + 96 /* &.xDeviceCharacteristics */))))(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pFd */))) 46426 if (dc & SQLITE_IOCAP_BATCH_ATOMIC) != 0 { 46427 bRes = 1 46428 } 46429 46430 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, bRes)) 46431 sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */))) 46432 return TCL_OK 46433 } 46434 46435 // Usage: sqlite3_next_stmt DB STMT 46436 // 46437 // Return the next statment in sequence after STMT. 46438 func test_next_stmt(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2645:26: */ 46439 bp := tls.Alloc(114) 46440 defer tls.Free(114) 46441 46442 // var pStmt uintptr at bp+56, 8 46443 46444 *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)) = uintptr(0) 46445 // var zBuf [50]int8 at bp+64, 50 46446 46447 if objc != 3 { 46448 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 46449 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+15989 /* " DB STMT" */, 0)) 46450 return TCL_ERROR 46451 } 46452 46453 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &db */) != 0 { 46454 return TCL_ERROR 46455 } 46456 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), bp+56 /* &pStmt */) != 0 { 46457 return TCL_ERROR 46458 } 46459 *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)) = sqlite3.Xsqlite3_next_stmt(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) 46460 if *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */)) != 0 { 46461 if sqlite3TestMakePointerStr(tls, interp, bp+64 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 56 /* pStmt */))) != 0 { 46462 return TCL_ERROR 46463 } 46464 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, bp+64 /* &zBuf[0] */, 0)) 46465 } 46466 return TCL_OK 46467 } 46468 46469 // Usage: sqlite3_stmt_readonly STMT 46470 // 46471 // Return true if STMT is a NULL pointer or a pointer to a statement 46472 // that is guaranteed to leave the database unmodified. 46473 func test_stmt_readonly(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2677:26: */ 46474 bp := tls.Alloc(40) 46475 defer tls.Free(40) 46476 46477 // var pStmt uintptr at bp+32, 8 46478 46479 var rc int32 46480 46481 if objc != 2 { 46482 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 46483 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+15998 /* " STMT" */, 0)) 46484 return TCL_ERROR 46485 } 46486 46487 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 46488 return TCL_ERROR 46489 } 46490 rc = sqlite3.Xsqlite3_stmt_readonly(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))) 46491 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, (libc.Bool32((rc) != 0)))) 46492 return TCL_OK 46493 } 46494 46495 // Usage: sqlite3_stmt_isexplain STMT 46496 // 46497 // Return 1, 2, or 0 respectively if STMT is an EXPLAIN statement, an 46498 // EXPLAIN QUERY PLAN statement or an ordinary statement or NULL pointer. 46499 func test_stmt_isexplain(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2704:26: */ 46500 bp := tls.Alloc(40) 46501 defer tls.Free(40) 46502 46503 // var pStmt uintptr at bp+32, 8 46504 46505 var rc int32 46506 46507 if objc != 2 { 46508 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 46509 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+15998 /* " STMT" */, 0)) 46510 return TCL_ERROR 46511 } 46512 46513 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 46514 return TCL_ERROR 46515 } 46516 rc = sqlite3.Xsqlite3_stmt_isexplain(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))) 46517 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) 46518 return TCL_OK 46519 } 46520 46521 // Usage: sqlite3_stmt_busy STMT 46522 // 46523 // Return true if STMT is a non-NULL pointer to a statement 46524 // that has been stepped but not to completion. 46525 func test_stmt_busy(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2731:26: */ 46526 bp := tls.Alloc(40) 46527 defer tls.Free(40) 46528 46529 // var pStmt uintptr at bp+32, 8 46530 46531 var rc int32 46532 46533 if objc != 2 { 46534 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 46535 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+15998 /* " STMT" */, 0)) 46536 return TCL_ERROR 46537 } 46538 46539 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 46540 return TCL_ERROR 46541 } 46542 rc = sqlite3.Xsqlite3_stmt_busy(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))) 46543 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, (libc.Bool32((rc) != 0)))) 46544 return TCL_OK 46545 } 46546 46547 // Usage: uses_stmt_journal STMT 46548 // 46549 // Return true if STMT uses a statement journal. 46550 func uses_stmt_journal(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2757:26: */ 46551 bp := tls.Alloc(40) 46552 defer tls.Free(40) 46553 46554 // var pStmt uintptr at bp+32, 8 46555 46556 if objc != 2 { 46557 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 46558 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+15998 /* " STMT" */, 0)) 46559 return TCL_ERROR 46560 } 46561 46562 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 46563 return TCL_ERROR 46564 } 46565 sqlite3.Xsqlite3_stmt_readonly(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))) 46566 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, (libc.Bool32((int32(*(*uint16)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)) + 200 /* &.usesStmtJournal */))>>9&0x1)) != 0)))) 46567 return TCL_OK 46568 } 46569 46570 // Usage: sqlite3_reset STMT 46571 // 46572 // Reset a statement handle. 46573 func test_reset(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2783:26: */ 46574 bp := tls.Alloc(40) 46575 defer tls.Free(40) 46576 46577 // var pStmt uintptr at bp+32, 8 46578 46579 var rc int32 46580 46581 if objc != 2 { 46582 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 46583 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+15684 /* " <STMT>" */, 0)) 46584 return TCL_ERROR 46585 } 46586 46587 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 46588 return TCL_ERROR 46589 } 46590 46591 rc = sqlite3.Xsqlite3_reset(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))) 46592 if (*(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)) != 0) && (sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))), rc) != 0) { 46593 return TCL_ERROR 46594 } 46595 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 46596 // 46597 // if( rc ){ 46598 // return TCL_ERROR; 46599 // } 46600 return TCL_OK 46601 } 46602 46603 // Usage: sqlite3_expired STMT 46604 // 46605 // Return TRUE if a recompilation of the statement is recommended. 46606 func test_expired(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2818:26: */ 46607 bp := tls.Alloc(40) 46608 defer tls.Free(40) 46609 46610 // var pStmt uintptr at bp+32, 8 46611 46612 if objc != 2 { 46613 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 46614 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+15684 /* " <STMT>" */, 0)) 46615 return TCL_ERROR 46616 } 46617 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 46618 return TCL_ERROR 46619 } 46620 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, (libc.Bool32((sqlite3.Xsqlite3_expired(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)))) != 0)))) 46621 return TCL_OK 46622 } 46623 46624 // Usage: sqlite3_transfer_bindings FROMSTMT TOSTMT 46625 // 46626 // Transfer all bindings from FROMSTMT over to TOSTMT 46627 func test_transfer_bind(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2842:26: */ 46628 bp := tls.Alloc(48) 46629 defer tls.Free(48) 46630 46631 // var pStmt1 uintptr at bp+32, 8 46632 46633 // var pStmt2 uintptr at bp+40, 8 46634 46635 if objc != 3 { 46636 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 46637 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+16004 /* " FROM-STMT TO-ST..." */, 0)) 46638 return TCL_ERROR 46639 } 46640 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt1 */) != 0 { 46641 return TCL_ERROR 46642 } 46643 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), bp+40 /* &pStmt2 */) != 0 { 46644 return TCL_ERROR 46645 } 46646 tcl.XTcl_SetObjResult(tls, interp, 46647 tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_transfer_bindings(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt1 */)), *(*uintptr)(unsafe.Pointer(bp + 40 /* pStmt2 */))))) 46648 return TCL_OK 46649 } 46650 46651 // Usage: sqlite3_changes DB 46652 // 46653 // Return the number of changes made to the database by the last SQL 46654 // execution. 46655 func test_changes(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:2869:26: */ 46656 bp := tls.Alloc(40) 46657 defer tls.Free(40) 46658 46659 // var db uintptr at bp+32, 8 46660 46661 if objc != 2 { 46662 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 46663 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+14683 /* " DB" */, 0)) 46664 return TCL_ERROR 46665 } 46666 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0 { 46667 return TCL_ERROR 46668 } 46669 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_changes(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */))))) 46670 return TCL_OK 46671 } 46672 46673 // This is the "static_bind_value" that variables are bound to when 46674 // the FLAG option of sqlite3_bind is "static" 46675 var sqlite_static_bind_value uintptr = uintptr(0) /* test1.c:2890:13 */ 46676 var sqlite_static_bind_nbyte int32 = 0 /* test1.c:2891:12 */ 46677 46678 // Usage: sqlite3_bind VM IDX VALUE FLAGS 46679 // 46680 // Sets the value of the IDX-th occurrence of "?" in the original SQL 46681 // string. VALUE is the new value. If FLAGS=="null" then VALUE is 46682 // ignored and the value is set to NULL. If FLAGS=="static" then 46683 // the value is set to the value of a static variable named 46684 // "sqlite_static_bind_value". If FLAGS=="normal" then a copy 46685 // of the VALUE is made. If FLAGS=="blob10" then a VALUE is ignored 46686 // an a 10-byte blob "abc\000xyz\000pq" is inserted. 46687 func test_bind(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:2904:26: */ 46688 bp := tls.Alloc(142) 46689 defer tls.Free(142) 46690 46691 // var pStmt uintptr at bp+80, 8 46692 46693 var rc int32 46694 // var idx int32 at bp+88, 4 46695 46696 if argc != 5 { 46697 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 46698 ts+16023 /* " VM IDX VALUE (n..." */, 0)) 46699 return TCL_ERROR 46700 } 46701 if getStmtPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+80 /* &pStmt */) != 0 { 46702 return TCL_ERROR 46703 } 46704 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+88 /* &idx */) != 0 { 46705 return TCL_ERROR 46706 } 46707 if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8)), ts+7387 /* "null" */) == 0 { 46708 rc = sqlite3.Xsqlite3_bind_null(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 88 /* idx */))) 46709 } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8)), ts+16059 /* "static" */) == 0 { 46710 rc = sqlite3.Xsqlite3_bind_text(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 88 /* idx */)), sqlite_static_bind_value, -1, uintptr(0)) 46711 } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8)), ts+16066 /* "static-nbytes" */) == 0 { 46712 rc = sqlite3.Xsqlite3_bind_text(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 88 /* idx */)), sqlite_static_bind_value, 46713 sqlite_static_bind_nbyte, uintptr(0)) 46714 } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8)), ts+16080 /* "normal" */) == 0 { 46715 rc = sqlite3.Xsqlite3_bind_text(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 88 /* idx */)), *(*uintptr)(unsafe.Pointer(argv + 3*8)), -1, libc.UintptrFromInt32(-1)) 46716 } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8)), ts+16087 /* "blob10" */) == 0 { 46717 rc = sqlite3.Xsqlite3_bind_text(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 88 /* idx */)), ts+16094 /* "abc\x00xyz\x00pq" */, 10, uintptr(0)) 46718 } else { 46719 tcl.XTcl_AppendResult(tls, interp, 46720 libc.VaList(bp+32, ts+16105 /* "4th argument sho..." */, 0)) 46721 return TCL_ERROR 46722 } 46723 if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */))), rc) != 0 { 46724 return TCL_ERROR 46725 } 46726 if rc != 0 { 46727 // var zBuf [50]int8 at bp+92, 50 46728 46729 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+92 /* &zBuf[0] */, ts+16159 /* "(%d) " */, libc.VaList(bp+48, rc)) 46730 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, bp+92 /* &zBuf[0] */, sqlite3.Xsqlite3ErrStr(tls, rc), 0)) 46731 return TCL_ERROR 46732 } 46733 return TCL_OK 46734 } 46735 46736 // Usage: add_test_collate <db ptr> <utf8> <utf16le> <utf16be> 46737 // 46738 // This function is used to test that SQLite selects the correct collation 46739 // sequence callback when multiple versions (for different text encodings) 46740 // are available. 46741 // 46742 // Calling this routine registers the collation sequence "test_collate" 46743 // with database handle <db>. The second argument must be a list of three 46744 // boolean values. If the first is true, then a version of test_collate is 46745 // registered for UTF-8, if the second is true, a version is registered for 46746 // UTF-16le, if the third is true, a UTF-16be version is available. 46747 // Previous versions of test_collate are deleted. 46748 // 46749 // The collation sequence test_collate is implemented by calling the 46750 // following TCL script: 46751 // 46752 // "test_collate <enc> <lhs> <rhs>" 46753 // 46754 // The <lhs> and <rhs> are the two values being compared, encoded in UTF-8. 46755 // The <enc> parameter is the encoding of the collation function that 46756 // SQLite selected to call. The TCL test script implements the 46757 // "test_collate" proc. 46758 // 46759 // Note that this will only work with one interpreter at a time, as the 46760 // interp pointer to use when evaluating the TCL script is stored in 46761 // pTestCollateInterp. 46762 var pTestCollateInterp uintptr /* test1.c:2975:18: */ 46763 46764 func test_collate_func(tls *libc.TLS, pCtx uintptr, nA int32, zA uintptr, nB int32, zB uintptr) int32 { /* test1.c:2976:12: */ 46765 bp := tls.Alloc(4) 46766 defer tls.Free(4) 46767 46768 var i uintptr = pTestCollateInterp 46769 var encin int32 = int32(pCtx) 46770 // var res int32 at bp, 4 46771 46772 var n int32 46773 var pVal uintptr 46774 var pX uintptr 46775 46776 pX = tcl.XTcl_NewStringObj(tls, ts+16165 /* "test_collate" */, -1) 46777 (*Tcl_Obj)(unsafe.Pointer(pX)).FrefCount++ 46778 46779 switch encin { 46780 case SQLITE_UTF8: 46781 tcl.XTcl_ListObjAppendElement(tls, i, pX, tcl.XTcl_NewStringObj(tls, ts+16178 /* "UTF-8" */, -1)) 46782 break 46783 case SQLITE_UTF16LE: 46784 tcl.XTcl_ListObjAppendElement(tls, i, pX, tcl.XTcl_NewStringObj(tls, ts+16184 /* "UTF-16LE" */, -1)) 46785 break 46786 case SQLITE_UTF16BE: 46787 tcl.XTcl_ListObjAppendElement(tls, i, pX, tcl.XTcl_NewStringObj(tls, ts+16193 /* "UTF-16BE" */, -1)) 46788 break 46789 default: 46790 46791 } 46792 46793 sqlite3.Xsqlite3BeginBenignMalloc(tls) 46794 pVal = sqlite3.Xsqlite3ValueNew(tls, uintptr(0)) 46795 if pVal != 0 { 46796 sqlite3.Xsqlite3ValueSetStr(tls, pVal, nA, zA, uint8(encin), uintptr(0)) 46797 n = sqlite3.Xsqlite3_value_bytes(tls, pVal) 46798 tcl.XTcl_ListObjAppendElement(tls, i, pX, 46799 tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, pVal), n)) 46800 sqlite3.Xsqlite3ValueSetStr(tls, pVal, nB, zB, uint8(encin), uintptr(0)) 46801 n = sqlite3.Xsqlite3_value_bytes(tls, pVal) 46802 tcl.XTcl_ListObjAppendElement(tls, i, pX, 46803 tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, pVal), n)) 46804 sqlite3.Xsqlite3ValueFree(tls, pVal) 46805 } 46806 sqlite3.Xsqlite3EndBenignMalloc(tls) 46807 46808 tcl.XTcl_EvalObjEx(tls, i, pX, 0) 46809 for ok := true; ok; ok = 0 != 0 { 46810 var _objPtr uintptr = pX 46811 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 46812 tcl.XTclFreeObj(tls, _objPtr) 46813 } 46814 } 46815 tcl.XTcl_GetIntFromObj(tls, i, tcl.XTcl_GetObjResult(tls, i), bp /* &res */) 46816 return *(*int32)(unsafe.Pointer(bp /* res */)) 46817 } 46818 46819 func test_collate(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3026:26: */ 46820 bp := tls.Alloc(60) 46821 defer tls.Free(60) 46822 46823 // var db uintptr at bp+48, 8 46824 46825 // var val int32 at bp+56, 4 46826 46827 var pVal uintptr 46828 var rc int32 46829 var zUtf16 uintptr 46830 46831 if !(objc != 5) { 46832 goto __1 46833 } 46834 goto bad_args 46835 __1: 46836 ; 46837 pTestCollateInterp = interp 46838 if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &db */) != 0) { 46839 goto __2 46840 } 46841 return TCL_ERROR 46842 __2: 46843 ; 46844 46845 if !(TCL_OK != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+56 /* &val */)) { 46846 goto __3 46847 } 46848 return TCL_ERROR 46849 __3: 46850 ; 46851 rc = sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), ts+16165 /* "test_collate" */, SQLITE_UTF8, 46852 uintptr(SQLITE_UTF8), func() uintptr { 46853 if *(*int32)(unsafe.Pointer(bp + 56 /* val */)) != 0 { 46854 return *(*uintptr)(unsafe.Pointer(&struct { 46855 f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 46856 }{test_collate_func})) 46857 } 46858 return uintptr(0) 46859 }()) 46860 if !(rc == SQLITE_OK) { 46861 goto __4 46862 } 46863 if !(TCL_OK != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+56 /* &val */)) { 46864 goto __5 46865 } 46866 return TCL_ERROR 46867 __5: 46868 ; 46869 rc = sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), ts+16165 /* "test_collate" */, SQLITE_UTF16LE, 46870 uintptr(SQLITE_UTF16LE), func() uintptr { 46871 if *(*int32)(unsafe.Pointer(bp + 56 /* val */)) != 0 { 46872 return *(*uintptr)(unsafe.Pointer(&struct { 46873 f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 46874 }{test_collate_func})) 46875 } 46876 return uintptr(0) 46877 }()) 46878 if !(TCL_OK != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+56 /* &val */)) { 46879 goto __6 46880 } 46881 return TCL_ERROR 46882 __6: 46883 ; 46884 46885 sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 48 /* db */)))).Fmutex) 46886 pVal = sqlite3.Xsqlite3ValueNew(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */))) 46887 sqlite3.Xsqlite3ValueSetStr(tls, pVal, -1, ts+16165 /* "test_collate" */, uint8(SQLITE_UTF8), uintptr(0)) 46888 zUtf16 = sqlite3.Xsqlite3ValueText(tls, pVal, func() uint8 { 46889 if int32(*(*int8)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3.Xsqlite3one))))) == 0 { 46890 return uint8(SQLITE_UTF16BE) 46891 } 46892 return uint8(SQLITE_UTF16LE) 46893 }()) 46894 if !((*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 48 /* db */)))).FmallocFailed != 0) { 46895 goto __7 46896 } 46897 rc = SQLITE_NOMEM 46898 goto __8 46899 __7: 46900 rc = sqlite3.Xsqlite3_create_collation16(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), zUtf16, SQLITE_UTF16BE, 46901 uintptr(SQLITE_UTF16BE), func() uintptr { 46902 if *(*int32)(unsafe.Pointer(bp + 56 /* val */)) != 0 { 46903 return *(*uintptr)(unsafe.Pointer(&struct { 46904 f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 46905 }{test_collate_func})) 46906 } 46907 return uintptr(0) 46908 }()) 46909 __8: 46910 ; 46911 sqlite3.Xsqlite3ValueFree(tls, pVal) 46912 sqlite3.Xsqlite3_mutex_leave(tls, (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 48 /* db */)))).Fmutex) 46913 __4: 46914 ; 46915 if !(sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), rc) != 0) { 46916 goto __9 46917 } 46918 return TCL_ERROR 46919 __9: 46920 ; 46921 46922 if !(rc != SQLITE_OK) { 46923 goto __10 46924 } 46925 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 46926 return TCL_ERROR 46927 __10: 46928 ; 46929 return TCL_OK 46930 46931 bad_args: 46932 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, ts+14631, /* "wrong # args: sh..." */ 46933 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+16202 /* " <DB> <utf8> <ut..." */, 0)) 46934 return TCL_ERROR 46935 } 46936 46937 // Usage: add_test_utf16bin_collate <db ptr> 46938 // 46939 // Add a utf-16 collation sequence named "utf16bin" to the database 46940 // handle. This collation sequence compares arguments in the same way as the 46941 // built-in collation "binary". 46942 func test_utf16bin_collate_func(tls *libc.TLS, pCtx uintptr, nA int32, zA uintptr, nB int32, zB uintptr) int32 { /* test1.c:3090:12: */ 46943 var nCmp int32 = func() int32 { 46944 if nA > nB { 46945 return nB 46946 } 46947 return nA 46948 }() 46949 var res int32 = libc.Xmemcmp(tls, zA, zB, uint64(nCmp)) 46950 if res == 0 { 46951 res = (nA - nB) 46952 } 46953 return res 46954 } 46955 46956 func test_utf16bin_collate(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3100:26: */ 46957 bp := tls.Alloc(8) 46958 defer tls.Free(8) 46959 46960 // var db uintptr at bp, 8 46961 46962 var rc int32 46963 46964 if !(objc != 2) { 46965 goto __1 46966 } 46967 goto bad_args 46968 __1: 46969 ; 46970 if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0) { 46971 goto __2 46972 } 46973 return TCL_ERROR 46974 __2: 46975 ; 46976 46977 rc = sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+16235 /* "utf16bin" */, SQLITE_UTF16, uintptr(0), 46978 *(*uintptr)(unsafe.Pointer(&struct { 46979 f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 46980 }{test_utf16bin_collate_func}))) 46981 if !(sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp /* db */)), rc) != 0) { 46982 goto __3 46983 } 46984 return TCL_ERROR 46985 __3: 46986 ; 46987 return TCL_OK 46988 46989 bad_args: 46990 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 46991 return TCL_ERROR 46992 } 46993 46994 // When the collation needed callback is invoked, record the name of 46995 // the requested collating function here. The recorded name is linked 46996 // to a TCL variable and used to make sure that the requested collation 46997 // name is correct. 46998 var zNeededCollation [200]int8 /* test1.c:3129:13: */ 46999 var pzNeededCollation uintptr = 0 /* test1.c:3130:13 */ 47000 47001 // Called when a collating sequence is needed. Registered using 47002 // sqlite3_collation_needed16(). 47003 func test_collate_needed_cb(tls *libc.TLS, pCtx uintptr, db uintptr, eTextRep int32, pName uintptr) { /* test1.c:3137:13: */ 47004 var enc int32 = int32((*sqlite31)(unsafe.Pointer(db)).Fenc) 47005 var i int32 47006 var z uintptr 47007 z = pName 47008 i = 0 47009 for ; (*(*int8)(unsafe.Pointer(z)) != 0) || (*(*int8)(unsafe.Pointer(z + 1)) != 0); z++ { 47010 if *(*int8)(unsafe.Pointer(z)) != 0 { 47011 zNeededCollation[libc.PostIncInt32(&i, 1)] = *(*int8)(unsafe.Pointer(z)) 47012 } 47013 } 47014 zNeededCollation[i] = int8(0) 47015 sqlite3.Xsqlite3_create_collation(tls, 47016 db, ts+16165 /* "test_collate" */, int32((*sqlite31)(unsafe.Pointer(db)).Fenc), uintptr(intptr_t(enc)), *(*uintptr)(unsafe.Pointer(&struct { 47017 f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 47018 }{test_collate_func}))) 47019 } 47020 47021 // Usage: add_test_collate_needed DB 47022 func test_collate_needed(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3157:26: */ 47023 bp := tls.Alloc(8) 47024 defer tls.Free(8) 47025 47026 // var db uintptr at bp, 8 47027 47028 var rc int32 47029 47030 if !(objc != 2) { 47031 goto __1 47032 } 47033 goto bad_args 47034 __1: 47035 ; 47036 if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0) { 47037 goto __2 47038 } 47039 return TCL_ERROR 47040 __2: 47041 ; 47042 rc = sqlite3.Xsqlite3_collation_needed16(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 47043 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) 47044 }{test_collate_needed_cb}))) 47045 zNeededCollation[0] = int8(0) 47046 if !(sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp /* db */)), rc) != 0) { 47047 goto __3 47048 } 47049 return TCL_ERROR 47050 __3: 47051 ; 47052 return TCL_OK 47053 47054 bad_args: 47055 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 47056 return TCL_ERROR 47057 } 47058 47059 // tclcmd: add_alignment_test_collations DB 47060 // 47061 // Add two new collating sequences to the database DB 47062 // 47063 // utf16_aligned 47064 // utf16_unaligned 47065 // 47066 // Both collating sequences use the same sort order as BINARY. 47067 // The only difference is that the utf16_aligned collating 47068 // sequence is declared with the SQLITE_UTF16_ALIGNED flag. 47069 // Both collating functions increment the unaligned utf16 counter 47070 // whenever they see a string that begins on an odd byte boundary. 47071 var unaligned_string_counter int32 = 0 /* test1.c:3192:12 */ 47072 47073 func alignmentCollFunc(tls *libc.TLS, NotUsed uintptr, nKey1 int32, pKey1 uintptr, nKey2 int32, pKey2 uintptr) int32 { /* test1.c:3193:12: */ 47074 var rc int32 47075 var n int32 47076 if nKey1 < nKey2 { 47077 n = nKey1 47078 } else { 47079 n = nKey2 47080 } 47081 if (nKey1 > 0) && (1 == (1 & (int32(pKey1)))) { 47082 unaligned_string_counter++ 47083 } 47084 if (nKey2 > 0) && (1 == (1 & (int32(pKey2)))) { 47085 unaligned_string_counter++ 47086 } 47087 rc = libc.Xmemcmp(tls, pKey1, pKey2, uint64(n)) 47088 if rc == 0 { 47089 rc = (nKey1 - nKey2) 47090 } 47091 return rc 47092 } 47093 47094 func add_alignment_test_collations(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3208:26: */ 47095 bp := tls.Alloc(8) 47096 defer tls.Free(8) 47097 47098 // var db uintptr at bp, 8 47099 47100 if objc >= 2 { 47101 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 47102 return TCL_ERROR 47103 } 47104 sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+16244 /* "utf16_unaligned" */, SQLITE_UTF16, 47105 uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 47106 f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 47107 }{alignmentCollFunc}))) 47108 sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+16260 /* "utf16_aligned" */, SQLITE_UTF16_ALIGNED, 47109 uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 47110 f func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32 47111 }{alignmentCollFunc}))) 47112 } 47113 return SQLITE_OK 47114 } 47115 47116 // Usage: add_test_function <db ptr> <utf8> <utf16le> <utf16be> 47117 // 47118 // This function is used to test that SQLite selects the correct user 47119 // function callback when multiple versions (for different text encodings) 47120 // are available. 47121 // 47122 // Calling this routine registers up to three versions of the user function 47123 // "test_function" with database handle <db>. If the second argument is 47124 // true, then a version of test_function is registered for UTF-8, if the 47125 // third is true, a version is registered for UTF-16le, if the fourth is 47126 // true, a UTF-16be version is available. Previous versions of 47127 // test_function are deleted. 47128 // 47129 // The user function is implemented by calling the following TCL script: 47130 // 47131 // "test_function <enc> <arg>" 47132 // 47133 // Where <enc> is one of UTF-8, UTF-16LE or UTF16BE, and <arg> is the 47134 // single argument passed to the SQL function. The value returned by 47135 // the TCL script is used as the return value of the SQL function. It 47136 // is passed to SQLite using UTF-16BE for a UTF-8 test_function(), UTF-8 47137 // for a UTF-16LE test_function(), and UTF-16LE for an implementation that 47138 // prefers UTF-16BE. 47139 func test_function_utf8(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* test1.c:3252:13: */ 47140 var interp uintptr 47141 var pX uintptr 47142 var pVal uintptr 47143 interp = sqlite3.Xsqlite3_user_data(tls, pCtx) 47144 pX = tcl.XTcl_NewStringObj(tls, ts+16274 /* "test_function" */, -1) 47145 (*Tcl_Obj)(unsafe.Pointer(pX)).FrefCount++ 47146 tcl.XTcl_ListObjAppendElement(tls, interp, pX, tcl.XTcl_NewStringObj(tls, ts+16178 /* "UTF-8" */, -1)) 47147 tcl.XTcl_ListObjAppendElement(tls, interp, pX, 47148 tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))), -1)) 47149 tcl.XTcl_EvalObjEx(tls, interp, pX, 0) 47150 for ok := true; ok; ok = 0 != 0 { 47151 var _objPtr uintptr = pX 47152 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 47153 tcl.XTclFreeObj(tls, _objPtr) 47154 } 47155 } 47156 sqlite3.Xsqlite3_result_text(tls, pCtx, tcl.XTcl_GetStringResult(tls, interp), -1, libc.UintptrFromInt32(-1)) 47157 pVal = sqlite3.Xsqlite3ValueNew(tls, uintptr(0)) 47158 sqlite3.Xsqlite3ValueSetStr(tls, pVal, -1, tcl.XTcl_GetStringResult(tls, interp), 47159 uint8(SQLITE_UTF8), uintptr(0)) 47160 sqlite3.Xsqlite3_result_text16be(tls, pCtx, sqlite3.Xsqlite3_value_text16be(tls, pVal), 47161 -1, libc.UintptrFromInt32(-1)) 47162 sqlite3.Xsqlite3ValueFree(tls, pVal) 47163 } 47164 47165 func test_function_utf16le(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* test1.c:3276:13: */ 47166 var interp uintptr 47167 var pX uintptr 47168 var pVal uintptr 47169 interp = sqlite3.Xsqlite3_user_data(tls, pCtx) 47170 pX = tcl.XTcl_NewStringObj(tls, ts+16274 /* "test_function" */, -1) 47171 (*Tcl_Obj)(unsafe.Pointer(pX)).FrefCount++ 47172 tcl.XTcl_ListObjAppendElement(tls, interp, pX, tcl.XTcl_NewStringObj(tls, ts+16184 /* "UTF-16LE" */, -1)) 47173 tcl.XTcl_ListObjAppendElement(tls, interp, pX, 47174 tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))), -1)) 47175 tcl.XTcl_EvalObjEx(tls, interp, pX, 0) 47176 for ok := true; ok; ok = 0 != 0 { 47177 var _objPtr uintptr = pX 47178 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 47179 tcl.XTclFreeObj(tls, _objPtr) 47180 } 47181 } 47182 pVal = sqlite3.Xsqlite3ValueNew(tls, uintptr(0)) 47183 sqlite3.Xsqlite3ValueSetStr(tls, pVal, -1, tcl.XTcl_GetStringResult(tls, interp), 47184 uint8(SQLITE_UTF8), uintptr(0)) 47185 sqlite3.Xsqlite3_result_text(tls, pCtx, sqlite3.Xsqlite3_value_text(tls, pVal), -1, libc.UintptrFromInt32(-1)) 47186 sqlite3.Xsqlite3ValueFree(tls, pVal) 47187 } 47188 47189 func test_function_utf16be(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* test1.c:3298:13: */ 47190 var interp uintptr 47191 var pX uintptr 47192 var pVal uintptr 47193 interp = sqlite3.Xsqlite3_user_data(tls, pCtx) 47194 pX = tcl.XTcl_NewStringObj(tls, ts+16274 /* "test_function" */, -1) 47195 (*Tcl_Obj)(unsafe.Pointer(pX)).FrefCount++ 47196 tcl.XTcl_ListObjAppendElement(tls, interp, pX, tcl.XTcl_NewStringObj(tls, ts+16193 /* "UTF-16BE" */, -1)) 47197 tcl.XTcl_ListObjAppendElement(tls, interp, pX, 47198 tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))), -1)) 47199 tcl.XTcl_EvalObjEx(tls, interp, pX, 0) 47200 for ok := true; ok; ok = 0 != 0 { 47201 var _objPtr uintptr = pX 47202 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 47203 tcl.XTclFreeObj(tls, _objPtr) 47204 } 47205 } 47206 pVal = sqlite3.Xsqlite3ValueNew(tls, uintptr(0)) 47207 sqlite3.Xsqlite3ValueSetStr(tls, pVal, -1, tcl.XTcl_GetStringResult(tls, interp), 47208 uint8(SQLITE_UTF8), uintptr(0)) 47209 sqlite3.Xsqlite3_result_text16(tls, pCtx, sqlite3.Xsqlite3_value_text16le(tls, pVal), 47210 -1, libc.UintptrFromInt32(-1)) 47211 sqlite3.Xsqlite3_result_text16be(tls, pCtx, sqlite3.Xsqlite3_value_text16le(tls, pVal), 47212 -1, libc.UintptrFromInt32(-1)) 47213 sqlite3.Xsqlite3_result_text16le(tls, pCtx, sqlite3.Xsqlite3_value_text16le(tls, pVal), 47214 -1, libc.UintptrFromInt32(-1)) 47215 sqlite3.Xsqlite3ValueFree(tls, pVal) 47216 } 47217 47218 func test_function(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3326:26: */ 47219 bp := tls.Alloc(44) 47220 defer tls.Free(44) 47221 47222 // var db uintptr at bp+32, 8 47223 47224 // var val int32 at bp+40, 4 47225 47226 if !(objc != 5) { 47227 goto __1 47228 } 47229 goto bad_args 47230 __1: 47231 ; 47232 if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0) { 47233 goto __2 47234 } 47235 return TCL_ERROR 47236 __2: 47237 ; 47238 47239 if !(TCL_OK != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &val */)) { 47240 goto __3 47241 } 47242 return TCL_ERROR 47243 __3: 47244 ; 47245 if !(*(*int32)(unsafe.Pointer(bp + 40 /* val */)) != 0) { 47246 goto __4 47247 } 47248 sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+16274 /* "test_function" */, 1, SQLITE_UTF8, 47249 interp, *(*uintptr)(unsafe.Pointer(&struct { 47250 f func(*libc.TLS, uintptr, int32, uintptr) 47251 }{test_function_utf8})), uintptr(0), uintptr(0)) 47252 __4: 47253 ; 47254 if !(TCL_OK != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+40 /* &val */)) { 47255 goto __5 47256 } 47257 return TCL_ERROR 47258 __5: 47259 ; 47260 if !(*(*int32)(unsafe.Pointer(bp + 40 /* val */)) != 0) { 47261 goto __6 47262 } 47263 sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+16274 /* "test_function" */, 1, SQLITE_UTF16LE, 47264 interp, *(*uintptr)(unsafe.Pointer(&struct { 47265 f func(*libc.TLS, uintptr, int32, uintptr) 47266 }{test_function_utf16le})), uintptr(0), uintptr(0)) 47267 __6: 47268 ; 47269 if !(TCL_OK != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+40 /* &val */)) { 47270 goto __7 47271 } 47272 return TCL_ERROR 47273 __7: 47274 ; 47275 if !(*(*int32)(unsafe.Pointer(bp + 40 /* val */)) != 0) { 47276 goto __8 47277 } 47278 sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+16274 /* "test_function" */, 1, SQLITE_UTF16BE, 47279 interp, *(*uintptr)(unsafe.Pointer(&struct { 47280 f func(*libc.TLS, uintptr, int32, uintptr) 47281 }{test_function_utf16be})), uintptr(0), uintptr(0)) 47282 __8: 47283 ; 47284 47285 return TCL_OK 47286 bad_args: 47287 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 47288 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+16202 /* " <DB> <utf8> <ut..." */, 0)) 47289 return TCL_ERROR 47290 } 47291 47292 // Usage: sqlite3_test_errstr <err code> 47293 // 47294 // Test that the english language string equivalents for sqlite error codes 47295 // are sane. The parameter is an integer representing an sqlite error code. 47296 // The result is a list of two elements, the string representation of the 47297 // error code and the english language explanation. 47298 func test_errstr(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3371:26: */ 47299 var zCode uintptr 47300 var i int32 47301 if objc != 1 { 47302 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16288 /* "<error code>" */) 47303 } 47304 47305 zCode = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 47306 for i = 0; i < 200; i++ { 47307 if 0 == libc.Xstrcmp(tls, sqlite3.Xsqlite3ErrName(tls, i), zCode) { 47308 break 47309 } 47310 } 47311 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrStr(tls, i), uintptr(0)) 47312 return TCL_OK 47313 } 47314 47315 // Usage: breakpoint 47316 // 47317 // This routine exists for one purpose - to provide a place to put a 47318 // breakpoint with GDB that can be triggered using TCL code. The use 47319 // for this is when a particular test fails on (say) the 1485th iteration. 47320 // In the TCL test script, we can add code like this: 47321 // 47322 // if {$i==1485} breakpoint 47323 // 47324 // Then run testfixture in the debugger and wait for the breakpoint to 47325 // fire. Then additional breakpoints can be set to trace down the bug. 47326 func test_breakpoint(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:3404:26: */ 47327 return TCL_OK // Do nothing 47328 } 47329 47330 // Usage: sqlite3_bind_zeroblob STMT IDX N 47331 // 47332 // Test the sqlite3_bind_zeroblob interface. STMT is a prepared statement. 47333 // IDX is the index of a wildcard in the prepared statement. This command 47334 // binds a N-byte zero-filled BLOB to the wildcard. 47335 func test_bind_zeroblob(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3420:26: */ 47336 bp := tls.Alloc(16) 47337 defer tls.Free(16) 47338 47339 // var pStmt uintptr at bp, 8 47340 47341 // var idx int32 at bp+8, 4 47342 47343 // var n int32 at bp+12, 4 47344 47345 var rc int32 47346 47347 if objc != 4 { 47348 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16301 /* "STMT IDX N" */) 47349 return TCL_ERROR 47350 } 47351 47352 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &pStmt */) != 0 { 47353 return TCL_ERROR 47354 } 47355 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &idx */) != 0 { 47356 return TCL_ERROR 47357 } 47358 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+12 /* &n */) != 0 { 47359 return TCL_ERROR 47360 } 47361 47362 rc = sqlite3.Xsqlite3_bind_zeroblob(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 8 /* idx */)), *(*int32)(unsafe.Pointer(bp + 12 /* n */))) 47363 if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))), rc) != 0 { 47364 return TCL_ERROR 47365 } 47366 if rc != SQLITE_OK { 47367 return TCL_ERROR 47368 } 47369 47370 return TCL_OK 47371 } 47372 47373 // Usage: sqlite3_bind_zeroblob64 STMT IDX N 47374 // 47375 // Test the sqlite3_bind_zeroblob64 interface. STMT is a prepared statement. 47376 // IDX is the index of a wildcard in the prepared statement. This command 47377 // binds a N-byte zero-filled BLOB to the wildcard. 47378 func test_bind_zeroblob64(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3456:26: */ 47379 bp := tls.Alloc(40) 47380 defer tls.Free(40) 47381 47382 // var pStmt uintptr at bp+16, 8 47383 47384 // var idx int32 at bp+24, 4 47385 47386 // var n Tcl_WideInt at bp+32, 8 47387 47388 var rc int32 47389 47390 if objc != 4 { 47391 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16301 /* "STMT IDX N" */) 47392 return TCL_ERROR 47393 } 47394 47395 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+16 /* &pStmt */) != 0 { 47396 return TCL_ERROR 47397 } 47398 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+24 /* &idx */) != 0 { 47399 return TCL_ERROR 47400 } 47401 if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+32 /* &n */) != 0 { 47402 return TCL_ERROR 47403 } 47404 47405 rc = sqlite3.Xsqlite3_bind_zeroblob64(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 24 /* idx */)), uint64(*(*Tcl_WideInt)(unsafe.Pointer(bp + 32 /* n */)))) 47406 if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))), rc) != 0 { 47407 return TCL_ERROR 47408 } 47409 if rc != SQLITE_OK { 47410 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 47411 return TCL_ERROR 47412 } 47413 47414 return TCL_OK 47415 } 47416 47417 // Usage: sqlite3_bind_int STMT N VALUE 47418 // 47419 // Test the sqlite3_bind_int interface. STMT is a prepared statement. 47420 // N is the index of a wildcard in the prepared statement. This command 47421 // binds a 32-bit integer VALUE to that wildcard. 47422 func test_bind_int(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3493:26: */ 47423 bp := tls.Alloc(48) 47424 defer tls.Free(48) 47425 47426 // var pStmt uintptr at bp+32, 8 47427 47428 // var idx int32 at bp+40, 4 47429 47430 // var value int32 at bp+44, 4 47431 47432 var rc int32 47433 47434 if objc != 4 { 47435 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 47436 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+16312 /* " STMT N VALUE" */, 0)) 47437 return TCL_ERROR 47438 } 47439 47440 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 47441 return TCL_ERROR 47442 } 47443 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &idx */) != 0 { 47444 return TCL_ERROR 47445 } 47446 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+44 /* &value */) != 0 { 47447 return TCL_ERROR 47448 } 47449 47450 rc = sqlite3.Xsqlite3_bind_int(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* idx */)), *(*int32)(unsafe.Pointer(bp + 44 /* value */))) 47451 if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))), rc) != 0 { 47452 return TCL_ERROR 47453 } 47454 if rc != SQLITE_OK { 47455 return TCL_ERROR 47456 } 47457 47458 return TCL_OK 47459 } 47460 47461 // Usage: intarray_addr INT ... 47462 // 47463 // Return the address of a C-language array of 32-bit integers. 47464 // 47465 // Space to hold the array is obtained from malloc(). Call this procedure once 47466 // with no arguments in order to release memory. Each call to this procedure 47467 // overwrites the previous array. 47468 func test_intarray_addr(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3533:26: */ 47469 var i int32 47470 47471 sqlite3.Xsqlite3_free(tls, p) 47472 p = uintptr(0) 47473 if objc > 1 { 47474 p = sqlite3.Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(int32(0))) * (uint64(objc - 1))))) 47475 if p == uintptr(0) { 47476 return TCL_ERROR 47477 } 47478 for i = 0; i < (objc - 1); i++ { 47479 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((1+i))*8)), (p+uintptr(i)*4)) != 0 { 47480 sqlite3.Xsqlite3_free(tls, p) 47481 p = uintptr(0) 47482 return TCL_ERROR 47483 } 47484 } 47485 } 47486 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, int64(p))) 47487 return TCL_OK 47488 } 47489 47490 var p uintptr = uintptr(0) /* test1.c:3540:14 */ 47491 47492 // Usage: intarray_addr INT ... 47493 // 47494 // Return the address of a C-language array of 32-bit integers. 47495 // 47496 // Space to hold the array is obtained from malloc(). Call this procedure once 47497 // with no arguments in order to release memory. Each call to this procedure 47498 // overwrites the previous array. 47499 func test_int64array_addr(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3567:26: */ 47500 bp := tls.Alloc(8) 47501 defer tls.Free(8) 47502 47503 var i int32 47504 47505 sqlite3.Xsqlite3_free(tls, p1) 47506 p1 = uintptr(0) 47507 if objc > 1 { 47508 p1 = sqlite3.Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(sqlite3_int64(0))) * (uint64(objc - 1))))) 47509 if p1 == uintptr(0) { 47510 return TCL_ERROR 47511 } 47512 for i = 0; i < (objc - 1); i++ { 47513 // var v Tcl_WideInt at bp, 8 47514 47515 if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((1+i))*8)), bp /* &v */) != 0 { 47516 sqlite3.Xsqlite3_free(tls, p1) 47517 p1 = uintptr(0) 47518 return TCL_ERROR 47519 } 47520 *(*sqlite3_int64)(unsafe.Pointer(p1 + uintptr(i)*8)) = *(*Tcl_WideInt)(unsafe.Pointer(bp /* v */)) 47521 } 47522 } 47523 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, int64(p1))) 47524 return TCL_OK 47525 } 47526 47527 var p1 uintptr = uintptr(0) /* test1.c:3574:24 */ 47528 47529 // Usage: doublearray_addr INT ... 47530 // 47531 // Return the address of a C-language array of doubles. 47532 // 47533 // Space to hold the array is obtained from malloc(). Call this procedure once 47534 // with no arguments in order to release memory. Each call to this procedure 47535 // overwrites the previous array. 47536 func test_doublearray_addr(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3603:26: */ 47537 var i int32 47538 47539 sqlite3.Xsqlite3_free(tls, p2) 47540 p2 = uintptr(0) 47541 if objc > 1 { 47542 p2 = sqlite3.Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(float64(0))) * (uint64(objc - 1))))) 47543 if p2 == uintptr(0) { 47544 return TCL_ERROR 47545 } 47546 for i = 0; i < (objc - 1); i++ { 47547 if tcl.XTcl_GetDoubleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((1+i))*8)), (p2+uintptr(i)*8)) != 0 { 47548 sqlite3.Xsqlite3_free(tls, p2) 47549 p2 = uintptr(0) 47550 return TCL_ERROR 47551 } 47552 } 47553 } 47554 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, int64(p2))) 47555 return TCL_OK 47556 } 47557 47558 var p2 uintptr = uintptr(0) /* test1.c:3610:17 */ 47559 47560 // Usage: textarray_addr TEXT ... 47561 // 47562 // Return the address of a C-language array of strings. 47563 // 47564 // Space to hold the array is obtained from malloc(). Call this procedure once 47565 // with no arguments in order to release memory. Each call to this procedure 47566 // overwrites the previous array. 47567 func test_textarray_addr(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3637:26: */ 47568 bp := tls.Alloc(8) 47569 defer tls.Free(8) 47570 47571 var i int32 47572 47573 for i = 0; i < n; i++ { 47574 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(p3 + uintptr(i)*8))) 47575 } 47576 sqlite3.Xsqlite3_free(tls, p3) 47577 p3 = uintptr(0) 47578 if objc > 1 { 47579 p3 = sqlite3.Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(uintptr(0))) * (uint64(objc - 1))))) 47580 if p3 == uintptr(0) { 47581 return TCL_ERROR 47582 } 47583 for i = 0; i < (objc - 1); i++ { 47584 *(*uintptr)(unsafe.Pointer(p3 + uintptr(i)*8)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr((1+i))*8))))) 47585 } 47586 } 47587 n = (objc - 1) 47588 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, int64(p3))) 47589 return TCL_OK 47590 } 47591 47592 var n int32 = 0 /* test1.c:3644:14 */ 47593 var p3 uintptr = uintptr(0) /* test1.c:3645:15 */ 47594 47595 // Usage: sqlite3_bind_int64 STMT N VALUE 47596 // 47597 // Test the sqlite3_bind_int64 interface. STMT is a prepared statement. 47598 // N is the index of a wildcard in the prepared statement. This command 47599 // binds a 64-bit integer VALUE to that wildcard. 47600 func test_bind_int64(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3670:26: */ 47601 bp := tls.Alloc(56) 47602 defer tls.Free(56) 47603 47604 // var pStmt uintptr at bp+32, 8 47605 47606 // var idx int32 at bp+40, 4 47607 47608 // var value Tcl_WideInt at bp+48, 8 47609 47610 var rc int32 47611 47612 if objc != 4 { 47613 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 47614 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+16312 /* " STMT N VALUE" */, 0)) 47615 return TCL_ERROR 47616 } 47617 47618 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 47619 return TCL_ERROR 47620 } 47621 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &idx */) != 0 { 47622 return TCL_ERROR 47623 } 47624 if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+48 /* &value */) != 0 { 47625 return TCL_ERROR 47626 } 47627 47628 rc = sqlite3.Xsqlite3_bind_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* idx */)), *(*Tcl_WideInt)(unsafe.Pointer(bp + 48 /* value */))) 47629 if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))), rc) != 0 { 47630 return TCL_ERROR 47631 } 47632 if rc != SQLITE_OK { 47633 return TCL_ERROR 47634 } 47635 47636 return TCL_OK 47637 } 47638 47639 // Usage: sqlite3_bind_double STMT N VALUE 47640 // 47641 // Test the sqlite3_bind_double interface. STMT is a prepared statement. 47642 // N is the index of a wildcard in the prepared statement. This command 47643 // binds a 64-bit integer VALUE to that wildcard. 47644 func test_bind_double(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3708:26: */ 47645 bp := tls.Alloc(64) 47646 defer tls.Free(64) 47647 47648 // var pStmt uintptr at bp+32, 8 47649 47650 // var idx int32 at bp+40, 4 47651 47652 *(*float64)(unsafe.Pointer(bp + 48 /* value */)) = float64(0) 47653 var rc int32 47654 var zVal uintptr 47655 var i int32 47656 47657 if objc != 4 { 47658 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 47659 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+16312 /* " STMT N VALUE" */, 0)) 47660 return TCL_ERROR 47661 } 47662 47663 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 47664 return TCL_ERROR 47665 } 47666 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &idx */) != 0 { 47667 return TCL_ERROR 47668 } 47669 47670 // Intercept the string "NaN" and generate a NaN value for it. 47671 // All other strings are passed through to Tcl_GetDoubleFromObj(). 47672 // Tcl_GetDoubleFromObj() should understand "NaN" but some versions 47673 // contain a bug. 47674 zVal = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 47675 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aSpecialFp)) / uint64(unsafe.Sizeof(struct { 47676 FzName uintptr 47677 FiUpper uint32 47678 FiLower uint32 47679 }{}))); i++ { 47680 if libc.Xstrcmp(tls, aSpecialFp[i].FzName, zVal) == 0 { 47681 // var x sqlite3_uint64 at bp+56, 8 47682 47683 *(*sqlite3_uint64)(unsafe.Pointer(bp + 56 /* x */)) = sqlite3_uint64(aSpecialFp[i].FiUpper) 47684 *(*sqlite3_uint64)(unsafe.Pointer(bp + 56 /* x */)) <<= 32 47685 *(*sqlite3_uint64)(unsafe.Pointer(bp + 56 /* x */)) |= sqlite3_uint64(aSpecialFp[i].FiLower) 47686 47687 libc.Xmemcpy(tls, bp+48 /* &value */, bp+56 /* &x */, uint64(8)) 47688 break 47689 } 47690 } 47691 if (uint64(i) >= (uint64(unsafe.Sizeof(aSpecialFp)) / uint64(unsafe.Sizeof(struct { 47692 FzName uintptr 47693 FiUpper uint32 47694 FiLower uint32 47695 }{})))) && (tcl.XTcl_GetDoubleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+48 /* &value */) != 0) { 47696 return TCL_ERROR 47697 } 47698 rc = sqlite3.Xsqlite3_bind_double(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* idx */)), *(*float64)(unsafe.Pointer(bp + 48 /* value */))) 47699 if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))), rc) != 0 { 47700 return TCL_ERROR 47701 } 47702 if rc != SQLITE_OK { 47703 return TCL_ERROR 47704 } 47705 47706 return TCL_OK 47707 } 47708 47709 var aSpecialFp = [10]struct { 47710 FzName uintptr 47711 FiUpper uint32 47712 FiLower uint32 47713 }{ 47714 {FzName: ts + 16326 /* "NaN" */, FiUpper: uint32(0x7fffffff), FiLower: 0xffffffff}, 47715 {FzName: ts + 16330 /* "SNaN" */, FiUpper: uint32(0x7ff7ffff), FiLower: 0xffffffff}, 47716 {FzName: ts + 16335 /* "-NaN" */, FiUpper: 0xffffffff, FiLower: 0xffffffff}, 47717 {FzName: ts + 16340 /* "-SNaN" */, FiUpper: 0xfff7ffff, FiLower: 0xffffffff}, 47718 {FzName: ts + 16346 /* "+Inf" */, FiUpper: uint32(0x7ff00000)}, 47719 {FzName: ts + 16351 /* "-Inf" */, FiUpper: 0xfff00000}, 47720 {FzName: ts + 16356 /* "Epsilon" */, FiLower: uint32(0x00000001)}, 47721 {FzName: ts + 16364 /* "-Epsilon" */, FiUpper: 0x80000000, FiLower: uint32(0x00000001)}, 47722 {FzName: ts + 16373 /* "NaN0" */, FiUpper: uint32(0x7ff80000)}, 47723 {FzName: ts + 16378 /* "-NaN0" */, FiUpper: 0xfff80000}, 47724 } /* test1.c:3724:5 */ 47725 47726 // Usage: sqlite3_bind_null STMT N 47727 // 47728 // Test the sqlite3_bind_null interface. STMT is a prepared statement. 47729 // N is the index of a wildcard in the prepared statement. This command 47730 // binds a NULL to the wildcard. 47731 func test_bind_null(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3784:26: */ 47732 bp := tls.Alloc(44) 47733 defer tls.Free(44) 47734 47735 // var pStmt uintptr at bp+32, 8 47736 47737 // var idx int32 at bp+40, 4 47738 47739 var rc int32 47740 47741 if objc != 3 { 47742 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 47743 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+16384 /* " STMT N" */, 0)) 47744 return TCL_ERROR 47745 } 47746 47747 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 47748 return TCL_ERROR 47749 } 47750 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &idx */) != 0 { 47751 return TCL_ERROR 47752 } 47753 47754 rc = sqlite3.Xsqlite3_bind_null(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* idx */))) 47755 if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))), rc) != 0 { 47756 return TCL_ERROR 47757 } 47758 if rc != SQLITE_OK { 47759 return TCL_ERROR 47760 } 47761 47762 return TCL_OK 47763 } 47764 47765 // Usage: sqlite3_bind_text STMT N STRING BYTES 47766 // 47767 // Test the sqlite3_bind_text interface. STMT is a prepared statement. 47768 // N is the index of a wildcard in the prepared statement. This command 47769 // binds a UTF-8 string STRING to the wildcard. The string is BYTES bytes 47770 // long. 47771 func test_bind_text(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3820:26: */ 47772 bp := tls.Alloc(64) 47773 defer tls.Free(64) 47774 47775 // var pStmt uintptr at bp+48, 8 47776 47777 // var idx int32 at bp+56, 4 47778 47779 // var bytes int32 at bp+60, 4 47780 47781 var value uintptr 47782 var rc int32 47783 47784 if objc != 5 { 47785 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 47786 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+16392 /* " STMT N VALUE BY..." */, 0)) 47787 return TCL_ERROR 47788 } 47789 47790 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &pStmt */) != 0 { 47791 return TCL_ERROR 47792 } 47793 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+56 /* &idx */) != 0 { 47794 return TCL_ERROR 47795 } 47796 value = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+60 /* &bytes */) 47797 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+60 /* &bytes */) != 0 { 47798 return TCL_ERROR 47799 } 47800 47801 rc = sqlite3.Xsqlite3_bind_text(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 56 /* idx */)), value, *(*int32)(unsafe.Pointer(bp + 60 /* bytes */)), libc.UintptrFromInt32(-1)) 47802 if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* pStmt */))), rc) != 0 { 47803 return TCL_ERROR 47804 } 47805 if rc != SQLITE_OK { 47806 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 47807 return TCL_ERROR 47808 } 47809 47810 return TCL_OK 47811 } 47812 47813 // Usage: sqlite3_bind_text16 ?-static? STMT N STRING BYTES 47814 // 47815 // Test the sqlite3_bind_text16 interface. STMT is a prepared statement. 47816 // N is the index of a wildcard in the prepared statement. This command 47817 // binds a UTF-16 string STRING to the wildcard. The string is BYTES bytes 47818 // long. 47819 func test_bind_text16(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3861:26: */ 47820 bp := tls.Alloc(64) 47821 defer tls.Free(64) 47822 47823 // var pStmt uintptr at bp+48, 8 47824 47825 // var idx int32 at bp+56, 4 47826 47827 // var bytes int32 at bp+60, 4 47828 47829 var value uintptr 47830 var rc int32 47831 47832 var xDel uintptr = func() uintptr { 47833 if objc == 6 { 47834 return uintptr(0) 47835 } 47836 return libc.UintptrFromInt32(-1) 47837 }() 47838 var oStmt uintptr = *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-4))*8)) 47839 var oN uintptr = *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-3))*8)) 47840 var oString uintptr = *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-2))*8)) 47841 var oBytes uintptr = *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-1))*8)) 47842 47843 if (objc != 5) && (objc != 6) { 47844 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 47845 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+16392 /* " STMT N VALUE BY..." */, 0)) 47846 return TCL_ERROR 47847 } 47848 47849 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, oStmt), bp+48 /* &pStmt */) != 0 { 47850 return TCL_ERROR 47851 } 47852 if tcl.XTcl_GetIntFromObj(tls, interp, oN, bp+56 /* &idx */) != 0 { 47853 return TCL_ERROR 47854 } 47855 value = tcl.XTcl_GetByteArrayFromObj(tls, oString, uintptr(0)) 47856 if tcl.XTcl_GetIntFromObj(tls, interp, oBytes, bp+60 /* &bytes */) != 0 { 47857 return TCL_ERROR 47858 } 47859 47860 rc = sqlite3.Xsqlite3_bind_text16(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 56 /* idx */)), value, *(*int32)(unsafe.Pointer(bp + 60 /* bytes */)), xDel) 47861 if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* pStmt */))), rc) != 0 { 47862 return TCL_ERROR 47863 } 47864 if rc != SQLITE_OK { 47865 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 47866 return TCL_ERROR 47867 } 47868 47869 return TCL_OK 47870 } 47871 47872 // Usage: sqlite3_bind_blob ?-static? STMT N DATA BYTES 47873 // 47874 // Test the sqlite3_bind_blob interface. STMT is a prepared statement. 47875 // N is the index of a wildcard in the prepared statement. This command 47876 // binds a BLOB to the wildcard. The BLOB is BYTES bytes in size. 47877 func test_bind_blob(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3909:26: */ 47878 bp := tls.Alloc(284) 47879 defer tls.Free(284) 47880 47881 // var pStmt uintptr at bp+64, 8 47882 47883 // var len int32 at bp+76, 4 47884 47885 // var idx int32 at bp+72, 4 47886 47887 // var bytes int32 at bp+80, 4 47888 47889 var value uintptr 47890 var rc int32 47891 var xDestructor sqlite3_destructor_type = libc.UintptrFromInt32(-1) 47892 47893 if (objc != 5) && (objc != 6) { 47894 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 47895 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+16412 /* " STMT N DATA BYT..." */, 0)) 47896 return TCL_ERROR 47897 } 47898 47899 if objc == 6 { 47900 xDestructor = uintptr(0) 47901 objv += 8 47902 } 47903 47904 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+64 /* &pStmt */) != 0 { 47905 return TCL_ERROR 47906 } 47907 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+72 /* &idx */) != 0 { 47908 return TCL_ERROR 47909 } 47910 47911 value = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+76 /* &len */) 47912 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+80 /* &bytes */) != 0 { 47913 return TCL_ERROR 47914 } 47915 47916 if *(*int32)(unsafe.Pointer(bp + 80 /* bytes */)) > *(*int32)(unsafe.Pointer(bp + 76 /* len */)) { 47917 // var zBuf [200]int8 at bp+84, 200 47918 47919 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([200]int8{})), bp+84, /* &zBuf[0] */ 47920 ts+16431 /* "cannot use %d bl..." */, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(bp + 80 /* bytes */)), *(*int32)(unsafe.Pointer(bp + 76 /* len */)))) 47921 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, bp+84 /* &zBuf[0] */, uintptr(0))) 47922 return TCL_ERROR 47923 } 47924 47925 rc = sqlite3.Xsqlite3_bind_blob(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 72 /* idx */)), value, *(*int32)(unsafe.Pointer(bp + 80 /* bytes */)), xDestructor) 47926 if sqlite3TestErrCode(tls, interp, sqlite3.Xsqlite3_db_handle(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */))), rc) != 0 { 47927 return TCL_ERROR 47928 } 47929 if rc != SQLITE_OK { 47930 return TCL_ERROR 47931 } 47932 47933 return TCL_OK 47934 } 47935 47936 // sqlite3_carray_bind [options...] STMT NAME VALUE ... 47937 // 47938 // Options: 47939 // -transient 47940 // -static 47941 // -int32 47942 // -int64 47943 // -double 47944 // -text 47945 // 47946 // Each call clears static data. Called with no options does nothing 47947 // but clear static data. 47948 func test_carray_bind(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:3972:26: */ 47949 bp := tls.Alloc(112) 47950 defer tls.Free(112) 47951 47952 // var pStmt uintptr at bp+80, 8 47953 47954 var eType int32 // CARRAY_INT32 47955 var nData int32 47956 var aData uintptr 47957 var isTransient int32 47958 var isStatic int32 47959 // var idx int32 at bp+88, 4 47960 47961 var i int32 47962 var j int32 47963 var rc int32 47964 var xDel uintptr 47965 var z uintptr 47966 // var v int32 at bp+92, 4 47967 // INT32 47968 var a uintptr 47969 // var v1 Tcl_WideInt at bp+96, 8 47970 // INT64 47971 var a1 uintptr 47972 // var v2 float64 at bp+104, 8 47973 // DOUBLE 47974 var a2 uintptr 47975 var v3 uintptr // TEXT 47976 var a3 uintptr 47977 eType = 0 47978 nData = 0 47979 aData = uintptr(0) 47980 isTransient = 0 47981 isStatic = 0 47982 xDel = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free})) 47983 47984 if !(aStaticData != 0) { 47985 goto __1 47986 } 47987 // Always clear preexisting static data on every call 47988 if !(eStaticType == 3) { 47989 goto __2 47990 } 47991 i = 0 47992 __3: 47993 if !(i < nStaticData) { 47994 goto __5 47995 } 47996 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer((aStaticData) + uintptr(i)*8))) 47997 goto __4 47998 __4: 47999 i++ 48000 goto __3 48001 goto __5 48002 __5: 48003 ; 48004 __2: 48005 ; 48006 sqlite3.Xsqlite3_free(tls, aStaticData) 48007 aStaticData = uintptr(0) 48008 nStaticData = 0 48009 eStaticType = 0 48010 __1: 48011 ; 48012 if !(objc == 1) { 48013 goto __6 48014 } 48015 return TCL_OK 48016 __6: 48017 ; 48018 48019 i = 1 48020 __7: 48021 if !((i < objc) && (int32(*(*int8)(unsafe.Pointer(tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)))))) == '-')) { 48022 goto __9 48023 } 48024 z = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8))) 48025 if !(libc.Xstrcmp(tls, z, ts+16465 /* "-transient" */) == 0) { 48026 goto __10 48027 } 48028 isTransient = 1 48029 xDel = libc.UintptrFromInt32(-1) 48030 goto __11 48031 __10: 48032 if !(libc.Xstrcmp(tls, z, ts+16476 /* "-static" */) == 0) { 48033 goto __12 48034 } 48035 isStatic = 1 48036 xDel = uintptr(0) 48037 goto __13 48038 __12: 48039 if !(libc.Xstrcmp(tls, z, ts+16484 /* "-int32" */) == 0) { 48040 goto __14 48041 } 48042 eType = 0 // CARRAY_INT32 48043 goto __15 48044 __14: 48045 if !(libc.Xstrcmp(tls, z, ts+16491 /* "-int64" */) == 0) { 48046 goto __16 48047 } 48048 eType = 1 // CARRAY_INT64 48049 goto __17 48050 __16: 48051 if !(libc.Xstrcmp(tls, z, ts+16498 /* "-double" */) == 0) { 48052 goto __18 48053 } 48054 eType = 2 // CARRAY_DOUBLE 48055 goto __19 48056 __18: 48057 if !(libc.Xstrcmp(tls, z, ts+16506 /* "-text" */) == 0) { 48058 goto __20 48059 } 48060 eType = 3 // CARRAY_TEXT 48061 goto __21 48062 __20: 48063 if !(libc.Xstrcmp(tls, z, ts+16512 /* "--" */) == 0) { 48064 goto __22 48065 } 48066 goto __9 48067 goto __23 48068 __22: 48069 48070 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+12135 /* "unknown option: " */, z, uintptr(0))) 48071 return TCL_ERROR 48072 __23: 48073 ; 48074 __21: 48075 ; 48076 __19: 48077 ; 48078 __17: 48079 ; 48080 __15: 48081 ; 48082 __13: 48083 ; 48084 __11: 48085 ; 48086 goto __8 48087 __8: 48088 i++ 48089 goto __7 48090 goto __9 48091 __9: 48092 ; 48093 if !(((eType == 3) && !(isStatic != 0)) && !(isTransient != 0)) { 48094 goto __24 48095 } 48096 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, ts+16515, /* "text data must b..." */ 48097 uintptr(0))) 48098 return TCL_ERROR 48099 __24: 48100 ; 48101 if !((isStatic != 0) && (isTransient != 0)) { 48102 goto __25 48103 } 48104 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, ts+16562, /* "cannot be both -..." */ 48105 uintptr(0))) 48106 return TCL_ERROR 48107 __25: 48108 ; 48109 if !((objc - i) < 2) { 48110 goto __26 48111 } 48112 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16600 /* "[OPTIONS] STMT I..." */) 48113 return TCL_ERROR 48114 __26: 48115 ; 48116 if !(getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8))), bp+80 /* &pStmt */) != 0) { 48117 goto __27 48118 } 48119 return TCL_ERROR 48120 __27: 48121 ; 48122 i++ 48123 if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+88 /* &idx */) != 0) { 48124 goto __28 48125 } 48126 return TCL_ERROR 48127 __28: 48128 ; 48129 i++ 48130 nData = (objc - i) 48131 switch eType + (4 * (libc.Bool32(nData <= 0))) { 48132 case 0: 48133 goto __30 48134 case 1: 48135 goto __31 48136 case 2: 48137 goto __32 48138 case 3: 48139 goto __33 48140 case 4: 48141 goto __34 48142 } 48143 goto __29 48144 __30: // INT32 48145 a = sqlite3.Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(int32(0))) * uint64(nData)))) 48146 if !(a == uintptr(0)) { 48147 goto __35 48148 } 48149 rc = SQLITE_NOMEM 48150 goto carray_bind_done 48151 __35: 48152 ; 48153 j = 0 48154 __36: 48155 if !(j < nData) { 48156 goto __38 48157 } 48158 if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+j))*8)), bp+92 /* &v */) != 0) { 48159 goto __39 48160 } 48161 sqlite3.Xsqlite3_free(tls, a) 48162 return TCL_ERROR 48163 __39: 48164 ; 48165 *(*int32)(unsafe.Pointer(a + uintptr(j)*4)) = *(*int32)(unsafe.Pointer(bp + 92 /* v */)) 48166 goto __37 48167 __37: 48168 j++ 48169 goto __36 48170 goto __38 48171 __38: 48172 ; 48173 aData = a 48174 goto __29 48175 48176 __31: // INT64 48177 a1 = sqlite3.Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(sqlite3_int64(0))) * uint64(nData)))) 48178 if !(a1 == uintptr(0)) { 48179 goto __40 48180 } 48181 rc = SQLITE_NOMEM 48182 goto carray_bind_done 48183 __40: 48184 ; 48185 j = 0 48186 __41: 48187 if !(j < nData) { 48188 goto __43 48189 } 48190 if !(tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+j))*8)), bp+96 /* &v1 */) != 0) { 48191 goto __44 48192 } 48193 sqlite3.Xsqlite3_free(tls, a1) 48194 return TCL_ERROR 48195 __44: 48196 ; 48197 *(*sqlite3_int64)(unsafe.Pointer(a1 + uintptr(j)*8)) = *(*Tcl_WideInt)(unsafe.Pointer(bp + 96 /* v1 */)) 48198 goto __42 48199 __42: 48200 j++ 48201 goto __41 48202 goto __43 48203 __43: 48204 ; 48205 aData = a1 48206 goto __29 48207 48208 __32: // DOUBLE 48209 a2 = sqlite3.Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(float64(0))) * uint64(nData)))) 48210 if !(a2 == uintptr(0)) { 48211 goto __45 48212 } 48213 rc = SQLITE_NOMEM 48214 goto carray_bind_done 48215 __45: 48216 ; 48217 j = 0 48218 __46: 48219 if !(j < nData) { 48220 goto __48 48221 } 48222 if !(tcl.XTcl_GetDoubleFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+j))*8)), bp+104 /* &v2 */) != 0) { 48223 goto __49 48224 } 48225 sqlite3.Xsqlite3_free(tls, a2) 48226 return TCL_ERROR 48227 __49: 48228 ; 48229 *(*float64)(unsafe.Pointer(a2 + uintptr(j)*8)) = *(*float64)(unsafe.Pointer(bp + 104 /* v2 */)) 48230 goto __47 48231 __47: 48232 j++ 48233 goto __46 48234 goto __48 48235 __48: 48236 ; 48237 aData = a2 48238 goto __29 48239 48240 __33: // TEXT 48241 a3 = sqlite3.Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(uintptr(0))) * uint64(nData)))) 48242 if !(a3 == uintptr(0)) { 48243 goto __50 48244 } 48245 rc = SQLITE_NOMEM 48246 goto carray_bind_done 48247 __50: 48248 ; 48249 j = 0 48250 __51: 48251 if !(j < nData) { 48252 goto __53 48253 } 48254 v3 = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+j))*8))) 48255 *(*uintptr)(unsafe.Pointer(a3 + uintptr(j)*8)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+56, v3)) 48256 goto __52 48257 __52: 48258 j++ 48259 goto __51 48260 goto __53 48261 __53: 48262 ; 48263 aData = a3 48264 goto __29 48265 48266 __34: // nData==0 48267 aData = ts + 489 /* "" */ 48268 xDel = uintptr(0) 48269 isTransient = 0 48270 isStatic = 0 48271 goto __29 48272 48273 __29: 48274 ; 48275 if !(isStatic != 0) { 48276 goto __54 48277 } 48278 aStaticData = aData 48279 nStaticData = nData 48280 eStaticType = eType 48281 __54: 48282 ; 48283 rc = sqlite3_carray_bind(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 88 /* idx */)), aData, nData, eType, xDel) 48284 if !(isTransient != 0) { 48285 goto __55 48286 } 48287 if !(eType == 3) { 48288 goto __56 48289 } 48290 i = 0 48291 __57: 48292 if !(i < nData) { 48293 goto __59 48294 } 48295 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer((aData) + uintptr(i)*8))) 48296 goto __58 48297 __58: 48298 i++ 48299 goto __57 48300 goto __59 48301 __59: 48302 ; 48303 __56: 48304 ; 48305 sqlite3.Xsqlite3_free(tls, aData) 48306 __55: 48307 ; 48308 carray_bind_done: 48309 if !(rc != 0) { 48310 goto __60 48311 } 48312 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, sqlite3.Xsqlite3_errstr(tls, rc), uintptr(0))) 48313 return TCL_ERROR 48314 __60: 48315 ; 48316 return TCL_OK 48317 } 48318 48319 var aStaticData uintptr = uintptr(0) /* test1.c:3988:15 */ 48320 var nStaticData int32 = 0 /* test1.c:3989:14 */ 48321 var eStaticType int32 = 0 /* test1.c:3990:14 */ 48322 48323 // Usage: sqlite3_bind_parameter_count STMT 48324 // 48325 // Return the number of wildcards in the given statement. 48326 func test_bind_parameter_count(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4150:26: */ 48327 bp := tls.Alloc(8) 48328 defer tls.Free(8) 48329 48330 // var pStmt uintptr at bp, 8 48331 48332 if objc != 2 { 48333 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16629 /* "STMT" */) 48334 return TCL_ERROR 48335 } 48336 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &pStmt */) != 0 { 48337 return TCL_ERROR 48338 } 48339 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_bind_parameter_count(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))))) 48340 return TCL_OK 48341 } 48342 48343 // Usage: sqlite3_bind_parameter_name STMT N 48344 // 48345 // Return the name of the Nth wildcard. The first wildcard is 1. 48346 // An empty string is returned if N is out of range or if the wildcard 48347 // is nameless. 48348 func test_bind_parameter_name(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4174:26: */ 48349 bp := tls.Alloc(12) 48350 defer tls.Free(12) 48351 48352 // var pStmt uintptr at bp, 8 48353 48354 // var i int32 at bp+8, 4 48355 48356 if objc != 3 { 48357 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16634 /* "STMT N" */) 48358 return TCL_ERROR 48359 } 48360 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &pStmt */) != 0 { 48361 return TCL_ERROR 48362 } 48363 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &i */) != 0 { 48364 return TCL_ERROR 48365 } 48366 tcl.XTcl_SetObjResult(tls, interp, 48367 tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_bind_parameter_name(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 8 /* i */))), -1)) 48368 return TCL_OK 48369 } 48370 48371 // Usage: sqlite3_bind_parameter_index STMT NAME 48372 // 48373 // Return the index of the wildcard called NAME. Return 0 if there is 48374 // no such wildcard. 48375 func test_bind_parameter_index(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4201:26: */ 48376 bp := tls.Alloc(8) 48377 defer tls.Free(8) 48378 48379 // var pStmt uintptr at bp, 8 48380 48381 if objc != 3 { 48382 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16641 /* "STMT NAME" */) 48383 return TCL_ERROR 48384 } 48385 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &pStmt */) != 0 { 48386 return TCL_ERROR 48387 } 48388 tcl.XTcl_SetObjResult(tls, interp, 48389 tcl.XTcl_NewIntObj(tls, 48390 sqlite3.Xsqlite3_bind_parameter_index(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)))))) 48391 return TCL_OK 48392 } 48393 48394 // Usage: sqlite3_clear_bindings STMT 48395 // 48396 func test_clear_bindings(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4226:26: */ 48397 bp := tls.Alloc(8) 48398 defer tls.Free(8) 48399 48400 // var pStmt uintptr at bp, 8 48401 48402 if objc != 2 { 48403 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16629 /* "STMT" */) 48404 return TCL_ERROR 48405 } 48406 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &pStmt */) != 0 { 48407 return TCL_ERROR 48408 } 48409 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_clear_bindings(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))))) 48410 return TCL_OK 48411 } 48412 48413 // Usage: sqlite3_sleep MILLISECONDS 48414 func test_sleep(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4246:26: */ 48415 bp := tls.Alloc(4) 48416 defer tls.Free(4) 48417 48418 // var ms int32 at bp, 4 48419 48420 if objc != 2 { 48421 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+12808 /* "MILLISECONDS" */) 48422 return TCL_ERROR 48423 } 48424 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &ms */) != 0 { 48425 return TCL_ERROR 48426 } 48427 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_sleep(tls, *(*int32)(unsafe.Pointer(bp /* ms */))))) 48428 return TCL_OK 48429 } 48430 48431 // Usage: sqlite3_extended_errcode DB 48432 // 48433 // Return the string representation of the most recent sqlite3_* API 48434 // error code. e.g. "SQLITE_ERROR". 48435 func test_ex_errcode(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4271:26: */ 48436 bp := tls.Alloc(56) 48437 defer tls.Free(56) 48438 48439 // var db uintptr at bp+48, 8 48440 48441 var rc int32 48442 48443 if objc != 2 { 48444 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 48445 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+14683 /* " DB" */, 0)) 48446 return TCL_ERROR 48447 } 48448 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &db */) != 0 { 48449 return TCL_ERROR 48450 } 48451 rc = sqlite3.Xsqlite3_extended_errcode(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */))) 48452 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 48453 return TCL_OK 48454 } 48455 48456 // Usage: sqlite3_errcode DB 48457 // 48458 // Return the string representation of the most recent sqlite3_* API 48459 // error code. e.g. "SQLITE_ERROR". 48460 func test_errcode(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4298:26: */ 48461 bp := tls.Alloc(56) 48462 defer tls.Free(56) 48463 48464 // var db uintptr at bp+48, 8 48465 48466 var rc int32 48467 48468 if objc != 2 { 48469 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 48470 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+14683 /* " DB" */, 0)) 48471 return TCL_ERROR 48472 } 48473 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &db */) != 0 { 48474 return TCL_ERROR 48475 } 48476 rc = sqlite3.Xsqlite3_errcode(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */))) 48477 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 48478 return TCL_OK 48479 } 48480 48481 // Usage: sqlite3_errmsg DB 48482 // 48483 // Returns the UTF-8 representation of the error message string for the 48484 // most recent sqlite3_* API call. 48485 func test_errmsg(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4324:26: */ 48486 bp := tls.Alloc(40) 48487 defer tls.Free(40) 48488 48489 // var db uintptr at bp+32, 8 48490 48491 var zErr uintptr 48492 48493 if objc != 2 { 48494 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 48495 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+14683 /* " DB" */, 0)) 48496 return TCL_ERROR 48497 } 48498 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0 { 48499 return TCL_ERROR 48500 } 48501 48502 zErr = sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */))) 48503 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, zErr, -1)) 48504 return TCL_OK 48505 } 48506 48507 // Usage: test_errmsg16 DB 48508 // 48509 // Returns the UTF-16 representation of the error message string for the 48510 // most recent sqlite3_* API call. This is a byte array object at the TCL 48511 // level, and it includes the 0x00 0x00 terminator bytes at the end of the 48512 // UTF-16 string. 48513 func test_errmsg16(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4353:26: */ 48514 bp := tls.Alloc(40) 48515 defer tls.Free(40) 48516 48517 // var db uintptr at bp+32, 8 48518 48519 var zErr uintptr 48520 var z uintptr 48521 var bytes int32 = 0 48522 48523 if objc != 2 { 48524 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 48525 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+14683 /* " DB" */, 0)) 48526 return TCL_ERROR 48527 } 48528 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0 { 48529 return TCL_ERROR 48530 } 48531 48532 zErr = sqlite3.Xsqlite3_errmsg16(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */))) 48533 if zErr != 0 { 48534 z = zErr 48535 for bytes = 0; (*(*int8)(unsafe.Pointer(z + uintptr(bytes))) != 0) || (*(*int8)(unsafe.Pointer(z + uintptr((bytes + 1)))) != 0); bytes = bytes + (2) { 48536 } 48537 } 48538 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewByteArrayObj(tls, zErr, bytes)) 48539 return TCL_OK 48540 } 48541 48542 // Usage: sqlite3_prepare DB sql bytes ?tailvar? 48543 // 48544 // Compile up to <bytes> bytes of the supplied SQL string <sql> using 48545 // database handle <DB>. The parameter <tailval> is the name of a global 48546 // variable that is set to the unused portion of <sql> (if any). A 48547 // STMT handle is returned. 48548 func test_prepare(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4390:26: */ 48549 bp := tls.Alloc(162) 48550 defer tls.Free(162) 48551 48552 // var db uintptr at bp+80, 8 48553 48554 var zSql uintptr 48555 // var bytes int32 at bp+88, 4 48556 48557 *(*uintptr)(unsafe.Pointer(bp + 104 /* zTail */)) = uintptr(0) 48558 *(*uintptr)(unsafe.Pointer(bp + 96 /* pStmt */)) = uintptr(0) 48559 // var zBuf [50]int8 at bp+112, 50 48560 48561 var rc int32 48562 48563 if (objc != 5) && (objc != 4) { 48564 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 48565 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16651 /* " DB sql bytes ?t..." */, 0)) 48566 return TCL_ERROR 48567 } 48568 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+80 /* &db */) != 0 { 48569 return TCL_ERROR 48570 } 48571 zSql = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 48572 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+88 /* &bytes */) != 0 { 48573 return TCL_ERROR 48574 } 48575 48576 rc = sqlite3.Xsqlite3_prepare(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */)), zSql, *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)), bp+96 /* &pStmt */, func() uintptr { 48577 if objc >= 5 { 48578 return bp + 104 /* &zTail */ 48579 } 48580 return uintptr(0) 48581 }()) 48582 tcl.XTcl_ResetResult(tls, interp) 48583 if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */)), rc) != 0 { 48584 return TCL_ERROR 48585 } 48586 if (*(*uintptr)(unsafe.Pointer(bp + 104 /* zTail */)) != 0) && (objc >= 5) { 48587 if *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) >= 0 { 48588 *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) = (*(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) - (int32((int64(*(*uintptr)(unsafe.Pointer(bp + 104 /* zTail */))) - int64(zSql)) / 1))) 48589 } 48590 if int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 104 /* zTail */)))) < *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) { 48591 *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(bp + 104 /* zTail */)))) 48592 } 48593 tcl.XTcl_ObjSetVar2(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), uintptr(0), tcl.XTcl_NewStringObj(tls, *(*uintptr)(unsafe.Pointer(bp + 104 /* zTail */)), *(*int32)(unsafe.Pointer(bp + 88 /* bytes */))), 0) 48594 } 48595 if rc != SQLITE_OK { 48596 48597 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+112 /* &zBuf[0] */, ts+16159 /* "(%d) " */, libc.VaList(bp+32, rc)) 48598 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+112 /* &zBuf[0] */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */))), 0)) 48599 return TCL_ERROR 48600 } 48601 48602 if *(*uintptr)(unsafe.Pointer(bp + 96 /* pStmt */)) != 0 { 48603 if sqlite3TestMakePointerStr(tls, interp, bp+112 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 96 /* pStmt */))) != 0 { 48604 return TCL_ERROR 48605 } 48606 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, bp+112 /* &zBuf[0] */, 0)) 48607 } 48608 return TCL_OK 48609 } 48610 48611 // Usage: sqlite3_prepare_v2 DB sql bytes ?tailvar? 48612 // 48613 // Compile up to <bytes> bytes of the supplied SQL string <sql> using 48614 // database handle <DB>. The parameter <tailval> is the name of a global 48615 // variable that is set to the unused portion of <sql> (if any). A 48616 // STMT handle is returned. 48617 func test_prepare_v2(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4447:26: */ 48618 bp := tls.Alloc(162) 48619 defer tls.Free(162) 48620 48621 // var db uintptr at bp+80, 8 48622 48623 var zSql uintptr 48624 var zCopy uintptr = uintptr(0) // malloc() copy of zSql 48625 // var bytes int32 at bp+88, 4 48626 48627 *(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */)) = uintptr(0) 48628 var pzTail uintptr 48629 *(*uintptr)(unsafe.Pointer(bp + 104 /* pStmt */)) = uintptr(0) 48630 // var zBuf [50]int8 at bp+112, 50 48631 48632 var rc int32 48633 48634 if (objc != 5) && (objc != 4) { 48635 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 48636 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16675 /* " DB sql bytes ta..." */, 0)) 48637 return TCL_ERROR 48638 } 48639 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+80 /* &db */) != 0 { 48640 return TCL_ERROR 48641 } 48642 zSql = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 48643 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+88 /* &bytes */) != 0 { 48644 return TCL_ERROR 48645 } 48646 48647 // Instead of using zSql directly, make a copy into a buffer obtained 48648 // directly from malloc(). The idea is to make it easier for valgrind 48649 // to spot buffer overreads. 48650 if *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) >= 0 { 48651 zCopy = libc.Xmalloc(tls, uint64(*(*int32)(unsafe.Pointer(bp + 88 /* bytes */)))) 48652 libc.Xmemcpy(tls, zCopy, zSql, uint64(*(*int32)(unsafe.Pointer(bp + 88 /* bytes */)))) 48653 } else { 48654 var n int32 = (int32(libc.Xstrlen(tls, zSql)) + 1) 48655 zCopy = libc.Xmalloc(tls, uint64(n)) 48656 libc.Xmemcpy(tls, zCopy, zSql, uint64(n)) 48657 } 48658 if objc >= 5 { 48659 pzTail = bp + 96 /* &zTail */ 48660 } else { 48661 pzTail = uintptr(0) 48662 } 48663 rc = sqlite3.Xsqlite3_prepare_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */)), zCopy, *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)), bp+104 /* &pStmt */, pzTail) 48664 if objc >= 5 { 48665 *(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */)) = (zSql + uintptr(((int64(*(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */))) - int64(zCopy)) / 1))) 48666 } 48667 libc.Xfree(tls, zCopy) 48668 48669 tcl.XTcl_ResetResult(tls, interp) 48670 if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */)), rc) != 0 { 48671 return TCL_ERROR 48672 } 48673 if ((rc == SQLITE_OK) && (objc >= 5)) && (*(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */)) != 0) { 48674 if *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) >= 0 { 48675 *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) = (*(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) - (int32((int64(*(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */))) - int64(zSql)) / 1))) 48676 } 48677 tcl.XTcl_ObjSetVar2(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), uintptr(0), tcl.XTcl_NewStringObj(tls, *(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */)), *(*int32)(unsafe.Pointer(bp + 88 /* bytes */))), 0) 48678 } 48679 if rc != SQLITE_OK { 48680 48681 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+112 /* &zBuf[0] */, ts+16159 /* "(%d) " */, libc.VaList(bp+32, rc)) 48682 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+112 /* &zBuf[0] */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */))), 0)) 48683 return TCL_ERROR 48684 } 48685 48686 if *(*uintptr)(unsafe.Pointer(bp + 104 /* pStmt */)) != 0 { 48687 if sqlite3TestMakePointerStr(tls, interp, bp+112 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 104 /* pStmt */))) != 0 { 48688 return TCL_ERROR 48689 } 48690 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, bp+112 /* &zBuf[0] */, 0)) 48691 } 48692 return TCL_OK 48693 } 48694 48695 // Usage: sqlite3_prepare_v3 DB sql bytes flags ?tailvar? 48696 // 48697 // Compile up to <bytes> bytes of the supplied SQL string <sql> using 48698 // database handle <DB> and flags <flags>. The parameter <tailval> is 48699 // the name of a global variable that is set to the unused portion of 48700 // <sql> (if any). A STMT handle is returned. 48701 func test_prepare_v3(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4521:26: */ 48702 bp := tls.Alloc(162) 48703 defer tls.Free(162) 48704 48705 // var db uintptr at bp+80, 8 48706 48707 var zSql uintptr 48708 var zCopy uintptr = uintptr(0) // malloc() copy of zSql 48709 // var bytes int32 at bp+88, 4 48710 48711 // var flags int32 at bp+92, 4 48712 48713 *(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */)) = uintptr(0) 48714 var pzTail uintptr 48715 *(*uintptr)(unsafe.Pointer(bp + 104 /* pStmt */)) = uintptr(0) 48716 // var zBuf [50]int8 at bp+112, 50 48717 48718 var rc int32 48719 48720 if (objc != 6) && (objc != 5) { 48721 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 48722 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16697 /* " DB sql bytes fl..." */, 0)) 48723 return TCL_ERROR 48724 } 48725 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+80 /* &db */) != 0 { 48726 return TCL_ERROR 48727 } 48728 zSql = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 48729 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+88 /* &bytes */) != 0 { 48730 return TCL_ERROR 48731 } 48732 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+92 /* &flags */) != 0 { 48733 return TCL_ERROR 48734 } 48735 48736 // Instead of using zSql directly, make a copy into a buffer obtained 48737 // directly from malloc(). The idea is to make it easier for valgrind 48738 // to spot buffer overreads. 48739 if *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) >= 0 { 48740 zCopy = libc.Xmalloc(tls, uint64(*(*int32)(unsafe.Pointer(bp + 88 /* bytes */)))) 48741 libc.Xmemcpy(tls, zCopy, zSql, uint64(*(*int32)(unsafe.Pointer(bp + 88 /* bytes */)))) 48742 } else { 48743 var n int32 = (int32(libc.Xstrlen(tls, zSql)) + 1) 48744 zCopy = libc.Xmalloc(tls, uint64(n)) 48745 libc.Xmemcpy(tls, zCopy, zSql, uint64(n)) 48746 } 48747 if objc >= 6 { 48748 pzTail = bp + 96 /* &zTail */ 48749 } else { 48750 pzTail = uintptr(0) 48751 } 48752 rc = sqlite3.Xsqlite3_prepare_v3(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */)), zCopy, *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)), uint32(*(*int32)(unsafe.Pointer(bp + 92 /* flags */))), bp+104 /* &pStmt */, pzTail) 48753 libc.Xfree(tls, zCopy) 48754 *(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */)) = (zSql + uintptr(((int64(*(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */))) - int64(zCopy)) / 1))) 48755 48756 tcl.XTcl_ResetResult(tls, interp) 48757 if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */)), rc) != 0 { 48758 return TCL_ERROR 48759 } 48760 if ((rc == SQLITE_OK) && (*(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */)) != 0)) && (objc >= 6) { 48761 if *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) >= 0 { 48762 *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) = (*(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) - (int32((int64(*(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */))) - int64(zSql)) / 1))) 48763 } 48764 tcl.XTcl_ObjSetVar2(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 5*8)), uintptr(0), tcl.XTcl_NewStringObj(tls, *(*uintptr)(unsafe.Pointer(bp + 96 /* zTail */)), *(*int32)(unsafe.Pointer(bp + 88 /* bytes */))), 0) 48765 } 48766 if rc != SQLITE_OK { 48767 48768 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+112 /* &zBuf[0] */, ts+16159 /* "(%d) " */, libc.VaList(bp+32, rc)) 48769 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+112 /* &zBuf[0] */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */))), 0)) 48770 return TCL_ERROR 48771 } 48772 48773 if *(*uintptr)(unsafe.Pointer(bp + 104 /* pStmt */)) != 0 { 48774 if sqlite3TestMakePointerStr(tls, interp, bp+112 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 104 /* pStmt */))) != 0 { 48775 return TCL_ERROR 48776 } 48777 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, bp+112 /* &zBuf[0] */, 0)) 48778 } 48779 return TCL_OK 48780 } 48781 48782 // Usage: sqlite3_prepare_tkt3134 DB 48783 // 48784 // Generate a prepared statement for a zero-byte string as a test 48785 // for ticket #3134. The string should be preceded by a zero byte. 48786 func test_prepare_tkt3134(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4592:26: */ 48787 bp := tls.Alloc(146) 48788 defer tls.Free(146) 48789 48790 // var db uintptr at bp+80, 8 48791 48792 *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */)) = uintptr(0) 48793 // var zBuf [50]int8 at bp+96, 50 48794 48795 var rc int32 48796 48797 if objc != 2 { 48798 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 48799 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16675 /* " DB sql bytes ta..." */, 0)) 48800 return TCL_ERROR 48801 } 48802 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+80 /* &db */) != 0 { 48803 return TCL_ERROR 48804 } 48805 rc = sqlite3.Xsqlite3_prepare_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */)), (uintptr(unsafe.Pointer(&zSql)) + 1), 0, bp+88 /* &pStmt */, uintptr(0)) 48806 48807 if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */)), rc) != 0 { 48808 return TCL_ERROR 48809 } 48810 if rc != SQLITE_OK { 48811 48812 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+96 /* &zBuf[0] */, ts+16159 /* "(%d) " */, libc.VaList(bp+32, rc)) 48813 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+96 /* &zBuf[0] */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */))), 0)) 48814 return TCL_ERROR 48815 } 48816 48817 if *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */)) != 0 { 48818 if sqlite3TestMakePointerStr(tls, interp, bp+96 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 88 /* pStmt */))) != 0 { 48819 return TCL_ERROR 48820 } 48821 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, bp+96 /* &zBuf[0] */, 0)) 48822 } 48823 return TCL_OK 48824 } 48825 48826 var zSql = *(*[10]int8)(unsafe.Pointer(ts + 16725 /* "\x00SELECT 1" */)) /* test1.c:4599:21 */ 48827 48828 // Usage: sqlite3_prepare16 DB sql bytes tailvar 48829 // 48830 // Compile up to <bytes> bytes of the supplied SQL string <sql> using 48831 // database handle <DB>. The parameter <tailval> is the name of a global 48832 // variable that is set to the unused portion of <sql> (if any). A 48833 // STMT handle is returned. 48834 func test_prepare16(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4635:26: */ 48835 bp := tls.Alloc(130) 48836 defer tls.Free(130) 48837 48838 // var db uintptr at bp+48, 8 48839 48840 var zSql uintptr 48841 *(*uintptr)(unsafe.Pointer(bp + 72 /* zTail */)) = uintptr(0) 48842 var pTail uintptr = uintptr(0) 48843 *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */)) = uintptr(0) 48844 // var zBuf [50]int8 at bp+80, 50 48845 48846 var rc int32 48847 // var bytes int32 at bp+60, 4 48848 // The integer specified as arg 3 48849 // var objlen int32 at bp+56, 4 48850 // The byte-array length of arg 2 48851 48852 if (objc != 5) && (objc != 4) { 48853 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 48854 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16651 /* " DB sql bytes ?t..." */, 0)) 48855 return TCL_ERROR 48856 } 48857 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &db */) != 0 { 48858 return TCL_ERROR 48859 } 48860 zSql = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+56 /* &objlen */) 48861 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+60 /* &bytes */) != 0 { 48862 return TCL_ERROR 48863 } 48864 48865 rc = sqlite3.Xsqlite3_prepare16(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), zSql, *(*int32)(unsafe.Pointer(bp + 60 /* bytes */)), bp+64 /* &pStmt */, func() uintptr { 48866 if objc >= 5 { 48867 return bp + 72 /* &zTail */ 48868 } 48869 return uintptr(0) 48870 }()) 48871 if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), rc) != 0 { 48872 return TCL_ERROR 48873 } 48874 if rc != 0 { 48875 return TCL_ERROR 48876 } 48877 48878 if objc >= 5 { 48879 if *(*uintptr)(unsafe.Pointer(bp + 72 /* zTail */)) != 0 { 48880 *(*int32)(unsafe.Pointer(bp + 56 /* objlen */)) = (*(*int32)(unsafe.Pointer(bp + 56 /* objlen */)) - (int32((int64(*(*uintptr)(unsafe.Pointer(bp + 72 /* zTail */))) - int64(zSql)) / 1))) 48881 } else { 48882 *(*int32)(unsafe.Pointer(bp + 56 /* objlen */)) = 0 48883 } 48884 pTail = tcl.XTcl_NewByteArrayObj(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* zTail */)), *(*int32)(unsafe.Pointer(bp + 56 /* objlen */))) 48885 (*Tcl_Obj)(unsafe.Pointer(pTail)).FrefCount++ 48886 tcl.XTcl_ObjSetVar2(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), uintptr(0), pTail, 0) 48887 for ok := true; ok; ok = 0 != 0 { 48888 var _objPtr uintptr = pTail 48889 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 48890 tcl.XTclFreeObj(tls, _objPtr) 48891 } 48892 } 48893 } 48894 48895 if *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */)) != 0 { 48896 if sqlite3TestMakePointerStr(tls, interp, bp+80 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */))) != 0 { 48897 return TCL_ERROR 48898 } 48899 } 48900 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, bp+80 /* &zBuf[0] */, 0)) 48901 return TCL_OK 48902 } 48903 48904 // Usage: sqlite3_prepare16_v2 DB sql bytes ?tailvar? 48905 // 48906 // Compile up to <bytes> bytes of the supplied SQL string <sql> using 48907 // database handle <DB>. The parameter <tailval> is the name of a global 48908 // variable that is set to the unused portion of <sql> (if any). A 48909 // STMT handle is returned. 48910 func test_prepare16_v2(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4695:26: */ 48911 bp := tls.Alloc(130) 48912 defer tls.Free(130) 48913 48914 // var db uintptr at bp+48, 8 48915 48916 var zSql uintptr 48917 *(*uintptr)(unsafe.Pointer(bp + 72 /* zTail */)) = uintptr(0) 48918 var pTail uintptr = uintptr(0) 48919 *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */)) = uintptr(0) 48920 // var zBuf [50]int8 at bp+80, 50 48921 48922 var rc int32 48923 // var bytes int32 at bp+60, 4 48924 // The integer specified as arg 3 48925 // var objlen int32 at bp+56, 4 48926 // The byte-array length of arg 2 48927 48928 if (objc != 5) && (objc != 4) { 48929 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 48930 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16651 /* " DB sql bytes ?t..." */, 0)) 48931 return TCL_ERROR 48932 } 48933 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &db */) != 0 { 48934 return TCL_ERROR 48935 } 48936 zSql = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+56 /* &objlen */) 48937 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+60 /* &bytes */) != 0 { 48938 return TCL_ERROR 48939 } 48940 48941 rc = sqlite3.Xsqlite3_prepare16_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), zSql, *(*int32)(unsafe.Pointer(bp + 60 /* bytes */)), bp+64 /* &pStmt */, func() uintptr { 48942 if objc >= 5 { 48943 return bp + 72 /* &zTail */ 48944 } 48945 return uintptr(0) 48946 }()) 48947 if sqlite3TestErrCode(tls, interp, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), rc) != 0 { 48948 return TCL_ERROR 48949 } 48950 if rc != 0 { 48951 return TCL_ERROR 48952 } 48953 48954 if objc >= 5 { 48955 if *(*uintptr)(unsafe.Pointer(bp + 72 /* zTail */)) != 0 { 48956 *(*int32)(unsafe.Pointer(bp + 56 /* objlen */)) = (*(*int32)(unsafe.Pointer(bp + 56 /* objlen */)) - (int32((int64(*(*uintptr)(unsafe.Pointer(bp + 72 /* zTail */))) - int64(zSql)) / 1))) 48957 } else { 48958 *(*int32)(unsafe.Pointer(bp + 56 /* objlen */)) = 0 48959 } 48960 pTail = tcl.XTcl_NewByteArrayObj(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* zTail */)), *(*int32)(unsafe.Pointer(bp + 56 /* objlen */))) 48961 (*Tcl_Obj)(unsafe.Pointer(pTail)).FrefCount++ 48962 tcl.XTcl_ObjSetVar2(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), uintptr(0), pTail, 0) 48963 for ok := true; ok; ok = 0 != 0 { 48964 var _objPtr uintptr = pTail 48965 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 48966 tcl.XTclFreeObj(tls, _objPtr) 48967 } 48968 } 48969 } 48970 48971 if *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */)) != 0 { 48972 if sqlite3TestMakePointerStr(tls, interp, bp+80 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 64 /* pStmt */))) != 0 { 48973 return TCL_ERROR 48974 } 48975 } 48976 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, bp+80 /* &zBuf[0] */, 0)) 48977 return TCL_OK 48978 } 48979 48980 // Usage: sqlite3_open filename ?options-list? 48981 func test_open(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4750:26: */ 48982 bp := tls.Alloc(156) 48983 defer tls.Free(156) 48984 48985 var zFilename uintptr 48986 // var db uintptr at bp+48, 8 48987 48988 // var zBuf [100]int8 at bp+56, 100 48989 48990 if ((objc != 3) && (objc != 2)) && (objc != 1) { 48991 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 48992 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16735 /* " filename option..." */, 0)) 48993 return TCL_ERROR 48994 } 48995 48996 if objc > 1 { 48997 zFilename = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 48998 } else { 48999 zFilename = uintptr(0) 49000 } 49001 sqlite3.Xsqlite3_open(tls, zFilename, bp+48 /* &db */) 49002 49003 if sqlite3TestMakePointerStr(tls, interp, bp+56 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */))) != 0 { 49004 return TCL_ERROR 49005 } 49006 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, bp+56 /* &zBuf[0] */, 0)) 49007 return TCL_OK 49008 } 49009 49010 // Usage: sqlite3_open_v2 FILENAME FLAGS VFS 49011 func test_open_v2(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4777:26: */ 49012 bp := tls.Alloc(468) 49013 defer tls.Free(468) 49014 49015 var zFilename uintptr 49016 var zVfs uintptr 49017 var flags int32 = 0 49018 // var db uintptr at bp+360, 8 49019 49020 var rc int32 49021 // var zBuf [100]int8 at bp+368, 100 49022 49023 // var nFlag int32 at bp+16, 4 49024 49025 // var apFlag uintptr at bp+24, 8 49026 49027 var i int32 49028 49029 if objc != 4 { 49030 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16758 /* "FILENAME FLAGS V..." */) 49031 return TCL_ERROR 49032 } 49033 zFilename = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 49034 zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 49035 if int32(*(*int8)(unsafe.Pointer(zVfs))) == 0x00 { 49036 zVfs = uintptr(0) 49037 } 49038 49039 rc = tcl.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+16 /* &nFlag */, bp+24 /* &apFlag */) 49040 if rc != TCL_OK { 49041 return rc 49042 } 49043 for i = 0; i < *(*int32)(unsafe.Pointer(bp + 16 /* nFlag */)); i++ { 49044 // var iFlag int32 at bp+352, 4 49045 49046 *(*[20]OpenFlag)(unsafe.Pointer(bp + 32 /* aFlag */)) = [20]OpenFlag{ 49047 {FzFlag: ts + 16777 /* "SQLITE_OPEN_READ..." */, Fflag: SQLITE_OPEN_READONLY}, 49048 {FzFlag: ts + 16798 /* "SQLITE_OPEN_READ..." */, Fflag: SQLITE_OPEN_READWRITE}, 49049 {FzFlag: ts + 16820 /* "SQLITE_OPEN_CREA..." */, Fflag: SQLITE_OPEN_CREATE}, 49050 {FzFlag: ts + 16839 /* "SQLITE_OPEN_DELE..." */, Fflag: SQLITE_OPEN_DELETEONCLOSE}, 49051 {FzFlag: ts + 16865 /* "SQLITE_OPEN_EXCL..." */, Fflag: SQLITE_OPEN_EXCLUSIVE}, 49052 {FzFlag: ts + 16887 /* "SQLITE_OPEN_AUTO..." */, Fflag: SQLITE_OPEN_AUTOPROXY}, 49053 {FzFlag: ts + 16909 /* "SQLITE_OPEN_MAIN..." */, Fflag: SQLITE_OPEN_MAIN_DB}, 49054 {FzFlag: ts + 16929 /* "SQLITE_OPEN_TEMP..." */, Fflag: SQLITE_OPEN_TEMP_DB}, 49055 {FzFlag: ts + 16949 /* "SQLITE_OPEN_TRAN..." */, Fflag: SQLITE_OPEN_TRANSIENT_DB}, 49056 {FzFlag: ts + 16974 /* "SQLITE_OPEN_MAIN..." */, Fflag: SQLITE_OPEN_MAIN_JOURNAL}, 49057 {FzFlag: ts + 16999 /* "SQLITE_OPEN_TEMP..." */, Fflag: SQLITE_OPEN_TEMP_JOURNAL}, 49058 {FzFlag: ts + 17024 /* "SQLITE_OPEN_SUBJ..." */, Fflag: SQLITE_OPEN_SUBJOURNAL}, 49059 {FzFlag: ts + 17047 /* "SQLITE_OPEN_SUPE..." */, Fflag: SQLITE_OPEN_SUPER_JOURNAL}, 49060 {FzFlag: ts + 17073 /* "SQLITE_OPEN_NOMU..." */, Fflag: SQLITE_OPEN_NOMUTEX}, 49061 {FzFlag: ts + 17093 /* "SQLITE_OPEN_FULL..." */, Fflag: SQLITE_OPEN_FULLMUTEX}, 49062 {FzFlag: ts + 17115 /* "SQLITE_OPEN_SHAR..." */, Fflag: SQLITE_OPEN_SHAREDCACHE}, 49063 {FzFlag: ts + 17139 /* "SQLITE_OPEN_PRIV..." */, Fflag: SQLITE_OPEN_PRIVATECACHE}, 49064 {FzFlag: ts + 17164 /* "SQLITE_OPEN_WAL" */, Fflag: SQLITE_OPEN_WAL}, 49065 {FzFlag: ts + 17180 /* "SQLITE_OPEN_URI" */, Fflag: SQLITE_OPEN_URI}, 49066 {}, 49067 } 49068 rc = tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* apFlag */)) + uintptr(i)*8)), bp+32 /* &aFlag[0] */, int32(unsafe.Sizeof(OpenFlag{})), 49069 ts+17196 /* "flag" */, 0, bp+352 /* &iFlag */) 49070 if rc != TCL_OK { 49071 return rc 49072 } 49073 flags = flags | ((*OpenFlag)(unsafe.Pointer(bp + 32 /* &aFlag */ + uintptr(*(*int32)(unsafe.Pointer(bp + 352 /* iFlag */)))*16)).Fflag) 49074 } 49075 49076 rc = sqlite3.Xsqlite3_open_v2(tls, zFilename, bp+360 /* &db */, flags, zVfs) 49077 if sqlite3TestMakePointerStr(tls, interp, bp+368 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 360 /* db */))) != 0 { 49078 return TCL_ERROR 49079 } 49080 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, bp+368 /* &zBuf[0] */, 0)) 49081 return TCL_OK 49082 } 49083 49084 type OpenFlag = struct { 49085 FzFlag uintptr 49086 Fflag int32 49087 _ [4]byte 49088 } /* test1.c:4806:5 */ 49089 49090 // Usage: sqlite3_open16 filename options 49091 func test_open16(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4847:26: */ 49092 bp := tls.Alloc(156) 49093 defer tls.Free(156) 49094 49095 var zFilename uintptr 49096 // var db uintptr at bp+48, 8 49097 49098 // var zBuf [100]int8 at bp+56, 100 49099 49100 if objc != 3 { 49101 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 49102 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16735 /* " filename option..." */, 0)) 49103 return TCL_ERROR 49104 } 49105 49106 zFilename = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(0)) 49107 sqlite3.Xsqlite3_open16(tls, zFilename, bp+48 /* &db */) 49108 49109 if sqlite3TestMakePointerStr(tls, interp, bp+56 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */))) != 0 { 49110 return TCL_ERROR 49111 } 49112 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, bp+56 /* &zBuf[0] */, 0)) 49113 return TCL_OK 49114 } 49115 49116 // Usage: sqlite3_complete16 <UTF-16 string> 49117 // 49118 // Return 1 if the supplied argument is a complete SQL statement, or zero 49119 // otherwise. 49120 func test_complete16(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4879:26: */ 49121 var zBuf uintptr 49122 49123 if objc != 2 { 49124 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17201 /* "<utf-16 sql>" */) 49125 return TCL_ERROR 49126 } 49127 49128 zBuf = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(0)) 49129 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_complete16(tls, zBuf))) 49130 return TCL_OK 49131 } 49132 49133 // Usage: sqlite3_normalize SQL 49134 // 49135 // Return the normalized value for an SQL statement. 49136 func test_normalize(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4904:26: */ 49137 var zSql uintptr 49138 var zNorm uintptr 49139 49140 if objc != 2 { 49141 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+10172 /* "SQL" */) 49142 return TCL_ERROR 49143 } 49144 49145 zSql = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 49146 zNorm = sqlite3_normalize(tls, zSql) 49147 if zNorm != 0 { 49148 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, zNorm, -1)) 49149 sqlite3.Xsqlite3_free(tls, zNorm) 49150 } 49151 return TCL_OK 49152 } 49153 49154 // Usage: sqlite3_step STMT 49155 // 49156 // Advance the statement to the next row. 49157 func test_step(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4933:26: */ 49158 bp := tls.Alloc(40) 49159 defer tls.Free(40) 49160 49161 // var pStmt uintptr at bp+32, 8 49162 49163 var rc int32 49164 49165 if objc != 2 { 49166 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 49167 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+15998 /* " STMT" */, 0)) 49168 return TCL_ERROR 49169 } 49170 49171 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 49172 return TCL_ERROR 49173 } 49174 rc = sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))) 49175 49176 // if( rc!=SQLITE_DONE && rc!=SQLITE_ROW ) return TCL_ERROR; 49177 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 49178 return TCL_OK 49179 } 49180 49181 func test_sql(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4956:26: */ 49182 bp := tls.Alloc(8) 49183 defer tls.Free(8) 49184 49185 // var pStmt uintptr at bp, 8 49186 49187 if objc != 2 { 49188 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16629 /* "STMT" */) 49189 return TCL_ERROR 49190 } 49191 49192 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &pStmt */) != 0 { 49193 return TCL_ERROR 49194 } 49195 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3_sql(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))), uintptr(1)) 49196 return TCL_OK 49197 } 49198 49199 func test_ex_sql(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:4973:26: */ 49200 bp := tls.Alloc(8) 49201 defer tls.Free(8) 49202 49203 // var pStmt uintptr at bp, 8 49204 49205 var z uintptr 49206 49207 if objc != 2 { 49208 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16629 /* "STMT" */) 49209 return TCL_ERROR 49210 } 49211 49212 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &pStmt */) != 0 { 49213 return TCL_ERROR 49214 } 49215 z = sqlite3.Xsqlite3_expanded_sql(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) 49216 tcl.XTcl_SetResult(tls, interp, z, uintptr(1)) 49217 sqlite3.Xsqlite3_free(tls, z) 49218 return TCL_OK 49219 } 49220 49221 // Usage: sqlite3_column_count STMT 49222 // 49223 // Return the number of columns returned by the sql statement STMT. 49224 func test_column_count(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5018:26: */ 49225 bp := tls.Alloc(40) 49226 defer tls.Free(40) 49227 49228 // var pStmt uintptr at bp+32, 8 49229 49230 if objc != 2 { 49231 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 49232 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+17214 /* " STMT column" */, 0)) 49233 return TCL_ERROR 49234 } 49235 49236 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 49237 return TCL_ERROR 49238 } 49239 49240 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))))) 49241 return TCL_OK 49242 } 49243 49244 // Usage: sqlite3_column_type STMT column 49245 // 49246 // Return the type of the data in column 'column' of the current row. 49247 func test_column_type(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5043:26: */ 49248 bp := tls.Alloc(44) 49249 defer tls.Free(44) 49250 49251 // var pStmt uintptr at bp+32, 8 49252 49253 // var col int32 at bp+40, 4 49254 49255 var tp int32 49256 49257 if objc != 3 { 49258 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 49259 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+17214 /* " STMT column" */, 0)) 49260 return TCL_ERROR 49261 } 49262 49263 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 49264 return TCL_ERROR 49265 } 49266 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &col */) != 0 { 49267 return TCL_ERROR 49268 } 49269 49270 tp = sqlite3.Xsqlite3_column_type(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* col */))) 49271 switch tp { 49272 case SQLITE_INTEGER: 49273 tcl.XTcl_SetResult(tls, interp, ts+2274 /* "INTEGER" */, uintptr(0)) 49274 break 49275 case SQLITE_NULL: 49276 tcl.XTcl_SetResult(tls, interp, ts+5717 /* "NULL" */, uintptr(0)) 49277 break 49278 case SQLITE_FLOAT: 49279 tcl.XTcl_SetResult(tls, interp, ts+17227 /* "FLOAT" */, uintptr(0)) 49280 break 49281 case SQLITE_TEXT: 49282 tcl.XTcl_SetResult(tls, interp, ts+17233 /* "TEXT" */, uintptr(0)) 49283 break 49284 case SQLITE_BLOB: 49285 tcl.XTcl_SetResult(tls, interp, ts+17238 /* "BLOB" */, uintptr(0)) 49286 break 49287 default: 49288 49289 } 49290 49291 return TCL_OK 49292 } 49293 49294 // Usage: sqlite3_column_int64 STMT column 49295 // 49296 // Return the data in column 'column' of the current row cast as an 49297 // wide (64-bit) integer. 49298 func test_column_int64(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5092:26: */ 49299 bp := tls.Alloc(44) 49300 defer tls.Free(44) 49301 49302 // var pStmt uintptr at bp+32, 8 49303 49304 // var col int32 at bp+40, 4 49305 49306 var iVal i64 49307 49308 if objc != 3 { 49309 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 49310 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+17214 /* " STMT column" */, 0)) 49311 return TCL_ERROR 49312 } 49313 49314 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 49315 return TCL_ERROR 49316 } 49317 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &col */) != 0 { 49318 return TCL_ERROR 49319 } 49320 49321 iVal = sqlite3.Xsqlite3_column_int64(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* col */))) 49322 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, iVal)) 49323 return TCL_OK 49324 } 49325 49326 // Usage: sqlite3_column_blob STMT column 49327 func test_column_blob(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5119:26: */ 49328 bp := tls.Alloc(44) 49329 defer tls.Free(44) 49330 49331 // var pStmt uintptr at bp+32, 8 49332 49333 // var col int32 at bp+40, 4 49334 49335 var len int32 49336 var pBlob uintptr 49337 49338 if objc != 3 { 49339 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 49340 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+17214 /* " STMT column" */, 0)) 49341 return TCL_ERROR 49342 } 49343 49344 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 49345 return TCL_ERROR 49346 } 49347 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &col */) != 0 { 49348 return TCL_ERROR 49349 } 49350 49351 len = sqlite3.Xsqlite3_column_bytes(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* col */))) 49352 pBlob = sqlite3.Xsqlite3_column_blob(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* col */))) 49353 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewByteArrayObj(tls, pBlob, len)) 49354 return TCL_OK 49355 } 49356 49357 // Usage: sqlite3_column_double STMT column 49358 // 49359 // Return the data in column 'column' of the current row cast as a double. 49360 func test_column_double(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5151:26: */ 49361 bp := tls.Alloc(44) 49362 defer tls.Free(44) 49363 49364 // var pStmt uintptr at bp+32, 8 49365 49366 // var col int32 at bp+40, 4 49367 49368 var rVal float64 49369 49370 if objc != 3 { 49371 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 49372 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+17214 /* " STMT column" */, 0)) 49373 return TCL_ERROR 49374 } 49375 49376 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 49377 return TCL_ERROR 49378 } 49379 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &col */) != 0 { 49380 return TCL_ERROR 49381 } 49382 49383 rVal = sqlite3.Xsqlite3_column_double(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* col */))) 49384 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewDoubleObj(tls, rVal)) 49385 return TCL_OK 49386 } 49387 49388 // Usage: sqlite3_data_count STMT 49389 // 49390 // Return the number of columns returned by the sql statement STMT. 49391 func test_data_count(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5180:26: */ 49392 bp := tls.Alloc(40) 49393 defer tls.Free(40) 49394 49395 // var pStmt uintptr at bp+32, 8 49396 49397 if objc != 2 { 49398 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 49399 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+17214 /* " STMT column" */, 0)) 49400 return TCL_ERROR 49401 } 49402 49403 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 49404 return TCL_ERROR 49405 } 49406 49407 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_data_count(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */))))) 49408 return TCL_OK 49409 } 49410 49411 // Usage: sqlite3_column_text STMT column 49412 // 49413 // Usage: sqlite3_column_decltype STMT column 49414 // 49415 // Usage: sqlite3_column_name STMT column 49416 func test_stmt_utf8(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5207:26: */ 49417 bp := tls.Alloc(44) 49418 defer tls.Free(44) 49419 49420 // var pStmt uintptr at bp+32, 8 49421 49422 // var col int32 at bp+40, 4 49423 49424 var xFunc uintptr 49425 var zRet uintptr 49426 49427 xFunc = clientData 49428 if objc != 3 { 49429 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 49430 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+17214 /* " STMT column" */, 0)) 49431 return TCL_ERROR 49432 } 49433 49434 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 49435 return TCL_ERROR 49436 } 49437 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &col */) != 0 { 49438 return TCL_ERROR 49439 } 49440 zRet = (*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(&xFunc)))(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* col */))) 49441 if zRet != 0 { 49442 tcl.XTcl_SetResult(tls, interp, zRet, uintptr(0)) 49443 } 49444 return TCL_OK 49445 } 49446 49447 func test_global_recover(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5234:26: */ 49448 var rc int32 49449 if objc != 1 { 49450 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 49451 return TCL_ERROR 49452 } 49453 rc = sqlite3.Xsqlite3_global_recover(tls) 49454 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 49455 return TCL_OK 49456 } 49457 49458 // Usage: sqlite3_column_text STMT column 49459 // 49460 // Usage: sqlite3_column_decltype STMT column 49461 // 49462 // Usage: sqlite3_column_name STMT column 49463 func test_stmt_utf16(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5259:26: */ 49464 bp := tls.Alloc(44) 49465 defer tls.Free(44) 49466 49467 // var pStmt uintptr at bp+32, 8 49468 49469 // var col int32 at bp+40, 4 49470 49471 var pRet uintptr 49472 var zName16 uintptr 49473 var xFunc uintptr 49474 49475 xFunc = clientData 49476 if objc != 3 { 49477 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 49478 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+17214 /* " STMT column" */, 0)) 49479 return TCL_ERROR 49480 } 49481 49482 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 49483 return TCL_ERROR 49484 } 49485 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &col */) != 0 { 49486 return TCL_ERROR 49487 } 49488 49489 zName16 = (*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer(&xFunc)))(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* col */))) 49490 if zName16 != 0 { 49491 var n int32 49492 var z uintptr = zName16 49493 for n = 0; (*(*int8)(unsafe.Pointer(z + uintptr(n))) != 0) || (*(*int8)(unsafe.Pointer(z + uintptr((n + 1)))) != 0); n = n + (2) { 49494 } 49495 pRet = tcl.XTcl_NewByteArrayObj(tls, zName16, (n + 2)) 49496 tcl.XTcl_SetObjResult(tls, interp, pRet) 49497 } 49498 49499 return TCL_OK 49500 } 49501 49502 // Usage: sqlite3_column_int STMT column 49503 // 49504 // Usage: sqlite3_column_bytes STMT column 49505 // 49506 // Usage: sqlite3_column_bytes16 STMT column 49507 // 49508 func test_stmt_int(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5303:26: */ 49509 bp := tls.Alloc(44) 49510 defer tls.Free(44) 49511 49512 // var pStmt uintptr at bp+32, 8 49513 49514 // var col int32 at bp+40, 4 49515 49516 var xFunc uintptr 49517 49518 xFunc = clientData 49519 if objc != 3 { 49520 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 49521 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+17214 /* " STMT column" */, 0)) 49522 return TCL_ERROR 49523 } 49524 49525 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &pStmt */) != 0 { 49526 return TCL_ERROR 49527 } 49528 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &col */) != 0 { 49529 return TCL_ERROR 49530 } 49531 49532 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&xFunc)))(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)), *(*int32)(unsafe.Pointer(bp + 40 /* col */))))) 49533 return TCL_OK 49534 } 49535 49536 // Usage: sqlite_set_magic DB MAGIC-NUMBER 49537 // 49538 // Set the db->magic value. This is used to test error recovery logic. 49539 func sqlite_set_magic(tls *libc.TLS, clientData uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:5332:26: */ 49540 bp := tls.Alloc(40) 49541 defer tls.Free(40) 49542 49543 // var db uintptr at bp+32, 8 49544 49545 if argc != 3 { 49546 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 49547 ts+17243 /* " DB MAGIC" */, 0)) 49548 return TCL_ERROR 49549 } 49550 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { 49551 return TCL_ERROR 49552 } 49553 if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)), ts+17253 /* "SQLITE_MAGIC_OPE..." */) == 0 { 49554 (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmagic = SQLITE_MAGIC_OPEN 49555 } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)), ts+17271 /* "SQLITE_MAGIC_CLO..." */) == 0 { 49556 (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmagic = SQLITE_MAGIC_CLOSED 49557 } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)), ts+17291 /* "SQLITE_MAGIC_BUS..." */) == 0 { 49558 (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmagic = SQLITE_MAGIC_BUSY 49559 } else if libc.Xstrcmp(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)), ts+17309 /* "SQLITE_MAGIC_ERR..." */) == 0 { 49560 (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmagic = SQLITE_MAGIC_ERROR 49561 } else if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), (*(*uintptr)(unsafe.Pointer(bp + 32 /* db */))+116 /* &.magic */)) != 0 { 49562 return TCL_ERROR 49563 } 49564 return TCL_OK 49565 } 49566 49567 // Usage: sqlite3_interrupt DB 49568 // 49569 // Trigger an interrupt on DB 49570 func test_interrupt(tls *libc.TLS, clientData uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:5364:26: */ 49571 bp := tls.Alloc(40) 49572 defer tls.Free(40) 49573 49574 // var db uintptr at bp+32, 8 49575 49576 if argc != 2 { 49577 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+14683 /* " DB" */, 0)) 49578 return TCL_ERROR 49579 } 49580 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { 49581 return TCL_ERROR 49582 } 49583 sqlite3.Xsqlite3_interrupt(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */))) 49584 return TCL_OK 49585 } 49586 49587 // Usage: sqlite_delete_function DB function-name 49588 // 49589 // Delete the user function 'function-name' from database handle DB. It 49590 // is assumed that the user function was created as UTF8, any number of 49591 // arguments (the way the TCL interface does it). 49592 func delete_function(tls *libc.TLS, clientData uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:5387:26: */ 49593 bp := tls.Alloc(40) 49594 defer tls.Free(40) 49595 49596 var rc int32 49597 // var db uintptr at bp+32, 8 49598 49599 if argc != 3 { 49600 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 49601 ts+17328 /* " DB function-nam..." */, 0)) 49602 return TCL_ERROR 49603 } 49604 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { 49605 return TCL_ERROR 49606 } 49607 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), *(*uintptr)(unsafe.Pointer(argv + 2*8)), -1, SQLITE_UTF8, uintptr(0), uintptr(0), uintptr(0), uintptr(0)) 49608 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 49609 return TCL_OK 49610 } 49611 49612 // Usage: sqlite_delete_collation DB collation-name 49613 // 49614 // Delete the collation sequence 'collation-name' from database handle 49615 // DB. It is assumed that the collation sequence was created as UTF8 (the 49616 // way the TCL interface does it). 49617 func delete_collation(tls *libc.TLS, clientData uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:5413:26: */ 49618 bp := tls.Alloc(40) 49619 defer tls.Free(40) 49620 49621 var rc int32 49622 // var db uintptr at bp+32, 8 49623 49624 if argc != 3 { 49625 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 49626 ts+17328 /* " DB function-nam..." */, 0)) 49627 return TCL_ERROR 49628 } 49629 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+32 /* &db */) != 0 { 49630 return TCL_ERROR 49631 } 49632 rc = sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), *(*uintptr)(unsafe.Pointer(argv + 2*8)), SQLITE_UTF8, uintptr(0), uintptr(0)) 49633 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 49634 return TCL_OK 49635 } 49636 49637 // Usage: sqlite3_get_autocommit DB 49638 // 49639 // Return true if the database DB is currently in auto-commit mode. 49640 // Return false if not. 49641 func get_autocommit(tls *libc.TLS, clientData uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:5438:26: */ 49642 bp := tls.Alloc(94) 49643 defer tls.Free(94) 49644 49645 // var zBuf [30]int8 at bp+64, 30 49646 49647 // var db uintptr at bp+56, 8 49648 49649 if argc != 2 { 49650 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 49651 ts+14683 /* " DB" */, 0)) 49652 return TCL_ERROR 49653 } 49654 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+56 /* &db */) != 0 { 49655 return TCL_ERROR 49656 } 49657 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+64 /* &zBuf[0] */, ts+1238 /* "%d" */, libc.VaList(bp+32, sqlite3.Xsqlite3_get_autocommit(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* db */))))) 49658 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+64 /* &zBuf[0] */, 0)) 49659 return TCL_OK 49660 } 49661 49662 // Usage: sqlite3_busy_timeout DB MS 49663 // 49664 // Set the busy timeout. This is more easily done using the timeout 49665 // method of the TCL interface. But we need a way to test the case 49666 // where it returns SQLITE_MISUSE. 49667 func test_busy_timeout(tls *libc.TLS, clientData uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test1.c:5464:26: */ 49668 bp := tls.Alloc(60) 49669 defer tls.Free(60) 49670 49671 var rc int32 49672 // var ms int32 at bp+56, 4 49673 49674 // var db uintptr at bp+48, 8 49675 49676 if argc != 3 { 49677 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 49678 ts+14683 /* " DB" */, 0)) 49679 return TCL_ERROR 49680 } 49681 if getDbPointer(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+48 /* &db */) != 0 { 49682 return TCL_ERROR 49683 } 49684 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+56 /* &ms */) != 0 { 49685 return TCL_ERROR 49686 } 49687 rc = sqlite3.Xsqlite3_busy_timeout(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), *(*int32)(unsafe.Pointer(bp + 56 /* ms */))) 49688 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 49689 return TCL_OK 49690 } 49691 49692 // Usage: tcl_variable_type VARIABLENAME 49693 // 49694 // Return the name of the internal representation for the 49695 // value of the given variable. 49696 func tcl_variable_type(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5490:26: */ 49697 var pVar uintptr 49698 if objc != 2 { 49699 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17346 /* "VARIABLE" */) 49700 return TCL_ERROR 49701 } 49702 pVar = tcl.XTcl_GetVar2Ex(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), uintptr(0), TCL_LEAVE_ERR_MSG) 49703 if pVar == uintptr(0) { 49704 return TCL_ERROR 49705 } 49706 if (*Tcl_Obj)(unsafe.Pointer(pVar)).FtypePtr != 0 { 49707 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, (*Tcl_ObjType)(unsafe.Pointer((*Tcl_Obj)(unsafe.Pointer(pVar)).FtypePtr)).Fname, -1)) 49708 } 49709 return TCL_OK 49710 } 49711 49712 // Usage: sqlite3_release_memory ?N? 49713 // 49714 // Attempt to release memory currently held but not actually required. 49715 // The integer N is the number of bytes we are trying to release. The 49716 // return value is the amount of memory actually released. 49717 func test_release_memory(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5516:26: */ 49718 bp := tls.Alloc(4) 49719 defer tls.Free(4) 49720 49721 // var N int32 at bp, 4 49722 49723 var amt int32 49724 if (objc != 1) && (objc != 2) { 49725 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17355 /* "?N?" */) 49726 return TCL_ERROR 49727 } 49728 if objc == 2 { 49729 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &N */) != 0 { 49730 return TCL_ERROR 49731 } 49732 } else { 49733 *(*int32)(unsafe.Pointer(bp /* N */)) = -1 49734 } 49735 amt = sqlite3.Xsqlite3_release_memory(tls, *(*int32)(unsafe.Pointer(bp /* N */))) 49736 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, amt)) 49737 return TCL_OK 49738 } 49739 49740 // Usage: sqlite3_db_release_memory DB 49741 // 49742 // Attempt to release memory currently held by database DB. Return the 49743 // result code (which in the current implementation is always zero). 49744 func test_db_release_memory(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5547:26: */ 49745 bp := tls.Alloc(8) 49746 defer tls.Free(8) 49747 49748 // var db uintptr at bp, 8 49749 49750 var rc int32 49751 if objc != 2 { 49752 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 49753 return TCL_ERROR 49754 } 49755 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 49756 return TCL_ERROR 49757 } 49758 rc = sqlite3.Xsqlite3_db_release_memory(tls, *(*uintptr)(unsafe.Pointer(bp /* db */))) 49759 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) 49760 return TCL_OK 49761 } 49762 49763 // Usage: sqlite3_db_cacheflush DB 49764 // 49765 // Attempt to flush any dirty pages to disk. 49766 func test_db_cacheflush(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5570:26: */ 49767 bp := tls.Alloc(8) 49768 defer tls.Free(8) 49769 49770 // var db uintptr at bp, 8 49771 49772 var rc int32 49773 if objc != 2 { 49774 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 49775 return TCL_ERROR 49776 } 49777 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 49778 return TCL_ERROR 49779 } 49780 rc = sqlite3.Xsqlite3_db_cacheflush(tls, *(*uintptr)(unsafe.Pointer(bp /* db */))) 49781 if rc != 0 { 49782 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrStr(tls, rc), uintptr(0)) 49783 return TCL_ERROR 49784 } 49785 49786 tcl.XTcl_ResetResult(tls, interp) 49787 return TCL_OK 49788 } 49789 49790 // Usage: sqlite3_system_errno DB 49791 // 49792 // Return the low-level system errno value. 49793 func test_system_errno(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5598:26: */ 49794 bp := tls.Alloc(8) 49795 defer tls.Free(8) 49796 49797 // var db uintptr at bp, 8 49798 49799 var iErrno int32 49800 if objc != 2 { 49801 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 49802 return TCL_ERROR 49803 } 49804 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 49805 return TCL_ERROR 49806 } 49807 iErrno = sqlite3.Xsqlite3_system_errno(tls, *(*uintptr)(unsafe.Pointer(bp /* db */))) 49808 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, iErrno)) 49809 return TCL_OK 49810 } 49811 49812 // Usage: sqlite3_db_filename DB DBNAME 49813 // 49814 // Return the name of a file associated with a database. 49815 func test_db_filename(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5621:26: */ 49816 bp := tls.Alloc(24) 49817 defer tls.Free(24) 49818 49819 // var db uintptr at bp+16, 8 49820 49821 var zDbName uintptr 49822 if objc != 3 { 49823 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15908 /* "DB DBNAME" */) 49824 return TCL_ERROR 49825 } 49826 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+16 /* &db */) != 0 { 49827 return TCL_ERROR 49828 } 49829 zDbName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 49830 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3_db_filename(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), zDbName), uintptr(0))) 49831 return TCL_OK 49832 } 49833 49834 // Usage: sqlite3_db_readonly DB DBNAME 49835 // 49836 // Return 1 or 0 if DBNAME is readonly or not. Return -1 if DBNAME does 49837 // not exist. 49838 func test_db_readonly(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5645:26: */ 49839 bp := tls.Alloc(8) 49840 defer tls.Free(8) 49841 49842 // var db uintptr at bp, 8 49843 49844 var zDbName uintptr 49845 if objc != 3 { 49846 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15908 /* "DB DBNAME" */) 49847 return TCL_ERROR 49848 } 49849 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 49850 return TCL_ERROR 49851 } 49852 zDbName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 49853 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_db_readonly(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zDbName))) 49854 return TCL_OK 49855 } 49856 49857 // Usage: sqlite3_soft_heap_limit ?N? 49858 // 49859 // Query or set the soft heap limit for the current thread. The 49860 // limit is only changed if the N is present. The previous limit 49861 // is returned. 49862 func test_soft_heap_limit(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5670:26: */ 49863 bp := tls.Alloc(8) 49864 defer tls.Free(8) 49865 49866 var amt sqlite3_int64 49867 *(*Tcl_WideInt)(unsafe.Pointer(bp /* N */)) = int64(-1) 49868 if (objc != 1) && (objc != 2) { 49869 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17355 /* "?N?" */) 49870 return TCL_ERROR 49871 } 49872 if objc == 2 { 49873 if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &N */) != 0 { 49874 return TCL_ERROR 49875 } 49876 } 49877 amt = sqlite3.Xsqlite3_soft_heap_limit64(tls, *(*Tcl_WideInt)(unsafe.Pointer(bp /* N */))) 49878 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, amt)) 49879 return TCL_OK 49880 } 49881 49882 // Usage: sqlite3_hard_heap_limit ?N? 49883 // 49884 // Query or set the hard heap limit for the current thread. The 49885 // limit is only changed if the N is present. The previous limit 49886 // is returned. 49887 func test_hard_heap_limit(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5697:26: */ 49888 bp := tls.Alloc(8) 49889 defer tls.Free(8) 49890 49891 var amt sqlite3_int64 49892 *(*Tcl_WideInt)(unsafe.Pointer(bp /* N */)) = int64(-1) 49893 if (objc != 1) && (objc != 2) { 49894 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17355 /* "?N?" */) 49895 return TCL_ERROR 49896 } 49897 if objc == 2 { 49898 if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &N */) != 0 { 49899 return TCL_ERROR 49900 } 49901 } 49902 amt = sqlite3.Xsqlite3_hard_heap_limit64(tls, *(*Tcl_WideInt)(unsafe.Pointer(bp /* N */))) 49903 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, amt)) 49904 return TCL_OK 49905 } 49906 49907 // Usage: sqlite3_thread_cleanup 49908 // 49909 // Call the sqlite3_thread_cleanup API. 49910 func test_thread_cleanup(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5722:26: */ 49911 sqlite3.Xsqlite3_thread_cleanup(tls) 49912 return TCL_OK 49913 } 49914 49915 // Usage: sqlite3_pager_refcounts DB 49916 // 49917 // Return a list of numbers which are the PagerRefcount for all 49918 // pagers on each database connection. 49919 func test_pager_refcounts(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5740:26: */ 49920 bp := tls.Alloc(40) 49921 defer tls.Free(40) 49922 49923 // var db uintptr at bp+32, 8 49924 49925 var i int32 49926 var v int32 49927 var a uintptr 49928 var pResult uintptr 49929 49930 if objc != 2 { 49931 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 49932 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+14683 /* " DB" */, 0)) 49933 return TCL_ERROR 49934 } 49935 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0 { 49936 return TCL_ERROR 49937 } 49938 pResult = tcl.XTcl_NewObj(tls) 49939 for i = 0; i < (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).FnDb; i++ { 49940 if (*Db)(unsafe.Pointer((*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).FaDb+uintptr(i)*32)).FpBt == uintptr(0) { 49941 v = -1 49942 } else { 49943 sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmutex) 49944 a = sqlite3.Xsqlite3PagerStats(tls, sqlite3.Xsqlite3BtreePager(tls, (*Db)(unsafe.Pointer((*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).FaDb+uintptr(i)*32)).FpBt)) 49945 v = *(*int32)(unsafe.Pointer(a)) 49946 sqlite3.Xsqlite3_mutex_leave(tls, (*sqlite31)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* db */)))).Fmutex) 49947 } 49948 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pResult, tcl.XTcl_NewIntObj(tls, v)) 49949 } 49950 tcl.XTcl_SetObjResult(tls, interp, pResult) 49951 return TCL_OK 49952 } 49953 49954 // tclcmd: working_64bit_int 49955 // 49956 // Some TCL builds (ex: cygwin) do not support 64-bit integers. This 49957 // leads to a number of test failures. The present command checks the 49958 // TCL build to see whether or not it supports 64-bit integers. It 49959 // returns TRUE if it does and FALSE if not. 49960 // 49961 // This command is used to warn users that their TCL build is defective 49962 // and that the errors they are seeing in the test scripts might be 49963 // a result of their defective TCL rather than problems in SQLite. 49964 func working_64bit_int(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5786:26: */ 49965 var pTestObj uintptr 49966 var working int32 = 0 49967 49968 pTestObj = tcl.XTcl_NewWideIntObj(tls, (int64(1000000) * int64(1234567890))) 49969 working = (libc.Bool32(libc.Xstrcmp(tls, tcl.XTcl_GetString(tls, pTestObj), ts+17359 /* "1234567890000000" */) == 0)) 49970 for ok := true; ok; ok = 0 != 0 { 49971 var _objPtr uintptr = pTestObj 49972 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 49973 tcl.XTclFreeObj(tls, _objPtr) 49974 } 49975 } 49976 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, (libc.Bool32((working) != 0)))) 49977 return TCL_OK 49978 } 49979 49980 // tclcmd: vfs_unlink_test 49981 // 49982 // This TCL command unregisters the primary VFS and then registers 49983 // it back again. This is used to test the ability to register a 49984 // VFS when none are previously registered, and the ability to 49985 // unregister the only available VFS. Ticket #2738 49986 func vfs_unlink_test(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5811:26: */ 49987 bp := tls.Alloc(496) 49988 defer tls.Free(496) 49989 49990 var i int32 49991 var pMain uintptr 49992 // var apVfs [20]uintptr at bp+336, 160 49993 49994 // var one sqlite3_vfs at bp, 168 49995 49996 // var two sqlite3_vfs at bp+168, 168 49997 49998 sqlite3.Xsqlite3_vfs_unregister(tls, uintptr(0)) // Unregister of NULL is harmless 49999 (*sqlite3_vfs)(unsafe.Pointer(bp /* &one */)).FzName = ts + 17376 /* "__one" */ 50000 (*sqlite3_vfs)(unsafe.Pointer(bp + 168 /* &two */)).FzName = ts + 17382 /* "__two" */ 50001 50002 // Calling sqlite3_vfs_register with 2nd argument of 0 does not 50003 // change the default VFS 50004 pMain = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 50005 sqlite3.Xsqlite3_vfs_register(tls, bp /* &one */, 0) 50006 50007 sqlite3.Xsqlite3_vfs_register(tls, bp+168 /* &two */, 0) 50008 50009 // We can find a VFS by its name 50010 50011 // Calling sqlite_vfs_register with non-zero second parameter changes the 50012 // default VFS, even if the 1st parameter is an existig VFS that is 50013 // previously registered as the non-default. 50014 sqlite3.Xsqlite3_vfs_register(tls, bp /* &one */, 1) 50015 50016 sqlite3.Xsqlite3_vfs_register(tls, bp+168 /* &two */, 1) 50017 50018 if pMain != 0 { 50019 sqlite3.Xsqlite3_vfs_register(tls, pMain, 1) 50020 50021 } 50022 50023 // Unlink the default VFS. Repeat until there are no more VFSes 50024 // registered. 50025 for i = 0; uint64(i) < (uint64(unsafe.Sizeof([20]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0)))); i++ { 50026 *(*uintptr)(unsafe.Pointer(bp + 336 /* &apVfs[0] */ + uintptr(i)*8)) = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 50027 if *(*uintptr)(unsafe.Pointer(bp + 336 /* &apVfs[0] */ + uintptr(i)*8)) != 0 { 50028 50029 sqlite3.Xsqlite3_vfs_unregister(tls, *(*uintptr)(unsafe.Pointer(bp + 336 /* &apVfs[0] */ + uintptr(i)*8))) 50030 50031 } 50032 } 50033 50034 // Register the main VFS as non-default (will be made default, since 50035 // it'll be the only one in existence). 50036 sqlite3.Xsqlite3_vfs_register(tls, pMain, 0) 50037 50038 // Un-register the main VFS again to restore an empty VFS list 50039 sqlite3.Xsqlite3_vfs_unregister(tls, pMain) 50040 50041 /* Relink all VFSes in reverse order. */ 50042 for i = (int32((uint64(unsafe.Sizeof([20]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0)))) - uint64(1))); i >= 0; i-- { 50043 if *(*uintptr)(unsafe.Pointer(bp + 336 /* &apVfs[0] */ + uintptr(i)*8)) != 0 { 50044 sqlite3.Xsqlite3_vfs_register(tls, *(*uintptr)(unsafe.Pointer(bp + 336 /* &apVfs[0] */ + uintptr(i)*8)), 1) 50045 50046 } 50047 } 50048 50049 // Unregister out sample VFSes. 50050 sqlite3.Xsqlite3_vfs_unregister(tls, bp /* &one */) 50051 sqlite3.Xsqlite3_vfs_unregister(tls, bp+168 /* &two */) 50052 50053 // Unregistering a VFS that is not currently registered is harmless 50054 sqlite3.Xsqlite3_vfs_unregister(tls, bp /* &one */) 50055 sqlite3.Xsqlite3_vfs_unregister(tls, bp+168 /* &two */) 50056 50057 // We should be left with the original default VFS back as the 50058 // original 50059 50060 return TCL_OK 50061 } 50062 50063 // tclcmd: vfs_initfail_test 50064 // 50065 // This TCL command attempts to vfs_find and vfs_register when the 50066 // sqlite3_initialize() interface is failing. All calls should fail. 50067 func vfs_initfail_test(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5913:26: */ 50068 bp := tls.Alloc(168) 50069 defer tls.Free(168) 50070 50071 // var one sqlite3_vfs at bp, 168 50072 50073 (*sqlite3_vfs)(unsafe.Pointer(bp /* &one */)).FzName = ts + 17376 /* "__one" */ 50074 50075 if sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) != 0 { 50076 return TCL_ERROR 50077 } 50078 sqlite3.Xsqlite3_vfs_register(tls, bp /* &one */, 0) 50079 if sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) != 0 { 50080 return TCL_ERROR 50081 } 50082 sqlite3.Xsqlite3_vfs_register(tls, bp /* &one */, 1) 50083 if sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) != 0 { 50084 return TCL_ERROR 50085 } 50086 return TCL_OK 50087 } 50088 50089 // Saved VFSes 50090 var apVfs [20]uintptr /* test1.c:5933:20: */ 50091 var nVfs int32 = 0 /* test1.c:5934:12 */ 50092 50093 // tclcmd: vfs_unregister_all 50094 // 50095 // Unregister all VFSes. 50096 func vfs_unregister_all(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5941:26: */ 50097 var i int32 50098 for i = 0; i < (int32(uint64(unsafe.Sizeof(apVfs)) / uint64(unsafe.Sizeof(uintptr(0))))); i++ { 50099 apVfs[i] = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 50100 if apVfs[i] == uintptr(0) { 50101 break 50102 } 50103 sqlite3.Xsqlite3_vfs_unregister(tls, apVfs[i]) 50104 } 50105 nVfs = i 50106 return TCL_OK 50107 } 50108 50109 // tclcmd: vfs_reregister_all 50110 // 50111 // Restore all VFSes that were removed using vfs_unregister_all. Taking 50112 // care to put the linked list back together in the same order as it was 50113 // in before vfs_unregister_all was invoked. 50114 func vfs_reregister_all(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5963:26: */ 50115 var i int32 50116 for i = (nVfs - 1); i >= 0; i-- { 50117 sqlite3.Xsqlite3_vfs_register(tls, apVfs[i], 1) 50118 } 50119 return TCL_OK 50120 } 50121 50122 // tclcmd: file_control_test DB 50123 // 50124 // This TCL command runs the sqlite3_file_control interface and 50125 // verifies correct operation of the same. 50126 func file_control_test(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:5983:26: */ 50127 bp := tls.Alloc(44) 50128 defer tls.Free(44) 50129 50130 *(*int32)(unsafe.Pointer(bp + 40 /* iArg */)) = 0 50131 // var db uintptr at bp+32, 8 50132 50133 var rc int32 50134 _ = rc 50135 50136 if objc != 2 { 50137 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 50138 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+14683 /* " DB" */, 0)) 50139 return TCL_ERROR 50140 } 50141 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0 { 50142 return TCL_ERROR 50143 } 50144 rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), uintptr(0), 0, bp+40 /* &iArg */) 50145 50146 rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+17388 /* "notadatabase" */, SQLITE_FCNTL_LOCKSTATE, bp+40 /* &iArg */) 50147 50148 rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+85 /* "main" */, -1, bp+40 /* &iArg */) 50149 50150 rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), ts+8379 /* "temp" */, -1, bp+40 /* &iArg */) 50151 50152 return TCL_OK 50153 } 50154 50155 // tclcmd: file_control_lasterrno_test DB 50156 // 50157 // This TCL command runs the sqlite3_file_control interface and 50158 // verifies correct operation of the SQLITE_LAST_ERRNO verb. 50159 func file_control_lasterrno_test(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6018:26: */ 50160 bp := tls.Alloc(76) 50161 defer tls.Free(76) 50162 50163 *(*int32)(unsafe.Pointer(bp + 72 /* iArg */)) = 0 50164 // var db uintptr at bp+64, 8 50165 50166 var rc int32 50167 50168 if objc != 2 { 50169 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 50170 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+14683 /* " DB" */, 0)) 50171 return TCL_ERROR 50172 } 50173 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+64 /* &db */) != 0 { 50174 return TCL_ERROR 50175 } 50176 rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* db */)), uintptr(0), SQLITE_FCNTL_LAST_ERRNO, bp+72 /* &iArg */) 50177 if rc != 0 { 50178 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) 50179 return TCL_ERROR 50180 } 50181 if *(*int32)(unsafe.Pointer(bp + 72 /* iArg */)) != 0 { 50182 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+17401, /* "Unexpected non-z..." */ 50183 tcl.XTcl_GetStringFromObj(tls, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 72 /* iArg */))), uintptr(0)), ts+4765 /* " " */, 0)) 50184 return TCL_ERROR 50185 } 50186 return TCL_OK 50187 } 50188 50189 // tclcmd: file_control_data_version DB DBNAME 50190 // 50191 // This TCL command runs the sqlite3_file_control with the 50192 // SQLITE_FCNTL_DATA_VERSION opcode, returning the result. 50193 func file_control_data_version(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6055:26: */ 50194 bp := tls.Alloc(120) 50195 defer tls.Free(120) 50196 50197 // var iVers uint32 at bp+16, 4 50198 // data version 50199 var zDb uintptr // Db name ("main", "temp" etc.) 50200 // var db uintptr at bp+8, 8 50201 // Database handle 50202 var rc int32 // file_control() return code 50203 // var zBuf [100]int8 at bp+20, 100 50204 50205 if (objc != 3) && (objc != 2) { 50206 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17429 /* "DB [DBNAME]" */) 50207 return TCL_ERROR 50208 } 50209 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+8 /* &db */) != 0 { 50210 return TCL_ERROR 50211 } 50212 if objc == 3 { 50213 zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 50214 } else { 50215 zDb = uintptr(0) 50216 } 50217 50218 rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* db */)), zDb, SQLITE_FCNTL_DATA_VERSION, bp+16 /* &iVers */) 50219 if rc != 0 { 50220 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 50221 return TCL_ERROR 50222 } else { 50223 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+20 /* &zBuf[0] */, ts+17441 /* "%u" */, libc.VaList(bp, *(*uint32)(unsafe.Pointer(bp + 16 /* iVers */)))) 50224 tcl.XTcl_SetResult(tls, interp, bp+20 /* zBuf */, uintptr(1)) 50225 return TCL_OK 50226 } 50227 return int32(0) 50228 } 50229 50230 // tclcmd: file_control_chunksize_test DB DBNAME SIZE 50231 // 50232 // This TCL command runs the sqlite3_file_control interface and 50233 // verifies correct operation of the SQLITE_GET_LOCKPROXYFILE and 50234 // SQLITE_SET_LOCKPROXYFILE verbs. 50235 func file_control_chunksize_test(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6094:26: */ 50236 bp := tls.Alloc(12) 50237 defer tls.Free(12) 50238 50239 // var nSize int32 at bp+8, 4 50240 // New chunk size 50241 var zDb uintptr // Db name ("main", "temp" etc.) 50242 // var db uintptr at bp, 8 50243 // Database handle 50244 var rc int32 // file_control() return code 50245 50246 if objc != 4 { 50247 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17444 /* "DB DBNAME SIZE" */) 50248 return TCL_ERROR 50249 } 50250 if (getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0) || 50251 (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+8 /* &nSize */) != 0) { 50252 return TCL_ERROR 50253 } 50254 zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 50255 if int32(*(*int8)(unsafe.Pointer(zDb))) == 0 { 50256 zDb = uintptr(0) 50257 } 50258 50259 rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zDb, SQLITE_FCNTL_CHUNK_SIZE, bp+8 /* &nSize */) 50260 if rc != 0 { 50261 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 50262 return TCL_ERROR 50263 } 50264 return TCL_OK 50265 } 50266 50267 // tclcmd: file_control_sizehint_test DB DBNAME SIZE 50268 // 50269 // This TCL command runs the sqlite3_file_control interface 50270 // with SQLITE_FCNTL_SIZE_HINT 50271 func file_control_sizehint_test(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6131:26: */ 50272 bp := tls.Alloc(16) 50273 defer tls.Free(16) 50274 50275 // var nSize Tcl_WideInt at bp+8, 8 50276 // Hinted size 50277 var zDb uintptr // Db name ("main", "temp" etc.) 50278 // var db uintptr at bp, 8 50279 // Database handle 50280 var rc int32 // file_control() return code 50281 50282 if objc != 4 { 50283 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17444 /* "DB DBNAME SIZE" */) 50284 return TCL_ERROR 50285 } 50286 if (getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0) || 50287 (tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+8 /* &nSize */) != 0) { 50288 return TCL_ERROR 50289 } 50290 zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 50291 if int32(*(*int8)(unsafe.Pointer(zDb))) == 0 { 50292 zDb = uintptr(0) 50293 } 50294 50295 rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zDb, SQLITE_FCNTL_SIZE_HINT, bp+8 /* &nSize */) 50296 if rc != 0 { 50297 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 50298 return TCL_ERROR 50299 } 50300 return TCL_OK 50301 } 50302 50303 // tclcmd: file_control_lockproxy_test DB PWD 50304 // 50305 // This TCL command runs the sqlite3_file_control interface and 50306 // verifies correct operation of the SQLITE_GET_LOCKPROXYFILE and 50307 // SQLITE_SET_LOCKPROXYFILE verbs. 50308 func file_control_lockproxy_test(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6169:26: */ 50309 bp := tls.Alloc(40) 50310 defer tls.Free(40) 50311 50312 // var db uintptr at bp+32, 8 50313 50314 if objc != 3 { 50315 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 50316 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+17459 /* " DB PWD" */, 0)) 50317 return TCL_ERROR 50318 } 50319 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0 { 50320 return TCL_ERROR 50321 } 50322 50323 return TCL_OK 50324 } 50325 50326 // tclcmd: file_control_persist_wal DB PERSIST-FLAG 50327 // 50328 // This TCL command runs the sqlite3_file_control interface with 50329 // the SQLITE_FCNTL_PERSIST_WAL opcode. 50330 func file_control_persist_wal(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6340:26: */ 50331 bp := tls.Alloc(176) 50332 defer tls.Free(176) 50333 50334 // var db uintptr at bp+64, 8 50335 50336 var rc int32 50337 // var bPersist int32 at bp+72, 4 50338 50339 // var z [100]int8 at bp+76, 100 50340 50341 if objc != 3 { 50342 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 50343 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+17467 /* " DB FLAG" */, 0)) 50344 return TCL_ERROR 50345 } 50346 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+64 /* &db */) != 0 { 50347 return TCL_ERROR 50348 } 50349 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+72 /* &bPersist */) != 0 { 50350 return TCL_ERROR 50351 } 50352 rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* db */)), uintptr(0), SQLITE_FCNTL_PERSIST_WAL, bp+72 /* &bPersist */) 50353 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+76 /* &z[0] */, ts+17476 /* "%d %d" */, libc.VaList(bp+32, rc, *(*int32)(unsafe.Pointer(bp + 72 /* bPersist */)))) 50354 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, bp+76 /* &z[0] */, uintptr(0))) 50355 return TCL_OK 50356 } 50357 50358 // tclcmd: file_control_powersafe_overwrite DB PSOW-FLAG 50359 // 50360 // This TCL command runs the sqlite3_file_control interface with 50361 // the SQLITE_FCNTL_POWERSAFE_OVERWRITE opcode. 50362 func file_control_powersafe_overwrite(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6372:26: */ 50363 bp := tls.Alloc(176) 50364 defer tls.Free(176) 50365 50366 // var db uintptr at bp+64, 8 50367 50368 var rc int32 50369 // var b int32 at bp+72, 4 50370 50371 // var z [100]int8 at bp+76, 100 50372 50373 if objc != 3 { 50374 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 50375 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+17467 /* " DB FLAG" */, 0)) 50376 return TCL_ERROR 50377 } 50378 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+64 /* &db */) != 0 { 50379 return TCL_ERROR 50380 } 50381 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+72 /* &b */) != 0 { 50382 return TCL_ERROR 50383 } 50384 rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* db */)), uintptr(0), SQLITE_FCNTL_POWERSAFE_OVERWRITE, bp+72 /* &b */) 50385 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+76 /* &z[0] */, ts+17476 /* "%d %d" */, libc.VaList(bp+32, rc, *(*int32)(unsafe.Pointer(bp + 72 /* b */)))) 50386 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, bp+76 /* &z[0] */, uintptr(0))) 50387 return TCL_OK 50388 } 50389 50390 // tclcmd: file_control_vfsname DB ?AUXDB? 50391 // 50392 // Return a string that describes the stack of VFSes. 50393 func file_control_vfsname(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6404:26: */ 50394 bp := tls.Alloc(64) 50395 defer tls.Free(64) 50396 50397 // var db uintptr at bp+48, 8 50398 50399 var zDbName uintptr = ts + 85 /* "main" */ 50400 *(*uintptr)(unsafe.Pointer(bp + 56 /* zVfsName */)) = uintptr(0) 50401 50402 if (objc != 2) && (objc != 3) { 50403 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 50404 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+17482 /* " DB ?AUXDB?" */, 0)) 50405 return TCL_ERROR 50406 } 50407 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &db */) != 0 { 50408 return TCL_ERROR 50409 } 50410 if objc == 3 { 50411 zDbName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 50412 } 50413 sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), zDbName, SQLITE_FCNTL_VFSNAME, bp+56 /* &zVfsName */) 50414 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(bp + 56 /* zVfsName */)), uintptr(0))) 50415 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* zVfsName */))) 50416 return TCL_OK 50417 } 50418 50419 // tclcmd: file_control_reservebytes DB N 50420 func file_control_reservebytes(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6434:26: */ 50421 bp := tls.Alloc(12) 50422 defer tls.Free(12) 50423 50424 // var db uintptr at bp, 8 50425 50426 var zDbName uintptr = ts + 85 /* "main" */ 50427 *(*int32)(unsafe.Pointer(bp + 8 /* n */)) = 0 50428 var rc int32 50429 50430 if objc != 3 { 50431 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17494 /* "DB N" */) 50432 return TCL_ERROR 50433 } 50434 if (getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0) || 50435 (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &n */) != 0) { 50436 return TCL_ERROR 50437 } 50438 50439 rc = sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zDbName, SQLITE_FCNTL_RESERVE_BYTES, bp+8 /* &n */) 50440 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 50441 return TCL_OK 50442 } 50443 50444 // tclcmd: file_control_tempfilename DB ?AUXDB? 50445 // 50446 // Return a string that is a temporary filename 50447 func file_control_tempfilename(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6466:26: */ 50448 bp := tls.Alloc(64) 50449 defer tls.Free(64) 50450 50451 // var db uintptr at bp+48, 8 50452 50453 var zDbName uintptr = ts + 85 /* "main" */ 50454 *(*uintptr)(unsafe.Pointer(bp + 56 /* zTName */)) = uintptr(0) 50455 50456 if (objc != 2) && (objc != 3) { 50457 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 50458 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+17482 /* " DB ?AUXDB?" */, 0)) 50459 return TCL_ERROR 50460 } 50461 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &db */) != 0 { 50462 return TCL_ERROR 50463 } 50464 if objc == 3 { 50465 zDbName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 50466 } 50467 sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* db */)), zDbName, SQLITE_FCNTL_TEMPFILENAME, bp+56 /* &zTName */) 50468 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(bp + 56 /* zTName */)), uintptr(0))) 50469 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* zTName */))) 50470 return TCL_OK 50471 } 50472 50473 // tclcmd: sqlite3_vfs_list 50474 // 50475 // Return a tcl list containing the names of all registered vfs's. 50476 func vfs_list(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6499:26: */ 50477 var pVfs uintptr 50478 var pRet uintptr = tcl.XTcl_NewObj(tls) 50479 if objc != 1 { 50480 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 50481 return TCL_ERROR 50482 } 50483 for pVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)); pVfs != 0; pVfs = (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpNext { 50484 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewStringObj(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FzName, -1)) 50485 } 50486 tcl.XTcl_SetObjResult(tls, interp, pRet) 50487 return TCL_OK 50488 } 50489 50490 // tclcmd: sqlite3_limit DB ID VALUE 50491 // 50492 // This TCL command runs the sqlite3_limit interface and 50493 // verifies correct operation of the same. 50494 func test_limit(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6524:26: */ 50495 bp := tls.Alloc(68) 50496 defer tls.Free(68) 50497 50498 // var db uintptr at bp+56, 8 50499 50500 var rc int32 50501 var i int32 50502 var id int32 = 0 50503 // var val int32 at bp+64, 4 50504 50505 var zId uintptr 50506 50507 if objc != 4 { 50508 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 50509 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+17499 /* " DB ID VALUE" */, 0)) 50510 return TCL_ERROR 50511 } 50512 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+56 /* &db */) != 0 { 50513 return TCL_ERROR 50514 } 50515 zId = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 50516 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aId)) / uint64(unsafe.Sizeof(struct { 50517 FzName uintptr 50518 Fid int32 50519 _ [4]byte 50520 }{}))); i++ { 50521 if libc.Xstrcmp(tls, zId, aId[i].FzName) == 0 { 50522 id = aId[i].Fid 50523 break 50524 } 50525 } 50526 if uint64(i) >= (uint64(unsafe.Sizeof(aId)) / uint64(unsafe.Sizeof(struct { 50527 FzName uintptr 50528 Fid int32 50529 _ [4]byte 50530 }{}))) { 50531 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+17512 /* "unknown limit ty..." */, zId, uintptr(0))) 50532 return TCL_ERROR 50533 } 50534 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+64 /* &val */) != 0 { 50535 return TCL_ERROR 50536 } 50537 rc = sqlite3.Xsqlite3_limit(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* db */)), id, *(*int32)(unsafe.Pointer(bp + 64 /* val */))) 50538 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) 50539 return TCL_OK 50540 } 50541 50542 var aId = [14]struct { 50543 FzName uintptr 50544 Fid int32 50545 _ [4]byte 50546 }{ 50547 {FzName: ts + 17533 /* "SQLITE_LIMIT_LEN..." */}, 50548 {FzName: ts + 17553 /* "SQLITE_LIMIT_SQL..." */, Fid: SQLITE_LIMIT_SQL_LENGTH}, 50549 {FzName: ts + 17577 /* "SQLITE_LIMIT_COL..." */, Fid: SQLITE_LIMIT_COLUMN}, 50550 {FzName: ts + 17597 /* "SQLITE_LIMIT_EXP..." */, Fid: SQLITE_LIMIT_EXPR_DEPTH}, 50551 {FzName: ts + 17621 /* "SQLITE_LIMIT_COM..." */, Fid: SQLITE_LIMIT_COMPOUND_SELECT}, 50552 {FzName: ts + 17650 /* "SQLITE_LIMIT_VDB..." */, Fid: SQLITE_LIMIT_VDBE_OP}, 50553 {FzName: ts + 17671 /* "SQLITE_LIMIT_FUN..." */, Fid: SQLITE_LIMIT_FUNCTION_ARG}, 50554 {FzName: ts + 17697 /* "SQLITE_LIMIT_ATT..." */, Fid: SQLITE_LIMIT_ATTACHED}, 50555 {FzName: ts + 17719 /* "SQLITE_LIMIT_LIK..." */, Fid: SQLITE_LIMIT_LIKE_PATTERN_LENGTH}, 50556 {FzName: ts + 17752 /* "SQLITE_LIMIT_VAR..." */, Fid: SQLITE_LIMIT_VARIABLE_NUMBER}, 50557 {FzName: ts + 17781 /* "SQLITE_LIMIT_TRI..." */, Fid: SQLITE_LIMIT_TRIGGER_DEPTH}, 50558 {FzName: ts + 17808 /* "SQLITE_LIMIT_WOR..." */, Fid: SQLITE_LIMIT_WORKER_THREADS}, 50559 50560 // Out of range test cases 50561 {FzName: ts + 17836 /* "SQLITE_LIMIT_TOO..." */, Fid: -1}, 50562 {FzName: ts + 17858 /* "SQLITE_LIMIT_TOO..." */, Fid: (SQLITE_LIMIT_WORKER_THREADS + 1)}, 50563 } /* test1.c:6535:5 */ 50564 50565 // tclcmd: save_prng_state 50566 // 50567 // Save the state of the pseudo-random number generator. 50568 // At the same time, verify that sqlite3_test_control works even when 50569 // called with an out-of-range opcode. 50570 func save_prng_state(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6587:26: */ 50571 var rc int32 = sqlite3.Xsqlite3_test_control(tls, 9999, 0) 50572 _ = rc 50573 50574 rc = sqlite3.Xsqlite3_test_control(tls, -1, 0) 50575 50576 sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_PRNG_SAVE, 0) 50577 return TCL_OK 50578 } 50579 50580 // tclcmd: restore_prng_state 50581 func restore_prng_state(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6603:26: */ 50582 sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_PRNG_RESTORE, 0) 50583 return TCL_OK 50584 } 50585 50586 // tclcmd: reset_prng_state 50587 func reset_prng_state(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6615:26: */ 50588 sqlite3.Xsqlite3_randomness(tls, 0, uintptr(0)) 50589 return TCL_OK 50590 } 50591 50592 // tclcmd: prng_seed INT ?DB? 50593 // 50594 // Set up the SQLITE_TESTCTRL_PRNG_SEED pragma with parameter INT and DB. 50595 // INT is an integer. DB is a database connection, or a NULL pointer if 50596 // omitted. 50597 // 50598 // When INT!=0 and DB!=0, set the PRNG seed to the value of the schema 50599 // cookie for DB, or to INT if the schema cookie happens to be zero. 50600 // 50601 // When INT!=0 and DB==0, set the PRNG seed to just INT. 50602 // 50603 // If INT==0 and DB==0 then use the default procedure of calling the 50604 // xRandomness method on the default VFS to get the PRNG seed. 50605 func prng_seed(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6639:26: */ 50606 bp := tls.Alloc(32) 50607 defer tls.Free(32) 50608 50609 *(*int32)(unsafe.Pointer(bp + 16 /* i */)) = 0 50610 *(*uintptr)(unsafe.Pointer(bp + 24 /* db */)) = uintptr(0) 50611 if (objc != 2) && (objc != 3) { 50612 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17878 /* "SEED ?DB?" */) 50613 return TCL_ERROR 50614 } 50615 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+16 /* &i */) != 0 { 50616 return TCL_ERROR 50617 } 50618 if (objc == 3) && (getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), bp+24 /* &db */) != 0) { 50619 return TCL_ERROR 50620 } 50621 sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_PRNG_SEED, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 16 /* i */)), *(*uintptr)(unsafe.Pointer(bp + 24 /* db */)))) 50622 return TCL_OK 50623 } 50624 50625 // tclcmd: extra_schema_checks BOOLEAN 50626 // 50627 // Enable or disable schema checks when parsing the sqlite_schema file. 50628 // This is always enabled in production, but it is sometimes useful to 50629 // disable the checks in order to make some internal error states reachable 50630 // for testing. 50631 func extra_schema_checks(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6667:26: */ 50632 bp := tls.Alloc(12) 50633 defer tls.Free(12) 50634 50635 *(*int32)(unsafe.Pointer(bp + 8 /* i */)) = 0 50636 if objc != 2 { 50637 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17888 /* "BOOLEAN" */) 50638 return TCL_ERROR 50639 } 50640 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+8 /* &i */) != 0 { 50641 return TCL_ERROR 50642 } 50643 sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* i */)))) 50644 return TCL_OK 50645 } 50646 50647 // tclcmd: database_may_be_corrupt 50648 // 50649 // Indicate that database files might be corrupt. In other words, set the normal 50650 // state of operation. 50651 func database_may_be_corrupt(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6689:26: */ 50652 bp := tls.Alloc(8) 50653 defer tls.Free(8) 50654 50655 sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_NEVER_CORRUPT, libc.VaList(bp, 0)) 50656 return TCL_OK 50657 } 50658 50659 // tclcmd: database_never_corrupt 50660 // 50661 // Indicate that database files are always well-formed. This enables 50662 // extra assert() statements that test conditions that are always true 50663 // for well-formed databases. 50664 func database_never_corrupt(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6705:26: */ 50665 bp := tls.Alloc(8) 50666 defer tls.Free(8) 50667 50668 sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_NEVER_CORRUPT, libc.VaList(bp, 1)) 50669 return TCL_OK 50670 } 50671 50672 // tclcmd: pcache_stats 50673 func test_pcache_stats(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6718:26: */ 50674 bp := tls.Alloc(16) 50675 defer tls.Free(16) 50676 50677 // var nMin int32 at bp+8, 4 50678 50679 // var nMax int32 at bp+4, 4 50680 50681 // var nCurrent int32 at bp, 4 50682 50683 // var nRecyclable int32 at bp+12, 4 50684 50685 var pRet uintptr 50686 50687 sqlite3.Xsqlite3PcacheStats(tls, bp /* &nCurrent */, bp+4 /* &nMax */, bp+8 /* &nMin */, bp+12 /* &nRecyclable */) 50688 50689 pRet = tcl.XTcl_NewObj(tls) 50690 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewStringObj(tls, ts+17896 /* "current" */, -1)) 50691 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp /* nCurrent */)))) 50692 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewStringObj(tls, ts+17904 /* "max" */, -1)) 50693 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 4 /* nMax */)))) 50694 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewStringObj(tls, ts+17908 /* "min" */, -1)) 50695 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 8 /* nMin */)))) 50696 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewStringObj(tls, ts+17912 /* "recyclable" */, -1)) 50697 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 12 /* nRecyclable */)))) 50698 50699 tcl.XTcl_SetObjResult(tls, interp, pRet) 50700 50701 return TCL_OK 50702 } 50703 50704 func test_unlock_notify_cb(tls *libc.TLS, aArg uintptr, nArg int32) { /* test1.c:6748:13: */ 50705 var ii int32 50706 for ii = 0; ii < nArg; ii++ { 50707 tcl.XTcl_EvalEx(tls, *(*uintptr)(unsafe.Pointer(aArg + uintptr(ii)*8)), ts+13374 /* "unlock_notify" */, -1, TCL_EVAL_GLOBAL) 50708 } 50709 } 50710 50711 // tclcmd: sqlite3_unlock_notify db 50712 func test_unlock_notify(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6760:26: */ 50713 bp := tls.Alloc(8) 50714 defer tls.Free(8) 50715 50716 // var db uintptr at bp, 8 50717 50718 var rc int32 50719 50720 if objc != 2 { 50721 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 50722 return TCL_ERROR 50723 } 50724 50725 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 50726 return TCL_ERROR 50727 } 50728 rc = sqlite3.Xsqlite3_unlock_notify(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), *(*uintptr)(unsafe.Pointer(&struct { 50729 f func(*libc.TLS, uintptr, int32) 50730 }{test_unlock_notify_cb})), interp) 50731 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 50732 return TCL_OK 50733 } 50734 50735 // tclcmd: sqlite3_wal_checkpoint db ?NAME? 50736 func test_wal_checkpoint(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6786:26: */ 50737 bp := tls.Alloc(8) 50738 defer tls.Free(8) 50739 50740 var zDb uintptr = uintptr(0) 50741 // var db uintptr at bp, 8 50742 50743 var rc int32 50744 50745 if (objc != 3) && (objc != 2) { 50746 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17923 /* "DB ?NAME?" */) 50747 return TCL_ERROR 50748 } 50749 50750 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 50751 return TCL_ERROR 50752 } 50753 if objc == 3 { 50754 zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 50755 } 50756 rc = sqlite3.Xsqlite3_wal_checkpoint(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zDb) 50757 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 50758 return TCL_OK 50759 } 50760 50761 // tclcmd: sqlite3_wal_checkpoint_v2 db MODE ?NAME? 50762 // 50763 // This command calls the wal_checkpoint_v2() function with the specified 50764 // mode argument (passive, full or restart). If present, the database name 50765 // NAME is passed as the second argument to wal_checkpoint_v2(). If it the 50766 // NAME argument is not present, a NULL pointer is passed instead. 50767 // 50768 // If wal_checkpoint_v2() returns any value other than SQLITE_BUSY or 50769 // SQLITE_OK, then this command returns TCL_ERROR. The Tcl result is set 50770 // to the error message obtained from sqlite3_errmsg(). 50771 // 50772 // Otherwise, this command returns a list of three integers. The first integer 50773 // is 1 if SQLITE_BUSY was returned, or 0 otherwise. The following two integers 50774 // are the values returned via the output parameters by wal_checkpoint_v2() - 50775 // the number of frames in the log and the number of frames in the log 50776 // that have been checkpointed. 50777 func test_wal_checkpoint_v2(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6830:26: */ 50778 bp := tls.Alloc(96) 50779 defer tls.Free(96) 50780 50781 var zDb uintptr = uintptr(0) 50782 // var db uintptr at bp+32, 8 50783 50784 var rc int32 50785 // var eMode int32 at bp+40, 4 50786 50787 *(*int32)(unsafe.Pointer(bp + 88 /* nLog */)) = -555 50788 *(*int32)(unsafe.Pointer(bp + 92 /* nCkpt */)) = -555 50789 var pRet uintptr 50790 50791 *(*[5]uintptr)(unsafe.Pointer(bp + 48 /* aMode */)) = [5]uintptr{ts + 17933 /* "passive" */, ts + 17941 /* "full" */, ts + 17946 /* "restart" */, ts + 17954 /* "truncate" */, uintptr(0)} 50792 50793 if (objc != 3) && (objc != 4) { 50794 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17963 /* "DB MODE ?NAME?" */) 50795 return TCL_ERROR 50796 } 50797 50798 if objc == 4 { 50799 zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 50800 } 50801 if (getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0) || ((TCL_OK != tcl.XTcl_GetIntFromObj(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &eMode */)) && 50802 (TCL_OK != tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+48 /* &aMode[0] */, int32(unsafe.Sizeof(uintptr(0))), ts+17978 /* "mode" */, 0, bp+40 /* &eMode */))) { 50803 return TCL_ERROR 50804 } 50805 50806 rc = sqlite3.Xsqlite3_wal_checkpoint_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), zDb, *(*int32)(unsafe.Pointer(bp + 40 /* eMode */)), bp+88 /* &nLog */, bp+92 /* &nCkpt */) 50807 if (rc != SQLITE_OK) && (rc != SQLITE_BUSY) { 50808 var zErrCode uintptr = sqlite3.Xsqlite3ErrName(tls, rc) 50809 tcl.XTcl_ResetResult(tls, interp) 50810 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, zErrCode, ts+10282 /* " - " */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */))), 0)) 50811 return TCL_ERROR 50812 } 50813 50814 pRet = tcl.XTcl_NewObj(tls) 50815 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewIntObj(tls, func() int32 { 50816 if rc == SQLITE_BUSY { 50817 return 1 50818 } 50819 return 0 50820 }())) 50821 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 88 /* nLog */)))) 50822 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 92 /* nCkpt */)))) 50823 tcl.XTcl_SetObjResult(tls, interp, pRet) 50824 50825 return TCL_OK 50826 } 50827 50828 // tclcmd: sqlite3_wal_autocheckpoint db VALUE 50829 func test_wal_autocheckpoint(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6886:26: */ 50830 bp := tls.Alloc(12) 50831 defer tls.Free(12) 50832 50833 // var db uintptr at bp, 8 50834 50835 var rc int32 50836 // var iVal int32 at bp+8, 4 50837 50838 if objc != 3 { 50839 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17983 /* "DB VALUE" */) 50840 return TCL_ERROR 50841 } 50842 50843 if (getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0) || 50844 (tcl.XTcl_GetIntFromObj(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &iVal */) != 0) { 50845 return TCL_ERROR 50846 } 50847 50848 rc = sqlite3.Xsqlite3_wal_autocheckpoint(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), *(*int32)(unsafe.Pointer(bp + 8 /* iVal */))) 50849 tcl.XTcl_ResetResult(tls, interp) 50850 if rc != SQLITE_OK { 50851 var zErrCode uintptr = sqlite3.Xsqlite3ErrName(tls, rc) 50852 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, zErrCode, -1)) 50853 return TCL_ERROR 50854 } 50855 50856 return TCL_OK 50857 } 50858 50859 // tclcmd: test_sqlite3_log ?SCRIPT? 50860 type LogCallback = struct { 50861 FpInterp uintptr 50862 FpObj uintptr 50863 } /* test1.c:6923:8 */ 50864 50865 // tclcmd: test_sqlite3_log ?SCRIPT? 50866 var logcallback = LogCallback{} /* test1.c:6926:3 */ 50867 50868 func xLogcallback(tls *libc.TLS, unused uintptr, err int32, zMsg uintptr) { /* test1.c:6927:13: */ 50869 var pNew uintptr = tcl.XTcl_DuplicateObj(tls, logcallback.FpObj) 50870 (*Tcl_Obj)(unsafe.Pointer(pNew)).FrefCount++ 50871 tcl.XTcl_ListObjAppendElement(tls, 50872 uintptr(0), pNew, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, err), -1)) 50873 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pNew, tcl.XTcl_NewStringObj(tls, zMsg, -1)) 50874 tcl.XTcl_EvalObjEx(tls, logcallback.FpInterp, pNew, (TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT)) 50875 for ok := true; ok; ok = 0 != 0 { 50876 var _objPtr uintptr = pNew 50877 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 50878 tcl.XTclFreeObj(tls, _objPtr) 50879 } 50880 } 50881 } 50882 50883 func test_sqlite3_log(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6937:26: */ 50884 bp := tls.Alloc(32) 50885 defer tls.Free(32) 50886 50887 if objc > 2 { 50888 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+11585 /* "SCRIPT" */) 50889 return TCL_ERROR 50890 } 50891 if logcallback.FpObj != 0 { 50892 for ok := true; ok; ok = 0 != 0 { 50893 var _objPtr uintptr = logcallback.FpObj 50894 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 50895 tcl.XTclFreeObj(tls, _objPtr) 50896 } 50897 } 50898 logcallback.FpObj = uintptr(0) 50899 logcallback.FpInterp = uintptr(0) 50900 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_LOG, libc.VaList(bp, uintptr(0), uintptr(0))) 50901 } 50902 if objc > 1 { 50903 logcallback.FpObj = *(*uintptr)(unsafe.Pointer(objv + 1*8)) 50904 (*Tcl_Obj)(unsafe.Pointer(logcallback.FpObj)).FrefCount++ 50905 logcallback.FpInterp = interp 50906 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_LOG, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(&struct { 50907 f func(*libc.TLS, uintptr, int32, uintptr) 50908 }{xLogcallback})), uintptr(0))) 50909 } 50910 return TCL_OK 50911 } 50912 50913 // tcl_objproc COMMANDNAME ARGS... 50914 // 50915 // Run a TCL command using its objProc interface. Throw an error if 50916 // the command has no objProc interface. 50917 func runAsObjProc(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:6968:26: */ 50918 bp := tls.Alloc(112) 50919 defer tls.Free(112) 50920 50921 // var cmdInfo Tcl_CmdInfo at bp+48, 64 50922 50923 if objc < 2 { 50924 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17992 /* "COMMAND ..." */) 50925 return TCL_ERROR 50926 } 50927 if !(tcl.XTcl_GetCommandInfo(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &cmdInfo */) != 0) { 50928 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14541, /* "command not foun..." */ 50929 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), uintptr(0))) 50930 return TCL_ERROR 50931 } 50932 if (*Tcl_CmdInfo)(unsafe.Pointer(bp+48 /* &cmdInfo */)).FobjProc == uintptr(0) { 50933 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, ts+18004, /* "command has no o..." */ 50934 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), uintptr(0))) 50935 return TCL_ERROR 50936 } 50937 return (*(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer((bp + 48 /* &cmdInfo */ + 8 /* &.objProc */))))(tls, (*Tcl_CmdInfo)(unsafe.Pointer(bp+48 /* &cmdInfo */)).FobjClientData, interp, (objc - 1), (objv + uintptr(1)*8)) 50938 } 50939 50940 // WARNING: The following function, printExplainQueryPlan() is an exact 50941 // copy of example code from eqp.in (eqp.html). If this code is modified, 50942 // then the documentation copy needs to be modified as well. 50943 // Argument pStmt is a prepared SQL statement. This function compiles 50944 // an EXPLAIN QUERY PLAN command to report on the prepared statement, 50945 // and prints the report to stdout using printf(). 50946 func printExplainQueryPlan(tls *libc.TLS, pStmt uintptr) int32 { /* test1.c:7003:5: */ 50947 bp := tls.Alloc(48) 50948 defer tls.Free(48) 50949 50950 var zSql uintptr // Input SQL 50951 var zExplain uintptr // SQL with EXPLAIN QUERY PLAN prepended 50952 // var pExplain uintptr at bp+40, 8 50953 // Compiled EXPLAIN QUERY PLAN command 50954 var rc int32 // Return code from sqlite3_prepare_v2() 50955 50956 zSql = sqlite3.Xsqlite3_sql(tls, pStmt) 50957 if zSql == uintptr(0) { 50958 return SQLITE_ERROR 50959 } 50960 50961 zExplain = sqlite3.Xsqlite3_mprintf(tls, ts+235 /* "EXPLAIN QUERY PL..." */, libc.VaList(bp, zSql)) 50962 if zExplain == uintptr(0) { 50963 return SQLITE_NOMEM 50964 } 50965 50966 rc = sqlite3.Xsqlite3_prepare_v2(tls, sqlite3.Xsqlite3_db_handle(tls, pStmt), zExplain, -1, bp+40 /* &pExplain */, uintptr(0)) 50967 sqlite3.Xsqlite3_free(tls, zExplain) 50968 if rc != SQLITE_OK { 50969 return rc 50970 } 50971 50972 for SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pExplain */))) { 50973 var iSelectid int32 = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pExplain */)), 0) 50974 var iOrder int32 = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pExplain */)), 1) 50975 var iFrom int32 = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pExplain */)), 2) 50976 var zDetail uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pExplain */)), 3) 50977 50978 libc.Xprintf(tls, ts+18029 /* "%d %d %d %s\n" */, libc.VaList(bp+8, iSelectid, iOrder, iFrom, zDetail)) 50979 } 50980 50981 return sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 40 /* pExplain */))) 50982 } 50983 50984 func test_print_eqp(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:7031:26: */ 50985 bp := tls.Alloc(8) 50986 defer tls.Free(8) 50987 50988 var rc int32 50989 // var pStmt uintptr at bp, 8 50990 50991 if objc != 2 { 50992 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16629 /* "STMT" */) 50993 return TCL_ERROR 50994 } 50995 if getStmtPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &pStmt */) != 0 { 50996 return TCL_ERROR 50997 } 50998 rc = printExplainQueryPlan(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) 50999 // This is needed on Windows so that a test case using this 51000 // function can open a read pipe and get the output of 51001 // printExplainQueryPlan() immediately. 51002 libc.Xfflush(tls, libc.Xstdout) 51003 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 51004 return TCL_OK 51005 } 51006 51007 // sqlite3_test_control VERB ARGS... 51008 func test_test_control(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:7059:26: */ 51009 bp := tls.Alloc(184) 51010 defer tls.Free(184) 51011 51012 *(*[4]Verb)(unsafe.Pointer(bp + 64 /* aVerb */)) = [4]Verb{ 51013 {FzName: ts + 18042 /* "SQLITE_TESTCTRL_..." */, Fi: SQLITE_TESTCTRL_LOCALTIME_FAULT}, 51014 {FzName: ts + 18074 /* "SQLITE_TESTCTRL_..." */, Fi: SQLITE_TESTCTRL_SORTER_MMAP}, 51015 {FzName: ts + 18102 /* "SQLITE_TESTCTRL_..." */, Fi: SQLITE_TESTCTRL_IMPOSTER}, 51016 {FzName: ts + 18127 /* "SQLITE_TESTCTRL_..." */, Fi: SQLITE_TESTCTRL_INTERNAL_FUNCTIONS}, 51017 } 51018 // var iVerb int32 at bp+128, 4 51019 51020 var iFlag int32 51021 var rc int32 51022 51023 if objc < 2 { 51024 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18162 /* "VERB ARGS..." */) 51025 return TCL_ERROR 51026 } 51027 51028 rc = tcl.XTcl_GetIndexFromObjStruct(tls, 51029 interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+64 /* &aVerb[0] */, int32(unsafe.Sizeof(Verb{})), ts+18175 /* "VERB" */, 0, bp+128 /* &iVerb */) 51030 if rc != TCL_OK { 51031 return rc 51032 } 51033 51034 iFlag = (*Verb)(unsafe.Pointer(bp + 64 /* &aVerb */ + uintptr(*(*int32)(unsafe.Pointer(bp + 128 /* iVerb */)))*16)).Fi 51035 switch iFlag { 51036 case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS: 51037 { 51038 *(*uintptr)(unsafe.Pointer(bp + 136 /* db */)) = uintptr(0) 51039 if objc != 3 { 51040 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+1911 /* "DB" */) 51041 return TCL_ERROR 51042 } 51043 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), bp+136 /* &db */) != 0 { 51044 return TCL_ERROR 51045 } 51046 sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_INTERNAL_FUNCTIONS, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(bp + 136 /* db */)))) 51047 break 51048 51049 } 51050 case SQLITE_TESTCTRL_LOCALTIME_FAULT: 51051 { 51052 // var val int32 at bp+144, 4 51053 51054 if objc != 3 { 51055 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+18180 /* "ONOFF" */) 51056 return TCL_ERROR 51057 } 51058 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+144 /* &val */) != 0 { 51059 return TCL_ERROR 51060 } 51061 sqlite3.Xsqlite3_test_control(tls, iFlag, libc.VaList(bp+8, *(*int32)(unsafe.Pointer(bp + 144 /* val */)))) 51062 break 51063 51064 } 51065 51066 case SQLITE_TESTCTRL_SORTER_MMAP: 51067 { 51068 // var val int32 at bp+160, 4 51069 51070 // var db uintptr at bp+152, 8 51071 51072 if objc != 4 { 51073 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+18186 /* "DB LIMIT" */) 51074 return TCL_ERROR 51075 } 51076 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), bp+152 /* &db */) != 0 { 51077 return TCL_ERROR 51078 } 51079 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+160 /* &val */) != 0 { 51080 return TCL_ERROR 51081 } 51082 sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_SORTER_MMAP, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(bp + 152 /* db */)), *(*int32)(unsafe.Pointer(bp + 160 /* val */)))) 51083 break 51084 51085 } 51086 51087 case SQLITE_TESTCTRL_IMPOSTER: 51088 { 51089 // var onOff int32 at bp+176, 4 51090 51091 // var tnum int32 at bp+180, 4 51092 51093 var zDbName uintptr 51094 // var db uintptr at bp+168, 8 51095 51096 if objc != 6 { 51097 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+18195 /* "DB dbName onOff ..." */) 51098 return TCL_ERROR 51099 } 51100 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), bp+168 /* &db */) != 0 { 51101 return TCL_ERROR 51102 } 51103 zDbName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 51104 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+176 /* &onOff */) != 0 { 51105 return TCL_ERROR 51106 } 51107 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 5*8)), bp+180 /* &tnum */) != 0 { 51108 return TCL_ERROR 51109 } 51110 sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_IMPOSTER, libc.VaList(bp+32, *(*uintptr)(unsafe.Pointer(bp + 168 /* db */)), zDbName, *(*int32)(unsafe.Pointer(bp + 176 /* onOff */)), *(*int32)(unsafe.Pointer(bp + 180 /* tnum */)))) 51111 break 51112 51113 } 51114 } 51115 51116 tcl.XTcl_ResetResult(tls, interp) 51117 return TCL_OK 51118 } 51119 51120 type Verb = struct { 51121 FzName uintptr 51122 Fi int32 51123 _ [4]byte 51124 } /* test1.c:7065:3 */ 51125 51126 // Value to indicate that there is no limit. 51127 51128 // We can represent all limits. 51129 51130 // Type for resource quantity measurement. 51131 type rlim_t = uint64 /* resource.h:133:20 */ 51132 type rlim64_t = uint64 /* resource.h:136:20 */ 51133 51134 type rlimit = struct { 51135 Frlim_cur rlim_t 51136 Frlim_max rlim_t 51137 } /* resource.h:139:1 */ 51138 51139 type rlimit64 = struct { 51140 Frlim_cur rlim64_t 51141 Frlim_max rlim64_t 51142 } /* resource.h:148:1 */ 51143 51144 // Define struct rusage. 51145 // Copyright (C) 1994-2018 Free Software Foundation, Inc. 51146 // This file is part of the GNU C Library. 51147 // 51148 // The GNU C Library is free software; you can redistribute it and/or 51149 // modify it under the terms of the GNU Lesser General Public 51150 // License as published by the Free Software Foundation; either 51151 // version 2.1 of the License, or (at your option) any later version. 51152 // 51153 // The GNU C Library is distributed in the hope that it will be useful, 51154 // but WITHOUT ANY WARRANTY; without even the implied warranty of 51155 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 51156 // Lesser General Public License for more details. 51157 // 51158 // You should have received a copy of the GNU Lesser General Public 51159 // License along with the GNU C Library; if not, see 51160 // <http://www.gnu.org/licenses/>. 51161 51162 // bits/types.h -- definitions of __*_t types underlying *_t types. 51163 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 51164 // This file is part of the GNU C Library. 51165 // 51166 // The GNU C Library is free software; you can redistribute it and/or 51167 // modify it under the terms of the GNU Lesser General Public 51168 // License as published by the Free Software Foundation; either 51169 // version 2.1 of the License, or (at your option) any later version. 51170 // 51171 // The GNU C Library is distributed in the hope that it will be useful, 51172 // but WITHOUT ANY WARRANTY; without even the implied warranty of 51173 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 51174 // Lesser General Public License for more details. 51175 // 51176 // You should have received a copy of the GNU Lesser General Public 51177 // License along with the GNU C Library; if not, see 51178 // <http://www.gnu.org/licenses/>. 51179 51180 // Never include this file directly; use <sys/types.h> instead. 51181 51182 // Structure which says how much of each resource has been used. 51183 51184 // The purpose of all the unions is to have the kernel-compatible layout 51185 // while keeping the API type as 'long int', and among machines where 51186 // __syscall_slong_t is not 'long int', this only does the right thing 51187 // for little-endian ones, like x32. 51188 type rusage = struct { 51189 Fru_utime struct { 51190 Ftv_sec int64 51191 Ftv_usec int64 51192 } 51193 Fru_stime struct { 51194 Ftv_sec int64 51195 Ftv_usec int64 51196 } 51197 F__32 struct{ Fru_maxrss int64 } 51198 F__40 struct{ Fru_ixrss int64 } 51199 F__48 struct{ Fru_idrss int64 } 51200 F__56 struct{ Fru_isrss int64 } 51201 F__64 struct{ Fru_minflt int64 } 51202 F__72 struct{ Fru_majflt int64 } 51203 F__80 struct{ Fru_nswap int64 } 51204 F__88 struct{ Fru_inblock int64 } 51205 F__96 struct{ Fru_oublock int64 } 51206 F__104 struct{ Fru_msgsnd int64 } 51207 F__112 struct{ Fru_msgrcv int64 } 51208 F__120 struct{ Fru_nsignals int64 } 51209 F__128 struct{ Fru_nvcsw int64 } 51210 F__136 struct{ Fru_nivcsw int64 } 51211 } /* struct_rusage.h:31:1 */ 51212 51213 func test_getrusage(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:7149:26: */ 51214 bp := tls.Alloc(1216) 51215 defer tls.Free(1216) 51216 51217 // var buf [1024]int8 at bp+192, 1024 51218 51219 // var r rusage at bp+48, 144 51220 51221 libc.Xmemset(tls, bp+48 /* &r */, 0, uint64(unsafe.Sizeof(rusage{}))) 51222 libc.Xgetrusage(tls, RUSAGE_SELF, bp+48 /* &r */) 51223 51224 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([1024]int8{})), bp+192, /* &buf[0] */ 51225 ts+18216, /* "ru_utime=%d.%06d..." */ 51226 libc.VaList(bp, int32((*rusage)(unsafe.Pointer(bp+48 /* &r */)).Fru_utime.Ftv_sec), int32((*rusage)(unsafe.Pointer(bp+48 /* &r */)).Fru_utime.Ftv_usec), 51227 int32((*rusage)(unsafe.Pointer(bp+48 /* &r */)).Fru_stime.Ftv_sec), int32((*rusage)(unsafe.Pointer(bp+48 /* &r */)).Fru_stime.Ftv_usec), 51228 int32(*(*int64)(unsafe.Pointer(bp + 48 /* &r */ + 64 /* &.ru_minflt */))), int32(*(*int64)(unsafe.Pointer(bp + 48 /* &r */ + 72 /* &.ru_majflt */))))) 51229 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, bp+192 /* &buf[0] */, -1)) 51230 return TCL_OK 51231 } 51232 51233 // optimization_control DB OPT BOOLEAN 51234 // 51235 // Enable or disable query optimizations using the sqlite3_test_control() 51236 // interface. Disable if BOOLEAN is false and enable if BOOLEAN is true. 51237 // OPT is the name of the optimization to be disabled. 51238 func optimization_control(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:7429:26: */ 51239 bp := tls.Alloc(68) 51240 defer tls.Free(68) 51241 51242 var i int32 51243 // var db uintptr at bp+56, 8 51244 51245 var zOpt uintptr 51246 // var onoff int32 at bp+64, 4 51247 51248 var mask int32 = 0 51249 51250 if objc != 4 { 51251 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18276 /* "DB OPT BOOLEAN" */) 51252 return TCL_ERROR 51253 } 51254 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+56 /* &db */) != 0 { 51255 return TCL_ERROR 51256 } 51257 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+64 /* &onoff */) != 0 { 51258 return TCL_ERROR 51259 } 51260 zOpt = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 51261 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aOpt)) / uint64(unsafe.Sizeof(struct { 51262 FzOptName uintptr 51263 Fmask int32 51264 _ [4]byte 51265 }{}))); i++ { 51266 if libc.Xstrcmp(tls, zOpt, aOpt[i].FzOptName) == 0 { 51267 mask = aOpt[i].Fmask 51268 break 51269 } 51270 } 51271 if *(*int32)(unsafe.Pointer(bp + 64 /* onoff */)) != 0 { 51272 mask = ^mask 51273 } 51274 if uint64(i) >= (uint64(unsafe.Sizeof(aOpt)) / uint64(unsafe.Sizeof(struct { 51275 FzOptName uintptr 51276 Fmask int32 51277 _ [4]byte 51278 }{}))) { 51279 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+18291, /* "unknown optimiza..." */ 51280 uintptr(0))) 51281 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aOpt)) / uint64(unsafe.Sizeof(struct { 51282 FzOptName uintptr 51283 Fmask int32 51284 _ [4]byte 51285 }{}))); i++ { 51286 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, ts+4765 /* " " */, aOpt[i].FzOptName, uintptr(0))) 51287 } 51288 return TCL_ERROR 51289 } 51290 sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_OPTIMIZATIONS, libc.VaList(bp+40, *(*uintptr)(unsafe.Pointer(bp + 56 /* db */)), mask)) 51291 return TCL_OK 51292 } 51293 51294 var aOpt = [13]struct { 51295 FzOptName uintptr 51296 Fmask int32 51297 _ [4]byte 51298 }{ 51299 {FzOptName: ts + 18332 /* "all" */, Fmask: libc.Int32FromUint32(SQLITE_AllOpts)}, 51300 {FzOptName: ts + 18336 /* "none" */}, 51301 {FzOptName: ts + 18341 /* "query-flattener" */, Fmask: SQLITE_QueryFlattener}, 51302 {FzOptName: ts + 18357 /* "groupby-order" */, Fmask: SQLITE_GroupByOrder}, 51303 {FzOptName: ts + 18371 /* "factor-constants" */, Fmask: SQLITE_FactorOutConst}, 51304 {FzOptName: ts + 18388 /* "distinct-opt" */, Fmask: SQLITE_DistinctOpt}, 51305 {FzOptName: ts + 18401 /* "cover-idx-scan" */, Fmask: SQLITE_CoverIdxScan}, 51306 {FzOptName: ts + 18416 /* "order-by-idx-joi..." */, Fmask: SQLITE_OrderByIdxJoin}, 51307 {FzOptName: ts + 18434 /* "transitive" */, Fmask: SQLITE_Transitive}, 51308 {FzOptName: ts + 18445 /* "omit-noop-join" */, Fmask: SQLITE_OmitNoopJoin}, 51309 {FzOptName: ts + 18460 /* "stat4" */, Fmask: SQLITE_Stat4}, 51310 {FzOptName: ts + 18466 /* "skip-scan" */, Fmask: SQLITE_SkipScan}, 51311 {FzOptName: ts + 18476 /* "push-down" */, Fmask: SQLITE_PushDown}, 51312 } /* test1.c:7443:5 */ 51313 51314 // load_static_extension DB NAME ... 51315 // 51316 // Load one or more statically linked extensions. 51317 func tclLoadStaticExtensionCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:7490:26: */ 51318 bp := tls.Alloc(80) 51319 defer tls.Free(80) 51320 51321 // var db uintptr at bp+64, 8 51322 51323 var zName uintptr 51324 var i int32 51325 var j int32 51326 var rc int32 51327 *(*uintptr)(unsafe.Pointer(bp + 72 /* zErrMsg */)) = uintptr(0) 51328 if objc < 3 { 51329 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18486 /* "DB NAME ..." */) 51330 return TCL_ERROR 51331 } 51332 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+64 /* &db */) != 0 { 51333 return TCL_ERROR 51334 } 51335 for j = 2; j < objc; j++ { 51336 zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(j)*8))) 51337 for i = 0; i < (int32(uint64(unsafe.Sizeof(aExtension)) / uint64(unsafe.Sizeof(struct { 51338 FzExtName uintptr 51339 FpInit uintptr 51340 }{})))); i++ { 51341 if libc.Xstrcmp(tls, zName, aExtension[i].FzExtName) == 0 { 51342 break 51343 } 51344 } 51345 if i >= (int32(uint64(unsafe.Sizeof(aExtension)) / uint64(unsafe.Sizeof(struct { 51346 FzExtName uintptr 51347 FpInit uintptr 51348 }{})))) { 51349 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+18498 /* "no such extensio..." */, zName, uintptr(0))) 51350 return TCL_ERROR 51351 } 51352 if aExtension[i].FpInit != 0 { 51353 rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aExtension)) + uintptr(i)*16 + 8 /* &.pInit */))))(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* db */)), bp+72 /* &zErrMsg */, uintptr(0)) 51354 } else { 51355 rc = SQLITE_OK 51356 } 51357 if ((rc != SQLITE_OK) && (rc != (SQLITE_OK | (int32(1) << 8)))) || (*(*uintptr)(unsafe.Pointer(bp + 72 /* zErrMsg */)) != 0) { 51358 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, ts+18518 /* "initialization o..." */, zName, ts+18537 /* " failed: " */, *(*uintptr)(unsafe.Pointer(bp + 72 /* zErrMsg */)), 51359 uintptr(0))) 51360 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* zErrMsg */))) 51361 return TCL_ERROR 51362 } 51363 } 51364 return TCL_OK 51365 } 51366 51367 var aExtension = [22]struct { 51368 FzExtName uintptr 51369 FpInit uintptr 51370 }{ 51371 {FzExtName: ts + 18547 /* "amatch" */, FpInit: 0}, 51372 {FzExtName: ts + 18554 /* "appendvfs" */, FpInit: 0}, 51373 {FzExtName: ts + 3931 /* "carray" */, FpInit: 0}, 51374 {FzExtName: ts + 18564 /* "closure" */, FpInit: 0}, 51375 {FzExtName: ts + 4686 /* "csv" */, FpInit: 0}, 51376 {FzExtName: ts + 4709 /* "decimal" */, FpInit: 0}, 51377 {FzExtName: ts + 4767 /* "eval" */, FpInit: 0}, 51378 {FzExtName: ts + 4845 /* "explain" */, FpInit: 0}, 51379 {FzExtName: ts + 18572 /* "fileio" */, FpInit: 0}, 51380 {FzExtName: ts + 5354 /* "fuzzer" */, FpInit: 0}, 51381 {FzExtName: ts + 5378 /* "ieee754" */, FpInit: 0}, 51382 {FzExtName: ts + 18579 /* "nextchar" */, FpInit: 0}, 51383 {FzExtName: ts + 5958 /* "percentile" */, FpInit: 0}, 51384 {FzExtName: ts + 6033 /* "prefixes" */, FpInit: 0}, 51385 {FzExtName: ts + 6345 /* "regexp" */, FpInit: 0}, 51386 {FzExtName: ts + 6352 /* "remember" */, FpInit: 0}, 51387 {FzExtName: ts + 18588 /* "series" */, FpInit: 0}, 51388 {FzExtName: ts + 18595 /* "spellfix" */, FpInit: 0}, 51389 {FzExtName: ts + 18604 /* "totype" */, FpInit: 0}, 51390 {FzExtName: ts + 8369 /* "unionvtab" */, FpInit: 0}, 51391 {FzExtName: ts + 8911 /* "wholenumber" */, FpInit: 0}, 51392 {FzExtName: ts + 9014 /* "zipfile" */, FpInit: 0}, 51393 } /* test1.c:7525:5 */ 51394 51395 // sorter_test_fakeheap BOOL 51396 // 51397 func sorter_test_fakeheap(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:7590:26: */ 51398 bp := tls.Alloc(4) 51399 defer tls.Free(4) 51400 51401 // var bArg int32 at bp, 4 51402 51403 if objc != 2 { 51404 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18611 /* "BOOL" */) 51405 return TCL_ERROR 51406 } 51407 51408 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &bArg */) != 0 { 51409 return TCL_ERROR 51410 } 51411 51412 if *(*int32)(unsafe.Pointer(bp /* bArg */)) != 0 { 51413 if sqlite3.Xsqlite3Config.FpHeap == uintptr(0) { 51414 sqlite3.Xsqlite3Config.FpHeap = libc.UintptrFromInt64(int64(-1)) 51415 } 51416 } else { 51417 if sqlite3.Xsqlite3Config.FpHeap == (libc.UintptrFromInt64(int64(-1))) { 51418 sqlite3.Xsqlite3Config.FpHeap = uintptr(0) 51419 } 51420 } 51421 51422 tcl.XTcl_ResetResult(tls, interp) 51423 return TCL_OK 51424 } 51425 51426 // sorter_test_sort4_helper DB SQL1 NSTEP SQL2 51427 // 51428 // Compile SQL statement $SQL1 and step it $NSTEP times. For each row, 51429 // check that the leftmost and rightmost columns returned are both integers, 51430 // and that both contain the same value. 51431 // 51432 // Then execute statement $SQL2. Check that the statement returns the same 51433 // set of integers in the same order as in the previous step (using $SQL1). 51434 func sorter_test_sort4_helper(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:7630:26: */ 51435 bp := tls.Alloc(80) 51436 defer tls.Free(80) 51437 51438 var zSql1 uintptr 51439 var zSql2 uintptr 51440 // var nStep int32 at bp+64, 4 51441 51442 var iStep int32 51443 var iCksum1 uint32 51444 var iCksum2 uint32 51445 var rc int32 51446 var iB int32 51447 // var db uintptr at bp+56, 8 51448 51449 // var pStmt uintptr at bp+72, 8 51450 51451 var a int32 51452 var a1 int32 51453 iCksum1 = uint32(0) 51454 iCksum2 = uint32(0) 51455 51456 if !(objc != 5) { 51457 goto __1 51458 } 51459 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18616 /* "DB SQL1 NSTEP SQ..." */) 51460 return TCL_ERROR 51461 __1: 51462 ; 51463 51464 if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+56 /* &db */) != 0) { 51465 goto __2 51466 } 51467 return TCL_ERROR 51468 __2: 51469 ; 51470 zSql1 = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 51471 if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+64 /* &nStep */) != 0) { 51472 goto __3 51473 } 51474 return TCL_ERROR 51475 __3: 51476 ; 51477 zSql2 = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8))) 51478 51479 rc = sqlite3.Xsqlite3_prepare_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* db */)), zSql1, -1, bp+72 /* &pStmt */, uintptr(0)) 51480 if !(rc != SQLITE_OK) { 51481 goto __4 51482 } 51483 goto sql_error 51484 __4: 51485 ; 51486 51487 iB = (sqlite3.Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */))) - 1) 51488 iStep = 0 51489 __5: 51490 if !((iStep < *(*int32)(unsafe.Pointer(bp + 64 /* nStep */))) && (SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */))))) { 51491 goto __7 51492 } 51493 a = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)), 0) 51494 if !(a != sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)), iB)) { 51495 goto __8 51496 } 51497 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+18635 /* "data error: (a!=..." */, 0)) 51498 return TCL_ERROR 51499 __8: 51500 ; 51501 51502 iCksum1 = iCksum1 + ((iCksum1 << 3) + uint32(a)) 51503 goto __6 51504 __6: 51505 iStep++ 51506 goto __5 51507 goto __7 51508 __7: 51509 ; 51510 rc = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */))) 51511 if !(rc != SQLITE_OK) { 51512 goto __9 51513 } 51514 goto sql_error 51515 __9: 51516 ; 51517 51518 rc = sqlite3.Xsqlite3_prepare_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* db */)), zSql2, -1, bp+72 /* &pStmt */, uintptr(0)) 51519 if !(rc != SQLITE_OK) { 51520 goto __10 51521 } 51522 goto sql_error 51523 __10: 51524 ; 51525 iStep = 0 51526 __11: 51527 if !(SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)))) { 51528 goto __13 51529 } 51530 a1 = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */)), 0) 51531 iCksum2 = iCksum2 + ((iCksum2 << 3) + uint32(a1)) 51532 goto __12 51533 __12: 51534 iStep++ 51535 goto __11 51536 goto __13 51537 __13: 51538 ; 51539 rc = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 72 /* pStmt */))) 51540 if !(rc != SQLITE_OK) { 51541 goto __14 51542 } 51543 goto sql_error 51544 __14: 51545 ; 51546 51547 if !(iCksum1 != iCksum2) { 51548 goto __15 51549 } 51550 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, ts+18654 /* "checksum mismatc..." */, 0)) 51551 return TCL_ERROR 51552 __15: 51553 ; 51554 51555 return TCL_OK 51556 sql_error: 51557 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+18672 /* "sql error: " */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 56 /* db */))), 0)) 51558 return TCL_ERROR 51559 } 51560 51561 // tclcmd: bad_behavior TYPE 51562 // 51563 // Do some things that should trigger a valgrind or -fsanitize=undefined 51564 // warning. This is used to verify that errors and warnings output by those 51565 // tools are detected by the test scripts. 51566 // 51567 // TYPE BEHAVIOR 51568 // 1 Overflow a signed integer 51569 // 2 Jump based on an uninitialized variable 51570 // 3 Read after free 51571 // 4 Panic 51572 func test_bad_behavior(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:7833:26: */ 51573 bp := tls.Alloc(44) 51574 defer tls.Free(44) 51575 51576 // var iType int32 at bp, 4 51577 51578 var xyz int32 51579 var i int32 = *(*int32)(unsafe.Pointer(clientData)) 51580 var j int32 51581 // var w [10]int32 at bp+4, 40 51582 51583 var a uintptr 51584 if objc != 2 { 51585 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18684 /* "TYPE" */) 51586 return TCL_ERROR 51587 } 51588 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &iType */) != 0 { 51589 return TCL_ERROR 51590 } 51591 switch *(*int32)(unsafe.Pointer(bp /* iType */)) { 51592 case 1: 51593 { 51594 xyz = (0x7fffff00 - i) 51595 xyz = xyz + (0x100) 51596 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, xyz)) 51597 break 51598 51599 } 51600 case 2: 51601 { 51602 *(*int32)(unsafe.Pointer(bp + 4 /* &w[0] */ + 1*4)) = 5 51603 if *(*int32)(unsafe.Pointer(bp + 4 /* &w[0] */ + uintptr(i)*4)) > 0 { 51604 *(*int32)(unsafe.Pointer(bp + 4 /* &w[0] */ + 1*4))++ 51605 } 51606 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 4 /* &w[0] */ + 1*4)))) 51607 break 51608 51609 } 51610 case 3: 51611 { 51612 a = libc.Xmalloc(tls, (uint64(unsafe.Sizeof(int32(0))) * uint64(10))) 51613 for j = 0; j < 10; j++ { 51614 *(*int32)(unsafe.Pointer(a + uintptr(j)*4)) = j 51615 } 51616 libc.Xfree(tls, a) 51617 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(a + uintptr(i)*4)))) 51618 break 51619 51620 } 51621 case 4: 51622 { 51623 tcl.XTcl_Panic(tls, ts+18689 /* "Deliberate panic" */, 0) 51624 break 51625 51626 } 51627 } 51628 return TCL_OK 51629 } 51630 51631 // tclcmd: register_dbstat_vtab DB 51632 // 51633 // Cause the dbstat virtual table to be available on the connection DB 51634 func test_register_dbstat_vtab(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:7883:26: */ 51635 bp := tls.Alloc(64) 51636 defer tls.Free(64) 51637 51638 var zDb uintptr 51639 // var cmdInfo Tcl_CmdInfo at bp, 64 51640 51641 if objc != 2 { 51642 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 51643 return TCL_ERROR 51644 } 51645 51646 zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 51647 if tcl.XTcl_GetCommandInfo(tls, interp, zDb, bp /* &cmdInfo */) != 0 { 51648 var db uintptr = (*struct{ Fdb uintptr })(unsafe.Pointer((*Tcl_CmdInfo)(unsafe.Pointer(bp /* &cmdInfo */)).FobjClientData)).Fdb 51649 sqlite3.Xsqlite3DbstatRegister(tls, db) 51650 } 51651 return TCL_OK 51652 } 51653 51654 // tclcmd: sqlite3_db_config DB SETTING VALUE 51655 // 51656 // Invoke sqlite3_db_config() for one of the setting values. 51657 func test_sqlite3_db_config(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:7917:26: */ 51658 bp := tls.Alloc(28) 51659 defer tls.Free(28) 51660 51661 var i int32 51662 *(*int32)(unsafe.Pointer(bp + 24 /* v */)) = 0 51663 var zSetting uintptr 51664 // var db uintptr at bp+16, 8 51665 51666 if (objc != 4) && (objc != 3) { 51667 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18706 /* "DB SETTING [VALU..." */) 51668 return TCL_ERROR 51669 } 51670 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+16 /* &db */) != 0 { 51671 return TCL_ERROR 51672 } 51673 zSetting = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 51674 if sqlite3.Xsqlite3_strglob(tls, ts+18725 /* "SQLITE_*" */, zSetting) == 0 { 51675 zSetting += uintptr(7) 51676 } 51677 if sqlite3.Xsqlite3_strglob(tls, ts+18734 /* "DBCONFIG_*" */, zSetting) == 0 { 51678 zSetting += uintptr(9) 51679 } 51680 if sqlite3.Xsqlite3_strglob(tls, ts+18745 /* "ENABLE_*" */, zSetting) == 0 { 51681 zSetting += uintptr(7) 51682 } 51683 for i = 0; i < (int32(uint64(unsafe.Sizeof(aSetting)) / uint64(unsafe.Sizeof(struct { 51684 FzName uintptr 51685 FeVal int32 51686 _ [4]byte 51687 }{})))); i++ { 51688 if libc.Xstrcmp(tls, zSetting, aSetting[i].FzName) == 0 { 51689 break 51690 } 51691 } 51692 if i >= (int32(uint64(unsafe.Sizeof(aSetting)) / uint64(unsafe.Sizeof(struct { 51693 FzName uintptr 51694 FeVal int32 51695 _ [4]byte 51696 }{})))) { 51697 tcl.XTcl_SetObjResult(tls, interp, 51698 tcl.XTcl_NewStringObj(tls, ts+18754 /* "unknown sqlite3_..." */, -1)) 51699 return TCL_ERROR 51700 } 51701 if objc == 4 { 51702 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+24 /* &v */) != 0 { 51703 return TCL_ERROR 51704 } 51705 } else { 51706 *(*int32)(unsafe.Pointer(bp + 24 /* v */)) = -1 51707 } 51708 sqlite3.Xsqlite3_db_config(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), aSetting[i].FeVal, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 24 /* v */)), bp+24 /* &v */)) 51709 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 24 /* v */)))) 51710 return TCL_OK 51711 } 51712 51713 var aSetting = [14]struct { 51714 FzName uintptr 51715 FeVal int32 51716 _ [4]byte 51717 }{ 51718 {FzName: ts + 18788 /* "FKEY" */, FeVal: SQLITE_DBCONFIG_ENABLE_FKEY}, 51719 {FzName: ts + 18793 /* "TRIGGER" */, FeVal: SQLITE_DBCONFIG_ENABLE_TRIGGER}, 51720 {FzName: ts + 18801 /* "FTS3_TOKENIZER" */, FeVal: SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER}, 51721 {FzName: ts + 18816 /* "LOAD_EXTENSION" */, FeVal: SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION}, 51722 {FzName: ts + 18831 /* "NO_CKPT_ON_CLOSE" */, FeVal: SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE}, 51723 {FzName: ts + 18848 /* "QPSG" */, FeVal: SQLITE_DBCONFIG_ENABLE_QPSG}, 51724 {FzName: ts + 18853 /* "TRIGGER_EQP" */, FeVal: SQLITE_DBCONFIG_TRIGGER_EQP}, 51725 {FzName: ts + 18865 /* "RESET_DB" */, FeVal: SQLITE_DBCONFIG_RESET_DATABASE}, 51726 {FzName: ts + 18874 /* "DEFENSIVE" */, FeVal: SQLITE_DBCONFIG_DEFENSIVE}, 51727 {FzName: ts + 18884 /* "WRITABLE_SCHEMA" */, FeVal: SQLITE_DBCONFIG_WRITABLE_SCHEMA}, 51728 {FzName: ts + 18900 /* "LEGACY_ALTER_TAB..." */, FeVal: SQLITE_DBCONFIG_LEGACY_ALTER_TABLE}, 51729 {FzName: ts + 18919 /* "DQS_DML" */, FeVal: SQLITE_DBCONFIG_DQS_DML}, 51730 {FzName: ts + 18927 /* "DQS_DDL" */, FeVal: SQLITE_DBCONFIG_DQS_DDL}, 51731 {FzName: ts + 18935 /* "LEGACY_FILE_FORM..." */, FeVal: SQLITE_DBCONFIG_LEGACY_FILE_FORMAT}, 51732 } /* test1.c:7926:5 */ 51733 51734 // tclcmd: sqlite3_txn_state DB ?SCHEMA? 51735 // 51736 // Invoke sqlite3_txn_state(DB,SCHEMA) and return the 51737 // numeric value that results. Use NULL for SCHEMA if the 3 argument 51738 // is omitted. 51739 func test_sqlite3_txn_state(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:7980:26: */ 51740 bp := tls.Alloc(8) 51741 defer tls.Free(8) 51742 51743 // var db uintptr at bp, 8 51744 51745 var zSchema uintptr 51746 var iTxn int32 51747 51748 if (objc != 2) && (objc != 3) { 51749 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18954 /* "DB ?SCHEMA?" */) 51750 return TCL_ERROR 51751 } 51752 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 51753 return TCL_ERROR 51754 } 51755 if objc == 3 { 51756 zSchema = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 51757 } else { 51758 zSchema = uintptr(0) 51759 } 51760 iTxn = sqlite3.Xsqlite3_txn_state(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zSchema) 51761 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, iTxn)) 51762 return TCL_OK 51763 } 51764 51765 // Change the name of the main database schema from "main" to "icecube". 51766 func test_dbconfig_maindbname_icecube(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:8004:26: */ 51767 bp := tls.Alloc(16) 51768 defer tls.Free(16) 51769 51770 var rc int32 51771 // var db uintptr at bp+8, 8 51772 51773 if objc != 2 { 51774 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 51775 return TCL_ERROR 51776 } else { 51777 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+8 /* &db */) != 0 { 51778 return TCL_ERROR 51779 } 51780 rc = sqlite3.Xsqlite3_db_config(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* db */)), SQLITE_DBCONFIG_MAINDBNAME, libc.VaList(bp, ts+18966 /* "icecube" */)) 51781 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) 51782 return TCL_OK 51783 } 51784 return int32(0) 51785 } 51786 51787 // Usage: sqlite3_mmap_warm DB DBNAME 51788 func test_mmap_warm(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:8027:26: */ 51789 bp := tls.Alloc(8) 51790 defer tls.Free(8) 51791 51792 if (objc != 2) && (objc != 3) { 51793 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18974 /* "DB ?DBNAME?" */) 51794 return TCL_ERROR 51795 } else { 51796 var rc int32 51797 // var db uintptr at bp, 8 51798 51799 var zDb uintptr = uintptr(0) 51800 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 51801 return TCL_ERROR 51802 } 51803 if objc == 3 { 51804 zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 51805 } 51806 rc = sqlite3_mmap_warm(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zDb) 51807 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 51808 return TCL_OK 51809 } 51810 return int32(0) 51811 } 51812 51813 // Usage: test_write_db DB OFFSET DATA 51814 // 51815 // Obtain the sqlite3_file* object for the database file for the "main" db 51816 // of handle DB. Then invoke its xWrite method to write data DATA to offset 51817 // OFFSET. 51818 func test_write_db(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:8060:26: */ 51819 bp := tls.Alloc(32) 51820 defer tls.Free(32) 51821 51822 *(*uintptr)(unsafe.Pointer(bp /* db */)) = uintptr(0) 51823 *(*Tcl_WideInt)(unsafe.Pointer(bp + 8 /* iOff */)) = int64(0) 51824 var aData uintptr = uintptr(0) 51825 *(*int32)(unsafe.Pointer(bp + 16 /* nData */)) = 0 51826 *(*uintptr)(unsafe.Pointer(bp + 24 /* pFile */)) = uintptr(0) 51827 var rc int32 51828 51829 if objc != 4 { 51830 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18986 /* "DB OFFSET DATA" */) 51831 return TCL_ERROR 51832 } 51833 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 51834 return TCL_ERROR 51835 } 51836 if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &iOff */) != 0 { 51837 return TCL_ERROR 51838 } 51839 aData = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+16 /* &nData */) 51840 51841 sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+85 /* "main" */, SQLITE_FCNTL_FILE_POINTER, bp+24 /* &pFile */) 51842 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 24 /* pFile */)))).FpMethods + 24 /* &.xWrite */))))(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pFile */)), aData, *(*int32)(unsafe.Pointer(bp + 16 /* nData */)), *(*Tcl_WideInt)(unsafe.Pointer(bp + 8 /* iOff */))) 51843 51844 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 51845 return TCL_OK 51846 } 51847 51848 // Usage: sqlite3_register_cksumvfs 51849 // 51850 func test_register_cksumvfs(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:8092:26: */ 51851 if objc != 1 { 51852 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 51853 return TCL_ERROR 51854 } else { 51855 var rc int32 = sqlite3_register_cksumvfs(tls, uintptr(0)) 51856 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 51857 } 51858 return TCL_OK 51859 } 51860 51861 // Usage: sqlite3_unregister_cksumvfs 51862 // 51863 func test_unregister_cksumvfs(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:8113:26: */ 51864 if objc != 1 { 51865 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 51866 return TCL_ERROR 51867 } else { 51868 var rc int32 = sqlite3_unregister_cksumvfs(tls) 51869 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 51870 } 51871 return TCL_OK 51872 } 51873 51874 // Usage: decode_hexdb TEXT 51875 // 51876 // Example: db deserialize [decode_hexdb $output_of_dbtotxt] 51877 // 51878 // This routine returns a byte-array for an SQLite database file that 51879 // is constructed from a text input which is the output of the "dbtotxt" 51880 // utility. 51881 func test_decode_hexdb(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test1.c:8139:26: */ 51882 bp := tls.Alloc(296) 51883 defer tls.Free(296) 51884 51885 var zIn uintptr = uintptr(0) 51886 var a uintptr = uintptr(0) 51887 *(*int32)(unsafe.Pointer(bp + 216 /* n */)) = 0 51888 var lineno int32 = 0 51889 var i int32 51890 var iNext int32 51891 var iOffset int32 = 0 51892 // var j int32 at bp+224, 4 51893 51894 // var k int32 at bp+228, 4 51895 51896 var rc int32 51897 // var x [16]uint32 at bp+232, 64 51898 51899 if objc != 2 { 51900 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+19001 /* "HEXDB" */) 51901 return TCL_ERROR 51902 } 51903 zIn = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 51904 for i = 0; *(*int8)(unsafe.Pointer(zIn + uintptr(i))) != 0; i = iNext { 51905 lineno++ 51906 for iNext = i; (*(*int8)(unsafe.Pointer(zIn + uintptr(iNext))) != 0) && (int32(*(*int8)(unsafe.Pointer(zIn + uintptr(iNext)))) != '\n'); iNext++ { 51907 } 51908 if int32(*(*int8)(unsafe.Pointer(zIn + uintptr(iNext)))) == '\n' { 51909 iNext++ 51910 } 51911 for (int32(*(*int8)(unsafe.Pointer(zIn + uintptr(i)))) == ' ') || (int32(*(*int8)(unsafe.Pointer(zIn + uintptr(i)))) == '\t') { 51912 i++ 51913 } 51914 if a == uintptr(0) { 51915 // var pgsz int32 at bp+220, 4 51916 51917 rc = libc.Xsscanf(tls, (zIn + uintptr(i)), ts+19007 /* "| size %d pagesi..." */, libc.VaList(bp, bp+216 /* &n */, bp+220 /* &pgsz */)) 51918 if rc != 2 { 51919 continue 51920 } 51921 if ((*(*int32)(unsafe.Pointer(bp + 220 /* pgsz */)) < 512) || (*(*int32)(unsafe.Pointer(bp + 220 /* pgsz */)) > 65536)) || ((*(*int32)(unsafe.Pointer(bp + 220 /* pgsz */)) & (*(*int32)(unsafe.Pointer(bp + 220 /* pgsz */)) - 1)) != 0) { 51922 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, ts+19029 /* "bad 'pagesize' f..." */, uintptr(0))) 51923 return TCL_ERROR 51924 } 51925 *(*int32)(unsafe.Pointer(bp + 216 /* n */)) = (((*(*int32)(unsafe.Pointer(bp + 216 /* n */)) + *(*int32)(unsafe.Pointer(bp + 220 /* pgsz */))) - 1) & ^(*(*int32)(unsafe.Pointer(bp + 220 /* pgsz */)) - 1)) // Round n up to the next multiple of pgsz 51926 if *(*int32)(unsafe.Pointer(bp + 216 /* n */)) < 512 { 51927 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+19050 /* "bad 'size' field" */, uintptr(0))) 51928 return TCL_ERROR 51929 } 51930 a = libc.Xmalloc(tls, uint64(*(*int32)(unsafe.Pointer(bp + 216 /* n */)))) 51931 if a == uintptr(0) { 51932 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+1930 /* "out of memory" */, uintptr(0))) 51933 return TCL_ERROR 51934 } 51935 libc.Xmemset(tls, a, 0, uint64(*(*int32)(unsafe.Pointer(bp + 216 /* n */)))) 51936 continue 51937 } 51938 rc = libc.Xsscanf(tls, (zIn + uintptr(i)), ts+19067 /* "| page %d offset..." */, libc.VaList(bp+64, bp+224 /* &j */, bp+228 /* &k */)) 51939 if rc == 2 { 51940 iOffset = *(*int32)(unsafe.Pointer(bp + 228 /* k */)) 51941 continue 51942 } 51943 rc = libc.Xsscanf(tls, (zIn + uintptr(i)), ts+19087, /* "| %d: %x %x %x %..." */ 51944 libc.VaList(bp+80, bp+224 /* &j */, (bp+232 /* &x */), (bp+232 /* &x */ +1*4), (bp+232 /* &x */ +2*4), (bp+232 /* &x */ +3*4), (bp+232 /* &x */ +4*4), (bp+232 /* &x */ +5*4), (bp+232 /* &x */ +6*4), (bp+232 /* &x */ +7*4), 51945 (bp+232 /* &x */ +8*4), (bp+232 /* &x */ +9*4), (bp+232 /* &x */ +10*4), (bp+232 /* &x */ +11*4), (bp+232 /* &x */ +12*4), (bp+232 /* &x */ +13*4), (bp+232 /* &x */ +14*4), (bp+232 /* &x */ +15*4))) 51946 if rc == 17 { 51947 *(*int32)(unsafe.Pointer(bp + 228 /* k */)) = (iOffset + *(*int32)(unsafe.Pointer(bp + 224 /* j */))) 51948 if (*(*int32)(unsafe.Pointer(bp + 228 /* k */)) + 16) <= *(*int32)(unsafe.Pointer(bp + 216 /* n */)) { 51949 var ii int32 51950 for ii = 0; ii < 16; ii++ { 51951 *(*uint8)(unsafe.Pointer(a + uintptr((*(*int32)(unsafe.Pointer(bp + 228 /* k */)) + ii)))) = (uint8(*(*uint32)(unsafe.Pointer(bp + 232 /* &x[0] */ + uintptr(ii)*4)) & uint32(0xff))) 51952 } 51953 } 51954 continue 51955 } 51956 } 51957 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewByteArrayObj(tls, a, *(*int32)(unsafe.Pointer(bp + 216 /* n */)))) 51958 libc.Xfree(tls, a) 51959 return TCL_OK 51960 } 51961 51962 // Register commands with the TCL interpreter. 51963 func Sqlitetest1_Init(tls *libc.TLS, interp uintptr) int32 { /* test1.c:8211:5: */ 51964 var i int32 51965 51966 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aCmd1)) / uint64(unsafe.Sizeof(struct { 51967 FzName uintptr 51968 FxProc uintptr 51969 }{}))); i++ { 51970 tcl.XTcl_CreateCommand(tls, interp, aCmd1[i].FzName, aCmd1[i].FxProc, uintptr(0), uintptr(0)) 51971 } 51972 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aObjCmd1)) / uint64(unsafe.Sizeof(struct { 51973 FzName uintptr 51974 FxProc uintptr 51975 FclientData uintptr 51976 }{}))); i++ { 51977 tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd1[i].FzName, 51978 aObjCmd1[i].FxProc, aObjCmd1[i].FclientData, uintptr(0)) 51979 } 51980 tcl.XTcl_LinkVar(tls, interp, ts+19141, /* "sqlite_search_co..." */ 51981 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_search_count)), TCL_LINK_INT) 51982 tcl.XTcl_LinkVar(tls, interp, ts+19161, /* "sqlite_found_cou..." */ 51983 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_found_count)), TCL_LINK_INT) 51984 tcl.XTcl_LinkVar(tls, interp, ts+19180, /* "sqlite_sort_coun..." */ 51985 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_sort_count)), TCL_LINK_INT) 51986 tcl.XTcl_LinkVar(tls, interp, ts+19198, /* "sqlite3_max_blob..." */ 51987 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_max_blobsize)), TCL_LINK_INT) 51988 tcl.XTcl_LinkVar(tls, interp, ts+19219, /* "sqlite_like_coun..." */ 51989 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_like_count)), TCL_LINK_INT) 51990 tcl.XTcl_LinkVar(tls, interp, ts+19237, /* "sqlite_interrupt..." */ 51991 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_interrupt_count)), TCL_LINK_INT) 51992 tcl.XTcl_LinkVar(tls, interp, ts+19260, /* "sqlite_open_file..." */ 51993 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_open_file_count)), TCL_LINK_INT) 51994 tcl.XTcl_LinkVar(tls, interp, ts+19283, /* "sqlite_current_t..." */ 51995 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_current_time)), TCL_LINK_INT) 51996 tcl.XTcl_LinkVar(tls, interp, ts+19303, /* "sqlite3_xferopt_..." */ 51997 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_xferopt_count)), TCL_LINK_INT) 51998 tcl.XTcl_LinkVar(tls, interp, ts+19325, /* "sqlite3_pager_re..." */ 51999 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_pager_readdb_count)), TCL_LINK_INT) 52000 tcl.XTcl_LinkVar(tls, interp, ts+19352, /* "sqlite3_pager_wr..." */ 52001 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_pager_writedb_count)), TCL_LINK_INT) 52002 tcl.XTcl_LinkVar(tls, interp, ts+19380, /* "sqlite3_pager_wr..." */ 52003 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_pager_writej_count)), TCL_LINK_INT) 52004 tcl.XTcl_LinkVar(tls, interp, ts+19407, /* "unaligned_string..." */ 52005 uintptr(unsafe.Pointer(&unaligned_string_counter)), TCL_LINK_INT) 52006 tcl.XTcl_LinkVar(tls, interp, ts+19432, /* "sqlite_last_need..." */ 52007 uintptr(unsafe.Pointer(&pzNeededCollation)), (TCL_LINK_STRING | TCL_LINK_READ_ONLY)) 52008 { 52009 tcl.XTcl_LinkVar(tls, interp, ts+19461, /* "sqlite_query_pla..." */ 52010 uintptr(unsafe.Pointer(&query_plan)), (TCL_LINK_STRING | TCL_LINK_READ_ONLY)) 52011 52012 } 52013 tcl.XTcl_LinkVar(tls, interp, ts+19479, /* "sqlite_opentemp_..." */ 52014 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_opentemp_count)), TCL_LINK_INT) 52015 tcl.XTcl_LinkVar(tls, interp, ts+19501, /* "sqlite_static_bi..." */ 52016 uintptr(unsafe.Pointer(&sqlite_static_bind_value)), TCL_LINK_STRING) 52017 tcl.XTcl_LinkVar(tls, interp, ts+19526, /* "sqlite_static_bi..." */ 52018 uintptr(unsafe.Pointer(&sqlite_static_bind_nbyte)), TCL_LINK_INT) 52019 tcl.XTcl_LinkVar(tls, interp, ts+19551, /* "sqlite_temp_dire..." */ 52020 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_temp_directory)), TCL_LINK_STRING) 52021 tcl.XTcl_LinkVar(tls, interp, ts+19573, /* "sqlite_data_dire..." */ 52022 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_data_directory)), TCL_LINK_STRING) 52023 tcl.XTcl_LinkVar(tls, interp, ts+19595, /* "bitmask_size" */ 52024 uintptr(unsafe.Pointer(&bitmask_size)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 52025 tcl.XTcl_LinkVar(tls, interp, ts+19608, /* "longdouble_size" */ 52026 uintptr(unsafe.Pointer(&longdouble_size)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 52027 tcl.XTcl_LinkVar(tls, interp, ts+19624, /* "sqlite_sync_coun..." */ 52028 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_sync_count)), TCL_LINK_INT) 52029 tcl.XTcl_LinkVar(tls, interp, ts+19642, /* "sqlite_fullsync_..." */ 52030 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_fullsync_count)), TCL_LINK_INT) 52031 return TCL_OK 52032 } 52033 52034 var iZero int32 = 0 /* test1.c:8224:14 */ 52035 var aCmd1 = [40]struct { 52036 FzName uintptr 52037 FxProc uintptr 52038 }{ 52039 {FzName: ts + 19664 /* "db_enter" */, FxProc: 0}, 52040 {FzName: ts + 19673 /* "db_leave" */, FxProc: 0}, 52041 {FzName: ts + 19682 /* "sqlite3_mprintf_..." */, FxProc: 0}, 52042 {FzName: ts + 19702 /* "sqlite3_mprintf_..." */, FxProc: 0}, 52043 {FzName: ts + 19724 /* "sqlite3_mprintf_..." */, FxProc: 0}, 52044 {FzName: ts + 19745 /* "sqlite3_mprintf_..." */, FxProc: 0}, 52045 {FzName: ts + 19765 /* "sqlite3_snprintf..." */, FxProc: 0}, 52046 {FzName: ts + 19786 /* "sqlite3_mprintf_..." */, FxProc: 0}, 52047 {FzName: ts + 19810 /* "sqlite3_mprintf_..." */, FxProc: 0}, 52048 {FzName: ts + 19833 /* "sqlite3_mprintf_..." */, FxProc: 0}, 52049 {FzName: ts + 19856 /* "sqlite3_mprintf_..." */, FxProc: 0}, 52050 {FzName: ts + 19882 /* "sqlite3_mprintf_..." */, FxProc: 0}, 52051 {FzName: ts + 19905 /* "sqlite3_mprintf_..." */, FxProc: 0}, 52052 {FzName: ts + 19928 /* "sqlite3_snprintf..." */, FxProc: 0}, 52053 {FzName: ts + 19949 /* "sqlite3_last_ins..." */, FxProc: 0}, 52054 {FzName: ts + 19975 /* "sqlite3_exec_pri..." */, FxProc: 0}, 52055 {FzName: ts + 19995 /* "sqlite3_exec_hex" */, FxProc: 0}, 52056 {FzName: ts + 20012 /* "sqlite3_exec" */, FxProc: 0}, 52057 {FzName: ts + 20025 /* "sqlite3_exec_nr" */, FxProc: 0}, 52058 {FzName: ts + 20041 /* "sqlite3_get_tabl..." */, FxProc: 0}, 52059 {FzName: ts + 20066 /* "sqlite3_close" */, FxProc: 0}, 52060 {FzName: ts + 20080 /* "sqlite3_close_v2" */, FxProc: 0}, 52061 {FzName: ts + 20097 /* "sqlite3_create_f..." */, FxProc: 0}, 52062 {FzName: ts + 20121 /* "sqlite3_create_a..." */, FxProc: 0}, 52063 {FzName: ts + 20146 /* "sqlite3_drop_mod..." */, FxProc: 0}, 52064 {FzName: ts + 20167 /* "sqlite_register_..." */, FxProc: 0}, 52065 {FzName: ts + 20197 /* "sqlite_abort" */, FxProc: 0}, 52066 {FzName: ts + 20210 /* "sqlite_bind" */, FxProc: 0}, 52067 {FzName: ts + 20222 /* "breakpoint" */, FxProc: 0}, 52068 {FzName: ts + 20233 /* "sqlite3_key" */, FxProc: 0}, 52069 {FzName: ts + 20245 /* "sqlite3_rekey" */, FxProc: 0}, 52070 {FzName: ts + 20259 /* "sqlite_set_magic" */, FxProc: 0}, 52071 {FzName: ts + 20276 /* "sqlite3_interrup..." */, FxProc: 0}, 52072 {FzName: ts + 20294 /* "sqlite_delete_fu..." */, FxProc: 0}, 52073 {FzName: ts + 20317 /* "sqlite_delete_co..." */, FxProc: 0}, 52074 {FzName: ts + 20341 /* "sqlite3_get_auto..." */, FxProc: 0}, 52075 {FzName: ts + 20364 /* "sqlite3_busy_tim..." */, FxProc: 0}, 52076 {FzName: ts + 20385 /* "printf" */, FxProc: 0}, 52077 {FzName: ts + 20392 /* "sqlite3IoTrace" */, FxProc: 0}, 52078 {FzName: ts + 20407 /* "clang_sanitize_a..." */, FxProc: 0}, 52079 } /* test1.c:8228:5 */ 52080 var aObjCmd1 = [160]struct { 52081 FzName uintptr 52082 FxProc uintptr 52083 FclientData uintptr 52084 }{ 52085 {FzName: ts + 20430 /* "sqlite3_db_confi..." */, FxProc: 0}, 52086 {FzName: ts + 20448 /* "sqlite3_txn_stat..." */, FxProc: 0}, 52087 {FzName: ts + 20466 /* "bad_behavior" */, FxProc: 0, FclientData: 0}, 52088 {FzName: ts + 20479 /* "register_dbstat_..." */, FxProc: 0}, 52089 {FzName: ts + 20500 /* "sqlite3_connecti..." */, FxProc: 0}, 52090 {FzName: ts + 20527 /* "intarray_addr" */, FxProc: 0}, 52091 {FzName: ts + 20541 /* "int64array_addr" */, FxProc: 0}, 52092 {FzName: ts + 20557 /* "doublearray_addr" */, FxProc: 0}, 52093 {FzName: ts + 20574 /* "textarray_addr" */, FxProc: 0}, 52094 {FzName: ts + 20589 /* "sqlite3_bind_int" */, FxProc: 0}, 52095 {FzName: ts + 20606 /* "sqlite3_bind_zer..." */, FxProc: 0}, 52096 {FzName: ts + 20628 /* "sqlite3_bind_zer..." */, FxProc: 0}, 52097 {FzName: ts + 20652 /* "sqlite3_bind_int..." */, FxProc: 0}, 52098 {FzName: ts + 20671 /* "sqlite3_bind_dou..." */, FxProc: 0}, 52099 {FzName: ts + 20691 /* "sqlite3_bind_nul..." */, FxProc: 0}, 52100 {FzName: ts + 20709 /* "sqlite3_bind_tex..." */, FxProc: 0}, 52101 {FzName: ts + 20727 /* "sqlite3_bind_tex..." */, FxProc: 0}, 52102 {FzName: ts + 20747 /* "sqlite3_bind_blo..." */, FxProc: 0}, 52103 {FzName: ts + 20765 /* "sqlite3_carray_b..." */, FxProc: 0}, 52104 {FzName: ts + 20785 /* "sqlite3_bind_par..." */, FxProc: 0}, 52105 {FzName: ts + 20814 /* "sqlite3_bind_par..." */, FxProc: 0}, 52106 {FzName: ts + 20842 /* "sqlite3_bind_par..." */, FxProc: 0}, 52107 {FzName: ts + 20871 /* "sqlite3_clear_bi..." */, FxProc: 0}, 52108 {FzName: ts + 20894 /* "sqlite3_sleep" */, FxProc: 0}, 52109 {FzName: ts + 20908 /* "sqlite3_errcode" */, FxProc: 0}, 52110 {FzName: ts + 20924 /* "sqlite3_extended..." */, FxProc: 0}, 52111 {FzName: ts + 20949 /* "sqlite3_errmsg" */, FxProc: 0}, 52112 {FzName: ts + 20964 /* "sqlite3_errmsg16" */, FxProc: 0}, 52113 {FzName: ts + 20981 /* "sqlite3_open" */, FxProc: 0}, 52114 {FzName: ts + 20994 /* "sqlite3_open16" */, FxProc: 0}, 52115 {FzName: ts + 21009 /* "sqlite3_open_v2" */, FxProc: 0}, 52116 {FzName: ts + 21025 /* "sqlite3_complete..." */, FxProc: 0}, 52117 {FzName: ts + 21044 /* "sqlite3_normaliz..." */, FxProc: 0}, 52118 52119 {FzName: ts + 21062 /* "sqlite3_prepare" */, FxProc: 0}, 52120 {FzName: ts + 21078 /* "sqlite3_prepare1..." */, FxProc: 0}, 52121 {FzName: ts + 21096 /* "sqlite3_prepare_..." */, FxProc: 0}, 52122 {FzName: ts + 21115 /* "sqlite3_prepare_..." */, FxProc: 0}, 52123 {FzName: ts + 21134 /* "sqlite3_prepare_..." */, FxProc: 0}, 52124 {FzName: ts + 21158 /* "sqlite3_prepare1..." */, FxProc: 0}, 52125 {FzName: ts + 21179 /* "sqlite3_finalize" */, FxProc: 0}, 52126 {FzName: ts + 21196 /* "sqlite3_stmt_sta..." */, FxProc: 0}, 52127 {FzName: ts + 21216 /* "sqlite3_reset" */, FxProc: 0}, 52128 {FzName: ts + 21230 /* "sqlite3_expired" */, FxProc: 0}, 52129 {FzName: ts + 21246 /* "sqlite3_transfer..." */, FxProc: 0}, 52130 {FzName: ts + 21272 /* "sqlite3_changes" */, FxProc: 0}, 52131 {FzName: ts + 21288 /* "sqlite3_step" */, FxProc: 0}, 52132 {FzName: ts + 21301 /* "sqlite3_sql" */, FxProc: 0}, 52133 {FzName: ts + 21313 /* "sqlite3_expanded..." */, FxProc: 0}, 52134 {FzName: ts + 21334 /* "sqlite3_next_stm..." */, FxProc: 0}, 52135 {FzName: ts + 21352 /* "sqlite3_stmt_rea..." */, FxProc: 0}, 52136 {FzName: ts + 21374 /* "sqlite3_stmt_ise..." */, FxProc: 0}, 52137 {FzName: ts + 21397 /* "sqlite3_stmt_bus..." */, FxProc: 0}, 52138 {FzName: ts + 21415 /* "uses_stmt_journa..." */, FxProc: 0}, 52139 52140 {FzName: ts + 21433 /* "sqlite3_release_..." */, FxProc: 0}, 52141 {FzName: ts + 21456 /* "sqlite3_db_relea..." */, FxProc: 0}, 52142 {FzName: ts + 21482 /* "sqlite3_db_cache..." */, FxProc: 0}, 52143 {FzName: ts + 21504 /* "sqlite3_system_e..." */, FxProc: 0}, 52144 {FzName: ts + 21525 /* "sqlite3_db_filen..." */, FxProc: 0}, 52145 {FzName: ts + 21545 /* "sqlite3_db_reado..." */, FxProc: 0}, 52146 {FzName: ts + 21565 /* "sqlite3_soft_hea..." */, FxProc: 0}, 52147 {FzName: ts + 21589 /* "sqlite3_soft_hea..." */, FxProc: 0}, 52148 {FzName: ts + 21615 /* "sqlite3_hard_hea..." */, FxProc: 0}, 52149 {FzName: ts + 21641 /* "sqlite3_thread_c..." */, FxProc: 0}, 52150 {FzName: ts + 21664 /* "sqlite3_pager_re..." */, FxProc: 0}, 52151 52152 {FzName: ts + 21688 /* "sqlite3_load_ext..." */, FxProc: 0}, 52153 {FzName: ts + 21711 /* "sqlite3_enable_l..." */, FxProc: 0}, 52154 {FzName: ts + 21741 /* "sqlite3_extended..." */, FxProc: 0}, 52155 {FzName: ts + 21771 /* "sqlite3_limit" */, FxProc: 0}, 52156 {FzName: ts + 21785 /* "dbconfig_maindbn..." */, FxProc: 0}, 52157 52158 {FzName: ts + 21813 /* "save_prng_state" */, FxProc: 0}, 52159 {FzName: ts + 21829 /* "restore_prng_sta..." */, FxProc: 0}, 52160 {FzName: ts + 21848 /* "reset_prng_state" */, FxProc: 0}, 52161 {FzName: ts + 21865 /* "prng_seed" */, FxProc: 0}, 52162 {FzName: ts + 21875 /* "extra_schema_che..." */, FxProc: 0}, 52163 {FzName: ts + 21895 /* "database_never_c..." */, FxProc: 0}, 52164 {FzName: ts + 21918 /* "database_may_be_..." */, FxProc: 0}, 52165 {FzName: ts + 21942 /* "optimization_con..." */, FxProc: 0}, 52166 {FzName: ts + 21963 /* "tcl_objproc" */, FxProc: 0}, 52167 52168 // sqlite3_column_*() API 52169 {FzName: ts + 21975 /* "sqlite3_column_c..." */, FxProc: 0}, 52170 {FzName: ts + 21996 /* "sqlite3_data_cou..." */, FxProc: 0}, 52171 {FzName: ts + 22015 /* "sqlite3_column_t..." */, FxProc: 0}, 52172 {FzName: ts + 22035 /* "sqlite3_column_b..." */, FxProc: 0}, 52173 {FzName: ts + 22055 /* "sqlite3_column_d..." */, FxProc: 0}, 52174 {FzName: ts + 22077 /* "sqlite3_column_i..." */, FxProc: 0}, 52175 {FzName: ts + 22098 /* "sqlite3_column_t..." */, FxProc: 0, FclientData: 0}, 52176 {FzName: ts + 22118 /* "sqlite3_column_n..." */, FxProc: 0, FclientData: 0}, 52177 {FzName: ts + 22138 /* "sqlite3_column_i..." */, FxProc: 0, FclientData: 0}, 52178 {FzName: ts + 22157 /* "sqlite3_column_b..." */, FxProc: 0, FclientData: 0}, 52179 {FzName: ts + 22178 /* "sqlite3_column_d..." */, FxProc: 0, FclientData: 0}, 52180 {FzName: ts + 22202 /* "sqlite3_column_d..." */, FxProc: 0, FclientData: 0}, 52181 {FzName: ts + 22231 /* "sqlite3_column_t..." */, FxProc: 0, FclientData: 0}, 52182 {FzName: ts + 22257 /* "sqlite3_column_o..." */, FxProc: 0, FclientData: 0}, 52183 52184 {FzName: ts + 22284 /* "sqlite3_column_b..." */, FxProc: 0, FclientData: 0}, 52185 {FzName: ts + 22307 /* "sqlite3_column_t..." */, FxProc: 0, FclientData: 0}, 52186 {FzName: ts + 22329 /* "sqlite3_column_n..." */, FxProc: 0, FclientData: 0}, 52187 {FzName: ts + 22351 /* "add_alignment_te..." */, FxProc: 0}, 52188 {FzName: ts + 22381 /* "sqlite3_column_d..." */, FxProc: 0, FclientData: 0}, 52189 {FzName: ts + 22407, /* "sqlite3_column_d..." */ 52190 FxProc: 0, FclientData: 0}, 52191 {FzName: ts + 22438 /* "sqlite3_column_t..." */, FxProc: 0, FclientData: 0}, 52192 {FzName: ts + 22466 /* "sqlite3_column_o..." */, FxProc: 0, FclientData: 0}, 52193 {FzName: ts + 22495 /* "sqlite3_create_c..." */, FxProc: 0}, 52194 {FzName: ts + 22523 /* "sqlite3_global_r..." */, FxProc: 0}, 52195 {FzName: ts + 22546 /* "working_64bit_in..." */, FxProc: 0}, 52196 {FzName: ts + 22564 /* "vfs_unlink_test" */, FxProc: 0}, 52197 {FzName: ts + 22580 /* "vfs_initfail_tes..." */, FxProc: 0}, 52198 {FzName: ts + 22598 /* "vfs_unregister_a..." */, FxProc: 0}, 52199 {FzName: ts + 22617 /* "vfs_reregister_a..." */, FxProc: 0}, 52200 {FzName: ts + 22636 /* "file_control_tes..." */, FxProc: 0}, 52201 {FzName: ts + 22654 /* "file_control_las..." */, FxProc: 0}, 52202 {FzName: ts + 22682 /* "file_control_loc..." */, FxProc: 0}, 52203 {FzName: ts + 22710 /* "file_control_chu..." */, FxProc: 0}, 52204 {FzName: ts + 22738 /* "file_control_siz..." */, FxProc: 0}, 52205 {FzName: ts + 22765 /* "file_control_dat..." */, FxProc: 0}, 52206 {FzName: ts + 22791 /* "file_control_per..." */, FxProc: 0}, 52207 {FzName: ts + 22816 /* "file_control_pow..." */, FxProc: 0}, 52208 {FzName: ts + 22849 /* "file_control_vfs..." */, FxProc: 0}, 52209 {FzName: ts + 22870 /* "file_control_res..." */, FxProc: 0}, 52210 {FzName: ts + 22896 /* "file_control_tem..." */, FxProc: 0}, 52211 {FzName: ts + 22922 /* "sqlite3_vfs_list" */, FxProc: 0}, 52212 {FzName: ts + 22939 /* "sqlite3_create_f..." */, FxProc: 0}, 52213 52214 // Functions from os.h 52215 {FzName: ts + 22966 /* "add_test_collate" */, FxProc: 0}, 52216 {FzName: ts + 22983 /* "add_test_collate..." */, FxProc: 0}, 52217 {FzName: ts + 23007 /* "add_test_functio..." */, FxProc: 0}, 52218 {FzName: ts + 23025 /* "add_test_utf16bi..." */, FxProc: 0}, 52219 {FzName: ts + 23051 /* "sqlite3_test_err..." */, FxProc: 0}, 52220 {FzName: ts + 23071 /* "tcl_variable_typ..." */, FxProc: 0}, 52221 {FzName: ts + 23089 /* "sqlite3_enable_s..." */, FxProc: 0}, 52222 {FzName: ts + 23117 /* "sqlite3_shared_c..." */, FxProc: 0}, 52223 {FzName: ts + 23145 /* "sqlite3_libversi..." */, FxProc: 0}, 52224 {FzName: ts + 23171 /* "sqlite3_table_co..." */, FxProc: 0}, 52225 {FzName: ts + 23201 /* "sqlite3_blob_reo..." */, FxProc: 0}, 52226 {FzName: ts + 23221 /* "pcache_stats" */, FxProc: 0}, 52227 {FzName: ts + 23234 /* "sqlite3_unlock_n..." */, FxProc: 0}, 52228 {FzName: ts + 23256 /* "sqlite3_wal_chec..." */, FxProc: 0}, 52229 {FzName: ts + 23279 /* "sqlite3_wal_chec..." */, FxProc: 0}, 52230 {FzName: ts + 23305 /* "sqlite3_wal_auto..." */, FxProc: 0}, 52231 {FzName: ts + 23332 /* "test_sqlite3_log" */, FxProc: 0}, 52232 {FzName: ts + 23349 /* "print_explain_qu..." */, FxProc: 0}, 52233 {FzName: ts + 23374 /* "sqlite3_test_con..." */, FxProc: 0}, 52234 {FzName: ts + 23395 /* "getrusage" */, FxProc: 0}, 52235 {FzName: ts + 23405 /* "load_static_exte..." */, FxProc: 0}, 52236 {FzName: ts + 23427 /* "sorter_test_fake..." */, FxProc: 0}, 52237 {FzName: ts + 23448 /* "sorter_test_sort..." */, FxProc: 0}, 52238 {FzName: ts + 23473 /* "vfs_current_time..." */, FxProc: 0}, 52239 {FzName: ts + 23496 /* "sqlite3_snapshot..." */, FxProc: 0}, 52240 {FzName: ts + 23517 /* "sqlite3_snapshot..." */, FxProc: 0}, 52241 {FzName: ts + 23539 /* "sqlite3_snapshot..." */, FxProc: 0}, 52242 {FzName: ts + 23561 /* "sqlite3_snapshot..." */, FxProc: 0}, 52243 {FzName: ts + 23582 /* "sqlite3_snapshot..." */, FxProc: 0}, 52244 {FzName: ts + 23607 /* "sqlite3_snapshot..." */, FxProc: 0}, 52245 {FzName: ts + 23633 /* "sqlite3_snapshot..." */, FxProc: 0}, 52246 {FzName: ts + 23660 /* "sqlite3_snapshot..." */, FxProc: 0}, 52247 {FzName: ts + 23686 /* "sqlite3_delete_d..." */, FxProc: 0}, 52248 {FzName: ts + 23710 /* "atomic_batch_wri..." */, FxProc: 0}, 52249 {FzName: ts + 23729 /* "sqlite3_mmap_war..." */, FxProc: 0}, 52250 {FzName: ts + 23747 /* "sqlite3_config_s..." */, FxProc: 0}, 52251 {FzName: ts + 23772 /* "decode_hexdb" */, FxProc: 0}, 52252 {FzName: ts + 23785 /* "test_write_db" */, FxProc: 0}, 52253 {FzName: ts + 23799 /* "sqlite3_register..." */, FxProc: 0}, 52254 {FzName: ts + 23825 /* "sqlite3_unregist..." */, FxProc: 0}, 52255 } /* test1.c:8276:5 */ 52256 var bitmask_size int32 = (int32(uint64(unsafe.Sizeof(Bitmask(0))) * uint64(8))) /* test1.c:8503:14 */ 52257 var longdouble_size int32 = int32(unsafe.Sizeof(float64(0))) /* test1.c:8504:14 */ 52258 var query_plan uintptr = ts + 23853 /* "*** OBSOLETE VAR..." */ /* test1.c:8576:23 */ 52259 52260 // Page size and reserved size used for testing. 52261 var test_pagesize int32 = 1024 /* test2.c:31:12 */ 52262 52263 // Dummy page reinitializer 52264 func pager_test_reiniter(tls *libc.TLS, pNotUsed uintptr) { /* test2.c:36:13: */ 52265 return 52266 } 52267 52268 // Usage: pager_open FILENAME N-PAGE 52269 // 52270 // Open a new pager 52271 func pager_open(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:45:26: */ 52272 bp := tls.Alloc(192) 52273 defer tls.Free(192) 52274 52275 // var pageSize u322 at bp+88, 4 52276 52277 // var pPager uintptr at bp+80, 8 52278 52279 // var nPage int32 at bp+72, 4 52280 52281 var rc int32 52282 // var zBuf [100]int8 at bp+92, 100 52283 52284 if argc != 3 { 52285 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52286 ts+23879 /* " FILENAME N-PAGE..." */, 0)) 52287 return TCL_ERROR 52288 } 52289 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+72 /* &nPage */) != 0 { 52290 return TCL_ERROR 52291 } 52292 rc = sqlite3.Xsqlite3PagerOpen(tls, sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)), bp+80 /* &pPager */, *(*uintptr)(unsafe.Pointer(argv + 1*8)), 0, 0, 52293 ((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_MAIN_DB), 52294 *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{pager_test_reiniter}))) 52295 if rc != SQLITE_OK { 52296 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 52297 return TCL_ERROR 52298 } 52299 sqlite3.Xsqlite3PagerSetCachesize(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pPager */)), *(*int32)(unsafe.Pointer(bp + 72 /* nPage */))) 52300 *(*u322)(unsafe.Pointer(bp + 88 /* pageSize */)) = u322(test_pagesize) 52301 sqlite3.Xsqlite3PagerSetPagesize(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pPager */)), bp+88 /* &pageSize */, -1) 52302 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+92 /* &zBuf[0] */, ts+13023 /* "%p" */, libc.VaList(bp+48, *(*uintptr)(unsafe.Pointer(bp + 80 /* pPager */)))) 52303 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, bp+92 /* &zBuf[0] */, 0)) 52304 return TCL_OK 52305 } 52306 52307 // Usage: pager_close ID 52308 // 52309 // Close the given pager. 52310 func pager_close(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:82:26: */ 52311 bp := tls.Alloc(48) 52312 defer tls.Free(48) 52313 52314 var pPager uintptr 52315 var rc int32 52316 if argc != 2 { 52317 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52318 ts+23897 /* " ID\"" */, 0)) 52319 return TCL_ERROR 52320 } 52321 pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 52322 rc = sqlite3.Xsqlite3PagerClose(tls, pPager, uintptr(0)) 52323 if rc != SQLITE_OK { 52324 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 52325 return TCL_ERROR 52326 } 52327 return TCL_OK 52328 } 52329 52330 // Usage: pager_rollback ID 52331 // 52332 // Rollback changes 52333 func pager_rollback(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:109:26: */ 52334 bp := tls.Alloc(48) 52335 defer tls.Free(48) 52336 52337 var pPager uintptr 52338 var rc int32 52339 if argc != 2 { 52340 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52341 ts+23897 /* " ID\"" */, 0)) 52342 return TCL_ERROR 52343 } 52344 pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 52345 rc = sqlite3.Xsqlite3PagerRollback(tls, pPager) 52346 if rc != SQLITE_OK { 52347 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 52348 return TCL_ERROR 52349 } 52350 return TCL_OK 52351 } 52352 52353 // Usage: pager_commit ID 52354 // 52355 // Commit all changes 52356 func pager_commit(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:136:26: */ 52357 bp := tls.Alloc(64) 52358 defer tls.Free(64) 52359 52360 var pPager uintptr 52361 var rc int32 52362 if argc != 2 { 52363 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52364 ts+23897 /* " ID\"" */, 0)) 52365 return TCL_ERROR 52366 } 52367 pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 52368 rc = sqlite3.Xsqlite3PagerCommitPhaseOne(tls, pPager, uintptr(0), 0) 52369 if rc != SQLITE_OK { 52370 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 52371 return TCL_ERROR 52372 } 52373 rc = sqlite3.Xsqlite3PagerCommitPhaseTwo(tls, pPager) 52374 if rc != SQLITE_OK { 52375 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 52376 return TCL_ERROR 52377 } 52378 return TCL_OK 52379 } 52380 52381 // Usage: pager_stmt_begin ID 52382 // 52383 // Start a new checkpoint. 52384 func pager_stmt_begin(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:168:26: */ 52385 bp := tls.Alloc(48) 52386 defer tls.Free(48) 52387 52388 var pPager uintptr 52389 var rc int32 52390 if argc != 2 { 52391 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52392 ts+23897 /* " ID\"" */, 0)) 52393 return TCL_ERROR 52394 } 52395 pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 52396 rc = sqlite3.Xsqlite3PagerOpenSavepoint(tls, pPager, 1) 52397 if rc != SQLITE_OK { 52398 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 52399 return TCL_ERROR 52400 } 52401 return TCL_OK 52402 } 52403 52404 // Usage: pager_stmt_rollback ID 52405 // 52406 // Rollback changes to a checkpoint 52407 func pager_stmt_rollback(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:195:26: */ 52408 bp := tls.Alloc(48) 52409 defer tls.Free(48) 52410 52411 var pPager uintptr 52412 var rc int32 52413 if argc != 2 { 52414 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52415 ts+23897 /* " ID\"" */, 0)) 52416 return TCL_ERROR 52417 } 52418 pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 52419 rc = sqlite3.Xsqlite3PagerSavepoint(tls, pPager, SAVEPOINT_ROLLBACK, 0) 52420 sqlite3.Xsqlite3PagerSavepoint(tls, pPager, SAVEPOINT_RELEASE, 0) 52421 if rc != SQLITE_OK { 52422 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 52423 return TCL_ERROR 52424 } 52425 return TCL_OK 52426 } 52427 52428 // Usage: pager_stmt_commit ID 52429 // 52430 // Commit changes to a checkpoint 52431 func pager_stmt_commit(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:223:26: */ 52432 bp := tls.Alloc(48) 52433 defer tls.Free(48) 52434 52435 var pPager uintptr 52436 var rc int32 52437 if argc != 2 { 52438 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52439 ts+23897 /* " ID\"" */, 0)) 52440 return TCL_ERROR 52441 } 52442 pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 52443 rc = sqlite3.Xsqlite3PagerSavepoint(tls, pPager, SAVEPOINT_RELEASE, 0) 52444 if rc != SQLITE_OK { 52445 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 52446 return TCL_ERROR 52447 } 52448 return TCL_OK 52449 } 52450 52451 // Usage: pager_stats ID 52452 // 52453 // Return pager statistics. 52454 func pager_stats(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:250:26: */ 52455 bp := tls.Alloc(140) 52456 defer tls.Free(140) 52457 52458 var pPager uintptr 52459 var i int32 52460 var a uintptr 52461 if argc != 2 { 52462 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52463 ts+23897 /* " ID\"" */, 0)) 52464 return TCL_ERROR 52465 } 52466 pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 52467 a = sqlite3.Xsqlite3PagerStats(tls, pPager) 52468 for i = 0; i < 9; i++ { 52469 // var zBuf [100]int8 at bp+40, 100 52470 52471 tcl.XTcl_AppendElement(tls, interp, zName[i]) 52472 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+40 /* &zBuf[0] */, ts+1238 /* "%d" */, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(a + uintptr(i)*4)))) 52473 tcl.XTcl_AppendElement(tls, interp, bp+40 /* &zBuf[0] */) 52474 } 52475 return TCL_OK 52476 } 52477 52478 var zName = [9]uintptr{ 52479 ts + 23902 /* "ref" */, ts + 23906 /* "page" */, ts + 17904 /* "max" */, ts + 11493 /* "size" */, ts + 10195 /* "state" */, ts + 23911, /* "err" */ 52480 ts + 23915 /* "hit" */, ts + 23919 /* "miss" */, ts + 23924, /* "ovfl" */ 52481 } /* test2.c:266:17 */ 52482 52483 // Usage: pager_pagecount ID 52484 // 52485 // Return the size of the database file. 52486 func pager_pagecount(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:283:26: */ 52487 bp := tls.Alloc(160) 52488 defer tls.Free(160) 52489 52490 var pPager uintptr 52491 // var zBuf [100]int8 at bp+60, 100 52492 52493 // var nPage int32 at bp+56, 4 52494 52495 if argc != 2 { 52496 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52497 ts+23897 /* " ID\"" */, 0)) 52498 return TCL_ERROR 52499 } 52500 pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 52501 sqlite3.Xsqlite3PagerPagecount(tls, pPager, bp+56 /* &nPage */) 52502 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+60 /* &zBuf[0] */, ts+1238 /* "%d" */, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(bp + 56 /* nPage */)))) 52503 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+60 /* &zBuf[0] */, 0)) 52504 return TCL_OK 52505 } 52506 52507 // Usage: page_get ID PGNO 52508 // 52509 // Return a pointer to a page from the database. 52510 func page_get(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:309:26: */ 52511 bp := tls.Alloc(188) 52512 defer tls.Free(188) 52513 52514 var pPager uintptr 52515 // var zBuf [100]int8 at bp+88, 100 52516 52517 *(*uintptr)(unsafe.Pointer(bp + 80 /* pPage */)) = uintptr(0) 52518 // var pgno int32 at bp+72, 4 52519 52520 var rc int32 52521 if argc != 3 { 52522 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52523 ts+23929 /* " ID PGNO\"" */, 0)) 52524 return TCL_ERROR 52525 } 52526 pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 52527 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+72 /* &pgno */) != 0 { 52528 return TCL_ERROR 52529 } 52530 rc = sqlite3.Xsqlite3PagerSharedLock(tls, pPager) 52531 if rc == SQLITE_OK { 52532 rc = sqlite3.Xsqlite3PagerGet(tls, pPager, uint32(*(*int32)(unsafe.Pointer(bp + 72 /* pgno */))), bp+80 /* &pPage */, 0) 52533 } 52534 if rc != SQLITE_OK { 52535 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 52536 return TCL_ERROR 52537 } 52538 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+88 /* &zBuf[0] */, ts+13023 /* "%p" */, libc.VaList(bp+48, *(*uintptr)(unsafe.Pointer(bp + 80 /* pPage */)))) 52539 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, bp+88 /* &zBuf[0] */, 0)) 52540 return TCL_OK 52541 } 52542 52543 // Usage: page_lookup ID PGNO 52544 // 52545 // Return a pointer to a page if the page is already in cache. 52546 // If not in cache, return an empty string. 52547 func page_lookup(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:346:26: */ 52548 bp := tls.Alloc(160) 52549 defer tls.Free(160) 52550 52551 var pPager uintptr 52552 // var zBuf [100]int8 at bp+60, 100 52553 52554 var pPage uintptr 52555 // var pgno int32 at bp+56, 4 52556 52557 if argc != 3 { 52558 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52559 ts+23929 /* " ID PGNO\"" */, 0)) 52560 return TCL_ERROR 52561 } 52562 pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 52563 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+56 /* &pgno */) != 0 { 52564 return TCL_ERROR 52565 } 52566 pPage = sqlite3.Xsqlite3PagerLookup(tls, pPager, uint32(*(*int32)(unsafe.Pointer(bp + 56 /* pgno */)))) 52567 if pPage != 0 { 52568 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+60 /* &zBuf[0] */, ts+13023 /* "%p" */, libc.VaList(bp+32, pPage)) 52569 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+60 /* &zBuf[0] */, 0)) 52570 } 52571 return TCL_OK 52572 } 52573 52574 // Usage: pager_truncate ID PGNO 52575 func pager_truncate(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:374:26: */ 52576 bp := tls.Alloc(36) 52577 defer tls.Free(36) 52578 52579 var pPager uintptr 52580 // var pgno int32 at bp+32, 4 52581 52582 if argc != 3 { 52583 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52584 ts+23929 /* " ID PGNO\"" */, 0)) 52585 return TCL_ERROR 52586 } 52587 pPager = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 52588 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+32 /* &pgno */) != 0 { 52589 return TCL_ERROR 52590 } 52591 sqlite3.Xsqlite3PagerTruncateImage(tls, pPager, uint32(*(*int32)(unsafe.Pointer(bp + 32 /* pgno */)))) 52592 return TCL_OK 52593 } 52594 52595 // Usage: page_unref PAGE 52596 // 52597 // Drop a pointer to a page. 52598 func page_unref(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:399:26: */ 52599 bp := tls.Alloc(32) 52600 defer tls.Free(32) 52601 52602 var pPage uintptr 52603 if argc != 2 { 52604 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52605 ts+23939 /* " PAGE\"" */, 0)) 52606 return TCL_ERROR 52607 } 52608 pPage = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 52609 sqlite3.Xsqlite3PagerUnref(tls, pPage) 52610 return TCL_OK 52611 } 52612 52613 // Usage: page_read PAGE 52614 // 52615 // Return the content of a page 52616 func page_read(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:421:26: */ 52617 bp := tls.Alloc(148) 52618 defer tls.Free(148) 52619 52620 // var zBuf [100]int8 at bp+48, 100 52621 52622 var pPage uintptr 52623 if argc != 2 { 52624 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52625 ts+23939 /* " PAGE\"" */, 0)) 52626 return TCL_ERROR 52627 } 52628 pPage = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 52629 libc.Xmemcpy(tls, bp+48 /* &zBuf[0] */, sqlite3.Xsqlite3PagerGetData(tls, pPage), uint64(unsafe.Sizeof([100]int8{}))) 52630 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, bp+48 /* &zBuf[0] */, 0)) 52631 return TCL_OK 52632 } 52633 52634 // Usage: page_number PAGE 52635 // 52636 // Return the page number for a page. 52637 func page_number(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:445:26: */ 52638 bp := tls.Alloc(156) 52639 defer tls.Free(156) 52640 52641 // var zBuf [100]int8 at bp+56, 100 52642 52643 var pPage uintptr 52644 if argc != 2 { 52645 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52646 ts+23939 /* " PAGE\"" */, 0)) 52647 return TCL_ERROR 52648 } 52649 pPage = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 52650 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+56 /* &zBuf[0] */, ts+1238 /* "%d" */, libc.VaList(bp+32, sqlite3.Xsqlite3PagerPagenumber(tls, pPage))) 52651 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+56 /* &zBuf[0] */, 0)) 52652 return TCL_OK 52653 } 52654 52655 // Usage: page_write PAGE DATA 52656 // 52657 // Write something into a page. 52658 func page_write(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:469:26: */ 52659 bp := tls.Alloc(48) 52660 defer tls.Free(48) 52661 52662 var pPage uintptr 52663 var pData uintptr 52664 var rc int32 52665 if argc != 3 { 52666 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52667 ts+23946 /* " PAGE DATA\"" */, 0)) 52668 return TCL_ERROR 52669 } 52670 pPage = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 52671 rc = sqlite3.Xsqlite3PagerWrite(tls, pPage) 52672 if rc != SQLITE_OK { 52673 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 52674 return TCL_ERROR 52675 } 52676 pData = sqlite3.Xsqlite3PagerGetData(tls, pPage) 52677 libc.Xstrncpy(tls, pData, *(*uintptr)(unsafe.Pointer(argv + 2*8)), (uint64(test_pagesize - 1))) 52678 *(*int8)(unsafe.Pointer(pData + uintptr((test_pagesize - 1)))) = int8(0) 52679 return TCL_OK 52680 } 52681 52682 // Usage: fake_big_file N FILENAME 52683 // 52684 // Write a few bytes at the N megabyte point of FILENAME. This will 52685 // create a large file. If the file was a valid SQLite database, then 52686 // the next time the database is opened, SQLite will begin allocating 52687 // new pages after N. If N is 2096 or bigger, this will test the 52688 // ability of SQLite to write to large files. 52689 func fake_big_file(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:505:26: */ 52690 bp := tls.Alloc(96) 52691 defer tls.Free(96) 52692 52693 var pVfs uintptr 52694 *(*uintptr)(unsafe.Pointer(bp + 88 /* fd */)) = uintptr(0) 52695 var rc int32 52696 // var n int32 at bp+80, 4 52697 52698 var offset i64 52699 var zFile uintptr 52700 var nFile int32 52701 if argc != 3 { 52702 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52703 ts+23958 /* " N-MEGABYTES FIL..." */, 0)) 52704 return TCL_ERROR 52705 } 52706 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+80 /* &n */) != 0 { 52707 return TCL_ERROR 52708 } 52709 52710 pVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 52711 nFile = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) 52712 zFile = sqlite3.Xsqlite3_malloc(tls, (nFile + 2)) 52713 if zFile == uintptr(0) { 52714 return TCL_ERROR 52715 } 52716 libc.Xmemcpy(tls, zFile, *(*uintptr)(unsafe.Pointer(argv + 2*8)), (uint64(nFile + 1))) 52717 *(*int8)(unsafe.Pointer(zFile + uintptr((nFile + 1)))) = int8(0) 52718 rc = sqlite3.Xsqlite3OsOpenMalloc(tls, pVfs, zFile, bp+88, /* &fd */ 52719 ((SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE) | SQLITE_OPEN_MAIN_DB), uintptr(0)) 52720 if rc != 0 { 52721 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+23977 /* "open failed: " */, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 52722 sqlite3.Xsqlite3_free(tls, zFile) 52723 return TCL_ERROR 52724 } 52725 offset = i64(*(*int32)(unsafe.Pointer(bp + 80 /* n */))) 52726 offset = offset * (int64(1024 * 1024)) 52727 rc = sqlite3.Xsqlite3OsWrite(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* fd */)), ts+23991 /* "Hello, World!" */, 14, offset) 52728 sqlite3.Xsqlite3OsCloseFree(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* fd */))) 52729 sqlite3.Xsqlite3_free(tls, zFile) 52730 if rc != 0 { 52731 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, ts+24005 /* "write failed: " */, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 52732 return TCL_ERROR 52733 } 52734 return TCL_OK 52735 } 52736 52737 // test_control_pending_byte PENDING_BYTE 52738 // 52739 // Set the PENDING_BYTE using the sqlite3_test_control() interface. 52740 func testPendingByte(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:558:26: */ 52741 bp := tls.Alloc(44) 52742 defer tls.Free(44) 52743 52744 // var pbyte int32 at bp+40, 4 52745 52746 var rc int32 52747 if argc != 2 { 52748 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52749 ts+24020 /* " PENDING-BYTE\"" */, uintptr(0))) 52750 return TCL_ERROR 52751 } 52752 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+40 /* &pbyte */) != 0 { 52753 return TCL_ERROR 52754 } 52755 rc = sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_PENDING_BYTE, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(bp + 40 /* pbyte */)))) 52756 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) 52757 return TCL_OK 52758 } 52759 52760 // The sqlite3FaultSim() callback: 52761 var faultSimInterp uintptr = uintptr(0) /* test2.c:580:19 */ 52762 var faultSimScriptSize int32 = 0 /* test2.c:581:12 */ 52763 var faultSimScript uintptr /* test2.c:582:13: */ 52764 52765 func faultSimCallback(tls *libc.TLS, x int32) int32 { /* test2.c:583:12: */ 52766 bp := tls.Alloc(38) 52767 defer tls.Free(38) 52768 52769 // var zInt [30]int8 at bp+8, 30 52770 52771 var i int32 52772 var isNeg int32 52773 var rc int32 52774 if x == 0 { 52775 libc.Xmemcpy(tls, (faultSimScript + uintptr(faultSimScriptSize)), ts+13875 /* "0" */, uint64(2)) 52776 } else { 52777 // Convert x to text without using any sqlite3 routines 52778 if x < 0 { 52779 isNeg = 1 52780 x = -x 52781 } else { 52782 isNeg = 0 52783 } 52784 *(*int8)(unsafe.Pointer(bp + 8 /* &zInt[0] */ + 29)) = int8(0) 52785 i = (int32(uint64(unsafe.Sizeof([30]int8{})) - uint64(2))) 52786 __1: 52787 if !((i > 0) && (x > 0)) { 52788 goto __3 52789 } 52790 { 52791 *(*int8)(unsafe.Pointer(bp + 8 /* &zInt[0] */ + uintptr(i))) = (int8((x % 10) + '0')) 52792 52793 } 52794 goto __2 52795 __2: 52796 i-- 52797 x = x / (10) 52798 goto __1 52799 goto __3 52800 __3: 52801 ; 52802 if isNeg != 0 { 52803 *(*int8)(unsafe.Pointer(bp + 8 /* &zInt[0] */ + uintptr(libc.PostDecInt32(&i, 1)))) = int8('-') 52804 } 52805 libc.Xmemcpy(tls, (faultSimScript + uintptr(faultSimScriptSize)), ((bp + 8 /* &zInt[0] */ + uintptr(i)) + uintptr(1)), (uint64(unsafe.Sizeof([30]int8{})) - uint64(i))) 52806 } 52807 rc = tcl.XTcl_Eval(tls, faultSimInterp, faultSimScript) 52808 if rc != 0 { 52809 libc.Xfprintf(tls, libc.Xstderr, ts+24035 /* "fault simulator ..." */, libc.VaList(bp, faultSimScript)) 52810 rc = SQLITE_ERROR 52811 } else { 52812 rc = libc.Xatoi(tls, tcl.XTcl_GetStringResult(tls, faultSimInterp)) 52813 } 52814 tcl.XTcl_ResetResult(tls, faultSimInterp) 52815 return rc 52816 } 52817 52818 // sqlite3_test_control_fault_install SCRIPT 52819 // 52820 // Arrange to invoke SCRIPT with the integer argument to sqlite3FaultSim() 52821 // appended, whenever sqlite3FaultSim() is called. Or, if SCRIPT is the 52822 // empty string, cancel the sqlite3FaultSim() callback. 52823 func faultInstallCmd(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:623:26: */ 52824 bp := tls.Alloc(64) 52825 defer tls.Free(64) 52826 52827 var zScript uintptr 52828 var nScript int32 52829 var rc int32 52830 if (argc != 1) && (argc != 2) { 52831 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52832 ts+24071 /* " SCRIPT\"" */, uintptr(0))) 52833 } 52834 if argc == 2 { 52835 zScript = *(*uintptr)(unsafe.Pointer(argv + 1*8)) 52836 } else { 52837 zScript = ts + 489 /* "" */ 52838 } 52839 nScript = int32(libc.Xstrlen(tls, zScript)) 52840 if faultSimScript != 0 { 52841 libc.Xfree(tls, faultSimScript) 52842 faultSimScript = uintptr(0) 52843 } 52844 if nScript == 0 { 52845 rc = sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_FAULT_INSTALL, libc.VaList(bp+32, 0)) 52846 } else { 52847 faultSimScript = libc.Xmalloc(tls, (uint64(nScript + 100))) 52848 if faultSimScript == uintptr(0) { 52849 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, ts+1930 /* "out of memory" */, uintptr(0))) 52850 return SQLITE_ERROR 52851 } 52852 libc.Xmemcpy(tls, faultSimScript, zScript, uint64(nScript)) 52853 *(*int8)(unsafe.Pointer(faultSimScript + uintptr(nScript))) = int8(' ') 52854 faultSimScriptSize = (nScript + 1) 52855 faultSimInterp = interp 52856 rc = sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_FAULT_INSTALL, libc.VaList(bp+56, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, int32) int32 }{faultSimCallback})))) 52857 } 52858 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) 52859 return SQLITE_OK 52860 } 52861 52862 // sqlite3BitvecBuiltinTest SIZE PROGRAM 52863 // 52864 // Invoke the SQLITE_TESTCTRL_BITVEC_TEST operator on test_control. 52865 // See comments on sqlite3BitvecBuiltinTest() for additional information. 52866 func testBitvecBuiltinTest(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test2.c:666:26: */ 52867 bp := tls.Alloc(452) 52868 defer tls.Free(452) 52869 52870 // var sz int32 at bp+48, 4 52871 52872 var rc int32 52873 var nProg int32 = 0 52874 // var aProg [100]int32 at bp+52, 400 52875 52876 var z uintptr 52877 if argc != 3 { 52878 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 52879 ts+24080 /* " SIZE PROGRAM\"" */, uintptr(0))) 52880 } 52881 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+48 /* &sz */) != 0 { 52882 return TCL_ERROR 52883 } 52884 z = *(*uintptr)(unsafe.Pointer(argv + 2*8)) 52885 for (nProg < 99) && (*(*int8)(unsafe.Pointer(z)) != 0) { 52886 for (*(*int8)(unsafe.Pointer(z)) != 0) && !((int32(sqlite3.Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z)))]) & 0x04) != 0) { 52887 z++ 52888 } 52889 if int32(*(*int8)(unsafe.Pointer(z))) == 0 { 52890 break 52891 } 52892 *(*int32)(unsafe.Pointer(bp + 52 /* &aProg[0] */ + uintptr(libc.PostIncInt32(&nProg, 1))*4)) = libc.Xatoi(tls, z) 52893 for (int32(sqlite3.Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z)))]) & 0x04) != 0 { 52894 z++ 52895 } 52896 } 52897 *(*int32)(unsafe.Pointer(bp + 52 /* &aProg[0] */ + uintptr(nProg)*4)) = 0 52898 rc = sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_BITVEC_TEST, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(bp + 48 /* sz */)), bp+52 /* &aProg[0] */)) 52899 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) 52900 return TCL_OK 52901 } 52902 52903 // Register commands with the TCL interpreter. 52904 func Sqlitetest2_Init(tls *libc.TLS, interp uintptr) int32 { /* test2.c:697:5: */ 52905 var i int32 52906 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aCmd2)) / uint64(unsafe.Sizeof(struct { 52907 FzName uintptr 52908 FxProc uintptr 52909 }{}))); i++ { 52910 tcl.XTcl_CreateCommand(tls, interp, aCmd2[i].FzName, aCmd2[i].FxProc, uintptr(0), uintptr(0)) 52911 } 52912 tcl.XTcl_LinkVar(tls, interp, ts+24095, /* "sqlite_io_error_..." */ 52913 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_io_error_pending)), TCL_LINK_INT) 52914 tcl.XTcl_LinkVar(tls, interp, ts+24119, /* "sqlite_io_error_..." */ 52915 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_io_error_persist)), TCL_LINK_INT) 52916 tcl.XTcl_LinkVar(tls, interp, ts+24143, /* "sqlite_io_error_..." */ 52917 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_io_error_hit)), TCL_LINK_INT) 52918 tcl.XTcl_LinkVar(tls, interp, ts+24163, /* "sqlite_io_error_..." */ 52919 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_io_error_hardhit)), TCL_LINK_INT) 52920 tcl.XTcl_LinkVar(tls, interp, ts+24187, /* "sqlite_diskfull_..." */ 52921 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_diskfull_pending)), TCL_LINK_INT) 52922 tcl.XTcl_LinkVar(tls, interp, ts+24211, /* "sqlite_diskfull" */ 52923 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3_diskfull)), TCL_LINK_INT) 52924 tcl.XTcl_LinkVar(tls, interp, ts+24227, /* "sqlite_pending_b..." */ 52925 uintptr(unsafe.Pointer(&sqlite3.Xsqlite3PendingByte)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 52926 return TCL_OK 52927 } 52928 52929 var aCmd2 = [20]struct { 52930 FzName uintptr 52931 FxProc uintptr 52932 }{ 52933 {FzName: ts + 24247 /* "pager_open" */, FxProc: 0}, 52934 {FzName: ts + 24258 /* "pager_close" */, FxProc: 0}, 52935 {FzName: ts + 24270 /* "pager_commit" */, FxProc: 0}, 52936 {FzName: ts + 24283 /* "pager_rollback" */, FxProc: 0}, 52937 {FzName: ts + 24298 /* "pager_stmt_begin" */, FxProc: 0}, 52938 {FzName: ts + 24315 /* "pager_stmt_commi..." */, FxProc: 0}, 52939 {FzName: ts + 24333 /* "pager_stmt_rollb..." */, FxProc: 0}, 52940 {FzName: ts + 24353 /* "pager_stats" */, FxProc: 0}, 52941 {FzName: ts + 24365 /* "pager_pagecount" */, FxProc: 0}, 52942 {FzName: ts + 24381 /* "page_get" */, FxProc: 0}, 52943 {FzName: ts + 24390 /* "page_lookup" */, FxProc: 0}, 52944 {FzName: ts + 24402 /* "page_unref" */, FxProc: 0}, 52945 {FzName: ts + 24413 /* "page_read" */, FxProc: 0}, 52946 {FzName: ts + 24423 /* "page_write" */, FxProc: 0}, 52947 {FzName: ts + 24434 /* "page_number" */, FxProc: 0}, 52948 {FzName: ts + 24446 /* "pager_truncate" */, FxProc: 0}, 52949 {FzName: ts + 24461 /* "fake_big_file" */, FxProc: 0}, 52950 {FzName: ts + 24475 /* "sqlite3BitvecBui..." */, FxProc: 0}, 52951 {FzName: ts + 24500 /* "sqlite3_test_con..." */, FxProc: 0}, 52952 {FzName: ts + 24534 /* "sqlite3_test_con..." */, FxProc: 0}, 52953 } /* test2.c:707:5 */ 52954 52955 // 2001 September 15 52956 // 52957 // The author disclaims copyright to this source code. In place of 52958 // a legal notice, here is a blessing: 52959 // 52960 // May you do good and not evil. 52961 // May you find forgiveness for yourself and forgive others. 52962 // May you share freely, never taking more than you give. 52963 // 52964 // 52965 // This header file defines the interface that the sqlite B-Tree file 52966 // subsystem. See comments in the source code for a detailed description 52967 // of what each interface routine does. 52968 52969 // TODO: This definition is just included so other modules compile. It 52970 // needs to be revisited. 52971 52972 // If defined as non-zero, auto-vacuum is enabled by default. Otherwise 52973 // it must be turned on for each database using "PRAGMA auto_vacuum = 1". 52974 52975 // Forward declarations of structure 52976 type Btree = Btree1 /* btree.h:39:22 */ 52977 type BtCursor = BtCursor1 /* btree.h:40:25 */ 52978 type BtShared = BtShared1 /* btree.h:41:25 */ 52979 52980 // 2004 April 6 52981 // 52982 // The author disclaims copyright to this source code. In place of 52983 // a legal notice, here is a blessing: 52984 // 52985 // May you do good and not evil. 52986 // May you find forgiveness for yourself and forgive others. 52987 // May you share freely, never taking more than you give. 52988 // 52989 // 52990 // This file implements an external (disk-based) database using BTrees. 52991 // For a detailed discussion of BTrees, refer to 52992 // 52993 // Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3: 52994 // "Sorting And Searching", pages 473-480. Addison-Wesley 52995 // Publishing Company, Reading, Massachusetts. 52996 // 52997 // The basic idea is that each page of the file contains N database 52998 // entries and N+1 pointers to subpages. 52999 // 53000 // ---------------------------------------------------------------- 53001 // | Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N-1) | Ptr(N) | 53002 // ---------------------------------------------------------------- 53003 // 53004 // All of the keys on the page that Ptr(0) points to have values less 53005 // than Key(0). All of the keys on page Ptr(1) and its subpages have 53006 // values greater than Key(0) and less than Key(1). All of the keys 53007 // on Ptr(N) and its subpages have values greater than Key(N-1). And 53008 // so forth. 53009 // 53010 // Finding a particular key requires reading O(log(M)) pages from the 53011 // disk where M is the number of entries in the tree. 53012 // 53013 // In this implementation, a single file can hold one or more separate 53014 // BTrees. Each BTree is identified by the index of its root page. The 53015 // key and data for any entry are combined to form the "payload". A 53016 // fixed amount of payload can be carried directly on the database 53017 // page. If the payload is larger than the preset amount then surplus 53018 // bytes are stored on overflow pages. The payload for an entry 53019 // and the preceding pointer are combined to form a "Cell". Each 53020 // page has a small header which contains the Ptr(N) pointer and other 53021 // information such as the size of key and data. 53022 // 53023 // FORMAT DETAILS 53024 // 53025 // The file is divided into pages. The first page is called page 1, 53026 // the second is page 2, and so forth. A page number of zero indicates 53027 // "no such page". The page size can be any power of 2 between 512 and 65536. 53028 // Each page can be either a btree page, a freelist page, an overflow 53029 // page, or a pointer-map page. 53030 // 53031 // The first page is always a btree page. The first 100 bytes of the first 53032 // page contain a special header (the "file header") that describes the file. 53033 // The format of the file header is as follows: 53034 // 53035 // OFFSET SIZE DESCRIPTION 53036 // 0 16 Header string: "SQLite format 3\000" 53037 // 16 2 Page size in bytes. (1 means 65536) 53038 // 18 1 File format write version 53039 // 19 1 File format read version 53040 // 20 1 Bytes of unused space at the end of each page 53041 // 21 1 Max embedded payload fraction (must be 64) 53042 // 22 1 Min embedded payload fraction (must be 32) 53043 // 23 1 Min leaf payload fraction (must be 32) 53044 // 24 4 File change counter 53045 // 28 4 Reserved for future use 53046 // 32 4 First freelist page 53047 // 36 4 Number of freelist pages in the file 53048 // 40 60 15 4-byte meta values passed to higher layers 53049 // 53050 // 40 4 Schema cookie 53051 // 44 4 File format of schema layer 53052 // 48 4 Size of page cache 53053 // 52 4 Largest root-page (auto/incr_vacuum) 53054 // 56 4 1=UTF-8 2=UTF16le 3=UTF16be 53055 // 60 4 User version 53056 // 64 4 Incremental vacuum mode 53057 // 68 4 Application-ID 53058 // 72 20 unused 53059 // 92 4 The version-valid-for number 53060 // 96 4 SQLITE_VERSION_NUMBER 53061 // 53062 // All of the integer values are big-endian (most significant byte first). 53063 // 53064 // The file change counter is incremented when the database is changed 53065 // This counter allows other processes to know when the file has changed 53066 // and thus when they need to flush their cache. 53067 // 53068 // The max embedded payload fraction is the amount of the total usable 53069 // space in a page that can be consumed by a single cell for standard 53070 // B-tree (non-LEAFDATA) tables. A value of 255 means 100%. The default 53071 // is to limit the maximum cell size so that at least 4 cells will fit 53072 // on one page. Thus the default max embedded payload fraction is 64. 53073 // 53074 // If the payload for a cell is larger than the max payload, then extra 53075 // payload is spilled to overflow pages. Once an overflow page is allocated, 53076 // as many bytes as possible are moved into the overflow pages without letting 53077 // the cell size drop below the min embedded payload fraction. 53078 // 53079 // The min leaf payload fraction is like the min embedded payload fraction 53080 // except that it applies to leaf nodes in a LEAFDATA tree. The maximum 53081 // payload fraction for a LEAFDATA tree is always 100% (or 255) and it 53082 // not specified in the header. 53083 // 53084 // Each btree pages is divided into three sections: The header, the 53085 // cell pointer array, and the cell content area. Page 1 also has a 100-byte 53086 // file header that occurs before the page header. 53087 // 53088 // |----------------| 53089 // | file header | 100 bytes. Page 1 only. 53090 // |----------------| 53091 // | page header | 8 bytes for leaves. 12 bytes for interior nodes 53092 // |----------------| 53093 // | cell pointer | | 2 bytes per cell. Sorted order. 53094 // | array | | Grows downward 53095 // | | v 53096 // |----------------| 53097 // | unallocated | 53098 // | space | 53099 // |----------------| ^ Grows upwards 53100 // | cell content | | Arbitrary order interspersed with freeblocks. 53101 // | area | | and free space fragments. 53102 // |----------------| 53103 // 53104 // The page headers looks like this: 53105 // 53106 // OFFSET SIZE DESCRIPTION 53107 // 0 1 Flags. 1: intkey, 2: zerodata, 4: leafdata, 8: leaf 53108 // 1 2 byte offset to the first freeblock 53109 // 3 2 number of cells on this page 53110 // 5 2 first byte of the cell content area 53111 // 7 1 number of fragmented free bytes 53112 // 8 4 Right child (the Ptr(N) value). Omitted on leaves. 53113 // 53114 // The flags define the format of this btree page. The leaf flag means that 53115 // this page has no children. The zerodata flag means that this page carries 53116 // only keys and no data. The intkey flag means that the key is an integer 53117 // which is stored in the key size entry of the cell header rather than in 53118 // the payload area. 53119 // 53120 // The cell pointer array begins on the first byte after the page header. 53121 // The cell pointer array contains zero or more 2-byte numbers which are 53122 // offsets from the beginning of the page to the cell content in the cell 53123 // content area. The cell pointers occur in sorted order. The system strives 53124 // to keep free space after the last cell pointer so that new cells can 53125 // be easily added without having to defragment the page. 53126 // 53127 // Cell content is stored at the very end of the page and grows toward the 53128 // beginning of the page. 53129 // 53130 // Unused space within the cell content area is collected into a linked list of 53131 // freeblocks. Each freeblock is at least 4 bytes in size. The byte offset 53132 // to the first freeblock is given in the header. Freeblocks occur in 53133 // increasing order. Because a freeblock must be at least 4 bytes in size, 53134 // any group of 3 or fewer unused bytes in the cell content area cannot 53135 // exist on the freeblock chain. A group of 3 or fewer free bytes is called 53136 // a fragment. The total number of bytes in all fragments is recorded. 53137 // in the page header at offset 7. 53138 // 53139 // SIZE DESCRIPTION 53140 // 2 Byte offset of the next freeblock 53141 // 2 Bytes in this freeblock 53142 // 53143 // Cells are of variable length. Cells are stored in the cell content area at 53144 // the end of the page. Pointers to the cells are in the cell pointer array 53145 // that immediately follows the page header. Cells is not necessarily 53146 // contiguous or in order, but cell pointers are contiguous and in order. 53147 // 53148 // Cell content makes use of variable length integers. A variable 53149 // length integer is 1 to 9 bytes where the lower 7 bits of each 53150 // byte are used. The integer consists of all bytes that have bit 8 set and 53151 // the first byte with bit 8 clear. The most significant byte of the integer 53152 // appears first. A variable-length integer may not be more than 9 bytes long. 53153 // As a special case, all 8 bytes of the 9th byte are used as data. This 53154 // allows a 64-bit integer to be encoded in 9 bytes. 53155 // 53156 // 0x00 becomes 0x00000000 53157 // 0x7f becomes 0x0000007f 53158 // 0x81 0x00 becomes 0x00000080 53159 // 0x82 0x00 becomes 0x00000100 53160 // 0x80 0x7f becomes 0x0000007f 53161 // 0x8a 0x91 0xd1 0xac 0x78 becomes 0x12345678 53162 // 0x81 0x81 0x81 0x81 0x01 becomes 0x10204081 53163 // 53164 // Variable length integers are used for rowids and to hold the number of 53165 // bytes of key and data in a btree cell. 53166 // 53167 // The content of a cell looks like this: 53168 // 53169 // SIZE DESCRIPTION 53170 // 4 Page number of the left child. Omitted if leaf flag is set. 53171 // var Number of bytes of data. Omitted if the zerodata flag is set. 53172 // var Number of bytes of key. Or the key itself if intkey flag is set. 53173 // * Payload 53174 // 4 First page of the overflow chain. Omitted if no overflow 53175 // 53176 // Overflow pages form a linked list. Each page except the last is completely 53177 // filled with data (pagesize - 4 bytes). The last page can have as little 53178 // as 1 byte of data. 53179 // 53180 // SIZE DESCRIPTION 53181 // 4 Page number of next overflow page 53182 // * Data 53183 // 53184 // Freelist pages come in two subtypes: trunk pages and leaf pages. The 53185 // file header points to the first in a linked list of trunk page. Each trunk 53186 // page points to multiple leaf pages. The content of a leaf page is 53187 // unspecified. A trunk page looks like this: 53188 // 53189 // SIZE DESCRIPTION 53190 // 4 Page number of next trunk page 53191 // 4 Number of leaf pointers on this page 53192 // * zero or more pages numbers of leaves 53193 // 2001 September 15 53194 // 53195 // The author disclaims copyright to this source code. In place of 53196 // a legal notice, here is a blessing: 53197 // 53198 // May you do good and not evil. 53199 // May you find forgiveness for yourself and forgive others. 53200 // May you share freely, never taking more than you give. 53201 // 53202 // 53203 // Internal interface definitions for SQLite. 53204 // 53205 53206 // The following value is the maximum cell size assuming a maximum page 53207 // size give above. 53208 53209 // The maximum number of cells on a single page of the database. This 53210 // assumes a minimum cell size of 6 bytes (4 bytes for the cell itself 53211 // plus 2 bytes for the index to the cell in the page header). Such 53212 // small cells will be rare, but they are possible. 53213 53214 // Forward declarations 53215 type MemPage1 = struct { 53216 FisInit u8 53217 FbBusy u8 53218 FintKey u8 53219 FintKeyLeaf u8 53220 Fpgno Pgno 53221 Fleaf u8 53222 FhdrOffset u8 53223 FchildPtrSize u8 53224 Fmax1bytePayload u8 53225 FnOverflow u8 53226 _ [1]byte 53227 FmaxLocal u16 53228 FminLocal u16 53229 FcellOffset u16 53230 FnFree int32 53231 FnCell u16 53232 FmaskPage u16 53233 FaiOvfl [4]u16 53234 _ [4]byte 53235 FapOvfl [4]uintptr 53236 FpBt uintptr 53237 FaData uintptr 53238 FaDataEnd uintptr 53239 FaCellIdx uintptr 53240 FaDataOfst uintptr 53241 FpDbPage uintptr 53242 FxCellSize uintptr 53243 FxParseCell uintptr 53244 } /* btree.h:39:9 */ 53245 53246 // 2004 April 6 53247 // 53248 // The author disclaims copyright to this source code. In place of 53249 // a legal notice, here is a blessing: 53250 // 53251 // May you do good and not evil. 53252 // May you find forgiveness for yourself and forgive others. 53253 // May you share freely, never taking more than you give. 53254 // 53255 // 53256 // This file implements an external (disk-based) database using BTrees. 53257 // For a detailed discussion of BTrees, refer to 53258 // 53259 // Donald E. Knuth, THE ART OF COMPUTER PROGRAMMING, Volume 3: 53260 // "Sorting And Searching", pages 473-480. Addison-Wesley 53261 // Publishing Company, Reading, Massachusetts. 53262 // 53263 // The basic idea is that each page of the file contains N database 53264 // entries and N+1 pointers to subpages. 53265 // 53266 // ---------------------------------------------------------------- 53267 // | Ptr(0) | Key(0) | Ptr(1) | Key(1) | ... | Key(N-1) | Ptr(N) | 53268 // ---------------------------------------------------------------- 53269 // 53270 // All of the keys on the page that Ptr(0) points to have values less 53271 // than Key(0). All of the keys on page Ptr(1) and its subpages have 53272 // values greater than Key(0) and less than Key(1). All of the keys 53273 // on Ptr(N) and its subpages have values greater than Key(N-1). And 53274 // so forth. 53275 // 53276 // Finding a particular key requires reading O(log(M)) pages from the 53277 // disk where M is the number of entries in the tree. 53278 // 53279 // In this implementation, a single file can hold one or more separate 53280 // BTrees. Each BTree is identified by the index of its root page. The 53281 // key and data for any entry are combined to form the "payload". A 53282 // fixed amount of payload can be carried directly on the database 53283 // page. If the payload is larger than the preset amount then surplus 53284 // bytes are stored on overflow pages. The payload for an entry 53285 // and the preceding pointer are combined to form a "Cell". Each 53286 // page has a small header which contains the Ptr(N) pointer and other 53287 // information such as the size of key and data. 53288 // 53289 // FORMAT DETAILS 53290 // 53291 // The file is divided into pages. The first page is called page 1, 53292 // the second is page 2, and so forth. A page number of zero indicates 53293 // "no such page". The page size can be any power of 2 between 512 and 65536. 53294 // Each page can be either a btree page, a freelist page, an overflow 53295 // page, or a pointer-map page. 53296 // 53297 // The first page is always a btree page. The first 100 bytes of the first 53298 // page contain a special header (the "file header") that describes the file. 53299 // The format of the file header is as follows: 53300 // 53301 // OFFSET SIZE DESCRIPTION 53302 // 0 16 Header string: "SQLite format 3\000" 53303 // 16 2 Page size in bytes. (1 means 65536) 53304 // 18 1 File format write version 53305 // 19 1 File format read version 53306 // 20 1 Bytes of unused space at the end of each page 53307 // 21 1 Max embedded payload fraction (must be 64) 53308 // 22 1 Min embedded payload fraction (must be 32) 53309 // 23 1 Min leaf payload fraction (must be 32) 53310 // 24 4 File change counter 53311 // 28 4 Reserved for future use 53312 // 32 4 First freelist page 53313 // 36 4 Number of freelist pages in the file 53314 // 40 60 15 4-byte meta values passed to higher layers 53315 // 53316 // 40 4 Schema cookie 53317 // 44 4 File format of schema layer 53318 // 48 4 Size of page cache 53319 // 52 4 Largest root-page (auto/incr_vacuum) 53320 // 56 4 1=UTF-8 2=UTF16le 3=UTF16be 53321 // 60 4 User version 53322 // 64 4 Incremental vacuum mode 53323 // 68 4 Application-ID 53324 // 72 20 unused 53325 // 92 4 The version-valid-for number 53326 // 96 4 SQLITE_VERSION_NUMBER 53327 // 53328 // All of the integer values are big-endian (most significant byte first). 53329 // 53330 // The file change counter is incremented when the database is changed 53331 // This counter allows other processes to know when the file has changed 53332 // and thus when they need to flush their cache. 53333 // 53334 // The max embedded payload fraction is the amount of the total usable 53335 // space in a page that can be consumed by a single cell for standard 53336 // B-tree (non-LEAFDATA) tables. A value of 255 means 100%. The default 53337 // is to limit the maximum cell size so that at least 4 cells will fit 53338 // on one page. Thus the default max embedded payload fraction is 64. 53339 // 53340 // If the payload for a cell is larger than the max payload, then extra 53341 // payload is spilled to overflow pages. Once an overflow page is allocated, 53342 // as many bytes as possible are moved into the overflow pages without letting 53343 // the cell size drop below the min embedded payload fraction. 53344 // 53345 // The min leaf payload fraction is like the min embedded payload fraction 53346 // except that it applies to leaf nodes in a LEAFDATA tree. The maximum 53347 // payload fraction for a LEAFDATA tree is always 100% (or 255) and it 53348 // not specified in the header. 53349 // 53350 // Each btree pages is divided into three sections: The header, the 53351 // cell pointer array, and the cell content area. Page 1 also has a 100-byte 53352 // file header that occurs before the page header. 53353 // 53354 // |----------------| 53355 // | file header | 100 bytes. Page 1 only. 53356 // |----------------| 53357 // | page header | 8 bytes for leaves. 12 bytes for interior nodes 53358 // |----------------| 53359 // | cell pointer | | 2 bytes per cell. Sorted order. 53360 // | array | | Grows downward 53361 // | | v 53362 // |----------------| 53363 // | unallocated | 53364 // | space | 53365 // |----------------| ^ Grows upwards 53366 // | cell content | | Arbitrary order interspersed with freeblocks. 53367 // | area | | and free space fragments. 53368 // |----------------| 53369 // 53370 // The page headers looks like this: 53371 // 53372 // OFFSET SIZE DESCRIPTION 53373 // 0 1 Flags. 1: intkey, 2: zerodata, 4: leafdata, 8: leaf 53374 // 1 2 byte offset to the first freeblock 53375 // 3 2 number of cells on this page 53376 // 5 2 first byte of the cell content area 53377 // 7 1 number of fragmented free bytes 53378 // 8 4 Right child (the Ptr(N) value). Omitted on leaves. 53379 // 53380 // The flags define the format of this btree page. The leaf flag means that 53381 // this page has no children. The zerodata flag means that this page carries 53382 // only keys and no data. The intkey flag means that the key is an integer 53383 // which is stored in the key size entry of the cell header rather than in 53384 // the payload area. 53385 // 53386 // The cell pointer array begins on the first byte after the page header. 53387 // The cell pointer array contains zero or more 2-byte numbers which are 53388 // offsets from the beginning of the page to the cell content in the cell 53389 // content area. The cell pointers occur in sorted order. The system strives 53390 // to keep free space after the last cell pointer so that new cells can 53391 // be easily added without having to defragment the page. 53392 // 53393 // Cell content is stored at the very end of the page and grows toward the 53394 // beginning of the page. 53395 // 53396 // Unused space within the cell content area is collected into a linked list of 53397 // freeblocks. Each freeblock is at least 4 bytes in size. The byte offset 53398 // to the first freeblock is given in the header. Freeblocks occur in 53399 // increasing order. Because a freeblock must be at least 4 bytes in size, 53400 // any group of 3 or fewer unused bytes in the cell content area cannot 53401 // exist on the freeblock chain. A group of 3 or fewer free bytes is called 53402 // a fragment. The total number of bytes in all fragments is recorded. 53403 // in the page header at offset 7. 53404 // 53405 // SIZE DESCRIPTION 53406 // 2 Byte offset of the next freeblock 53407 // 2 Bytes in this freeblock 53408 // 53409 // Cells are of variable length. Cells are stored in the cell content area at 53410 // the end of the page. Pointers to the cells are in the cell pointer array 53411 // that immediately follows the page header. Cells is not necessarily 53412 // contiguous or in order, but cell pointers are contiguous and in order. 53413 // 53414 // Cell content makes use of variable length integers. A variable 53415 // length integer is 1 to 9 bytes where the lower 7 bits of each 53416 // byte are used. The integer consists of all bytes that have bit 8 set and 53417 // the first byte with bit 8 clear. The most significant byte of the integer 53418 // appears first. A variable-length integer may not be more than 9 bytes long. 53419 // As a special case, all 8 bytes of the 9th byte are used as data. This 53420 // allows a 64-bit integer to be encoded in 9 bytes. 53421 // 53422 // 0x00 becomes 0x00000000 53423 // 0x7f becomes 0x0000007f 53424 // 0x81 0x00 becomes 0x00000080 53425 // 0x82 0x00 becomes 0x00000100 53426 // 0x80 0x7f becomes 0x0000007f 53427 // 0x8a 0x91 0xd1 0xac 0x78 becomes 0x12345678 53428 // 0x81 0x81 0x81 0x81 0x01 becomes 0x10204081 53429 // 53430 // Variable length integers are used for rowids and to hold the number of 53431 // bytes of key and data in a btree cell. 53432 // 53433 // The content of a cell looks like this: 53434 // 53435 // SIZE DESCRIPTION 53436 // 4 Page number of the left child. Omitted if leaf flag is set. 53437 // var Number of bytes of data. Omitted if the zerodata flag is set. 53438 // var Number of bytes of key. Or the key itself if intkey flag is set. 53439 // * Payload 53440 // 4 First page of the overflow chain. Omitted if no overflow 53441 // 53442 // Overflow pages form a linked list. Each page except the last is completely 53443 // filled with data (pagesize - 4 bytes). The last page can have as little 53444 // as 1 byte of data. 53445 // 53446 // SIZE DESCRIPTION 53447 // 4 Page number of next overflow page 53448 // * Data 53449 // 53450 // Freelist pages come in two subtypes: trunk pages and leaf pages. The 53451 // file header points to the first in a linked list of trunk page. Each trunk 53452 // page points to multiple leaf pages. The content of a leaf page is 53453 // unspecified. A trunk page looks like this: 53454 // 53455 // SIZE DESCRIPTION 53456 // 4 Page number of next trunk page 53457 // 4 Number of leaf pointers on this page 53458 // * zero or more pages numbers of leaves 53459 // 2001 September 15 53460 // 53461 // The author disclaims copyright to this source code. In place of 53462 // a legal notice, here is a blessing: 53463 // 53464 // May you do good and not evil. 53465 // May you find forgiveness for yourself and forgive others. 53466 // May you share freely, never taking more than you give. 53467 // 53468 // 53469 // Internal interface definitions for SQLite. 53470 // 53471 53472 // The following value is the maximum cell size assuming a maximum page 53473 // size give above. 53474 53475 // The maximum number of cells on a single page of the database. This 53476 // assumes a minimum cell size of 6 bytes (4 bytes for the cell itself 53477 // plus 2 bytes for the index to the cell in the page header). Such 53478 // small cells will be rare, but they are possible. 53479 53480 // Forward declarations 53481 type MemPage = MemPage1 /* btreeInt.h:232:24 */ 53482 type BtLock1 = struct { 53483 FpBtree uintptr 53484 FiTable Pgno 53485 FeLock u8 53486 _ [3]byte 53487 FpNext uintptr 53488 } /* btree.h:39:9 */ 53489 53490 type BtLock = BtLock1 /* btreeInt.h:233:23 */ 53491 type CellInfo1 = struct { 53492 FnKey i64 53493 FpPayload uintptr 53494 FnPayload u322 53495 FnLocal u16 53496 FnSize u16 53497 } /* btree.h:39:9 */ 53498 53499 type CellInfo = CellInfo1 /* btreeInt.h:234:25 */ 53500 53501 // Legal values for BtCursor.curFlags 53502 53503 // Potential values for BtCursor.eState. 53504 // 53505 // CURSOR_INVALID: 53506 // Cursor does not point to a valid entry. This can happen (for example) 53507 // because the table is empty or because BtreeCursorFirst() has not been 53508 // called. 53509 // 53510 // CURSOR_VALID: 53511 // Cursor points to a valid entry. getPayload() etc. may be called. 53512 // 53513 // CURSOR_SKIPNEXT: 53514 // Cursor is valid except that the Cursor.skipNext field is non-zero 53515 // indicating that the next sqlite3BtreeNext() or sqlite3BtreePrevious() 53516 // operation should be a no-op. 53517 // 53518 // CURSOR_REQUIRESEEK: 53519 // The table that this cursor was opened on still exists, but has been 53520 // modified since the cursor was last used. The cursor position is saved 53521 // in variables BtCursor.pKey and BtCursor.nKey. When a cursor is in 53522 // this state, restoreCursorPosition() can be called to attempt to 53523 // seek the cursor to the saved position. 53524 // 53525 // CURSOR_FAULT: 53526 // An unrecoverable error (an I/O error or a malloc failure) has occurred 53527 // on a different connection that shares the BtShared cache with this 53528 // cursor. The error has left the cache in an inconsistent state. 53529 // Do nothing else with this cursor. Any attempt to use the cursor 53530 // should return the error code stored in BtCursor.skipNext 53531 53532 // The database page the PENDING_BYTE occupies. This page is never used. 53533 53534 // These macros define the location of the pointer-map entry for a 53535 // database page. The first argument to each is the number of usable 53536 // bytes on each page of the database (often 1024). The second is the 53537 // page number to look up in the pointer map. 53538 // 53539 // PTRMAP_PAGENO returns the database page number of the pointer-map 53540 // page that stores the required pointer. PTRMAP_PTROFFSET returns 53541 // the offset of the requested map entry. 53542 // 53543 // If the pgno argument passed to PTRMAP_PAGENO is a pointer-map page, 53544 // then pgno is returned. So (pgno==PTRMAP_PAGENO(pgsz, pgno)) can be 53545 // used to test if pgno is a pointer-map page. PTRMAP_ISPAGE implements 53546 // this test. 53547 53548 // The pointer map is a lookup table that identifies the parent page for 53549 // each child page in the database file. The parent page is the page that 53550 // contains a pointer to the child. Every page in the database contains 53551 // 0 or 1 parent pages. (In this context 'database page' refers 53552 // to any page that is not part of the pointer map itself.) Each pointer map 53553 // entry consists of a single byte 'type' and a 4 byte parent page number. 53554 // The PTRMAP_XXX identifiers below are the valid types. 53555 // 53556 // The purpose of the pointer map is to facility moving pages from one 53557 // position in the file to another as part of autovacuum. When a page 53558 // is moved, the pointer in its parent must be updated to point to the 53559 // new location. The pointer map is used to locate the parent page quickly. 53560 // 53561 // PTRMAP_ROOTPAGE: The database page is a root-page. The page-number is not 53562 // used in this case. 53563 // 53564 // PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number 53565 // is not used in this case. 53566 // 53567 // PTRMAP_OVERFLOW1: The database page is the first page in a list of 53568 // overflow pages. The page number identifies the page that 53569 // contains the cell with a pointer to this overflow page. 53570 // 53571 // PTRMAP_OVERFLOW2: The database page is the second or later page in a list of 53572 // overflow pages. The page-number identifies the previous 53573 // page in the overflow page list. 53574 // 53575 // PTRMAP_BTREE: The database page is a non-root btree page. The page number 53576 // identifies the parent page in the btree. 53577 53578 // A bunch of assert() statements to check the transaction state variables 53579 // of handle p (type Btree*) are internally consistent. 53580 53581 // The ISAUTOVACUUM macro is used within balance_nonroot() to determine 53582 // if the database supports auto-vacuum or not. Because it is used 53583 // within an expression that is an argument to another macro 53584 // (sqliteMallocRaw), it is not possible to use conditional compilation. 53585 // So, this macro is defined instead. 53586 53587 // This structure is passed around through all the sanity checking routines 53588 // in order to keep track of some global state information. 53589 // 53590 // The aRef[] array is allocated so that there is 1 bit for each page in 53591 // the database. As the integrity-check proceeds, for each page used in 53592 // the database the corresponding bit is set. This allows integrity-check to 53593 // detect pages that are used twice and orphaned pages (both of which 53594 // indicate corruption). 53595 type IntegrityCk1 = struct { 53596 FpBt uintptr 53597 FpPager uintptr 53598 FaPgRef uintptr 53599 FnPage Pgno 53600 FmxErr int32 53601 FnErr int32 53602 FbOomFault int32 53603 FzPfx uintptr 53604 Fv1 Pgno 53605 Fv2 int32 53606 FerrMsg StrAccum 53607 Fheap uintptr 53608 Fdb uintptr 53609 } /* btreeInt.h:692:9 */ 53610 53611 // Legal values for BtCursor.curFlags 53612 53613 // Potential values for BtCursor.eState. 53614 // 53615 // CURSOR_INVALID: 53616 // Cursor does not point to a valid entry. This can happen (for example) 53617 // because the table is empty or because BtreeCursorFirst() has not been 53618 // called. 53619 // 53620 // CURSOR_VALID: 53621 // Cursor points to a valid entry. getPayload() etc. may be called. 53622 // 53623 // CURSOR_SKIPNEXT: 53624 // Cursor is valid except that the Cursor.skipNext field is non-zero 53625 // indicating that the next sqlite3BtreeNext() or sqlite3BtreePrevious() 53626 // operation should be a no-op. 53627 // 53628 // CURSOR_REQUIRESEEK: 53629 // The table that this cursor was opened on still exists, but has been 53630 // modified since the cursor was last used. The cursor position is saved 53631 // in variables BtCursor.pKey and BtCursor.nKey. When a cursor is in 53632 // this state, restoreCursorPosition() can be called to attempt to 53633 // seek the cursor to the saved position. 53634 // 53635 // CURSOR_FAULT: 53636 // An unrecoverable error (an I/O error or a malloc failure) has occurred 53637 // on a different connection that shares the BtShared cache with this 53638 // cursor. The error has left the cache in an inconsistent state. 53639 // Do nothing else with this cursor. Any attempt to use the cursor 53640 // should return the error code stored in BtCursor.skipNext 53641 53642 // The database page the PENDING_BYTE occupies. This page is never used. 53643 53644 // These macros define the location of the pointer-map entry for a 53645 // database page. The first argument to each is the number of usable 53646 // bytes on each page of the database (often 1024). The second is the 53647 // page number to look up in the pointer map. 53648 // 53649 // PTRMAP_PAGENO returns the database page number of the pointer-map 53650 // page that stores the required pointer. PTRMAP_PTROFFSET returns 53651 // the offset of the requested map entry. 53652 // 53653 // If the pgno argument passed to PTRMAP_PAGENO is a pointer-map page, 53654 // then pgno is returned. So (pgno==PTRMAP_PAGENO(pgsz, pgno)) can be 53655 // used to test if pgno is a pointer-map page. PTRMAP_ISPAGE implements 53656 // this test. 53657 53658 // The pointer map is a lookup table that identifies the parent page for 53659 // each child page in the database file. The parent page is the page that 53660 // contains a pointer to the child. Every page in the database contains 53661 // 0 or 1 parent pages. (In this context 'database page' refers 53662 // to any page that is not part of the pointer map itself.) Each pointer map 53663 // entry consists of a single byte 'type' and a 4 byte parent page number. 53664 // The PTRMAP_XXX identifiers below are the valid types. 53665 // 53666 // The purpose of the pointer map is to facility moving pages from one 53667 // position in the file to another as part of autovacuum. When a page 53668 // is moved, the pointer in its parent must be updated to point to the 53669 // new location. The pointer map is used to locate the parent page quickly. 53670 // 53671 // PTRMAP_ROOTPAGE: The database page is a root-page. The page-number is not 53672 // used in this case. 53673 // 53674 // PTRMAP_FREEPAGE: The database page is an unused (free) page. The page-number 53675 // is not used in this case. 53676 // 53677 // PTRMAP_OVERFLOW1: The database page is the first page in a list of 53678 // overflow pages. The page number identifies the page that 53679 // contains the cell with a pointer to this overflow page. 53680 // 53681 // PTRMAP_OVERFLOW2: The database page is the second or later page in a list of 53682 // overflow pages. The page-number identifies the previous 53683 // page in the overflow page list. 53684 // 53685 // PTRMAP_BTREE: The database page is a non-root btree page. The page number 53686 // identifies the parent page in the btree. 53687 53688 // A bunch of assert() statements to check the transaction state variables 53689 // of handle p (type Btree*) are internally consistent. 53690 53691 // The ISAUTOVACUUM macro is used within balance_nonroot() to determine 53692 // if the database supports auto-vacuum or not. Because it is used 53693 // within an expression that is an argument to another macro 53694 // (sqliteMallocRaw), it is not possible to use conditional compilation. 53695 // So, this macro is defined instead. 53696 53697 // This structure is passed around through all the sanity checking routines 53698 // in order to keep track of some global state information. 53699 // 53700 // The aRef[] array is allocated so that there is 1 bit for each page in 53701 // the database. As the integrity-check proceeds, for each page used in 53702 // the database the corresponding bit is set. This allows integrity-check to 53703 // detect pages that are used twice and orphaned pages (both of which 53704 // indicate corruption). 53705 type IntegrityCk = IntegrityCk1 /* btreeInt.h:692:28 */ 53706 53707 // A bogus sqlite3 connection structure for use in the btree 53708 // tests. 53709 var sDb sqlite31 /* test3.c:32:16: */ 53710 var nRefSqlite3 int32 = 0 /* test3.c:33:12 */ 53711 53712 // Usage: btree_open FILENAME NCACHE 53713 // 53714 // Open a new database 53715 func btree_open(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test3.c:40:26: */ 53716 bp := tls.Alloc(188) 53717 defer tls.Free(188) 53718 53719 // var pBt uintptr at bp+80, 8 53720 53721 var rc int32 53722 // var nCache int32 at bp+72, 4 53723 53724 // var zBuf [100]int8 at bp+88, 100 53725 53726 var n int32 53727 var zFilename uintptr 53728 if argc != 3 { 53729 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 53730 ts+24569 /* " FILENAME NCACHE..." */, 0)) 53731 return TCL_ERROR 53732 } 53733 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+72 /* &nCache */) != 0 { 53734 return TCL_ERROR 53735 } 53736 nRefSqlite3++ 53737 if nRefSqlite3 == 1 { 53738 sDb.FpVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 53739 sDb.Fmutex = sqlite3.Xsqlite3MutexAlloc(tls, SQLITE_MUTEX_RECURSIVE) 53740 sqlite3.Xsqlite3_mutex_enter(tls, sDb.Fmutex) 53741 } 53742 n = int32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) 53743 zFilename = sqlite3.Xsqlite3_malloc(tls, (n + 2)) 53744 if zFilename == uintptr(0) { 53745 return TCL_ERROR 53746 } 53747 libc.Xmemcpy(tls, zFilename, *(*uintptr)(unsafe.Pointer(argv + 1*8)), (uint64(n + 1))) 53748 *(*int8)(unsafe.Pointer(zFilename + uintptr((n + 1)))) = int8(0) 53749 rc = sqlite3.Xsqlite3BtreeOpen(tls, sDb.FpVfs, zFilename, uintptr(unsafe.Pointer(&sDb)), bp+80 /* &pBt */, 0, 53750 ((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_MAIN_DB)) 53751 sqlite3.Xsqlite3_free(tls, zFilename) 53752 if rc != SQLITE_OK { 53753 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 53754 return TCL_ERROR 53755 } 53756 sqlite3.Xsqlite3BtreeSetCacheSize(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pBt */)), *(*int32)(unsafe.Pointer(bp + 72 /* nCache */))) 53757 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+88 /* &zBuf[0] */, ts+13023 /* "%p" */, libc.VaList(bp+48, *(*uintptr)(unsafe.Pointer(bp + 80 /* pBt */)))) 53758 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, bp+88 /* &zBuf[0] */, 0)) 53759 return TCL_OK 53760 } 53761 53762 // Usage: btree_close ID 53763 // 53764 // Close the given database. 53765 func btree_close(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test3.c:86:26: */ 53766 bp := tls.Alloc(48) 53767 defer tls.Free(48) 53768 53769 var pBt uintptr 53770 var rc int32 53771 if argc != 2 { 53772 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 53773 ts+23897 /* " ID\"" */, 0)) 53774 return TCL_ERROR 53775 } 53776 pBt = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 53777 rc = sqlite3.Xsqlite3BtreeClose(tls, pBt) 53778 if rc != SQLITE_OK { 53779 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 53780 return TCL_ERROR 53781 } 53782 nRefSqlite3-- 53783 if nRefSqlite3 == 0 { 53784 sqlite3.Xsqlite3_mutex_leave(tls, sDb.Fmutex) 53785 sqlite3.Xsqlite3_mutex_free(tls, sDb.Fmutex) 53786 sDb.Fmutex = uintptr(0) 53787 sDb.FpVfs = uintptr(0) 53788 } 53789 return TCL_OK 53790 } 53791 53792 // Usage: btree_begin_transaction ID 53793 // 53794 // Start a new transaction 53795 func btree_begin_transaction(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test3.c:121:26: */ 53796 bp := tls.Alloc(48) 53797 defer tls.Free(48) 53798 53799 var pBt uintptr 53800 var rc int32 53801 if argc != 2 { 53802 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 53803 ts+23897 /* " ID\"" */, 0)) 53804 return TCL_ERROR 53805 } 53806 pBt = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 53807 sqlite3.Xsqlite3BtreeEnter(tls, pBt) 53808 rc = sqlite3.Xsqlite3BtreeBeginTrans(tls, pBt, 1, uintptr(0)) 53809 sqlite3.Xsqlite3BtreeLeave(tls, pBt) 53810 if rc != SQLITE_OK { 53811 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 53812 return TCL_ERROR 53813 } 53814 return TCL_OK 53815 } 53816 53817 // Usage: btree_pager_stats ID 53818 // 53819 // Returns pager statistics 53820 func btree_pager_stats(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test3.c:150:26: */ 53821 bp := tls.Alloc(140) 53822 defer tls.Free(140) 53823 53824 var pBt uintptr 53825 var i int32 53826 var a uintptr 53827 53828 if argc != 2 { 53829 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 53830 ts+23897 /* " ID\"" */, 0)) 53831 return TCL_ERROR 53832 } 53833 pBt = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 53834 53835 // Normally in this file, with a b-tree handle opened using the 53836 // [btree_open] command it is safe to call sqlite3BtreeEnter() directly. 53837 // But this function is sometimes called with a btree handle obtained 53838 // from an open SQLite connection (using [btree_from_db]). In this case 53839 // we need to obtain the mutex for the controlling SQLite handle before 53840 // it is safe to call sqlite3BtreeEnter(). 53841 sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBt)).Fdb)).Fmutex) 53842 53843 sqlite3.Xsqlite3BtreeEnter(tls, pBt) 53844 a = sqlite3.Xsqlite3PagerStats(tls, sqlite3.Xsqlite3BtreePager(tls, pBt)) 53845 for i = 0; i < 11; i++ { 53846 // var zBuf [100]int8 at bp+40, 100 53847 53848 tcl.XTcl_AppendElement(tls, interp, zName1[i]) 53849 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+40 /* &zBuf[0] */, ts+1238 /* "%d" */, libc.VaList(bp+32, *(*int32)(unsafe.Pointer(a + uintptr(i)*4)))) 53850 tcl.XTcl_AppendElement(tls, interp, bp+40 /* &zBuf[0] */) 53851 } 53852 sqlite3.Xsqlite3BtreeLeave(tls, pBt) 53853 53854 // Release the mutex on the SQLite handle that controls this b-tree 53855 sqlite3.Xsqlite3_mutex_leave(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBt)).Fdb)).Fmutex) 53856 return TCL_OK 53857 } 53858 53859 var zName1 = [11]uintptr{ 53860 ts + 23902 /* "ref" */, ts + 23906 /* "page" */, ts + 17904 /* "max" */, ts + 11493 /* "size" */, ts + 10195 /* "state" */, ts + 23911, /* "err" */ 53861 ts + 23915 /* "hit" */, ts + 23919 /* "miss" */, ts + 23924 /* "ovfl" */, ts + 24593 /* "read" */, ts + 24598, /* "write" */ 53862 } /* test3.c:179:17 */ 53863 53864 // Usage: btree_cursor ID TABLENUM WRITEABLE 53865 // 53866 // Create a new cursor. Return the ID for the cursor. 53867 func btree_cursor(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test3.c:200:26: */ 53868 bp := tls.Alloc(110) 53869 defer tls.Free(110) 53870 53871 var pBt uintptr 53872 // var iTable int32 at bp+72, 4 53873 53874 var pCur uintptr 53875 var rc int32 = SQLITE_OK 53876 // var wrFlag int32 at bp+76, 4 53877 53878 // var zBuf [30]int8 at bp+80, 30 53879 53880 if argc != 4 { 53881 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 53882 ts+24604 /* " ID TABLENUM WRI..." */, 0)) 53883 return TCL_ERROR 53884 } 53885 pBt = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 53886 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+72 /* &iTable */) != 0 { 53887 return TCL_ERROR 53888 } 53889 if tcl.XTcl_GetBoolean(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 3*8)), bp+76 /* &wrFlag */) != 0 { 53890 return TCL_ERROR 53891 } 53892 if *(*int32)(unsafe.Pointer(bp + 76 /* wrFlag */)) != 0 { 53893 *(*int32)(unsafe.Pointer(bp + 76 /* wrFlag */)) = BTREE_WRCSR 53894 } 53895 pCur = tcl.XTcl_Alloc(tls, uint32(sqlite3.Xsqlite3BtreeCursorSize(tls))) 53896 libc.Xmemset(tls, pCur, 0, uint64(sqlite3.Xsqlite3BtreeCursorSize(tls))) 53897 sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBt)).Fdb)).Fmutex) 53898 sqlite3.Xsqlite3BtreeEnter(tls, pBt) 53899 rc = sqlite3.Xsqlite3BtreeLockTable(tls, pBt, *(*int32)(unsafe.Pointer(bp + 72 /* iTable */)), libc.BoolUint8(!(!(*(*int32)(unsafe.Pointer(bp + 76 /* wrFlag */)) != 0)))) 53900 if rc == SQLITE_OK { 53901 rc = sqlite3.Xsqlite3BtreeCursor(tls, pBt, uint32(*(*int32)(unsafe.Pointer(bp + 72 /* iTable */))), *(*int32)(unsafe.Pointer(bp + 76 /* wrFlag */)), uintptr(0), pCur) 53902 } 53903 sqlite3.Xsqlite3BtreeLeave(tls, pBt) 53904 sqlite3.Xsqlite3_mutex_leave(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBt)).Fdb)).Fmutex) 53905 if rc != 0 { 53906 tcl.XTcl_Free(tls, pCur) 53907 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 53908 return TCL_ERROR 53909 } 53910 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+80 /* &zBuf[0] */, ts+13023 /* "%p" */, libc.VaList(bp+48, pCur)) 53911 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, bp+80 /* &zBuf[0] */, 0)) 53912 return SQLITE_OK 53913 } 53914 53915 // Usage: btree_close_cursor ID 53916 // 53917 // Close a cursor opened using btree_cursor. 53918 func btree_close_cursor(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test3.c:249:26: */ 53919 bp := tls.Alloc(48) 53920 defer tls.Free(48) 53921 53922 var pCur uintptr 53923 var rc int32 53924 53925 if argc != 2 { 53926 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 53927 ts+23897 /* " ID\"" */, 0)) 53928 return TCL_ERROR 53929 } 53930 pCur = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 53931 { 53932 var pBt uintptr = (*BtCursor)(unsafe.Pointer(pCur)).FpBtree 53933 sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBt)).Fdb)).Fmutex) 53934 sqlite3.Xsqlite3BtreeEnter(tls, pBt) 53935 rc = sqlite3.Xsqlite3BtreeCloseCursor(tls, pCur) 53936 sqlite3.Xsqlite3BtreeLeave(tls, pBt) 53937 sqlite3.Xsqlite3_mutex_leave(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBt)).Fdb)).Fmutex) 53938 53939 } 53940 tcl.XTcl_Free(tls, pCur) 53941 if rc != 0 { 53942 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 53943 return TCL_ERROR 53944 } 53945 return SQLITE_OK 53946 } 53947 53948 // Usage: btree_next ID 53949 // 53950 // Move the cursor to the next entry in the table. Return 0 on success 53951 // or 1 if the cursor was already on the last entry in the table or if 53952 // the table is empty. 53953 func btree_next(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test3.c:291:26: */ 53954 bp := tls.Alloc(172) 53955 defer tls.Free(172) 53956 53957 var pCur uintptr 53958 var rc int32 53959 var res int32 = 0 53960 // var zBuf [100]int8 at bp+72, 100 53961 53962 if argc != 2 { 53963 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 53964 ts+23897 /* " ID\"" */, 0)) 53965 return TCL_ERROR 53966 } 53967 pCur = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 53968 sqlite3.Xsqlite3BtreeEnter(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) 53969 rc = sqlite3.Xsqlite3BtreeNext(tls, pCur, 0) 53970 if rc == SQLITE_DONE { 53971 res = 1 53972 rc = SQLITE_OK 53973 } 53974 sqlite3.Xsqlite3BtreeLeave(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) 53975 if rc != 0 { 53976 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 53977 return TCL_ERROR 53978 } 53979 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+72 /* &zBuf[0] */, ts+1238 /* "%d" */, libc.VaList(bp+48, res)) 53980 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, bp+72 /* &zBuf[0] */, 0)) 53981 return SQLITE_OK 53982 } 53983 53984 // Usage: btree_first ID 53985 // 53986 // Move the cursor to the first entry in the table. Return 0 if the 53987 // cursor was left point to something and 1 if the table is empty. 53988 func btree_first(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test3.c:330:26: */ 53989 bp := tls.Alloc(176) 53990 defer tls.Free(176) 53991 53992 var pCur uintptr 53993 var rc int32 53994 *(*int32)(unsafe.Pointer(bp + 72 /* res */)) = 0 53995 // var zBuf [100]int8 at bp+76, 100 53996 53997 if argc != 2 { 53998 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 53999 ts+23897 /* " ID\"" */, 0)) 54000 return TCL_ERROR 54001 } 54002 pCur = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 54003 sqlite3.Xsqlite3BtreeEnter(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) 54004 rc = sqlite3.Xsqlite3BtreeFirst(tls, pCur, bp+72 /* &res */) 54005 sqlite3.Xsqlite3BtreeLeave(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) 54006 if rc != 0 { 54007 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc), 0)) 54008 return TCL_ERROR 54009 } 54010 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+76 /* &zBuf[0] */, ts+1238 /* "%d" */, libc.VaList(bp+48, *(*int32)(unsafe.Pointer(bp + 72 /* res */)))) 54011 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, bp+76 /* &zBuf[0] */, 0)) 54012 return SQLITE_OK 54013 } 54014 54015 // Usage: btree_eof ID 54016 // 54017 // Return TRUE if the given cursor is not pointing at a valid entry. 54018 // Return FALSE if the cursor does point to a valid entry. 54019 func btree_eof(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test3.c:365:26: */ 54020 bp := tls.Alloc(106) 54021 defer tls.Free(106) 54022 54023 var pCur uintptr 54024 var rc int32 54025 // var zBuf [50]int8 at bp+56, 50 54026 54027 if argc != 2 { 54028 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 54029 ts+23897 /* " ID\"" */, 0)) 54030 return TCL_ERROR 54031 } 54032 pCur = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 54033 sqlite3.Xsqlite3BtreeEnter(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) 54034 rc = sqlite3.Xsqlite3BtreeEof(tls, pCur) 54035 sqlite3.Xsqlite3BtreeLeave(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) 54036 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+56 /* &zBuf[0] */, ts+1238 /* "%d" */, libc.VaList(bp+32, rc)) 54037 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+56 /* &zBuf[0] */, 0)) 54038 return SQLITE_OK 54039 } 54040 54041 // Usage: btree_payload_size ID 54042 // 54043 // Return the number of bytes of payload 54044 func btree_payload_size(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test3.c:394:26: */ 54045 bp := tls.Alloc(106) 54046 defer tls.Free(106) 54047 54048 var pCur uintptr 54049 var n u322 54050 // var zBuf [50]int8 at bp+56, 50 54051 54052 if argc != 2 { 54053 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 54054 ts+23897 /* " ID\"" */, 0)) 54055 return TCL_ERROR 54056 } 54057 pCur = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 54058 sqlite3.Xsqlite3BtreeEnter(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) 54059 n = sqlite3.Xsqlite3BtreePayloadSize(tls, pCur) 54060 sqlite3.Xsqlite3BtreeLeave(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) 54061 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+56 /* &zBuf[0] */, ts+17441 /* "%u" */, libc.VaList(bp+32, n)) 54062 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+56 /* &zBuf[0] */, 0)) 54063 return SQLITE_OK 54064 } 54065 54066 // usage: varint_test START MULTIPLIER COUNT INCREMENT 54067 // 54068 // This command tests the putVarint() and getVarint() 54069 // routines, both for accuracy and for speed. 54070 // 54071 // An integer is written using putVarint() and read back with 54072 // getVarint() and varified to be unchanged. This repeats COUNT 54073 // times. The first integer is START*MULTIPLIER. Each iteration 54074 // increases the integer by INCREMENT. 54075 // 54076 // This command returns nothing if it works. It returns an error message 54077 // if something goes wrong. 54078 func btree_varint_test(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test3.c:432:26: */ 54079 bp := tls.Alloc(516) 54080 defer tls.Free(516) 54081 54082 // var start u322 at bp+184, 4 54083 54084 // var mult u322 at bp+188, 4 54085 54086 // var count u322 at bp+192, 4 54087 54088 // var incr u322 at bp+196, 4 54089 54090 var in u64 54091 // var out u64 at bp+504, 8 54092 54093 var n1 int32 54094 var n2 int32 54095 var i int32 54096 var j int32 54097 // var zBuf [100]uint8 at bp+200, 100 54098 54099 if argc != 5 { 54100 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 54101 ts+24628 /* " START MULTIPLIE..." */, 0)) 54102 return TCL_ERROR 54103 } 54104 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+184 /* &start */) != 0 { 54105 return TCL_ERROR 54106 } 54107 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+188 /* &mult */) != 0 { 54108 return TCL_ERROR 54109 } 54110 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 3*8)), bp+192 /* &count */) != 0 { 54111 return TCL_ERROR 54112 } 54113 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 4*8)), bp+196 /* &incr */) != 0 { 54114 return TCL_ERROR 54115 } 54116 in = u64(*(*u322)(unsafe.Pointer(bp + 184 /* start */))) 54117 in = in * (u64(*(*u322)(unsafe.Pointer(bp + 188 /* mult */)))) 54118 for i = 0; i < int32(*(*u322)(unsafe.Pointer(bp + 192 /* count */))); i++ { 54119 // var zErr [200]int8 at bp+300, 200 54120 54121 n1 = sqlite3.Xsqlite3PutVarint(tls, bp+200 /* &zBuf[0] */, in) 54122 if (n1 > 9) || (n1 < 1) { 54123 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([200]int8{})), bp+300, /* &zErr[0] */ 54124 ts+24663 /* "putVarint return..." */, libc.VaList(bp+32, n1)) 54125 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+300 /* &zErr[0] */, 0)) 54126 return TCL_ERROR 54127 } 54128 n2 = int32(sqlite3.Xsqlite3GetVarint(tls, bp+200 /* &zBuf[0] */, bp+504 /* &out */)) 54129 if n1 != n2 { 54130 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([200]int8{})), bp+300, /* &zErr[0] */ 54131 ts+24713 /* "putVarint return..." */, libc.VaList(bp+56, n1, n2)) 54132 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+72, bp+300 /* &zErr[0] */, 0)) 54133 return TCL_ERROR 54134 } 54135 if in != *(*u64)(unsafe.Pointer(bp + 504 /* out */)) { 54136 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([200]int8{})), bp+300, /* &zErr[0] */ 54137 ts+24761 /* "Wrote 0x%016llx ..." */, libc.VaList(bp+88, in, *(*u64)(unsafe.Pointer(bp + 504 /* out */)))) 54138 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+104, bp+300 /* &zErr[0] */, 0)) 54139 return TCL_ERROR 54140 } 54141 if (in & uint64(0xffffffff)) == in { 54142 // var out32 u322 at bp+512, 4 54143 54144 n2 = int32(func() uint8 { 54145 if int32(*(*uint8)(unsafe.Pointer(bp + 200 /* zBuf */))) < int32(u8(0x80)) { 54146 return uint8(func() int32 { 54147 (*(*u322)(unsafe.Pointer(bp + 512 /* out32 */))) = u322(*(*uint8)(unsafe.Pointer(bp + 200 /* zBuf */))) 54148 return 1 54149 }()) 54150 } 54151 return sqlite3.Xsqlite3GetVarint32(tls, bp+200 /* &zBuf[0] */, bp+512 /* &out32 */) 54152 }()) 54153 *(*u64)(unsafe.Pointer(bp + 504 /* out */)) = u64(*(*u322)(unsafe.Pointer(bp + 512 /* out32 */))) 54154 if n1 != n2 { 54155 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([200]int8{})), bp+300, /* &zErr[0] */ 54156 ts+24800, /* "putVarint return..." */ 54157 libc.VaList(bp+120, n1, n2)) 54158 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+136, bp+300 /* &zErr[0] */, 0)) 54159 return TCL_ERROR 54160 } 54161 if in != *(*u64)(unsafe.Pointer(bp + 504 /* out */)) { 54162 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([200]int8{})), bp+300, /* &zErr[0] */ 54163 ts+24850, /* "Wrote 0x%016llx ..." */ 54164 libc.VaList(bp+152, in, *(*u64)(unsafe.Pointer(bp + 504 /* out */)))) 54165 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+168, bp+300 /* &zErr[0] */, 0)) 54166 return TCL_ERROR 54167 } 54168 } 54169 54170 // In order to get realistic timings, run getVarint 19 more times. 54171 // This is because getVarint is called about 20 times more often 54172 // than putVarint. 54173 for j = 0; j < 19; j++ { 54174 sqlite3.Xsqlite3GetVarint(tls, bp+200 /* &zBuf[0] */, bp+504 /* &out */) 54175 } 54176 in = in + (u64(*(*u322)(unsafe.Pointer(bp + 196 /* incr */)))) 54177 } 54178 return TCL_OK 54179 } 54180 54181 // usage: btree_from_db DB-HANDLE 54182 // 54183 // This command returns the btree handle for the main database associated 54184 // with the database-handle passed as the argument. Example usage: 54185 // 54186 // sqlite3 db test.db 54187 // set bt [btree_from_db db] 54188 func btree_from_db(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test3.c:516:26: */ 54189 bp := tls.Alloc(236) 54190 defer tls.Free(236) 54191 54192 // var zBuf [100]int8 at bp+136, 100 54193 54194 // var info Tcl_CmdInfo at bp+72, 64 54195 54196 var db uintptr 54197 var pBt uintptr 54198 var iDb int32 = 0 54199 54200 if (argc != 2) && (argc != 3) { 54201 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 54202 ts+24906 /* " DB-HANDLE ?N?\"" */, 0)) 54203 return TCL_ERROR 54204 } 54205 54206 if 1 != tcl.XTcl_GetCommandInfo(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8)), bp+72 /* &info */) { 54207 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+24922 /* "No such db-handl..." */, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+11636 /* "\"" */, 0)) 54208 return TCL_ERROR 54209 } 54210 if argc == 3 { 54211 iDb = libc.Xatoi(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) 54212 } 54213 54214 db = *(*uintptr)(unsafe.Pointer((*Tcl_CmdInfo)(unsafe.Pointer(bp + 72 /* &info */)).FobjClientData)) 54215 54216 pBt = (*Db)(unsafe.Pointer((*sqlite31)(unsafe.Pointer(db)).FaDb + uintptr(iDb)*32)).FpBt 54217 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+136 /* &zBuf[0] */, ts+13023 /* "%p" */, libc.VaList(bp+64, pBt)) 54218 tcl.XTcl_SetResult(tls, interp, bp+136 /* &zBuf[0] */, uintptr(1)) 54219 return TCL_OK 54220 } 54221 54222 // Usage: btree_ismemdb ID 54223 // 54224 // Return true if the B-Tree is currently stored entirely in memory. 54225 func btree_ismemdb(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test3.c:556:26: */ 54226 bp := tls.Alloc(32) 54227 defer tls.Free(32) 54228 54229 var pBt uintptr 54230 var res int32 54231 var pFile uintptr 54232 54233 if argc != 2 { 54234 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 54235 ts+23897 /* " ID\"" */, 0)) 54236 return TCL_ERROR 54237 } 54238 pBt = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 54239 sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBt)).Fdb)).Fmutex) 54240 sqlite3.Xsqlite3BtreeEnter(tls, pBt) 54241 pFile = sqlite3.Xsqlite3PagerFile(tls, sqlite3.Xsqlite3BtreePager(tls, pBt)) 54242 res = (libc.Bool32((*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods == uintptr(0))) 54243 sqlite3.Xsqlite3BtreeLeave(tls, pBt) 54244 sqlite3.Xsqlite3_mutex_leave(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBt)).Fdb)).Fmutex) 54245 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, (libc.Bool32((res) != 0)))) 54246 return SQLITE_OK 54247 } 54248 54249 // usage: btree_set_cache_size ID NCACHE 54250 // 54251 // Set the size of the cache used by btree $ID. 54252 func btree_set_cache_size(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test3.c:587:26: */ 54253 bp := tls.Alloc(36) 54254 defer tls.Free(36) 54255 54256 // var nCache int32 at bp+32, 4 54257 54258 var pBt uintptr 54259 54260 if argc != 3 { 54261 tcl.XTcl_AppendResult(tls, 54262 interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), ts+24943 /* " BT NCACHE\"" */, 0)) 54263 return TCL_ERROR 54264 } 54265 pBt = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 54266 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+32 /* &nCache */) != 0 { 54267 return TCL_ERROR 54268 } 54269 54270 sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBt)).Fdb)).Fmutex) 54271 sqlite3.Xsqlite3BtreeEnter(tls, pBt) 54272 sqlite3.Xsqlite3BtreeSetCacheSize(tls, pBt, *(*int32)(unsafe.Pointer(bp + 32 /* nCache */))) 54273 sqlite3.Xsqlite3BtreeLeave(tls, pBt) 54274 sqlite3.Xsqlite3_mutex_leave(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer(pBt)).Fdb)).Fmutex) 54275 return TCL_OK 54276 } 54277 54278 // usage: btree_insert CSR ?KEY? VALUE 54279 // 54280 // Set the size of the cache used by btree $ID. 54281 func btree_insert(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test3.c:617:26: */ 54282 bp := tls.Alloc(68) 54283 defer tls.Free(68) 54284 54285 var pCur uintptr 54286 // var rc int32 at bp+64, 4 54287 54288 // var x BtreePayload at bp+16, 48 54289 54290 if (objc != 4) && (objc != 3) { 54291 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+24955 /* "?-intkey? CSR KE..." */) 54292 return TCL_ERROR 54293 } 54294 54295 libc.Xmemset(tls, bp+16 /* &x */, 0, uint64(unsafe.Sizeof(BtreePayload{}))) 54296 if objc == 4 { 54297 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+64 /* &rc */) != 0 { 54298 return TCL_ERROR 54299 } 54300 (*BtreePayload)(unsafe.Pointer(bp + 16 /* &x */)).FnKey = sqlite3_int64(*(*int32)(unsafe.Pointer(bp + 64 /* rc */))) 54301 (*BtreePayload)(unsafe.Pointer(bp + 16 /* &x */)).FpData = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), (bp + 16 /* &x */ + 36 /* &.nData */)) 54302 } else { 54303 (*BtreePayload)(unsafe.Pointer(bp + 16 /* &x */)).FpKey = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+64 /* &rc */) 54304 (*BtreePayload)(unsafe.Pointer(bp + 16 /* &x */)).FnKey = sqlite3_int64(*(*int32)(unsafe.Pointer(bp + 64 /* rc */))) 54305 } 54306 pCur = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 54307 54308 sqlite3.Xsqlite3_mutex_enter(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBtree)).Fdb)).Fmutex) 54309 sqlite3.Xsqlite3BtreeEnter(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) 54310 *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = sqlite3.Xsqlite3BtreeInsert(tls, pCur, bp+16 /* &x */, 0, 0) 54311 sqlite3.Xsqlite3BtreeLeave(tls, (*BtCursor)(unsafe.Pointer(pCur)).FpBtree) 54312 sqlite3.Xsqlite3_mutex_leave(tls, (*sqlite31)(unsafe.Pointer((*Btree)(unsafe.Pointer((*BtCursor)(unsafe.Pointer(pCur)).FpBtree)).Fdb)).Fmutex) 54313 54314 tcl.XTcl_ResetResult(tls, interp) 54315 if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) != 0 { 54316 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3ErrName(tls, *(*int32)(unsafe.Pointer(bp + 64 /* rc */))), 0)) 54317 return TCL_ERROR 54318 } 54319 return TCL_OK 54320 } 54321 54322 // Register commands with the TCL interpreter. 54323 func Sqlitetest3_Init(tls *libc.TLS, interp uintptr) int32 { /* test3.c:661:5: */ 54324 var i int32 54325 54326 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aCmd3)) / uint64(unsafe.Sizeof(struct { 54327 FzName uintptr 54328 FxProc uintptr 54329 }{}))); i++ { 54330 tcl.XTcl_CreateCommand(tls, interp, aCmd3[i].FzName, aCmd3[i].FxProc, uintptr(0), uintptr(0)) 54331 } 54332 54333 tcl.XTcl_CreateObjCommand(tls, interp, ts+24979 /* "btree_insert" */, *(*uintptr)(unsafe.Pointer(&struct { 54334 f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 54335 }{btree_insert})), uintptr(0), uintptr(0)) 54336 54337 return TCL_OK 54338 } 54339 54340 var aCmd3 = [14]struct { 54341 FzName uintptr 54342 FxProc uintptr 54343 }{ 54344 {FzName: ts + 24992 /* "btree_open" */, FxProc: 0}, 54345 {FzName: ts + 25003 /* "btree_close" */, FxProc: 0}, 54346 {FzName: ts + 25015 /* "btree_begin_tran..." */, FxProc: 0}, 54347 {FzName: ts + 25039 /* "btree_pager_stat..." */, FxProc: 0}, 54348 {FzName: ts + 25057 /* "btree_cursor" */, FxProc: 0}, 54349 {FzName: ts + 25070 /* "btree_close_curs..." */, FxProc: 0}, 54350 {FzName: ts + 25089 /* "btree_next" */, FxProc: 0}, 54351 {FzName: ts + 25100 /* "btree_eof" */, FxProc: 0}, 54352 {FzName: ts + 25110 /* "btree_payload_si..." */, FxProc: 0}, 54353 {FzName: ts + 25129 /* "btree_first" */, FxProc: 0}, 54354 {FzName: ts + 25141 /* "btree_varint_tes..." */, FxProc: 0}, 54355 {FzName: ts + 25159 /* "btree_from_db" */, FxProc: 0}, 54356 {FzName: ts + 25173 /* "btree_ismemdb" */, FxProc: 0}, 54357 {FzName: ts + 25187 /* "btree_set_cache_..." */, FxProc: 0}, 54358 } /* test3.c:665:5 */ 54359 54360 // end block for C++ 54361 54362 // Local Variables: 54363 // mode: c 54364 // c-basic-offset: 4 54365 // fill-column: 78 54366 // End: 54367 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 54368 // This file is part of the GNU C Library. 54369 // 54370 // The GNU C Library is free software; you can redistribute it and/or 54371 // modify it under the terms of the GNU Lesser General Public 54372 // License as published by the Free Software Foundation; either 54373 // version 2.1 of the License, or (at your option) any later version. 54374 // 54375 // The GNU C Library is distributed in the hope that it will be useful, 54376 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54377 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54378 // Lesser General Public License for more details. 54379 // 54380 // You should have received a copy of the GNU Lesser General Public 54381 // License along with the GNU C Library; if not, see 54382 // <http://www.gnu.org/licenses/>. 54383 54384 // ISO C99 Standard: 7.20 General utilities <stdlib.h> 54385 54386 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 54387 // This file is part of the GNU C Library. 54388 // 54389 // The GNU C Library is free software; you can redistribute it and/or 54390 // modify it under the terms of the GNU Lesser General Public 54391 // License as published by the Free Software Foundation; either 54392 // version 2.1 of the License, or (at your option) any later version. 54393 // 54394 // The GNU C Library is distributed in the hope that it will be useful, 54395 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54396 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54397 // Lesser General Public License for more details. 54398 // 54399 // You should have received a copy of the GNU Lesser General Public 54400 // License along with the GNU C Library; if not, see 54401 // <http://www.gnu.org/licenses/>. 54402 54403 // ISO C99 Standard: 7.21 String handling <string.h> 54404 54405 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 54406 // This file is part of the GNU C Library. 54407 // 54408 // The GNU C Library is free software; you can redistribute it and/or 54409 // modify it under the terms of the GNU Lesser General Public 54410 // License as published by the Free Software Foundation; either 54411 // version 2.1 of the License, or (at your option) any later version. 54412 // 54413 // The GNU C Library is distributed in the hope that it will be useful, 54414 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54415 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54416 // Lesser General Public License for more details. 54417 // 54418 // You should have received a copy of the GNU Lesser General Public 54419 // License along with the GNU C Library; if not, see 54420 // <http://www.gnu.org/licenses/>. 54421 54422 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 54423 // This file is part of the GNU C Library. 54424 // 54425 // The GNU C Library is free software; you can redistribute it and/or 54426 // modify it under the terms of the GNU Lesser General Public 54427 // License as published by the Free Software Foundation; either 54428 // version 2.1 of the License, or (at your option) any later version. 54429 // 54430 // The GNU C Library is distributed in the hope that it will be useful, 54431 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54432 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54433 // Lesser General Public License for more details. 54434 // 54435 // You should have received a copy of the GNU Lesser General Public 54436 // License along with the GNU C Library; if not, see 54437 // <http://www.gnu.org/licenses/>. 54438 54439 // Copyright (C) 1992-2018 Free Software Foundation, Inc. 54440 // This file is part of the GNU C Library. 54441 // 54442 // The GNU C Library is free software; you can redistribute it and/or 54443 // modify it under the terms of the GNU Lesser General Public 54444 // License as published by the Free Software Foundation; either 54445 // version 2.1 of the License, or (at your option) any later version. 54446 // 54447 // The GNU C Library is distributed in the hope that it will be useful, 54448 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54449 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54450 // Lesser General Public License for more details. 54451 // 54452 // You should have received a copy of the GNU Lesser General Public 54453 // License along with the GNU C Library; if not, see 54454 // <http://www.gnu.org/licenses/>. 54455 54456 // Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface. 54457 // Copyright (C) 1996-2018 Free Software Foundation, Inc. 54458 // This file is part of the GNU C Library. 54459 // 54460 // The GNU C Library is free software; you can redistribute it and/or 54461 // modify it under the terms of the GNU Lesser General Public 54462 // License as published by the Free Software Foundation; either 54463 // version 2.1 of the License, or (at your option) any later version. 54464 // 54465 // The GNU C Library is distributed in the hope that it will be useful, 54466 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54467 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54468 // Lesser General Public License for more details. 54469 // 54470 // You should have received a copy of the GNU Lesser General Public 54471 // License along with the GNU C Library; if not, see 54472 // <http://www.gnu.org/licenses/>. 54473 54474 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 54475 // This file is part of the GNU C Library. 54476 // 54477 // The GNU C Library is free software; you can redistribute it and/or 54478 // modify it under the terms of the GNU Lesser General Public 54479 // License as published by the Free Software Foundation; either 54480 // version 2.1 of the License, or (at your option) any later version. 54481 // 54482 // The GNU C Library is distributed in the hope that it will be useful, 54483 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54484 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54485 // Lesser General Public License for more details. 54486 // 54487 // You should have received a copy of the GNU Lesser General Public 54488 // License along with the GNU C Library; if not, see 54489 // <http://www.gnu.org/licenses/>. 54490 54491 // Get type definitions. 54492 // bits/types.h -- definitions of __*_t types underlying *_t types. 54493 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 54494 // This file is part of the GNU C Library. 54495 // 54496 // The GNU C Library is free software; you can redistribute it and/or 54497 // modify it under the terms of the GNU Lesser General Public 54498 // License as published by the Free Software Foundation; either 54499 // version 2.1 of the License, or (at your option) any later version. 54500 // 54501 // The GNU C Library is distributed in the hope that it will be useful, 54502 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54503 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54504 // Lesser General Public License for more details. 54505 // 54506 // You should have received a copy of the GNU Lesser General Public 54507 // License along with the GNU C Library; if not, see 54508 // <http://www.gnu.org/licenses/>. 54509 54510 // Never include this file directly; use <sys/types.h> instead. 54511 54512 // Copyright (C) 1989-2018 Free Software Foundation, Inc. 54513 // 54514 // This file is part of GCC. 54515 // 54516 // GCC is free software; you can redistribute it and/or modify 54517 // it under the terms of the GNU General Public License as published by 54518 // the Free Software Foundation; either version 3, or (at your option) 54519 // any later version. 54520 // 54521 // GCC is distributed in the hope that it will be useful, 54522 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54523 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 54524 // GNU General Public License for more details. 54525 // 54526 // Under Section 7 of GPL version 3, you are granted additional 54527 // permissions described in the GCC Runtime Library Exception, version 54528 // 3.1, as published by the Free Software Foundation. 54529 // 54530 // You should have received a copy of the GNU General Public License and 54531 // a copy of the GCC Runtime Library Exception along with this program; 54532 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 54533 // <http://www.gnu.org/licenses/>. 54534 54535 // ISO C Standard: 7.17 Common definitions <stddef.h> 54536 54537 // Any one of these symbols __need_* means that GNU libc 54538 // wants us just to define one data type. So don't define 54539 // the symbols that indicate this file's entire job has been done. 54540 54541 // This avoids lossage on SunOS but only if stdtypes.h comes first. 54542 // There's no way to win with the other order! Sun lossage. 54543 54544 // On 4.3bsd-net2, make sure ansi.h is included, so we have 54545 // one less case to deal with in the following. 54546 // On FreeBSD 5, machine/ansi.h does not exist anymore... 54547 54548 // In 4.3bsd-net2, machine/ansi.h defines these symbols, which are 54549 // defined if the corresponding type is *not* defined. 54550 // FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_. 54551 // NetBSD defines _I386_ANSI_H_ and _X86_64_ANSI_H_ instead of _ANSI_H_ 54552 54553 // Sequent's header files use _PTRDIFF_T_ in some conflicting way. 54554 // Just ignore it. 54555 54556 // On VxWorks, <type/vxTypesBase.h> may have defined macros like 54557 // _TYPE_size_t which will typedef size_t. fixincludes patched the 54558 // vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is 54559 // not defined, and so that defining this macro defines _GCC_SIZE_T. 54560 // If we find that the macros are still defined at this point, we must 54561 // invoke them so that the type is defined as expected. 54562 54563 // In case nobody has defined these types, but we aren't running under 54564 // GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and 54565 // __WCHAR_TYPE__ have reasonable values. This can happen if the 54566 // parts of GCC is compiled by an older compiler, that actually 54567 // include gstddef.h, such as collect2. 54568 54569 // Signed type of difference of two pointers. 54570 54571 // Define this type if we are doing the whole job, 54572 // or if we want this type in particular. 54573 54574 // If this symbol has done its job, get rid of it. 54575 54576 // Unsigned type of `sizeof' something. 54577 54578 // Define this type if we are doing the whole job, 54579 // or if we want this type in particular. 54580 54581 // Wide character type. 54582 // Locale-writers should change this as necessary to 54583 // be big enough to hold unique values not between 0 and 127, 54584 // and not (wchar_t) -1, for each defined multibyte character. 54585 54586 // Define this type if we are doing the whole job, 54587 // or if we want this type in particular. 54588 54589 // In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. 54590 // are already defined. 54591 // BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. 54592 // NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here. 54593 54594 // A null pointer constant. 54595 54596 // Offset of member MEMBER in a struct of type TYPE. 54597 54598 // NB: Include guard matches what <linux/time.h> uses. 54599 54600 // Get system specific constant and data structure definitions. 54601 // Definitions of constants and data structure for POSIX 1003.1b-1993 54602 // scheduling interface. 54603 // Copyright (C) 1996-2018 Free Software Foundation, Inc. 54604 // This file is part of the GNU C Library. 54605 // 54606 // The GNU C Library is free software; you can redistribute it and/or 54607 // modify it under the terms of the GNU Lesser General Public 54608 // License as published by the Free Software Foundation; either 54609 // version 2.1 of the License, or (at your option) any later version. 54610 // 54611 // The GNU C Library is distributed in the hope that it will be useful, 54612 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54613 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54614 // Lesser General Public License for more details. 54615 // 54616 // You should have received a copy of the GNU Lesser General Public 54617 // License along with the GNU C Library; if not, see 54618 // <http://www.gnu.org/licenses/>. 54619 54620 // Scheduling algorithms. 54621 54622 // Cloning flags. 54623 54624 // Sched parameter structure. Generic version. 54625 // Copyright (C) 1996-2018 Free Software Foundation, Inc. 54626 // This file is part of the GNU C Library. 54627 // 54628 // The GNU C Library is free software; you can redistribute it and/or 54629 // modify it under the terms of the GNU Lesser General Public 54630 // License as published by the Free Software Foundation; either 54631 // version 2.1 of the License, or (at your option) any later version. 54632 // 54633 // The GNU C Library is distributed in the hope that it will be useful, 54634 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54635 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54636 // Lesser General Public License for more details. 54637 // 54638 // You should have received a copy of the GNU Lesser General Public 54639 // License along with the GNU C Library; if not, see 54640 // <http://www.gnu.org/licenses/>. 54641 54642 // Data structure to describe a process' schedulability. 54643 type sched_param = struct{ Fsched_priority int32 } /* struct_sched_param.h:23:1 */ 54644 54645 // Basic access functions. 54646 54647 // Data structure to describe CPU mask. 54648 type cpu_set_t = struct{ F__bits [16]uint64 } /* cpu-set.h:42:3 */ 54649 54650 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 54651 // This file is part of the GNU C Library. 54652 // 54653 // The GNU C Library is free software; you can redistribute it and/or 54654 // modify it under the terms of the GNU Lesser General Public 54655 // License as published by the Free Software Foundation; either 54656 // version 2.1 of the License, or (at your option) any later version. 54657 // 54658 // The GNU C Library is distributed in the hope that it will be useful, 54659 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54660 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54661 // Lesser General Public License for more details. 54662 // 54663 // You should have received a copy of the GNU Lesser General Public 54664 // License along with the GNU C Library; if not, see 54665 // <http://www.gnu.org/licenses/>. 54666 54667 // ISO C99 Standard: 7.23 Date and time <time.h> 54668 54669 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 54670 // This file is part of the GNU C Library. 54671 // 54672 // The GNU C Library is free software; you can redistribute it and/or 54673 // modify it under the terms of the GNU Lesser General Public 54674 // License as published by the Free Software Foundation; either 54675 // version 2.1 of the License, or (at your option) any later version. 54676 // 54677 // The GNU C Library is distributed in the hope that it will be useful, 54678 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54679 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54680 // Lesser General Public License for more details. 54681 // 54682 // You should have received a copy of the GNU Lesser General Public 54683 // License along with the GNU C Library; if not, see 54684 // <http://www.gnu.org/licenses/>. 54685 54686 // Copyright (C) 1989-2018 Free Software Foundation, Inc. 54687 // 54688 // This file is part of GCC. 54689 // 54690 // GCC is free software; you can redistribute it and/or modify 54691 // it under the terms of the GNU General Public License as published by 54692 // the Free Software Foundation; either version 3, or (at your option) 54693 // any later version. 54694 // 54695 // GCC is distributed in the hope that it will be useful, 54696 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54697 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 54698 // GNU General Public License for more details. 54699 // 54700 // Under Section 7 of GPL version 3, you are granted additional 54701 // permissions described in the GCC Runtime Library Exception, version 54702 // 3.1, as published by the Free Software Foundation. 54703 // 54704 // You should have received a copy of the GNU General Public License and 54705 // a copy of the GCC Runtime Library Exception along with this program; 54706 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 54707 // <http://www.gnu.org/licenses/>. 54708 54709 // ISO C Standard: 7.17 Common definitions <stddef.h> 54710 54711 // Any one of these symbols __need_* means that GNU libc 54712 // wants us just to define one data type. So don't define 54713 // the symbols that indicate this file's entire job has been done. 54714 54715 // This avoids lossage on SunOS but only if stdtypes.h comes first. 54716 // There's no way to win with the other order! Sun lossage. 54717 54718 // On 4.3bsd-net2, make sure ansi.h is included, so we have 54719 // one less case to deal with in the following. 54720 // On FreeBSD 5, machine/ansi.h does not exist anymore... 54721 54722 // In 4.3bsd-net2, machine/ansi.h defines these symbols, which are 54723 // defined if the corresponding type is *not* defined. 54724 // FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_. 54725 // NetBSD defines _I386_ANSI_H_ and _X86_64_ANSI_H_ instead of _ANSI_H_ 54726 54727 // Sequent's header files use _PTRDIFF_T_ in some conflicting way. 54728 // Just ignore it. 54729 54730 // On VxWorks, <type/vxTypesBase.h> may have defined macros like 54731 // _TYPE_size_t which will typedef size_t. fixincludes patched the 54732 // vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is 54733 // not defined, and so that defining this macro defines _GCC_SIZE_T. 54734 // If we find that the macros are still defined at this point, we must 54735 // invoke them so that the type is defined as expected. 54736 54737 // In case nobody has defined these types, but we aren't running under 54738 // GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and 54739 // __WCHAR_TYPE__ have reasonable values. This can happen if the 54740 // parts of GCC is compiled by an older compiler, that actually 54741 // include gstddef.h, such as collect2. 54742 54743 // Signed type of difference of two pointers. 54744 54745 // Define this type if we are doing the whole job, 54746 // or if we want this type in particular. 54747 54748 // If this symbol has done its job, get rid of it. 54749 54750 // Unsigned type of `sizeof' something. 54751 54752 // Define this type if we are doing the whole job, 54753 // or if we want this type in particular. 54754 54755 // Wide character type. 54756 // Locale-writers should change this as necessary to 54757 // be big enough to hold unique values not between 0 and 127, 54758 // and not (wchar_t) -1, for each defined multibyte character. 54759 54760 // Define this type if we are doing the whole job, 54761 // or if we want this type in particular. 54762 54763 // In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. 54764 // are already defined. 54765 // BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. 54766 // NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here. 54767 54768 // A null pointer constant. 54769 54770 // Offset of member MEMBER in a struct of type TYPE. 54771 54772 // This defines CLOCKS_PER_SEC, which is the number of processor clock 54773 // ticks per second, and possibly a number of other constants. 54774 // System-dependent timing definitions. Linux version. 54775 // Copyright (C) 1996-2018 Free Software Foundation, Inc. 54776 // This file is part of the GNU C Library. 54777 // 54778 // The GNU C Library is free software; you can redistribute it and/or 54779 // modify it under the terms of the GNU Lesser General Public 54780 // License as published by the Free Software Foundation; either 54781 // version 2.1 of the License, or (at your option) any later version. 54782 // 54783 // The GNU C Library is distributed in the hope that it will be useful, 54784 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54785 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54786 // Lesser General Public License for more details. 54787 // 54788 // You should have received a copy of the GNU Lesser General Public 54789 // License along with the GNU C Library; if not, see 54790 // <http://www.gnu.org/licenses/>. 54791 54792 // Never include this file directly; use <time.h> instead. 54793 54794 // bits/types.h -- definitions of __*_t types underlying *_t types. 54795 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 54796 // This file is part of the GNU C Library. 54797 // 54798 // The GNU C Library is free software; you can redistribute it and/or 54799 // modify it under the terms of the GNU Lesser General Public 54800 // License as published by the Free Software Foundation; either 54801 // version 2.1 of the License, or (at your option) any later version. 54802 // 54803 // The GNU C Library is distributed in the hope that it will be useful, 54804 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54805 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54806 // Lesser General Public License for more details. 54807 // 54808 // You should have received a copy of the GNU Lesser General Public 54809 // License along with the GNU C Library; if not, see 54810 // <http://www.gnu.org/licenses/>. 54811 54812 // Never include this file directly; use <sys/types.h> instead. 54813 54814 // ISO/IEC 9899:1999 7.23.1: Components of time 54815 // The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is 54816 // the number per second of the value returned by the `clock' function. 54817 // CAE XSH, Issue 4, Version 2: <time.h> 54818 // The value of CLOCKS_PER_SEC is required to be 1 million on all 54819 // XSI-conformant systems. 54820 54821 // Identifier for system-wide realtime clock. 54822 // Monotonic system-wide clock. 54823 // High-resolution timer from the CPU. 54824 // Thread-specific CPU-time clock. 54825 // Monotonic system-wide clock, not adjusted for frequency scaling. 54826 // Identifier for system-wide realtime clock, updated only on ticks. 54827 // Monotonic system-wide clock, updated only on ticks. 54828 // Monotonic system-wide clock that includes time spent in suspension. 54829 // Like CLOCK_REALTIME but also wakes suspended system. 54830 // Like CLOCK_BOOTTIME but also wakes suspended system. 54831 // Like CLOCK_REALTIME but in International Atomic Time. 54832 54833 // Flag to indicate time is absolute. 54834 54835 // Copyright (C) 1995-2018 Free Software Foundation, Inc. 54836 // This file is part of the GNU C Library. 54837 // 54838 // The GNU C Library is free software; you can redistribute it and/or 54839 // modify it under the terms of the GNU Lesser General Public 54840 // License as published by the Free Software Foundation; either 54841 // version 2.1 of the License, or (at your option) any later version. 54842 // 54843 // The GNU C Library is distributed in the hope that it will be useful, 54844 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54845 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54846 // Lesser General Public License for more details. 54847 // 54848 // You should have received a copy of the GNU Lesser General Public 54849 // License along with the GNU C Library; if not, see 54850 // <http://www.gnu.org/licenses/>. 54851 54852 // bits/types.h -- definitions of __*_t types underlying *_t types. 54853 // Copyright (C) 2002-2018 Free Software Foundation, Inc. 54854 // This file is part of the GNU C Library. 54855 // 54856 // The GNU C Library is free software; you can redistribute it and/or 54857 // modify it under the terms of the GNU Lesser General Public 54858 // License as published by the Free Software Foundation; either 54859 // version 2.1 of the License, or (at your option) any later version. 54860 // 54861 // The GNU C Library is distributed in the hope that it will be useful, 54862 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54863 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54864 // Lesser General Public License for more details. 54865 // 54866 // You should have received a copy of the GNU Lesser General Public 54867 // License along with the GNU C Library; if not, see 54868 // <http://www.gnu.org/licenses/>. 54869 54870 // Never include this file directly; use <sys/types.h> instead. 54871 54872 // These definitions from linux/timex.h as of 3.18. 54873 54874 type timex = struct { 54875 Fmodes uint32 54876 _ [4]byte 54877 Foffset int64 54878 Ffreq int64 54879 Fmaxerror int64 54880 Festerror int64 54881 Fstatus int32 54882 _ [4]byte 54883 Fconstant int64 54884 Fprecision int64 54885 Ftolerance int64 54886 Ftime struct { 54887 Ftv_sec int64 54888 Ftv_usec int64 54889 } 54890 Ftick int64 54891 Fppsfreq int64 54892 Fjitter int64 54893 Fshift int32 54894 _ [4]byte 54895 Fstabil int64 54896 Fjitcnt int64 54897 Fcalcnt int64 54898 Ferrcnt int64 54899 Fstbcnt int64 54900 Ftai int32 54901 __164 uint32 /* int : 32 */ 54902 __168 uint32 /* int : 32 */ 54903 __172 uint32 /* int : 32 */ 54904 __176 uint32 /* int : 32 */ 54905 __180 uint32 /* int : 32 */ 54906 __184 uint32 /* int : 32 */ 54907 __188 uint32 /* int : 32 */ 54908 __192 uint32 /* int : 32 */ 54909 __196 uint32 /* int : 32 */ 54910 __200 uint32 /* int : 32 */ 54911 __204 uint32 /* int : 32 */ 54912 } /* timex.h:26:1 */ 54913 54914 // Declaration of common pthread types for all architectures. 54915 // Copyright (C) 2017-2018 Free Software Foundation, Inc. 54916 // This file is part of the GNU C Library. 54917 // 54918 // The GNU C Library is free software; you can redistribute it and/or 54919 // modify it under the terms of the GNU Lesser General Public 54920 // License as published by the Free Software Foundation; either 54921 // version 2.1 of the License, or (at your option) any later version. 54922 // 54923 // The GNU C Library is distributed in the hope that it will be useful, 54924 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54925 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54926 // Lesser General Public License for more details. 54927 // 54928 // You should have received a copy of the GNU Lesser General Public 54929 // License along with the GNU C Library; if not, see 54930 // <http://www.gnu.org/licenses/>. 54931 54932 // Copyright (C) 2000-2018 Free Software Foundation, Inc. 54933 // This file is part of the GNU C Library. 54934 // 54935 // The GNU C Library is free software; you can redistribute it and/or 54936 // modify it under the terms of the GNU Lesser General Public 54937 // License as published by the Free Software Foundation; either 54938 // version 2.1 of the License, or (at your option) any later version. 54939 // 54940 // The GNU C Library is distributed in the hope that it will be useful, 54941 // but WITHOUT ANY WARRANTY; without even the implied warranty of 54942 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 54943 // Lesser General Public License for more details. 54944 // 54945 // You should have received a copy of the GNU Lesser General Public 54946 // License along with the GNU C Library; if not, see 54947 // <http://www.gnu.org/licenses/>. 54948 54949 // Define the machine-dependent type `jmp_buf'. IBM s390 version. 54950 54951 // Determine the wordsize from the preprocessor defines. 54952 54953 type __s390_jmp_buf = struct { 54954 F__gregs [10]int64 54955 F__fpregs [8]int64 54956 } /* setjmp.h:31:9 */ 54957 54958 // Conditional variable handling. 54959 54960 // Cleanup buffers 54961 type _pthread_cleanup_buffer = struct { 54962 F__routine uintptr 54963 F__arg uintptr 54964 F__canceltype int32 54965 _ [4]byte 54966 F__prev uintptr 54967 } /* pthread.h:191:1 */ 54968 54969 // No special attributes by default. 54970 54971 // Structure to hold the cleanup handler information. 54972 type __pthread_cleanup_frame = struct { 54973 F__cancel_routine uintptr 54974 F__cancel_arg uintptr 54975 F__do_it int32 54976 F__cancel_type int32 54977 } /* pthread.h:541:1 */ 54978 54979 // Each thread is controlled by an instance of the following 54980 // structure. 54981 type Thread = struct { 54982 FzFilename uintptr 54983 FxOp uintptr 54984 FzArg uintptr 54985 Fopnum int32 54986 Fbusy int32 54987 Fcompleted int32 54988 _ [4]byte 54989 Fdb uintptr 54990 FpStmt uintptr 54991 FzErr uintptr 54992 FzStaticErr uintptr 54993 Frc int32 54994 Fargc int32 54995 Fargv [100]uintptr 54996 Fcolv [100]uintptr 54997 } /* test4.c:33:23 */ 54998 54999 // There can be as many as 26 threads running at once. Each is named 55000 // by a capital letter: A, B, C, ..., Y, Z. 55001 var threadset [26]Thread /* test4.c:61:15: */ 55002 55003 // The main loop for a thread. Threads use busy waiting. 55004 func test_thread_main(tls *libc.TLS, pArg uintptr) uintptr { /* test4.c:67:13: */ 55005 var p uintptr = pArg 55006 if (*Thread)(unsafe.Pointer(p)).Fdb != 0 { 55007 sqlite3.Xsqlite3_close(tls, (*Thread)(unsafe.Pointer(p)).Fdb) 55008 } 55009 sqlite3.Xsqlite3_open(tls, (*Thread)(unsafe.Pointer(p)).FzFilename, (p + 40 /* &.db */)) 55010 if SQLITE_OK != sqlite3.Xsqlite3_errcode(tls, (*Thread)(unsafe.Pointer(p)).Fdb) { 55011 (*Thread)(unsafe.Pointer(p)).FzErr = libc.Xstrdup(tls, sqlite3.Xsqlite3_errmsg(tls, (*Thread)(unsafe.Pointer(p)).Fdb)) 55012 sqlite3.Xsqlite3_close(tls, (*Thread)(unsafe.Pointer(p)).Fdb) 55013 (*Thread)(unsafe.Pointer(p)).Fdb = uintptr(0) 55014 } 55015 (*Thread)(unsafe.Pointer(p)).FpStmt = uintptr(0) 55016 (*Thread)(unsafe.Pointer(p)).Fcompleted = 1 55017 for (*Thread)(unsafe.Pointer(p)).Fopnum <= (*Thread)(unsafe.Pointer(p)).Fcompleted { 55018 libc2.Xsched_yield(tls) 55019 } 55020 for (*Thread)(unsafe.Pointer(p)).FxOp != 0 { 55021 if ((*Thread)(unsafe.Pointer(p)).FzErr != 0) && ((*Thread)(unsafe.Pointer(p)).FzErr != (*Thread)(unsafe.Pointer(p)).FzStaticErr) { 55022 sqlite3.Xsqlite3_free(tls, (*Thread)(unsafe.Pointer(p)).FzErr) 55023 (*Thread)(unsafe.Pointer(p)).FzErr = uintptr(0) 55024 } 55025 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((p + 8 /* &.xOp */))))(tls, p) 55026 (*Thread)(unsafe.Pointer(p)).Fcompleted++ 55027 for (*Thread)(unsafe.Pointer(p)).Fopnum <= (*Thread)(unsafe.Pointer(p)).Fcompleted { 55028 libc2.Xsched_yield(tls) 55029 } 55030 } 55031 if (*Thread)(unsafe.Pointer(p)).FpStmt != 0 { 55032 sqlite3.Xsqlite3_finalize(tls, (*Thread)(unsafe.Pointer(p)).FpStmt) 55033 (*Thread)(unsafe.Pointer(p)).FpStmt = uintptr(0) 55034 } 55035 if (*Thread)(unsafe.Pointer(p)).Fdb != 0 { 55036 sqlite3.Xsqlite3_close(tls, (*Thread)(unsafe.Pointer(p)).Fdb) 55037 (*Thread)(unsafe.Pointer(p)).Fdb = uintptr(0) 55038 } 55039 if ((*Thread)(unsafe.Pointer(p)).FzErr != 0) && ((*Thread)(unsafe.Pointer(p)).FzErr != (*Thread)(unsafe.Pointer(p)).FzStaticErr) { 55040 sqlite3.Xsqlite3_free(tls, (*Thread)(unsafe.Pointer(p)).FzErr) 55041 (*Thread)(unsafe.Pointer(p)).FzErr = uintptr(0) 55042 } 55043 (*Thread)(unsafe.Pointer(p)).Fcompleted++ 55044 sqlite3.Xsqlite3_thread_cleanup(tls) 55045 return uintptr(0) 55046 } 55047 55048 // Get a thread ID which is an upper case letter. Return the index. 55049 // If the argument is not a valid thread ID put an error message in 55050 // the interpreter and return -1. 55051 func parse_thread_id(tls *libc.TLS, interp uintptr, zArg uintptr) int32 { /* test4.c:114:12: */ 55052 bp := tls.Alloc(16) 55053 defer tls.Free(16) 55054 55055 if (((zArg == uintptr(0)) || (int32(*(*int8)(unsafe.Pointer(zArg))) == 0)) || (int32(*(*int8)(unsafe.Pointer(zArg + 1))) != 0)) || !((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(zArg)))))*2))) & int32(_ISupper)) != 0) { 55056 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+25208 /* "thread ID must b..." */, 0)) 55057 return -1 55058 } 55059 return (int32(*(*int8)(unsafe.Pointer(zArg))) - 'A') 55060 } 55061 55062 // Usage: thread_create NAME FILENAME 55063 // 55064 // NAME should be an upper case letter. Start the thread running with 55065 // an open connection to the given database. 55066 func tcl_thread_create(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test4.c:128:26: */ 55067 bp := tls.Alloc(96) 55068 defer tls.Free(96) 55069 55070 var i int32 55071 // var x pthread_t at bp+88, 8 55072 55073 var rc int32 55074 55075 if argc != 3 { 55076 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 55077 ts+25247 /* " ID FILENAME" */, 0)) 55078 return TCL_ERROR 55079 } 55080 i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 55081 if i < 0 { 55082 return TCL_ERROR 55083 } 55084 if threadset[i].Fbusy != 0 { 55085 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25260 /* "thread " */, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+25268 /* " is already runn..." */, 0)) 55086 return TCL_ERROR 55087 } 55088 threadset[i].Fbusy = 1 55089 sqlite3.Xsqlite3_free(tls, threadset[i].FzFilename) 55090 threadset[i].FzFilename = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+64, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) 55091 threadset[i].Fopnum = 1 55092 threadset[i].Fcompleted = 0 55093 rc = libc2.Xpthread_create(tls, bp+88 /* &x */, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 55094 f func(*libc.TLS, uintptr) uintptr 55095 }{test_thread_main})), (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) 55096 if rc != 0 { 55097 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+72, ts+25288 /* "failed to create..." */, 0)) 55098 sqlite3.Xsqlite3_free(tls, threadset[i].FzFilename) 55099 threadset[i].Fbusy = 0 55100 return TCL_ERROR 55101 } 55102 libc2.Xpthread_detach(tls, *(*pthread_t)(unsafe.Pointer(bp + 88 /* x */))) 55103 return TCL_OK 55104 } 55105 55106 // Wait for a thread to reach its idle state. 55107 func test_thread_wait(tls *libc.TLS, p uintptr) { /* test4.c:168:13: */ 55108 for (*Thread)(unsafe.Pointer(p)).Fopnum > (*Thread)(unsafe.Pointer(p)).Fcompleted { 55109 libc2.Xsched_yield(tls) 55110 } 55111 } 55112 55113 // Usage: thread_wait ID 55114 // 55115 // Wait on thread ID to reach its idle state. 55116 func tcl_thread_wait(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test4.c:177:26: */ 55117 bp := tls.Alloc(48) 55118 defer tls.Free(48) 55119 55120 var i int32 55121 55122 if argc != 2 { 55123 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 55124 ts+25316 /* " ID" */, 0)) 55125 return TCL_ERROR 55126 } 55127 i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 55128 if i < 0 { 55129 return TCL_ERROR 55130 } 55131 if !(threadset[i].Fbusy != 0) { 55132 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 55133 return TCL_ERROR 55134 } 55135 test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) 55136 return TCL_OK 55137 } 55138 55139 // Stop a thread. 55140 func test_stop_thread(tls *libc.TLS, p uintptr) { /* test4.c:203:13: */ 55141 test_thread_wait(tls, p) 55142 (*Thread)(unsafe.Pointer(p)).FxOp = uintptr(0) 55143 (*Thread)(unsafe.Pointer(p)).Fopnum++ 55144 test_thread_wait(tls, p) 55145 sqlite3.Xsqlite3_free(tls, (*Thread)(unsafe.Pointer(p)).FzArg) 55146 (*Thread)(unsafe.Pointer(p)).FzArg = uintptr(0) 55147 sqlite3.Xsqlite3_free(tls, (*Thread)(unsafe.Pointer(p)).FzFilename) 55148 (*Thread)(unsafe.Pointer(p)).FzFilename = uintptr(0) 55149 (*Thread)(unsafe.Pointer(p)).Fbusy = 0 55150 } 55151 55152 // Usage: thread_halt ID 55153 // 55154 // Cause a thread to shut itself down. Wait for the shutdown to be 55155 // completed. If ID is "*" then stop all threads. 55156 func tcl_thread_halt(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test4.c:221:26: */ 55157 bp := tls.Alloc(48) 55158 defer tls.Free(48) 55159 55160 var i int32 55161 55162 if argc != 2 { 55163 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 55164 ts+25316 /* " ID" */, 0)) 55165 return TCL_ERROR 55166 } 55167 if (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + 1*8))))) == '*') && (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + 1*8)) + 1))) == 0) { 55168 for i = 0; i < N_THREAD; i++ { 55169 if threadset[i].Fbusy != 0 { 55170 test_stop_thread(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) 55171 } 55172 } 55173 } else { 55174 i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 55175 if i < 0 { 55176 return TCL_ERROR 55177 } 55178 if !(threadset[i].Fbusy != 0) { 55179 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 55180 return TCL_ERROR 55181 } 55182 test_stop_thread(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) 55183 } 55184 return TCL_OK 55185 } 55186 55187 // Usage: thread_argc ID 55188 // 55189 // Wait on the most recent thread_step to complete, then return the 55190 // number of columns in the result set. 55191 func tcl_thread_argc(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test4.c:256:26: */ 55192 bp := tls.Alloc(172) 55193 defer tls.Free(172) 55194 55195 var i int32 55196 // var zBuf [100]int8 at bp+72, 100 55197 55198 if argc != 2 { 55199 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 55200 ts+25316 /* " ID" */, 0)) 55201 return TCL_ERROR 55202 } 55203 i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 55204 if i < 0 { 55205 return TCL_ERROR 55206 } 55207 if !(threadset[i].Fbusy != 0) { 55208 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 55209 return TCL_ERROR 55210 } 55211 test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) 55212 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+72 /* &zBuf[0] */, ts+1238 /* "%d" */, libc.VaList(bp+48, threadset[i].Fargc)) 55213 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, bp+72 /* &zBuf[0] */, 0)) 55214 return TCL_OK 55215 } 55216 55217 // Usage: thread_argv ID N 55218 // 55219 // Wait on the most recent thread_step to complete, then return the 55220 // value of the N-th columns in the result set. 55221 func tcl_thread_argv(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test4.c:288:26: */ 55222 bp := tls.Alloc(84) 55223 defer tls.Free(84) 55224 55225 var i int32 55226 // var n int32 at bp+80, 4 55227 55228 if argc != 3 { 55229 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 55230 ts+25335 /* " ID N" */, 0)) 55231 return TCL_ERROR 55232 } 55233 i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 55234 if i < 0 { 55235 return TCL_ERROR 55236 } 55237 if !(threadset[i].Fbusy != 0) { 55238 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 55239 return TCL_ERROR 55240 } 55241 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+80 /* &n */) != 0 { 55242 return TCL_ERROR 55243 } 55244 test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) 55245 if (*(*int32)(unsafe.Pointer(bp + 80 /* n */)) < 0) || (*(*int32)(unsafe.Pointer(bp + 80 /* n */)) >= threadset[i].Fargc) { 55246 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+25341 /* "column number ou..." */, 0)) 55247 return TCL_ERROR 55248 } 55249 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, *(*uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680 + 80 /* &.argv */) + uintptr(*(*int32)(unsafe.Pointer(bp + 80 /* n */)))*8)), 0)) 55250 return TCL_OK 55251 } 55252 55253 // Usage: thread_colname ID N 55254 // 55255 // Wait on the most recent thread_step to complete, then return the 55256 // name of the N-th columns in the result set. 55257 func tcl_thread_colname(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test4.c:324:26: */ 55258 bp := tls.Alloc(84) 55259 defer tls.Free(84) 55260 55261 var i int32 55262 // var n int32 at bp+80, 4 55263 55264 if argc != 3 { 55265 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 55266 ts+25335 /* " ID N" */, 0)) 55267 return TCL_ERROR 55268 } 55269 i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 55270 if i < 0 { 55271 return TCL_ERROR 55272 } 55273 if !(threadset[i].Fbusy != 0) { 55274 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 55275 return TCL_ERROR 55276 } 55277 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+80 /* &n */) != 0 { 55278 return TCL_ERROR 55279 } 55280 test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) 55281 if (*(*int32)(unsafe.Pointer(bp + 80 /* n */)) < 0) || (*(*int32)(unsafe.Pointer(bp + 80 /* n */)) >= threadset[i].Fargc) { 55282 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+25341 /* "column number ou..." */, 0)) 55283 return TCL_ERROR 55284 } 55285 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, *(*uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680 + 880 /* &.colv */) + uintptr(*(*int32)(unsafe.Pointer(bp + 80 /* n */)))*8)), 0)) 55286 return TCL_OK 55287 } 55288 55289 // Usage: thread_result ID 55290 // 55291 // Wait on the most recent operation to complete, then return the 55292 // result code from that operation. 55293 func tcl_thread_result(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test4.c:360:26: */ 55294 bp := tls.Alloc(64) 55295 defer tls.Free(64) 55296 55297 var i int32 55298 var zName uintptr 55299 55300 if argc != 2 { 55301 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 55302 ts+25316 /* " ID" */, 0)) 55303 return TCL_ERROR 55304 } 55305 i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 55306 if i < 0 { 55307 return TCL_ERROR 55308 } 55309 if !(threadset[i].Fbusy != 0) { 55310 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 55311 return TCL_ERROR 55312 } 55313 test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) 55314 zName = sqlite3.Xsqlite3ErrName(tls, threadset[i].Frc) 55315 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, zName, 0)) 55316 return TCL_OK 55317 } 55318 55319 // Usage: thread_error ID 55320 // 55321 // Wait on the most recent operation to complete, then return the 55322 // error string. 55323 func tcl_thread_error(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test4.c:392:26: */ 55324 bp := tls.Alloc(64) 55325 defer tls.Free(64) 55326 55327 var i int32 55328 55329 if argc != 2 { 55330 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 55331 ts+25316 /* " ID" */, 0)) 55332 return TCL_ERROR 55333 } 55334 i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 55335 if i < 0 { 55336 return TCL_ERROR 55337 } 55338 if !(threadset[i].Fbusy != 0) { 55339 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 55340 return TCL_ERROR 55341 } 55342 test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) 55343 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, threadset[i].FzErr, 0)) 55344 return TCL_OK 55345 } 55346 55347 // This procedure runs in the thread to compile an SQL statement. 55348 func do_compile(tls *libc.TLS, p uintptr) { /* test4.c:419:13: */ 55349 if (*Thread)(unsafe.Pointer(p)).Fdb == uintptr(0) { 55350 (*Thread)(unsafe.Pointer(p)).FzErr = libc.AssignPtrUintptr(p+64 /* &.zStaticErr */, ts+25368 /* "no database is o..." */) 55351 (*Thread)(unsafe.Pointer(p)).Frc = SQLITE_ERROR 55352 return 55353 } 55354 if (*Thread)(unsafe.Pointer(p)).FpStmt != 0 { 55355 sqlite3.Xsqlite3_finalize(tls, (*Thread)(unsafe.Pointer(p)).FpStmt) 55356 (*Thread)(unsafe.Pointer(p)).FpStmt = uintptr(0) 55357 } 55358 (*Thread)(unsafe.Pointer(p)).Frc = sqlite3.Xsqlite3_prepare(tls, (*Thread)(unsafe.Pointer(p)).Fdb, (*Thread)(unsafe.Pointer(p)).FzArg, -1, (p + 48 /* &.pStmt */), uintptr(0)) 55359 } 55360 55361 // Usage: thread_compile ID SQL 55362 // 55363 // Compile a new virtual machine. 55364 func tcl_thread_compile(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test4.c:437:26: */ 55365 bp := tls.Alloc(56) 55366 defer tls.Free(56) 55367 55368 var i int32 55369 if argc != 3 { 55370 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 55371 ts+25388 /* " ID SQL" */, 0)) 55372 return TCL_ERROR 55373 } 55374 i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 55375 if i < 0 { 55376 return TCL_ERROR 55377 } 55378 if !(threadset[i].Fbusy != 0) { 55379 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 55380 return TCL_ERROR 55381 } 55382 test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) 55383 threadset[i].FxOp = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{do_compile})) 55384 sqlite3.Xsqlite3_free(tls, threadset[i].FzArg) 55385 threadset[i].FzArg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+48, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) 55386 threadset[i].Fopnum++ 55387 return TCL_OK 55388 } 55389 55390 // This procedure runs in the thread to step the virtual machine. 55391 func do_step(tls *libc.TLS, p uintptr) { /* test4.c:466:13: */ 55392 var i int32 55393 if (*Thread)(unsafe.Pointer(p)).FpStmt == uintptr(0) { 55394 (*Thread)(unsafe.Pointer(p)).FzErr = libc.AssignPtrUintptr(p+64 /* &.zStaticErr */, ts+25396 /* "no virtual machi..." */) 55395 (*Thread)(unsafe.Pointer(p)).Frc = SQLITE_ERROR 55396 return 55397 } 55398 (*Thread)(unsafe.Pointer(p)).Frc = sqlite3.Xsqlite3_step(tls, (*Thread)(unsafe.Pointer(p)).FpStmt) 55399 if (*Thread)(unsafe.Pointer(p)).Frc == SQLITE_ROW { 55400 (*Thread)(unsafe.Pointer(p)).Fargc = sqlite3.Xsqlite3_column_count(tls, (*Thread)(unsafe.Pointer(p)).FpStmt) 55401 for i = 0; i < sqlite3.Xsqlite3_data_count(tls, (*Thread)(unsafe.Pointer(p)).FpStmt); i++ { 55402 *(*uintptr)(unsafe.Pointer((p + 80 /* &.argv */) + uintptr(i)*8)) = sqlite3.Xsqlite3_column_text(tls, (*Thread)(unsafe.Pointer(p)).FpStmt, i) 55403 } 55404 for i = 0; i < (*Thread)(unsafe.Pointer(p)).Fargc; i++ { 55405 *(*uintptr)(unsafe.Pointer((p + 880 /* &.colv */) + uintptr(i)*8)) = sqlite3.Xsqlite3_column_name(tls, (*Thread)(unsafe.Pointer(p)).FpStmt, i) 55406 } 55407 } 55408 } 55409 55410 // Usage: thread_step ID 55411 // 55412 // Advance the virtual machine by one step 55413 func tcl_thread_step(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test4.c:490:26: */ 55414 bp := tls.Alloc(48) 55415 defer tls.Free(48) 55416 55417 var i int32 55418 if argc != 2 { 55419 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 55420 ts+25425 /* " IDL" */, 0)) 55421 return TCL_ERROR 55422 } 55423 i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 55424 if i < 0 { 55425 return TCL_ERROR 55426 } 55427 if !(threadset[i].Fbusy != 0) { 55428 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 55429 return TCL_ERROR 55430 } 55431 test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) 55432 threadset[i].FxOp = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{do_step})) 55433 threadset[i].Fopnum++ 55434 return TCL_OK 55435 } 55436 55437 // This procedure runs in the thread to finalize a virtual machine. 55438 func do_finalize(tls *libc.TLS, p uintptr) { /* test4.c:517:13: */ 55439 if (*Thread)(unsafe.Pointer(p)).FpStmt == uintptr(0) { 55440 (*Thread)(unsafe.Pointer(p)).FzErr = libc.AssignPtrUintptr(p+64 /* &.zStaticErr */, ts+25396 /* "no virtual machi..." */) 55441 (*Thread)(unsafe.Pointer(p)).Frc = SQLITE_ERROR 55442 return 55443 } 55444 (*Thread)(unsafe.Pointer(p)).Frc = sqlite3.Xsqlite3_finalize(tls, (*Thread)(unsafe.Pointer(p)).FpStmt) 55445 (*Thread)(unsafe.Pointer(p)).FpStmt = uintptr(0) 55446 } 55447 55448 // Usage: thread_finalize ID 55449 // 55450 // Finalize the virtual machine. 55451 func tcl_thread_finalize(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test4.c:532:26: */ 55452 bp := tls.Alloc(48) 55453 defer tls.Free(48) 55454 55455 var i int32 55456 if argc != 2 { 55457 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 55458 ts+25425 /* " IDL" */, 0)) 55459 return TCL_ERROR 55460 } 55461 i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 55462 if i < 0 { 55463 return TCL_ERROR 55464 } 55465 if !(threadset[i].Fbusy != 0) { 55466 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 55467 return TCL_ERROR 55468 } 55469 test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) 55470 threadset[i].FxOp = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{do_finalize})) 55471 sqlite3.Xsqlite3_free(tls, threadset[i].FzArg) 55472 threadset[i].FzArg = uintptr(0) 55473 threadset[i].Fopnum++ 55474 return TCL_OK 55475 } 55476 55477 // Usage: thread_swap ID ID 55478 // 55479 // Interchange the sqlite* pointer between two threads. 55480 func tcl_thread_swap(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test4.c:563:26: */ 55481 bp := tls.Alloc(64) 55482 defer tls.Free(64) 55483 55484 var i int32 55485 var j int32 55486 var temp uintptr 55487 if argc != 3 { 55488 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 55489 ts+25430 /* " ID1 ID2" */, 0)) 55490 return TCL_ERROR 55491 } 55492 i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 55493 if i < 0 { 55494 return TCL_ERROR 55495 } 55496 if !(threadset[i].Fbusy != 0) { 55497 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 55498 return TCL_ERROR 55499 } 55500 test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) 55501 j = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8))) 55502 if j < 0 { 55503 return TCL_ERROR 55504 } 55505 if !(threadset[j].Fbusy != 0) { 55506 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+25320 /* "no such thread" */, 0)) 55507 return TCL_ERROR 55508 } 55509 test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(j)*1680)) 55510 temp = threadset[i].Fdb 55511 threadset[i].Fdb = threadset[j].Fdb 55512 threadset[j].Fdb = temp 55513 return TCL_OK 55514 } 55515 55516 // Usage: thread_db_get ID 55517 // 55518 // Return the database connection pointer for the given thread. Then 55519 // remove the pointer from the thread itself. Afterwards, the thread 55520 // can be stopped and the connection can be used by the main thread. 55521 func tcl_thread_db_get(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test4.c:603:26: */ 55522 bp := tls.Alloc(164) 55523 defer tls.Free(164) 55524 55525 var i int32 55526 // var zBuf [100]int8 at bp+64, 100 55527 55528 if argc != 2 { 55529 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 55530 ts+25316 /* " ID" */, 0)) 55531 return TCL_ERROR 55532 } 55533 i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 55534 if i < 0 { 55535 return TCL_ERROR 55536 } 55537 if !(threadset[i].Fbusy != 0) { 55538 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 55539 return TCL_ERROR 55540 } 55541 test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) 55542 sqlite3TestMakePointerStr(tls, interp, bp+64 /* &zBuf[0] */, threadset[i].Fdb) 55543 threadset[i].Fdb = uintptr(0) 55544 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, bp+64 /* &zBuf[0] */, uintptr(0))) 55545 return TCL_OK 55546 } 55547 55548 // Usage: thread_db_put ID DB 55549 // 55550 func tcl_thread_db_put(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test4.c:634:26: */ 55551 bp := tls.Alloc(48) 55552 defer tls.Free(48) 55553 55554 var i int32 55555 if argc != 3 { 55556 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 55557 ts+25439 /* " ID DB" */, 0)) 55558 return TCL_ERROR 55559 } 55560 i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 55561 if i < 0 { 55562 return TCL_ERROR 55563 } 55564 if !(threadset[i].Fbusy != 0) { 55565 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 55566 return TCL_ERROR 55567 } 55568 test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) 55569 55570 threadset[i].Fdb = sqlite3TestTextToPtr(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) 55571 return TCL_OK 55572 } 55573 55574 // Usage: thread_stmt_get ID 55575 // 55576 // Return the database stmt pointer for the given thread. Then 55577 // remove the pointer from the thread itself. 55578 func tcl_thread_stmt_get(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test4.c:666:26: */ 55579 bp := tls.Alloc(164) 55580 defer tls.Free(164) 55581 55582 var i int32 55583 // var zBuf [100]int8 at bp+64, 100 55584 55585 if argc != 2 { 55586 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 55587 ts+25316 /* " ID" */, 0)) 55588 return TCL_ERROR 55589 } 55590 i = parse_thread_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 55591 if i < 0 { 55592 return TCL_ERROR 55593 } 55594 if !(threadset[i].Fbusy != 0) { 55595 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 55596 return TCL_ERROR 55597 } 55598 test_thread_wait(tls, (uintptr(unsafe.Pointer(&threadset)) + uintptr(i)*1680)) 55599 sqlite3TestMakePointerStr(tls, interp, bp+64 /* &zBuf[0] */, threadset[i].FpStmt) 55600 threadset[i].FpStmt = uintptr(0) 55601 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, bp+64 /* &zBuf[0] */, uintptr(0))) 55602 return TCL_OK 55603 } 55604 55605 // Register commands with the TCL interpreter. 55606 func Sqlitetest4_Init(tls *libc.TLS, interp uintptr) int32 { /* test4.c:696:5: */ 55607 var i int32 55608 55609 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aCmd4)) / uint64(unsafe.Sizeof(struct { 55610 FzName uintptr 55611 FxProc uintptr 55612 }{}))); i++ { 55613 tcl.XTcl_CreateCommand(tls, interp, aCmd4[i].FzName, aCmd4[i].FxProc, uintptr(0), uintptr(0)) 55614 } 55615 return TCL_OK 55616 } 55617 55618 var aCmd4 = [15]struct { 55619 FzName uintptr 55620 FxProc uintptr 55621 }{ 55622 {FzName: ts + 25446 /* "thread_create" */, FxProc: 0}, 55623 {FzName: ts + 25460 /* "thread_wait" */, FxProc: 0}, 55624 {FzName: ts + 25472 /* "thread_halt" */, FxProc: 0}, 55625 {FzName: ts + 25484 /* "thread_argc" */, FxProc: 0}, 55626 {FzName: ts + 25496 /* "thread_argv" */, FxProc: 0}, 55627 {FzName: ts + 25508 /* "thread_colname" */, FxProc: 0}, 55628 {FzName: ts + 25523 /* "thread_result" */, FxProc: 0}, 55629 {FzName: ts + 25537 /* "thread_error" */, FxProc: 0}, 55630 {FzName: ts + 25550 /* "thread_compile" */, FxProc: 0}, 55631 {FzName: ts + 25565 /* "thread_step" */, FxProc: 0}, 55632 {FzName: ts + 25577 /* "thread_finalize" */, FxProc: 0}, 55633 {FzName: ts + 25593 /* "thread_swap" */, FxProc: 0}, 55634 {FzName: ts + 25605 /* "thread_db_get" */, FxProc: 0}, 55635 {FzName: ts + 25619 /* "thread_db_put" */, FxProc: 0}, 55636 {FzName: ts + 25633 /* "thread_stmt_get" */, FxProc: 0}, 55637 } /* test4.c:700:5 */ 55638 55639 // end block for C++ 55640 55641 // Local Variables: 55642 // mode: c 55643 // c-basic-offset: 4 55644 // fill-column: 78 55645 // End: 55646 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 55647 // This file is part of the GNU C Library. 55648 // 55649 // The GNU C Library is free software; you can redistribute it and/or 55650 // modify it under the terms of the GNU Lesser General Public 55651 // License as published by the Free Software Foundation; either 55652 // version 2.1 of the License, or (at your option) any later version. 55653 // 55654 // The GNU C Library is distributed in the hope that it will be useful, 55655 // but WITHOUT ANY WARRANTY; without even the implied warranty of 55656 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 55657 // Lesser General Public License for more details. 55658 // 55659 // You should have received a copy of the GNU Lesser General Public 55660 // License along with the GNU C Library; if not, see 55661 // <http://www.gnu.org/licenses/>. 55662 55663 // ISO C99 Standard: 7.20 General utilities <stdlib.h> 55664 55665 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 55666 // This file is part of the GNU C Library. 55667 // 55668 // The GNU C Library is free software; you can redistribute it and/or 55669 // modify it under the terms of the GNU Lesser General Public 55670 // License as published by the Free Software Foundation; either 55671 // version 2.1 of the License, or (at your option) any later version. 55672 // 55673 // The GNU C Library is distributed in the hope that it will be useful, 55674 // but WITHOUT ANY WARRANTY; without even the implied warranty of 55675 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 55676 // Lesser General Public License for more details. 55677 // 55678 // You should have received a copy of the GNU Lesser General Public 55679 // License along with the GNU C Library; if not, see 55680 // <http://www.gnu.org/licenses/>. 55681 55682 // ISO C99 Standard: 7.21 String handling <string.h> 55683 55684 // The first argument is a TCL UTF-8 string. Return the byte array 55685 // object with the encoded representation of the string, including 55686 // the NULL terminator. 55687 func binarize(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test5.c:33:26: */ 55688 bp := tls.Alloc(4) 55689 defer tls.Free(4) 55690 55691 // var len int32 at bp, 4 55692 55693 var bytes uintptr 55694 var pRet uintptr 55695 55696 bytes = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &len */) 55697 pRet = tcl.XTcl_NewByteArrayObj(tls, bytes, (*(*int32)(unsafe.Pointer(bp /* len */)) + 1)) 55698 tcl.XTcl_SetObjResult(tls, interp, pRet) 55699 return TCL_OK 55700 } 55701 55702 // Usage: test_value_overhead <repeat-count> <do-calls>. 55703 // 55704 // This routine is used to test the overhead of calls to 55705 // sqlite3_value_text(), on a value that contains a UTF-8 string. The idea 55706 // is to figure out whether or not it is a problem to use sqlite3_value 55707 // structures with collation sequence functions. 55708 // 55709 // If <do-calls> is 0, then the calls to sqlite3_value_text() are not 55710 // actually made. 55711 func test_value_overhead(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test5.c:61:26: */ 55712 bp := tls.Alloc(96) 55713 defer tls.Free(96) 55714 55715 // var do_calls int32 at bp+36, 4 55716 55717 // var repeat_count int32 at bp+32, 4 55718 55719 var i int32 55720 // var val Mem at bp+40, 56 55721 55722 if objc != 3 { 55723 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 55724 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), ts+25649 /* " <repeat-count> ..." */, 0)) 55725 return TCL_ERROR 55726 } 55727 55728 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+32 /* &repeat_count */) != 0 { 55729 return TCL_ERROR 55730 } 55731 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+36 /* &do_calls */) != 0 { 55732 return TCL_ERROR 55733 } 55734 55735 (*Mem)(unsafe.Pointer(bp + 40 /* &val */)).Fflags = (u16((MEM_Str | MEM_Term) | MEM_Static)) 55736 (*Mem)(unsafe.Pointer(bp + 40 /* &val */)).Fz = ts + 25676 /* "hello world" */ 55737 (*Mem)(unsafe.Pointer(bp + 40 /* &val */)).Fenc = u8(SQLITE_UTF8) 55738 55739 for i = 0; i < *(*int32)(unsafe.Pointer(bp + 32 /* repeat_count */)); i++ { 55740 if *(*int32)(unsafe.Pointer(bp + 36 /* do_calls */)) != 0 { 55741 sqlite3.Xsqlite3_value_text(tls, bp+40 /* &val */) 55742 } 55743 } 55744 55745 return TCL_OK 55746 } 55747 55748 func name_to_enc(tls *libc.TLS, interp uintptr, pObj uintptr) u8 { /* test5.c:94:11: */ 55749 bp := tls.Alloc(104) 55750 defer tls.Free(104) 55751 55752 *(*[5]EncName)(unsafe.Pointer(bp + 24 /* encnames */)) = [5]EncName{ 55753 {FzName: ts + 25688 /* "UTF8" */, Fenc: u8(SQLITE_UTF8)}, 55754 {FzName: ts + 25693 /* "UTF16LE" */, Fenc: u8(SQLITE_UTF16LE)}, 55755 {FzName: ts + 25701 /* "UTF16BE" */, Fenc: u8(SQLITE_UTF16BE)}, 55756 {FzName: ts + 25709 /* "UTF16" */, Fenc: u8(SQLITE_UTF16)}, 55757 {}, 55758 } 55759 var pEnc uintptr 55760 var z uintptr = tcl.XTcl_GetString(tls, pObj) 55761 for pEnc = (bp + 24 /* &encnames */); (*EncName)(unsafe.Pointer(pEnc)).FzName != 0; pEnc += 16 { 55762 if 0 == sqlite3.Xsqlite3StrICmp(tls, z, (*EncName)(unsafe.Pointer(pEnc)).FzName) { 55763 break 55764 } 55765 } 55766 if !(int32((*EncName)(unsafe.Pointer(pEnc)).Fenc) != 0) { 55767 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+25715 /* "No such encoding..." */, z, 0)) 55768 } 55769 if int32((*EncName)(unsafe.Pointer(pEnc)).Fenc) == SQLITE_UTF16 { 55770 return func() uint8 { 55771 if int32(*(*int8)(unsafe.Pointer(uintptr(unsafe.Pointer(&sqlite3.Xsqlite3one))))) == 0 { 55772 return uint8(SQLITE_UTF16BE) 55773 } 55774 return uint8(SQLITE_UTF16LE) 55775 }() 55776 } 55777 return (*EncName)(unsafe.Pointer(pEnc)).Fenc 55778 } 55779 55780 type EncName = struct { 55781 FzName uintptr 55782 Fenc u8 55783 _ [7]byte 55784 } /* test5.c:95:3 */ 55785 55786 // Usage: test_translate <string/blob> <from enc> <to enc> ?<transient>? 55787 // 55788 func test_translate(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test5.c:125:26: */ 55789 bp := tls.Alloc(44) 55790 defer tls.Free(44) 55791 55792 var enc_from u8 55793 var enc_to u8 55794 var pVal uintptr 55795 var z uintptr 55796 // var len int32 at bp+40, 4 55797 55798 var xDel uintptr = uintptr(0) 55799 55800 if (objc != 4) && (objc != 5) { 55801 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 55802 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv)), uintptr(0)), 55803 ts+25734 /* " <string/blob> <..." */, 0)) 55804 return TCL_ERROR 55805 } 55806 if objc == 5 { 55807 xDel = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free})) 55808 } 55809 55810 enc_from = name_to_enc(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 55811 if !(enc_from != 0) { 55812 return TCL_ERROR 55813 } 55814 enc_to = name_to_enc(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 55815 if !(enc_to != 0) { 55816 return TCL_ERROR 55817 } 55818 55819 pVal = sqlite3.Xsqlite3ValueNew(tls, uintptr(0)) 55820 55821 if int32(enc_from) == SQLITE_UTF8 { 55822 z = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 55823 if objc == 5 { 55824 z = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+32, z)) 55825 } 55826 sqlite3.Xsqlite3ValueSetStr(tls, pVal, -1, z, enc_from, xDel) 55827 } else { 55828 z = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+40 /* &len */) 55829 if objc == 5 { 55830 var zTmp uintptr = z 55831 z = sqlite3.Xsqlite3_malloc(tls, *(*int32)(unsafe.Pointer(bp + 40 /* len */))) 55832 libc.Xmemcpy(tls, z, zTmp, uint64(*(*int32)(unsafe.Pointer(bp + 40 /* len */)))) 55833 } 55834 sqlite3.Xsqlite3ValueSetStr(tls, pVal, -1, z, enc_from, xDel) 55835 } 55836 55837 z = sqlite3.Xsqlite3ValueText(tls, pVal, enc_to) 55838 *(*int32)(unsafe.Pointer(bp + 40 /* len */)) = (sqlite3.Xsqlite3ValueBytes(tls, pVal, enc_to) + (func() int32 { 55839 if int32(enc_to) == SQLITE_UTF8 { 55840 return 1 55841 } 55842 return 2 55843 }())) 55844 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewByteArrayObj(tls, z, *(*int32)(unsafe.Pointer(bp + 40 /* len */)))) 55845 55846 sqlite3.Xsqlite3ValueFree(tls, pVal) 55847 55848 return TCL_OK 55849 } 55850 55851 func test_translate_selftest(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test5.c:189:26: */ 55852 sqlite3.Xsqlite3UtfSelfTest(tls) 55853 return SQLITE_OK 55854 } 55855 55856 // Register commands with the TCL interpreter. 55857 func Sqlitetest5_Init(tls *libc.TLS, interp uintptr) int32 { /* test5.c:205:5: */ 55858 var i int32 55859 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aCmd5)) / uint64(unsafe.Sizeof(struct { 55860 FzName uintptr 55861 FxProc uintptr 55862 }{}))); i++ { 55863 tcl.XTcl_CreateObjCommand(tls, interp, aCmd5[i].FzName, aCmd5[i].FxProc, uintptr(0), uintptr(0)) 55864 } 55865 return SQLITE_OK 55866 } 55867 55868 var aCmd5 = [4]struct { 55869 FzName uintptr 55870 FxProc uintptr 55871 }{ 55872 {FzName: ts + 25769 /* "binarize" */, FxProc: 0}, 55873 {FzName: ts + 25778 /* "test_value_overh..." */, FxProc: 0}, 55874 {FzName: ts + 25798 /* "test_translate" */, FxProc: 0}, 55875 {FzName: ts + 25813 /* "translate_selfte..." */, FxProc: 0}, 55876 } /* test5.c:209:5 */ 55877 55878 // end block for C++ 55879 55880 // Local Variables: 55881 // mode: c 55882 // c-basic-offset: 4 55883 // fill-column: 78 55884 // End: 55885 55886 // #define TRACE_CRASHTEST 55887 55888 type CrashFile1 = struct { 55889 FpMethod uintptr 55890 FpRealFile uintptr 55891 FzName uintptr 55892 Fflags int32 55893 _ [4]byte 55894 FzData uintptr 55895 FnData int32 55896 _ [4]byte 55897 FiSize i64 55898 } /* test6.c:29:9 */ 55899 55900 // end block for C++ 55901 55902 // Local Variables: 55903 // mode: c 55904 // c-basic-offset: 4 55905 // fill-column: 78 55906 // End: 55907 55908 // #define TRACE_CRASHTEST 55909 55910 type CrashFile = CrashFile1 /* test6.c:29:26 */ 55911 type CrashGlobal1 = struct { 55912 FpWriteList uintptr 55913 FpWriteListEnd uintptr 55914 FiSectorSize int32 55915 FiDeviceCharacteristics int32 55916 FiCrash int32 55917 FzCrashFile [500]int8 55918 } /* test6.c:30:9 */ 55919 55920 type CrashGlobal = CrashGlobal1 /* test6.c:30:28 */ 55921 type WriteBuffer1 = struct { 55922 FiOffset i64 55923 FnBuf int32 55924 _ [4]byte 55925 FzBuf uintptr 55926 FpFile uintptr 55927 FpNext uintptr 55928 } /* test6.c:30:9 */ 55929 55930 type WriteBuffer = WriteBuffer1 /* test6.c:31:28 */ 55931 55932 var g = CrashGlobal{FiSectorSize: SQLITE_DEFAULT_SECTOR_SIZE} /* test6.c:156:20 */ 55933 55934 // Set this global variable to 1 to enable crash testing. 55935 var sqlite3CrashTestEnable int32 = 0 /* test6.c:161:12 */ 55936 55937 func crash_malloc(tls *libc.TLS, nByte int32) uintptr { /* test6.c:163:13: */ 55938 return tcl.XTcl_AttemptAlloc(tls, uint32(size_t(nByte))) 55939 } 55940 55941 func crash_free(tls *libc.TLS, p uintptr) { /* test6.c:166:13: */ 55942 tcl.XTcl_Free(tls, p) 55943 } 55944 55945 func crash_realloc(tls *libc.TLS, p uintptr, n int32) uintptr { /* test6.c:169:13: */ 55946 return tcl.XTcl_AttemptRealloc(tls, p, uint32(size_t(n))) 55947 } 55948 55949 // Wrapper around the sqlite3OsWrite() function that avoids writing to the 55950 // 512 byte block begining at offset PENDING_BYTE. 55951 func writeDbFile(tls *libc.TLS, p uintptr, z uintptr, iAmt i64, iOff i64) int32 { /* test6.c:177:12: */ 55952 var rc int32 = SQLITE_OK 55953 var iSkip int32 = 0 55954 if (iAmt - i64(iSkip)) > int64(0) { 55955 rc = sqlite3.Xsqlite3OsWrite(tls, (*CrashFile)(unsafe.Pointer(p)).FpRealFile, (z + uintptr(iSkip)), (int32(iAmt - i64(iSkip))), (iOff + i64(iSkip))) 55956 } 55957 return rc 55958 } 55959 55960 // Flush the write-list as if xSync() had been called on file handle 55961 // pFile. If isCrash is true, simulate a crash. 55962 func writeListSync(tls *libc.TLS, pFile uintptr, isCrash int32) int32 { /* test6.c:190:12: */ 55963 bp := tls.Alloc(16) 55964 defer tls.Free(16) 55965 55966 var rc int32 = SQLITE_OK 55967 var iDc int32 = g.FiDeviceCharacteristics 55968 var pWrite uintptr 55969 var ppPtr uintptr 55970 55971 // If this is not a crash simulation, set pFinal to point to the 55972 // last element of the write-list that is associated with file handle 55973 // pFile. 55974 // 55975 // If this is a crash simulation, set pFinal to an arbitrarily selected 55976 // element of the write-list. 55977 var pFinal uintptr = uintptr(0) 55978 if !(isCrash != 0) { 55979 for pWrite = g.FpWriteList; pWrite != 0; pWrite = (*WriteBuffer)(unsafe.Pointer(pWrite)).FpNext { 55980 if (*WriteBuffer)(unsafe.Pointer(pWrite)).FpFile == pFile { 55981 pFinal = pWrite 55982 } 55983 } 55984 } else if (iDc & (SQLITE_IOCAP_SEQUENTIAL | SQLITE_IOCAP_SAFE_APPEND)) != 0 { 55985 var nWrite int32 = 0 55986 // var iFinal int32 at bp, 4 55987 55988 for pWrite = g.FpWriteList; pWrite != 0; pWrite = (*WriteBuffer)(unsafe.Pointer(pWrite)).FpNext { 55989 nWrite++ 55990 } 55991 sqlite3.Xsqlite3_randomness(tls, int32(unsafe.Sizeof(int32(0))), bp /* &iFinal */) 55992 *(*int32)(unsafe.Pointer(bp /* iFinal */)) = ((func() int32 { 55993 if *(*int32)(unsafe.Pointer(bp /* iFinal */)) < 0 { 55994 return (-1 * *(*int32)(unsafe.Pointer(bp /* iFinal */))) 55995 } 55996 return *(*int32)(unsafe.Pointer(bp /* iFinal */)) 55997 }()) % nWrite) 55998 for pWrite = g.FpWriteList; *(*int32)(unsafe.Pointer(bp /* iFinal */)) > 0; pWrite = (*WriteBuffer)(unsafe.Pointer(pWrite)).FpNext { 55999 *(*int32)(unsafe.Pointer(bp /* iFinal */))-- 56000 } 56001 pFinal = pWrite 56002 } 56003 56004 ppPtr = (uintptr(unsafe.Pointer(&g)) /* &.pWriteList */) 56005 for pWrite = *(*uintptr)(unsafe.Pointer(ppPtr)); (rc == SQLITE_OK) && (pWrite != 0); pWrite = *(*uintptr)(unsafe.Pointer(ppPtr)) { 56006 var pRealFile uintptr = (*CrashFile)(unsafe.Pointer((*WriteBuffer)(unsafe.Pointer(pWrite)).FpFile)).FpRealFile 56007 56008 // (eAction==1) -> write block out normally, 56009 // (eAction==2) -> do nothing, 56010 // (eAction==3) -> trash sectors. 56011 var eAction int32 = 0 56012 if !(isCrash != 0) { 56013 eAction = 2 56014 if ((*WriteBuffer)(unsafe.Pointer(pWrite)).FpFile == pFile) || ((iDc & SQLITE_IOCAP_SEQUENTIAL) != 0) { 56015 eAction = 1 56016 } 56017 } else { 56018 // var random int8 at bp+4, 1 56019 56020 sqlite3.Xsqlite3_randomness(tls, 1, bp+4 /* &random */) 56021 56022 // Do not select option 3 (sector trashing) if the IOCAP_ATOMIC flag 56023 // is set or this is an OsTruncate(), not an Oswrite(). 56024 if ((iDc & SQLITE_IOCAP_ATOMIC) != 0) || ((*WriteBuffer)(unsafe.Pointer(pWrite)).FzBuf == uintptr(0)) { 56025 *(*int8)(unsafe.Pointer(bp + 4 /* random */)) &= int8(0x01) 56026 } 56027 56028 // If IOCAP_SEQUENTIAL is set and this is not the final entry 56029 // in the truncated write-list, always select option 1 (write 56030 // out correctly). 56031 if ((iDc & SQLITE_IOCAP_SEQUENTIAL) != 0) && (pWrite != pFinal) { 56032 *(*int8)(unsafe.Pointer(bp + 4 /* random */)) = int8(0) 56033 } 56034 56035 // If IOCAP_SAFE_APPEND is set and this OsWrite() operation is 56036 // an append (first byte of the written region is 1 byte past the 56037 // current EOF), always select option 1 (write out correctly). 56038 if ((iDc & SQLITE_IOCAP_SAFE_APPEND) != 0) && ((*WriteBuffer)(unsafe.Pointer(pWrite)).FzBuf != 0) { 56039 // var iSize i64 at bp+8, 8 56040 56041 sqlite3.Xsqlite3OsFileSize(tls, pRealFile, bp+8 /* &iSize */) 56042 if *(*i64)(unsafe.Pointer(bp + 8 /* iSize */)) == (*WriteBuffer)(unsafe.Pointer(pWrite)).FiOffset { 56043 *(*int8)(unsafe.Pointer(bp + 4 /* random */)) = int8(0) 56044 } 56045 } 56046 56047 if (int32(*(*int8)(unsafe.Pointer(bp + 4 /* random */))) & 0x06) == 0x06 { 56048 eAction = 3 56049 } else { 56050 eAction = func() int32 { 56051 if (int32(*(*int8)(unsafe.Pointer(bp + 4 /* random */))) & 0x01) != 0 { 56052 return 2 56053 } 56054 return 1 56055 }() 56056 } 56057 } 56058 56059 switch eAction { 56060 case 1: 56061 { // Write out correctly 56062 if (*WriteBuffer)(unsafe.Pointer(pWrite)).FzBuf != 0 { 56063 rc = writeDbFile(tls, 56064 (*WriteBuffer)(unsafe.Pointer(pWrite)).FpFile, (*WriteBuffer)(unsafe.Pointer(pWrite)).FzBuf, int64((*WriteBuffer)(unsafe.Pointer(pWrite)).FnBuf), (*WriteBuffer)(unsafe.Pointer(pWrite)).FiOffset) 56065 } else { 56066 rc = sqlite3.Xsqlite3OsTruncate(tls, pRealFile, (*WriteBuffer)(unsafe.Pointer(pWrite)).FiOffset) 56067 } 56068 *(*uintptr)(unsafe.Pointer(ppPtr)) = (*WriteBuffer)(unsafe.Pointer(pWrite)).FpNext 56069 crash_free(tls, pWrite) 56070 break 56071 56072 } 56073 case 2: 56074 { // Do nothing 56075 ppPtr = (pWrite + 32 /* &.pNext */) 56076 break 56077 56078 } 56079 case 3: 56080 { // Trash sectors 56081 var zGarbage uintptr 56082 var iFirst int32 = (int32((*WriteBuffer)(unsafe.Pointer(pWrite)).FiOffset / i64(g.FiSectorSize))) 56083 var iLast int32 = (int32((((*WriteBuffer)(unsafe.Pointer(pWrite)).FiOffset + i64((*WriteBuffer)(unsafe.Pointer(pWrite)).FnBuf)) - int64(1)) / i64(g.FiSectorSize))) 56084 56085 zGarbage = crash_malloc(tls, g.FiSectorSize) 56086 if zGarbage != 0 { 56087 var i sqlite3_int64 56088 for i = sqlite3_int64(iFirst); (rc == SQLITE_OK) && (i <= sqlite3_int64(iLast)); i++ { 56089 sqlite3.Xsqlite3_randomness(tls, g.FiSectorSize, zGarbage) 56090 rc = writeDbFile(tls, 56091 (*WriteBuffer)(unsafe.Pointer(pWrite)).FpFile, zGarbage, int64(g.FiSectorSize), (i * sqlite3_int64(g.FiSectorSize))) 56092 } 56093 crash_free(tls, zGarbage) 56094 } else { 56095 rc = SQLITE_NOMEM 56096 } 56097 56098 ppPtr = (pWrite + 32 /* &.pNext */) 56099 break 56100 56101 } 56102 56103 default: 56104 56105 } 56106 56107 if pWrite == pFinal { 56108 break 56109 } 56110 } 56111 56112 if (rc == SQLITE_OK) && (isCrash != 0) { 56113 libc.Xexit(tls, -1) 56114 } 56115 56116 for pWrite = g.FpWriteList; (pWrite != 0) && ((*WriteBuffer)(unsafe.Pointer(pWrite)).FpNext != 0); pWrite = (*WriteBuffer)(unsafe.Pointer(pWrite)).FpNext { 56117 } 56118 g.FpWriteListEnd = pWrite 56119 56120 return rc 56121 } 56122 56123 // Add an entry to the end of the write-list. 56124 func writeListAppend(tls *libc.TLS, pFile uintptr, iOffset sqlite3_int64, zBuf uintptr, nBuf int32) int32 { /* test6.c:362:12: */ 56125 var pNew uintptr 56126 56127 pNew = crash_malloc(tls, (int32(uint64(unsafe.Sizeof(WriteBuffer{})) + uint64(nBuf)))) 56128 if pNew == uintptr(0) { 56129 libc.Xfprintf(tls, libc.Xstderr, ts+25832 /* "out of memory in..." */, 0) 56130 } 56131 libc.Xmemset(tls, pNew, 0, (uint64(unsafe.Sizeof(WriteBuffer{})) + uint64(nBuf))) 56132 (*WriteBuffer)(unsafe.Pointer(pNew)).FiOffset = iOffset 56133 (*WriteBuffer)(unsafe.Pointer(pNew)).FnBuf = nBuf 56134 (*WriteBuffer)(unsafe.Pointer(pNew)).FpFile = pFile 56135 if zBuf != 0 { 56136 (*WriteBuffer)(unsafe.Pointer(pNew)).FzBuf = (pNew + 1*40) 56137 libc.Xmemcpy(tls, (*WriteBuffer)(unsafe.Pointer(pNew)).FzBuf, zBuf, uint64(nBuf)) 56138 } 56139 56140 if g.FpWriteList != 0 { 56141 56142 (*WriteBuffer)(unsafe.Pointer(g.FpWriteListEnd)).FpNext = pNew 56143 } else { 56144 g.FpWriteList = pNew 56145 } 56146 g.FpWriteListEnd = pNew 56147 56148 return SQLITE_OK 56149 } 56150 56151 // Close a crash-file. 56152 func cfClose(tls *libc.TLS, pFile uintptr) int32 { /* test6.c:399:12: */ 56153 var pCrash uintptr = pFile 56154 writeListSync(tls, pCrash, 0) 56155 sqlite3.Xsqlite3OsClose(tls, (*CrashFile)(unsafe.Pointer(pCrash)).FpRealFile) 56156 return SQLITE_OK 56157 } 56158 56159 // Read data from a crash-file. 56160 func cfRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test6.c:409:12: */ 56161 var pCrash uintptr = pFile 56162 var nCopy int32 = func() int32 { 56163 if (i64(iAmt)) < ((*CrashFile)(unsafe.Pointer(pCrash)).FiSize - iOfst) { 56164 return int32(i64(iAmt)) 56165 } 56166 return (int32((*CrashFile)(unsafe.Pointer(pCrash)).FiSize - iOfst)) 56167 }() 56168 56169 if nCopy > 0 { 56170 libc.Xmemcpy(tls, zBuf, ((*CrashFile)(unsafe.Pointer(pCrash)).FzData + uintptr(iOfst)), uint64(nCopy)) 56171 } 56172 56173 // Check the file-size to see if this is a short-read 56174 if nCopy < iAmt { 56175 return (SQLITE_IOERR | (int32(2) << 8)) 56176 } 56177 56178 return SQLITE_OK 56179 } 56180 56181 // Write data to a crash-file. 56182 func cfWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test6.c:433:12: */ 56183 var pCrash uintptr = pFile 56184 if (sqlite_int64(iAmt) + iOfst) > (*CrashFile)(unsafe.Pointer(pCrash)).FiSize { 56185 (*CrashFile)(unsafe.Pointer(pCrash)).FiSize = i64((int32(sqlite_int64(iAmt) + iOfst))) 56186 } 56187 for (*CrashFile)(unsafe.Pointer(pCrash)).FiSize > i64((*CrashFile)(unsafe.Pointer(pCrash)).FnData) { 56188 var zNew uintptr 56189 var nNew int32 = (((*CrashFile)(unsafe.Pointer(pCrash)).FnData * 2) + 4096) 56190 zNew = crash_realloc(tls, (*CrashFile)(unsafe.Pointer(pCrash)).FzData, nNew) 56191 if !(zNew != 0) { 56192 return SQLITE_NOMEM 56193 } 56194 libc.Xmemset(tls, (zNew + uintptr((*CrashFile)(unsafe.Pointer(pCrash)).FnData)), 0, (uint64(nNew - (*CrashFile)(unsafe.Pointer(pCrash)).FnData))) 56195 (*CrashFile)(unsafe.Pointer(pCrash)).FnData = nNew 56196 (*CrashFile)(unsafe.Pointer(pCrash)).FzData = zNew 56197 } 56198 libc.Xmemcpy(tls, ((*CrashFile)(unsafe.Pointer(pCrash)).FzData + uintptr(iOfst)), zBuf, uint64(iAmt)) 56199 return writeListAppend(tls, pFile, iOfst, zBuf, iAmt) 56200 } 56201 56202 // Truncate a crash-file. 56203 func cfTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { /* test6.c:461:12: */ 56204 var pCrash uintptr = pFile 56205 56206 if (*CrashFile)(unsafe.Pointer(pCrash)).FiSize > size { 56207 (*CrashFile)(unsafe.Pointer(pCrash)).FiSize = i64(int32(size)) 56208 } 56209 return writeListAppend(tls, pFile, size, uintptr(0), 0) 56210 } 56211 56212 // Sync a crash-file. 56213 func cfSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* test6.c:473:12: */ 56214 var pCrash uintptr = pFile 56215 var isCrash int32 = 0 56216 56217 var zName uintptr = (*CrashFile)(unsafe.Pointer(pCrash)).FzName 56218 var zCrashFile uintptr = uintptr(unsafe.Pointer(&g)) + 28 /* &.zCrashFile */ 56219 var nName int32 = int32(libc.Xstrlen(tls, zName)) 56220 var nCrashFile int32 = int32(libc.Xstrlen(tls, zCrashFile)) 56221 56222 if (nCrashFile > 0) && (int32(*(*int8)(unsafe.Pointer(zCrashFile + uintptr((nCrashFile - 1))))) == '*') { 56223 nCrashFile-- 56224 if nName > nCrashFile { 56225 nName = nCrashFile 56226 } 56227 } 56228 56229 if (nName == nCrashFile) && (0 == libc.Xmemcmp(tls, zName, zCrashFile, uint64(nName))) { 56230 if (libc.PreDecInt32(&g.FiCrash, 1)) == 0 { 56231 isCrash = 1 56232 } 56233 } 56234 56235 return writeListSync(tls, pCrash, isCrash) 56236 } 56237 56238 // Return the current file-size of the crash-file. 56239 func cfFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { /* test6.c:505:12: */ 56240 var pCrash uintptr = pFile 56241 *(*sqlite_int64)(unsafe.Pointer(pSize)) = (*CrashFile)(unsafe.Pointer(pCrash)).FiSize 56242 return SQLITE_OK 56243 } 56244 56245 // Calls related to file-locks are passed on to the real file handle. 56246 func cfLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test6.c:514:12: */ 56247 return sqlite3.Xsqlite3OsLock(tls, (*CrashFile)(unsafe.Pointer(pFile)).FpRealFile, eLock) 56248 } 56249 56250 func cfUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test6.c:517:12: */ 56251 return sqlite3.Xsqlite3OsUnlock(tls, (*CrashFile)(unsafe.Pointer(pFile)).FpRealFile, eLock) 56252 } 56253 56254 func cfCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int32 { /* test6.c:520:12: */ 56255 return sqlite3.Xsqlite3OsCheckReservedLock(tls, (*CrashFile)(unsafe.Pointer(pFile)).FpRealFile, pResOut) 56256 } 56257 56258 func cfFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 { /* test6.c:523:12: */ 56259 if op == SQLITE_FCNTL_SIZE_HINT { 56260 var pCrash uintptr = pFile 56261 var nByte i64 = *(*i64)(unsafe.Pointer(pArg)) 56262 if nByte > (*CrashFile)(unsafe.Pointer(pCrash)).FiSize { 56263 if SQLITE_OK == writeListAppend(tls, pFile, nByte, uintptr(0), 0) { 56264 (*CrashFile)(unsafe.Pointer(pCrash)).FiSize = i64(int32(nByte)) 56265 } 56266 } 56267 return SQLITE_OK 56268 } 56269 return sqlite3.Xsqlite3OsFileControl(tls, (*CrashFile)(unsafe.Pointer(pFile)).FpRealFile, op, pArg) 56270 } 56271 56272 // The xSectorSize() and xDeviceCharacteristics() functions return 56273 // the global values configured by the [sqlite_crashparams] tcl 56274 // interface. 56275 func cfSectorSize(tls *libc.TLS, pFile uintptr) int32 { /* test6.c:542:12: */ 56276 return g.FiSectorSize 56277 } 56278 56279 func cfDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { /* test6.c:545:12: */ 56280 return g.FiDeviceCharacteristics 56281 } 56282 56283 // Pass-throughs for WAL support. 56284 func cfShmLock(tls *libc.TLS, pFile uintptr, ofst int32, n int32, flags int32) int32 { /* test6.c:552:12: */ 56285 var pReal uintptr = (*CrashFile)(unsafe.Pointer(pFile)).FpRealFile 56286 return (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pReal)).FpMethods + 112 /* &.xShmLock */))))(tls, pReal, ofst, n, flags) 56287 } 56288 56289 func cfShmBarrier(tls *libc.TLS, pFile uintptr) { /* test6.c:556:13: */ 56290 var pReal uintptr = (*CrashFile)(unsafe.Pointer(pFile)).FpRealFile 56291 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pReal)).FpMethods + 120 /* &.xShmBarrier */))))(tls, pReal) 56292 } 56293 56294 func cfShmUnmap(tls *libc.TLS, pFile uintptr, delFlag int32) int32 { /* test6.c:560:12: */ 56295 var pReal uintptr = (*CrashFile)(unsafe.Pointer(pFile)).FpRealFile 56296 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pReal)).FpMethods + 128 /* &.xShmUnmap */))))(tls, pReal, delFlag) 56297 } 56298 56299 func cfShmMap(tls *libc.TLS, pFile uintptr, iRegion int32, sz int32, w int32, pp uintptr) int32 { /* test6.c:564:12: */ 56300 var pReal uintptr = (*CrashFile)(unsafe.Pointer(pFile)).FpRealFile 56301 return (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pReal)).FpMethods + 104 /* &.xShmMap */))))(tls, pReal, iRegion, sz, w, libc.AtomicLoadUintptr(&pp)) 56302 } 56303 56304 var CrashFileVtab = sqlite3_io_methods{ 56305 FiVersion: 2, // iVersion 56306 FxClose: 0, // xClose 56307 FxRead: 0, // xRead 56308 FxWrite: 0, // xWrite 56309 FxTruncate: 0, // xTruncate 56310 FxSync: 0, // xSync 56311 FxFileSize: 0, // xFileSize 56312 FxLock: 0, // xLock 56313 FxUnlock: 0, // xUnlock 56314 FxCheckReservedLock: 0, // xCheckReservedLock 56315 FxFileControl: 0, // xFileControl 56316 FxSectorSize: 0, // xSectorSize 56317 FxDeviceCharacteristics: 0, // xDeviceCharacteristics 56318 FxShmMap: 0, // xShmMap 56319 FxShmLock: 0, // xShmLock 56320 FxShmBarrier: 0, // xShmBarrier 56321 FxShmUnmap: 0, // xShmUnmap 56322 } /* test6.c:575:33 */ 56323 56324 // Application data for the crash VFS 56325 type crashAppData = struct{ FpOrig uintptr } /* test6.c:598:1 */ 56326 56327 // Open a crash-file file handle. 56328 // 56329 // The caller will have allocated pVfs->szOsFile bytes of space 56330 // at pFile. This file uses this space for the CrashFile structure 56331 // and allocates space for the "real" file structure using 56332 // sqlite3_malloc(). The assumption here is (pVfs->szOsFile) is 56333 // equal or greater than sizeof(CrashFile). 56334 func cfOpen(tls *libc.TLS, pCfVfs uintptr, zName uintptr, pFile uintptr, flags int32, pOutFlags uintptr) int32 { /* test6.c:611:12: */ 56335 bp := tls.Alloc(8) 56336 defer tls.Free(8) 56337 56338 var pVfs uintptr = (*sqlite3_vfs)(unsafe.Pointer(pCfVfs)).FpAppData 56339 var rc int32 56340 var pWrapper uintptr = pFile 56341 var pReal uintptr = (pWrapper + 1*56) 56342 56343 libc.Xmemset(tls, pWrapper, 0, uint64(unsafe.Sizeof(CrashFile{}))) 56344 rc = sqlite3.Xsqlite3OsOpen(tls, pVfs, zName, pReal, flags, pOutFlags) 56345 56346 if rc == SQLITE_OK { 56347 // var iSize i64 at bp, 8 56348 56349 (*CrashFile)(unsafe.Pointer(pWrapper)).FpMethod = uintptr(unsafe.Pointer(&CrashFileVtab)) 56350 (*CrashFile)(unsafe.Pointer(pWrapper)).FzName = zName 56351 (*CrashFile)(unsafe.Pointer(pWrapper)).FpRealFile = pReal 56352 rc = sqlite3.Xsqlite3OsFileSize(tls, pReal, bp /* &iSize */) 56353 (*CrashFile)(unsafe.Pointer(pWrapper)).FiSize = i64(int32(*(*i64)(unsafe.Pointer(bp /* iSize */)))) 56354 (*CrashFile)(unsafe.Pointer(pWrapper)).Fflags = flags 56355 } 56356 if rc == SQLITE_OK { 56357 (*CrashFile)(unsafe.Pointer(pWrapper)).FnData = (int32(int64(4096) + (*CrashFile)(unsafe.Pointer(pWrapper)).FiSize)) 56358 (*CrashFile)(unsafe.Pointer(pWrapper)).FzData = crash_malloc(tls, (*CrashFile)(unsafe.Pointer(pWrapper)).FnData) 56359 if (*CrashFile)(unsafe.Pointer(pWrapper)).FzData != 0 { 56360 // os_unix.c contains an assert() that fails if the caller attempts 56361 // to read data from the 512-byte locking region of a file opened 56362 // with the SQLITE_OPEN_MAIN_DB flag. This region of a database file 56363 // never contains valid data anyhow. So avoid doing such a read here. 56364 // 56365 // UPDATE: It also contains an assert() verifying that each call 56366 // to the xRead() method reads less than 128KB of data. 56367 var iOff i64 56368 56369 libc.Xmemset(tls, (*CrashFile)(unsafe.Pointer(pWrapper)).FzData, 0, uint64((*CrashFile)(unsafe.Pointer(pWrapper)).FnData)) 56370 for iOff = int64(0); iOff < (*CrashFile)(unsafe.Pointer(pWrapper)).FiSize; iOff = iOff + (int64(512)) { 56371 var nRead int32 = (int32((*CrashFile)(unsafe.Pointer(pWrapper)).FiSize - iOff)) 56372 if nRead > 512 { 56373 nRead = 512 56374 } 56375 rc = sqlite3.Xsqlite3OsRead(tls, pReal, ((*CrashFile)(unsafe.Pointer(pWrapper)).FzData + uintptr(iOff)), nRead, iOff) 56376 } 56377 } else { 56378 rc = SQLITE_NOMEM 56379 } 56380 } 56381 if (rc != SQLITE_OK) && ((*CrashFile)(unsafe.Pointer(pWrapper)).FpMethod != 0) { 56382 sqlite3.Xsqlite3OsClose(tls, pFile) 56383 } 56384 return rc 56385 } 56386 56387 func cfDelete(tls *libc.TLS, pCfVfs uintptr, zPath uintptr, dirSync int32) int32 { /* test6.c:665:12: */ 56388 var pVfs uintptr = (*sqlite3_vfs)(unsafe.Pointer(pCfVfs)).FpAppData 56389 return (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer((pVfs + 48 /* &.xDelete */))))(tls, pVfs, zPath, dirSync) 56390 } 56391 56392 func cfAccess(tls *libc.TLS, pCfVfs uintptr, zPath uintptr, flags int32, pResOut uintptr) int32 { /* test6.c:669:12: */ 56393 var pVfs uintptr = (*sqlite3_vfs)(unsafe.Pointer(pCfVfs)).FpAppData 56394 return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pVfs + 56 /* &.xAccess */))))(tls, pVfs, zPath, flags, pResOut) 56395 } 56396 56397 func cfFullPathname(tls *libc.TLS, pCfVfs uintptr, zPath uintptr, nPathOut int32, zPathOut uintptr) int32 { /* test6.c:678:12: */ 56398 var pVfs uintptr = (*sqlite3_vfs)(unsafe.Pointer(pCfVfs)).FpAppData 56399 return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pVfs + 64 /* &.xFullPathname */))))(tls, pVfs, zPath, nPathOut, zPathOut) 56400 } 56401 56402 func cfDlOpen(tls *libc.TLS, pCfVfs uintptr, zPath uintptr) uintptr { /* test6.c:687:13: */ 56403 var pVfs uintptr = (*sqlite3_vfs)(unsafe.Pointer(pCfVfs)).FpAppData 56404 return (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer((pVfs + 72 /* &.xDlOpen */))))(tls, pVfs, zPath) 56405 } 56406 56407 func cfDlError(tls *libc.TLS, pCfVfs uintptr, nByte int32, zErrMsg uintptr) { /* test6.c:691:13: */ 56408 var pVfs uintptr = (*sqlite3_vfs)(unsafe.Pointer(pCfVfs)).FpAppData 56409 (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer((pVfs + 80 /* &.xDlError */))))(tls, pVfs, nByte, zErrMsg) 56410 } 56411 56412 func cfDlSym(tls *libc.TLS, pCfVfs uintptr, pH uintptr, zSym uintptr) uintptr { /* test6.c:695:13: */ 56413 var pVfs uintptr = (*sqlite3_vfs)(unsafe.Pointer(pCfVfs)).FpAppData 56414 return (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer((pVfs + 88 /* &.xDlSym */))))(tls, pVfs, pH, zSym) 56415 } 56416 56417 func cfDlClose(tls *libc.TLS, pCfVfs uintptr, pHandle uintptr) { /* test6.c:699:13: */ 56418 var pVfs uintptr = (*sqlite3_vfs)(unsafe.Pointer(pCfVfs)).FpAppData 56419 (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer((pVfs + 96 /* &.xDlClose */))))(tls, pVfs, pHandle) 56420 } 56421 56422 func cfRandomness(tls *libc.TLS, pCfVfs uintptr, nByte int32, zBufOut uintptr) int32 { /* test6.c:703:12: */ 56423 var pVfs uintptr = (*sqlite3_vfs)(unsafe.Pointer(pCfVfs)).FpAppData 56424 return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((pVfs + 104 /* &.xRandomness */))))(tls, pVfs, nByte, zBufOut) 56425 } 56426 56427 func cfSleep(tls *libc.TLS, pCfVfs uintptr, nMicro int32) int32 { /* test6.c:707:12: */ 56428 var pVfs uintptr = (*sqlite3_vfs)(unsafe.Pointer(pCfVfs)).FpAppData 56429 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((pVfs + 112 /* &.xSleep */))))(tls, pVfs, nMicro) 56430 } 56431 56432 func cfCurrentTime(tls *libc.TLS, pCfVfs uintptr, pTimeOut uintptr) int32 { /* test6.c:711:12: */ 56433 var pVfs uintptr = (*sqlite3_vfs)(unsafe.Pointer(pCfVfs)).FpAppData 56434 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pVfs + 120 /* &.xCurrentTime */))))(tls, pVfs, pTimeOut) 56435 } 56436 56437 func cfGetLastError(tls *libc.TLS, pCfVfs uintptr, n int32, z uintptr) int32 { /* test6.c:715:12: */ 56438 var pVfs uintptr = (*sqlite3_vfs)(unsafe.Pointer(pCfVfs)).FpAppData 56439 return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((pVfs + 128 /* &.xGetLastError */))))(tls, pVfs, n, z) 56440 } 56441 56442 func processDevSymArgs(tls *libc.TLS, interp uintptr, objc int32, objv uintptr, piDeviceChar uintptr, piSectorSize uintptr) int32 { /* test6.c:720:12: */ 56443 bp := tls.Alloc(316) 56444 defer tls.Free(316) 56445 56446 *(*[14]DeviceFlag)(unsafe.Pointer(bp + 88 /* aFlag */)) = [14]DeviceFlag{ 56447 {FzName: ts + 25870 /* "atomic" */, FiValue: SQLITE_IOCAP_ATOMIC}, 56448 {FzName: ts + 25877 /* "atomic512" */, FiValue: SQLITE_IOCAP_ATOMIC512}, 56449 {FzName: ts + 25887 /* "atomic1k" */, FiValue: SQLITE_IOCAP_ATOMIC1K}, 56450 {FzName: ts + 25896 /* "atomic2k" */, FiValue: SQLITE_IOCAP_ATOMIC2K}, 56451 {FzName: ts + 25905 /* "atomic4k" */, FiValue: SQLITE_IOCAP_ATOMIC4K}, 56452 {FzName: ts + 25914 /* "atomic8k" */, FiValue: SQLITE_IOCAP_ATOMIC8K}, 56453 {FzName: ts + 25923 /* "atomic16k" */, FiValue: SQLITE_IOCAP_ATOMIC16K}, 56454 {FzName: ts + 25933 /* "atomic32k" */, FiValue: SQLITE_IOCAP_ATOMIC32K}, 56455 {FzName: ts + 25943 /* "atomic64k" */, FiValue: SQLITE_IOCAP_ATOMIC64K}, 56456 {FzName: ts + 25953 /* "sequential" */, FiValue: SQLITE_IOCAP_SEQUENTIAL}, 56457 {FzName: ts + 25964 /* "safe_append" */, FiValue: SQLITE_IOCAP_SAFE_APPEND}, 56458 {FzName: ts + 25976 /* "powersafe_overwr..." */, FiValue: SQLITE_IOCAP_POWERSAFE_OVERWRITE}, 56459 {FzName: ts + 25996 /* "batch-atomic" */, FiValue: SQLITE_IOCAP_BATCH_ATOMIC}, 56460 {}, 56461 } 56462 var i int32 56463 var iDc int32 = 0 56464 *(*int32)(unsafe.Pointer(bp + 68 /* iSectorSize */)) = 0 56465 var setSectorsize int32 = 0 56466 var setDeviceChar int32 = 0 56467 56468 for i = 0; i < objc; i = i + (2) { 56469 // var nOpt int32 at bp+64, 4 56470 56471 var zOpt uintptr = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp+64 /* &nOpt */) 56472 56473 if (((*(*int32)(unsafe.Pointer(bp + 64 /* nOpt */)) > 11) || (*(*int32)(unsafe.Pointer(bp + 64 /* nOpt */)) < 2)) || (libc.Xstrncmp(tls, ts+26009 /* "-sectorsize" */, zOpt, uint64(*(*int32)(unsafe.Pointer(bp + 64 /* nOpt */)))) != 0)) && 56474 (((*(*int32)(unsafe.Pointer(bp + 64 /* nOpt */)) > 16) || (*(*int32)(unsafe.Pointer(bp + 64 /* nOpt */)) < 2)) || (libc.Xstrncmp(tls, ts+26021 /* "-characteristics" */, zOpt, uint64(*(*int32)(unsafe.Pointer(bp + 64 /* nOpt */)))) != 0)) { 56475 tcl.XTcl_AppendResult(tls, interp, 56476 libc.VaList(bp, ts+26038 /* "Bad option: \"" */, zOpt, 56477 ts+26052 /* "\" - must be \"-ch..." */, 0)) 56478 return TCL_ERROR 56479 } 56480 if i == (objc - 1) { 56481 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+26100 /* "Option requires ..." */, zOpt, ts+11636 /* "\"" */, 0)) 56482 return TCL_ERROR 56483 } 56484 56485 if int32(*(*int8)(unsafe.Pointer(zOpt + 1))) == 's' { 56486 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)), bp+68 /* &iSectorSize */) != 0 { 56487 return TCL_ERROR 56488 } 56489 setSectorsize = 1 56490 } else { 56491 var j int32 56492 // var apObj uintptr at bp+80, 8 56493 56494 // var nObj int32 at bp+72, 4 56495 56496 if tcl.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)), bp+72 /* &nObj */, bp+80 /* &apObj */) != 0 { 56497 return TCL_ERROR 56498 } 56499 for j = 0; j < *(*int32)(unsafe.Pointer(bp + 72 /* nObj */)); j++ { 56500 var rc int32 56501 // var iChoice int32 at bp+312, 4 56502 56503 var pFlag uintptr = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 80 /* apObj */)) + uintptr(j)*8))) 56504 (*Tcl_Obj)(unsafe.Pointer(pFlag)).FrefCount++ 56505 tcl.XTcl_UtfToLower(tls, tcl.XTcl_GetString(tls, pFlag)) 56506 56507 rc = tcl.XTcl_GetIndexFromObjStruct(tls, 56508 interp, pFlag, bp+88 /* &aFlag[0] */, int32(unsafe.Sizeof(DeviceFlag{})), ts+26131 /* "no such flag" */, 0, bp+312 /* &iChoice */) 56509 for ok := true; ok; ok = 0 != 0 { 56510 var _objPtr uintptr = pFlag 56511 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 56512 tcl.XTclFreeObj(tls, _objPtr) 56513 } 56514 } 56515 if rc != 0 { 56516 return TCL_ERROR 56517 } 56518 56519 iDc = iDc | ((*DeviceFlag)(unsafe.Pointer(bp + 88 /* &aFlag */ + uintptr(*(*int32)(unsafe.Pointer(bp + 312 /* iChoice */)))*16)).FiValue) 56520 } 56521 setDeviceChar = 1 56522 } 56523 } 56524 56525 if setDeviceChar != 0 { 56526 *(*int32)(unsafe.Pointer(piDeviceChar)) = iDc 56527 } 56528 if setSectorsize != 0 { 56529 *(*int32)(unsafe.Pointer(piSectorSize)) = *(*int32)(unsafe.Pointer(bp + 68 /* iSectorSize */)) 56530 } 56531 56532 return TCL_OK 56533 } 56534 56535 type DeviceFlag = struct { 56536 FzName uintptr 56537 FiValue int32 56538 _ [4]byte 56539 } /* test6.c:727:3 */ 56540 56541 // tclcmd: sqlite3_crash_now 56542 // 56543 // Simulate a crash immediately. This function does not return 56544 // (writeListSync() calls exit(-1)). 56545 func crashNowCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test6.c:820:26: */ 56546 if objc != 1 { 56547 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 56548 return TCL_ERROR 56549 } 56550 writeListSync(tls, uintptr(0), 1) 56551 56552 return TCL_OK 56553 } 56554 56555 // tclcmd: sqlite_crash_enable ENABLE ?DEFAULT? 56556 // 56557 // Parameter ENABLE must be a boolean value. If true, then the "crash" 56558 // vfs is added to the system. If false, it is removed. 56559 func crashEnableCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test6.c:841:26: */ 56560 bp := tls.Alloc(8) 56561 defer tls.Free(8) 56562 56563 // var isEnable int32 at bp, 4 56564 56565 *(*int32)(unsafe.Pointer(bp + 4 /* isDefault */)) = 0 56566 56567 if (objc != 2) && (objc != 3) { 56568 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+26144 /* "ENABLE ?DEFAULT?" */) 56569 return TCL_ERROR 56570 } 56571 56572 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &isEnable */) != 0 { 56573 return TCL_ERROR 56574 } 56575 if (objc == 3) && (tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+4 /* &isDefault */) != 0) { 56576 return TCL_ERROR 56577 } 56578 56579 if ((*(*int32)(unsafe.Pointer(bp /* isEnable */)) != 0) && (crashVfs.FpAppData != 0)) || (!(*(*int32)(unsafe.Pointer(bp /* isEnable */)) != 0) && !(int32(crashVfs.FpAppData) != 0)) { 56580 return TCL_OK 56581 } 56582 56583 if crashVfs.FpAppData == uintptr(0) { 56584 var pOriginalVfs uintptr = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 56585 crashVfs.FmxPathname = (*sqlite3_vfs)(unsafe.Pointer(pOriginalVfs)).FmxPathname 56586 crashVfs.FpAppData = pOriginalVfs 56587 crashVfs.FszOsFile = (int32(uint64(unsafe.Sizeof(CrashFile{})) + uint64((*sqlite3_vfs)(unsafe.Pointer(pOriginalVfs)).FszOsFile))) 56588 sqlite3.Xsqlite3_vfs_register(tls, uintptr(unsafe.Pointer(&crashVfs)), *(*int32)(unsafe.Pointer(bp + 4 /* isDefault */))) 56589 } else { 56590 crashVfs.FpAppData = uintptr(0) 56591 sqlite3.Xsqlite3_vfs_unregister(tls, uintptr(unsafe.Pointer(&crashVfs))) 56592 } 56593 56594 return TCL_OK 56595 } 56596 56597 var crashVfs = sqlite3_vfs{ 56598 FiVersion: 2, // pNext 56599 FzName: ts + 26161, /* "crash" */ // pAppData 56600 56601 FxOpen: 0, // xOpen 56602 FxDelete: 0, // xDelete 56603 FxAccess: 0, // xAccess 56604 FxFullPathname: 0, // xFullPathname 56605 FxDlOpen: 0, // xDlOpen 56606 FxDlError: 0, // xDlError 56607 FxDlSym: 0, // xDlSym 56608 FxDlClose: 0, // xDlClose 56609 FxRandomness: 0, // xRandomness 56610 FxSleep: 0, // xSleep 56611 FxCurrentTime: 0, // xCurrentTime 56612 FxGetLastError: 0, // xCurrentTimeInt64 56613 } /* test6.c:849:22 */ 56614 56615 // tclcmd: sqlite_crashparams ?OPTIONS? DELAY CRASHFILE 56616 // 56617 // This procedure implements a TCL command that enables crash testing 56618 // in testfixture. Once enabled, crash testing cannot be disabled. 56619 // 56620 // Available options are "-characteristics" and "-sectorsize". Both require 56621 // an argument. For -sectorsize, this is the simulated sector size in 56622 // bytes. For -characteristics, the argument must be a list of io-capability 56623 // flags to simulate. Valid flags are "atomic", "atomic512", "atomic1K", 56624 // "atomic2K", "atomic4K", "atomic8K", "atomic16K", "atomic32K", 56625 // "atomic64K", "sequential" and "safe_append". 56626 // 56627 // Example: 56628 // 56629 // sqlite_crashparams -sect 1024 -char {atomic sequential} ./test.db 1 56630 // 56631 func crashParamsObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test6.c:920:26: */ 56632 bp := tls.Alloc(48) 56633 defer tls.Free(48) 56634 56635 // var iDelay int32 at bp+36, 4 56636 56637 var zCrashFile uintptr 56638 // var nCrashFile int32 at bp+32, 4 56639 56640 // var iDc int32 at bp+40, 4 56641 56642 // var iSectorSize int32 at bp+44, 4 56643 56644 *(*int32)(unsafe.Pointer(bp + 40 /* iDc */)) = -1 56645 *(*int32)(unsafe.Pointer(bp + 44 /* iSectorSize */)) = -1 56646 56647 if !(objc < 3) { 56648 goto __1 56649 } 56650 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+26167 /* "?OPTIONS? DELAY ..." */) 56651 goto error 56652 __1: 56653 ; 56654 56655 zCrashFile = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-1))*8)), bp+32 /* &nCrashFile */) 56656 if !(uint64(*(*int32)(unsafe.Pointer(bp + 32 /* nCrashFile */))) >= uint64(unsafe.Sizeof([500]int8{}))) { 56657 goto __2 56658 } 56659 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+26193 /* "Filename is too ..." */, zCrashFile, ts+11636 /* "\"" */, 0)) 56660 goto error 56661 __2: 56662 ; 56663 if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((objc-2))*8)), bp+36 /* &iDelay */) != 0) { 56664 goto __3 56665 } 56666 goto error 56667 __3: 56668 ; 56669 56670 if !(processDevSymArgs(tls, interp, (objc-3), (objv+1*8), bp+40 /* &iDc */, bp+44 /* &iSectorSize */) != 0) { 56671 goto __4 56672 } 56673 return TCL_ERROR 56674 __4: 56675 ; 56676 56677 if !(*(*int32)(unsafe.Pointer(bp + 40 /* iDc */)) >= 0) { 56678 goto __5 56679 } 56680 g.FiDeviceCharacteristics = *(*int32)(unsafe.Pointer(bp + 40 /* iDc */)) 56681 __5: 56682 ; 56683 if !(*(*int32)(unsafe.Pointer(bp + 44 /* iSectorSize */)) >= 0) { 56684 goto __6 56685 } 56686 g.FiSectorSize = *(*int32)(unsafe.Pointer(bp + 44 /* iSectorSize */)) 56687 __6: 56688 ; 56689 56690 g.FiCrash = *(*int32)(unsafe.Pointer(bp + 36 /* iDelay */)) 56691 libc.Xmemcpy(tls, uintptr(unsafe.Pointer(&g))+28 /* &.zCrashFile */, zCrashFile, (uint64(*(*int32)(unsafe.Pointer(bp + 32 /* nCrashFile */)) + 1))) 56692 sqlite3CrashTestEnable = 1 56693 return TCL_OK 56694 56695 error: 56696 return TCL_ERROR 56697 } 56698 56699 func devSymObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test6.c:967:26: */ 56700 bp := tls.Alloc(8) 56701 defer tls.Free(8) 56702 56703 *(*int32)(unsafe.Pointer(bp /* iDc */)) = -1 56704 *(*int32)(unsafe.Pointer(bp + 4 /* iSectorSize */)) = -1 56705 56706 if processDevSymArgs(tls, interp, (objc-1), (objv+1*8), bp /* &iDc */, bp+4 /* &iSectorSize */) != 0 { 56707 return TCL_ERROR 56708 } 56709 devsym_register(tls, *(*int32)(unsafe.Pointer(bp /* iDc */)), *(*int32)(unsafe.Pointer(bp + 4 /* iSectorSize */))) 56710 56711 return TCL_OK 56712 } 56713 56714 // tclcmd: sqlite3_crash_on_write N 56715 func writeCrashObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test6.c:989:26: */ 56716 bp := tls.Alloc(4) 56717 defer tls.Free(4) 56718 56719 *(*int32)(unsafe.Pointer(bp /* nWrite */)) = 0 56720 56721 if objc != 2 { 56722 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+26217 /* "NWRITE" */) 56723 return TCL_ERROR 56724 } 56725 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &nWrite */) != 0 { 56726 return TCL_ERROR 56727 } 56728 56729 devsym_crash_on_write(tls, *(*int32)(unsafe.Pointer(bp /* nWrite */))) 56730 return TCL_OK 56731 } 56732 56733 // tclcmd: unregister_devsim 56734 func dsUnregisterObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test6.c:1013:26: */ 56735 56736 if objc != 1 { 56737 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 56738 return TCL_ERROR 56739 } 56740 56741 devsym_unregister(tls) 56742 return TCL_OK 56743 } 56744 56745 // tclcmd: register_jt_vfs ?-default? PARENT-VFS 56746 func jtObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test6.c:1033:26: */ 56747 bp := tls.Alloc(48) 56748 defer tls.Free(48) 56749 56750 var zParent uintptr = uintptr(0) 56751 56752 if (objc != 2) && (objc != 3) { 56753 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+26224 /* "?-default? PAREN..." */) 56754 return TCL_ERROR 56755 } 56756 zParent = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 56757 if objc == 3 { 56758 if libc.Xstrcmp(tls, zParent, ts+26246 /* "-default" */) != 0 { 56759 tcl.XTcl_AppendResult(tls, interp, 56760 libc.VaList(bp, ts+11535 /* "bad option \"" */, zParent, ts+26255 /* "\": must be -defa..." */, 0)) 56761 return TCL_ERROR 56762 } 56763 zParent = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 56764 } 56765 56766 if !(int32(*(*int8)(unsafe.Pointer(zParent))) != 0) { 56767 zParent = uintptr(0) 56768 } 56769 if jt_register(tls, zParent, (libc.Bool32(objc == 3))) != 0 { 56770 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+26275 /* "Error in jt_regi..." */, 0)) 56771 return TCL_ERROR 56772 } 56773 56774 return TCL_OK 56775 } 56776 56777 // tclcmd: unregister_jt_vfs 56778 func jtUnregisterObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test6.c:1071:26: */ 56779 56780 if objc != 1 { 56781 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 56782 return TCL_ERROR 56783 } 56784 56785 jt_unregister(tls) 56786 return TCL_OK 56787 } 56788 56789 // This procedure registers the TCL procedures defined in this file. 56790 func Sqlitetest6_Init(tls *libc.TLS, interp uintptr) int32 { /* test6.c:1093:5: */ 56791 tcl.XTcl_CreateObjCommand(tls, interp, ts+26296 /* "sqlite3_crash_en..." */, *(*uintptr)(unsafe.Pointer(&struct { 56792 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 56793 }{crashEnableCmd})), uintptr(0), uintptr(0)) 56794 tcl.XTcl_CreateObjCommand(tls, interp, ts+26317 /* "sqlite3_crashpar..." */, *(*uintptr)(unsafe.Pointer(&struct { 56795 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 56796 }{crashParamsObjCmd})), uintptr(0), uintptr(0)) 56797 tcl.XTcl_CreateObjCommand(tls, interp, ts+26337 /* "sqlite3_crash_no..." */, *(*uintptr)(unsafe.Pointer(&struct { 56798 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 56799 }{crashNowCmd})), uintptr(0), uintptr(0)) 56800 tcl.XTcl_CreateObjCommand(tls, interp, ts+26355 /* "sqlite3_simulate..." */, *(*uintptr)(unsafe.Pointer(&struct { 56801 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 56802 }{devSymObjCmd})), uintptr(0), uintptr(0)) 56803 tcl.XTcl_CreateObjCommand(tls, interp, ts+26379 /* "sqlite3_crash_on..." */, *(*uintptr)(unsafe.Pointer(&struct { 56804 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 56805 }{writeCrashObjCmd})), uintptr(0), uintptr(0)) 56806 tcl.XTcl_CreateObjCommand(tls, interp, ts+26402 /* "unregister_devsi..." */, *(*uintptr)(unsafe.Pointer(&struct { 56807 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 56808 }{dsUnregisterObjCmd})), uintptr(0), uintptr(0)) 56809 tcl.XTcl_CreateObjCommand(tls, interp, ts+26420 /* "register_jt_vfs" */, *(*uintptr)(unsafe.Pointer(&struct { 56810 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 56811 }{jtObjCmd})), uintptr(0), uintptr(0)) 56812 tcl.XTcl_CreateObjCommand(tls, interp, ts+26436 /* "unregister_jt_vf..." */, *(*uintptr)(unsafe.Pointer(&struct { 56813 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 56814 }{jtUnregisterObjCmd})), uintptr(0), uintptr(0)) 56815 return TCL_OK 56816 } 56817 56818 // Each thread is controlled by an instance of the following 56819 // structure. 56820 type Thread1 = struct { 56821 FzFilename uintptr 56822 FxOp uintptr 56823 FzArg uintptr 56824 Fopnum int32 56825 Fbusy int32 56826 Fcompleted int32 56827 _ [4]byte 56828 Fdb uintptr 56829 FpStmt uintptr 56830 FzErr uintptr 56831 FzStaticErr uintptr 56832 Frc int32 56833 Fargc int32 56834 Fargv [100]uintptr 56835 Fcolv [100]uintptr 56836 FnServer int32 56837 _ [4]byte 56838 } /* test7.c:53:23 */ 56839 56840 // There can be as many as 26 threads running at once. Each is named 56841 // by a capital letter: A, B, C, ..., Y, Z. 56842 var threadset1 [26]Thread1 /* test7.c:90:15: */ 56843 56844 // The main loop for a thread. Threads use busy waiting. 56845 func client_main(tls *libc.TLS, pArg uintptr) uintptr { /* test7.c:95:13: */ 56846 var p uintptr = pArg 56847 if (*Thread1)(unsafe.Pointer(p)).Fdb != 0 { 56848 sqlite3_client_close(tls, (*Thread1)(unsafe.Pointer(p)).Fdb) 56849 } 56850 sqlite3_client_open(tls, (*Thread1)(unsafe.Pointer(p)).FzFilename, (p + 40 /* &.db */)) 56851 if SQLITE_OK != sqlite3.Xsqlite3_errcode(tls, (*Thread1)(unsafe.Pointer(p)).Fdb) { 56852 (*Thread1)(unsafe.Pointer(p)).FzErr = libc.Xstrdup(tls, sqlite3.Xsqlite3_errmsg(tls, (*Thread1)(unsafe.Pointer(p)).Fdb)) 56853 sqlite3_client_close(tls, (*Thread1)(unsafe.Pointer(p)).Fdb) 56854 (*Thread1)(unsafe.Pointer(p)).Fdb = uintptr(0) 56855 } 56856 (*Thread1)(unsafe.Pointer(p)).FpStmt = uintptr(0) 56857 (*Thread1)(unsafe.Pointer(p)).Fcompleted = 1 56858 for (*Thread1)(unsafe.Pointer(p)).Fopnum <= (*Thread1)(unsafe.Pointer(p)).Fcompleted { 56859 libc2.Xsched_yield(tls) 56860 } 56861 for (*Thread1)(unsafe.Pointer(p)).FxOp != 0 { 56862 if ((*Thread1)(unsafe.Pointer(p)).FzErr != 0) && ((*Thread1)(unsafe.Pointer(p)).FzErr != (*Thread1)(unsafe.Pointer(p)).FzStaticErr) { 56863 sqlite3.Xsqlite3_free(tls, (*Thread1)(unsafe.Pointer(p)).FzErr) 56864 (*Thread1)(unsafe.Pointer(p)).FzErr = uintptr(0) 56865 } 56866 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((p + 8 /* &.xOp */))))(tls, p) 56867 (*Thread1)(unsafe.Pointer(p)).Fcompleted++ 56868 for (*Thread1)(unsafe.Pointer(p)).Fopnum <= (*Thread1)(unsafe.Pointer(p)).Fcompleted { 56869 libc2.Xsched_yield(tls) 56870 } 56871 } 56872 if (*Thread1)(unsafe.Pointer(p)).FpStmt != 0 { 56873 sqlite3_client_finalize(tls, (*Thread1)(unsafe.Pointer(p)).FpStmt) 56874 (*Thread1)(unsafe.Pointer(p)).FpStmt = uintptr(0) 56875 } 56876 if (*Thread1)(unsafe.Pointer(p)).Fdb != 0 { 56877 sqlite3_client_close(tls, (*Thread1)(unsafe.Pointer(p)).Fdb) 56878 (*Thread1)(unsafe.Pointer(p)).Fdb = uintptr(0) 56879 } 56880 if ((*Thread1)(unsafe.Pointer(p)).FzErr != 0) && ((*Thread1)(unsafe.Pointer(p)).FzErr != (*Thread1)(unsafe.Pointer(p)).FzStaticErr) { 56881 sqlite3.Xsqlite3_free(tls, (*Thread1)(unsafe.Pointer(p)).FzErr) 56882 (*Thread1)(unsafe.Pointer(p)).FzErr = uintptr(0) 56883 } 56884 (*Thread1)(unsafe.Pointer(p)).Fcompleted++ 56885 sqlite3.Xsqlite3_thread_cleanup(tls) 56886 return uintptr(0) 56887 } 56888 56889 // Get a thread ID which is an upper case letter. Return the index. 56890 // If the argument is not a valid thread ID put an error message in 56891 // the interpreter and return -1. 56892 func parse_client_id(tls *libc.TLS, interp uintptr, zArg uintptr) int32 { /* test7.c:142:12: */ 56893 bp := tls.Alloc(16) 56894 defer tls.Free(16) 56895 56896 if (((zArg == uintptr(0)) || (int32(*(*int8)(unsafe.Pointer(zArg))) == 0)) || (int32(*(*int8)(unsafe.Pointer(zArg + 1))) != 0)) || !((int32(*(*uint16)(unsafe.Pointer((*(*uintptr)(unsafe.Pointer(libc.X__ctype_b_loc(tls)))) + uintptr(int32(uint8(*(*int8)(unsafe.Pointer(zArg)))))*2))) & int32(_ISupper)) != 0) { 56897 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+25208 /* "thread ID must b..." */, 0)) 56898 return -1 56899 } 56900 return (int32(*(*int8)(unsafe.Pointer(zArg))) - 'A') 56901 } 56902 56903 // Usage: client_create NAME FILENAME 56904 // 56905 // NAME should be an upper case letter. Start the thread running with 56906 // an open connection to the given database. 56907 func tcl_client_create(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test7.c:156:26: */ 56908 bp := tls.Alloc(96) 56909 defer tls.Free(96) 56910 56911 var i int32 56912 // var x pthread_t at bp+88, 8 56913 56914 var rc int32 56915 56916 if argc != 3 { 56917 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 56918 ts+25247 /* " ID FILENAME" */, 0)) 56919 return TCL_ERROR 56920 } 56921 i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 56922 if i < 0 { 56923 return TCL_ERROR 56924 } 56925 if threadset1[i].Fbusy != 0 { 56926 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25260 /* "thread " */, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+25268 /* " is already runn..." */, 0)) 56927 return TCL_ERROR 56928 } 56929 threadset1[i].Fbusy = 1 56930 sqlite3.Xsqlite3_free(tls, threadset1[i].FzFilename) 56931 threadset1[i].FzFilename = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+64, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) 56932 threadset1[i].Fopnum = 1 56933 threadset1[i].Fcompleted = 0 56934 rc = libc2.Xpthread_create(tls, bp+88 /* &x */, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 56935 f func(*libc.TLS, uintptr) uintptr 56936 }{client_main})), (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) 56937 if rc != 0 { 56938 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+72, ts+25288 /* "failed to create..." */, 0)) 56939 sqlite3.Xsqlite3_free(tls, threadset1[i].FzFilename) 56940 threadset1[i].Fbusy = 0 56941 return TCL_ERROR 56942 } 56943 libc2.Xpthread_detach(tls, *(*pthread_t)(unsafe.Pointer(bp + 88 /* x */))) 56944 if threadset1[i].FnServer == 0 { 56945 threadset1[i].FnServer = 1 56946 sqlite3_server_start2(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688 + 1680 /* &.nServer */)) 56947 } 56948 return TCL_OK 56949 } 56950 56951 // Wait for a thread to reach its idle state. 56952 func client_wait(tls *libc.TLS, p uintptr) { /* test7.c:200:13: */ 56953 for (*Thread1)(unsafe.Pointer(p)).Fopnum > (*Thread1)(unsafe.Pointer(p)).Fcompleted { 56954 libc2.Xsched_yield(tls) 56955 } 56956 } 56957 56958 // Usage: client_wait ID 56959 // 56960 // Wait on thread ID to reach its idle state. 56961 func tcl_client_wait(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test7.c:209:26: */ 56962 bp := tls.Alloc(48) 56963 defer tls.Free(48) 56964 56965 var i int32 56966 56967 if argc != 2 { 56968 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 56969 ts+25316 /* " ID" */, 0)) 56970 return TCL_ERROR 56971 } 56972 i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 56973 if i < 0 { 56974 return TCL_ERROR 56975 } 56976 if !(threadset1[i].Fbusy != 0) { 56977 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 56978 return TCL_ERROR 56979 } 56980 client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) 56981 return TCL_OK 56982 } 56983 56984 // Stop a thread. 56985 func stop_thread(tls *libc.TLS, p uintptr) { /* test7.c:235:13: */ 56986 client_wait(tls, p) 56987 (*Thread1)(unsafe.Pointer(p)).FxOp = uintptr(0) 56988 (*Thread1)(unsafe.Pointer(p)).Fopnum++ 56989 client_wait(tls, p) 56990 sqlite3.Xsqlite3_free(tls, (*Thread1)(unsafe.Pointer(p)).FzArg) 56991 (*Thread1)(unsafe.Pointer(p)).FzArg = uintptr(0) 56992 sqlite3.Xsqlite3_free(tls, (*Thread1)(unsafe.Pointer(p)).FzFilename) 56993 (*Thread1)(unsafe.Pointer(p)).FzFilename = uintptr(0) 56994 (*Thread1)(unsafe.Pointer(p)).Fbusy = 0 56995 } 56996 56997 // Usage: client_halt ID 56998 // 56999 // Cause a client thread to shut itself down. Wait for the shutdown to be 57000 // completed. If ID is "*" then stop all client threads. 57001 func tcl_client_halt(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test7.c:253:26: */ 57002 bp := tls.Alloc(48) 57003 defer tls.Free(48) 57004 57005 var i int32 57006 57007 if argc != 2 { 57008 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 57009 ts+25316 /* " ID" */, 0)) 57010 return TCL_ERROR 57011 } 57012 if (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + 1*8))))) == '*') && (int32(*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(argv + 1*8)) + 1))) == 0) { 57013 for i = 0; i < N_THREAD; i++ { 57014 if threadset1[i].Fbusy != 0 { 57015 stop_thread(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) 57016 } 57017 } 57018 } else { 57019 i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 57020 if i < 0 { 57021 return TCL_ERROR 57022 } 57023 if !(threadset1[i].Fbusy != 0) { 57024 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 57025 return TCL_ERROR 57026 } 57027 stop_thread(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) 57028 } 57029 57030 // If no client threads are still running, also stop the server 57031 for i = 0; (i < N_THREAD) && (threadset1[i].Fbusy == 0); i++ { 57032 } 57033 if i >= N_THREAD { 57034 sqlite3_server_stop(tls) 57035 for 1 != 0 { 57036 for i = 0; (i < N_THREAD) && (threadset1[i].FnServer == 0); i++ { 57037 } 57038 if i == N_THREAD { 57039 break 57040 } 57041 libc2.Xsched_yield(tls) 57042 } 57043 } 57044 return TCL_OK 57045 } 57046 57047 // Usage: client_argc ID 57048 // 57049 // Wait on the most recent client_step to complete, then return the 57050 // number of columns in the result set. 57051 func tcl_client_argc(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test7.c:301:26: */ 57052 bp := tls.Alloc(172) 57053 defer tls.Free(172) 57054 57055 var i int32 57056 // var zBuf [100]int8 at bp+72, 100 57057 57058 if argc != 2 { 57059 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 57060 ts+25316 /* " ID" */, 0)) 57061 return TCL_ERROR 57062 } 57063 i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 57064 if i < 0 { 57065 return TCL_ERROR 57066 } 57067 if !(threadset1[i].Fbusy != 0) { 57068 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 57069 return TCL_ERROR 57070 } 57071 client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) 57072 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+72 /* &zBuf[0] */, ts+1238 /* "%d" */, libc.VaList(bp+48, threadset1[i].Fargc)) 57073 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+56, bp+72 /* &zBuf[0] */, 0)) 57074 return TCL_OK 57075 } 57076 57077 // Usage: client_argv ID N 57078 // 57079 // Wait on the most recent client_step to complete, then return the 57080 // value of the N-th columns in the result set. 57081 func tcl_client_argv(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test7.c:333:26: */ 57082 bp := tls.Alloc(84) 57083 defer tls.Free(84) 57084 57085 var i int32 57086 // var n int32 at bp+80, 4 57087 57088 if argc != 3 { 57089 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 57090 ts+25335 /* " ID N" */, 0)) 57091 return TCL_ERROR 57092 } 57093 i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 57094 if i < 0 { 57095 return TCL_ERROR 57096 } 57097 if !(threadset1[i].Fbusy != 0) { 57098 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 57099 return TCL_ERROR 57100 } 57101 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+80 /* &n */) != 0 { 57102 return TCL_ERROR 57103 } 57104 client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) 57105 if (*(*int32)(unsafe.Pointer(bp + 80 /* n */)) < 0) || (*(*int32)(unsafe.Pointer(bp + 80 /* n */)) >= threadset1[i].Fargc) { 57106 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+25341 /* "column number ou..." */, 0)) 57107 return TCL_ERROR 57108 } 57109 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, *(*uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688 + 80 /* &.argv */) + uintptr(*(*int32)(unsafe.Pointer(bp + 80 /* n */)))*8)), 0)) 57110 return TCL_OK 57111 } 57112 57113 // Usage: client_colname ID N 57114 // 57115 // Wait on the most recent client_step to complete, then return the 57116 // name of the N-th columns in the result set. 57117 func tcl_client_colname(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test7.c:369:26: */ 57118 bp := tls.Alloc(84) 57119 defer tls.Free(84) 57120 57121 var i int32 57122 // var n int32 at bp+80, 4 57123 57124 if argc != 3 { 57125 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 57126 ts+25335 /* " ID N" */, 0)) 57127 return TCL_ERROR 57128 } 57129 i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 57130 if i < 0 { 57131 return TCL_ERROR 57132 } 57133 if !(threadset1[i].Fbusy != 0) { 57134 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 57135 return TCL_ERROR 57136 } 57137 if tcl.XTcl_GetInt(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8)), bp+80 /* &n */) != 0 { 57138 return TCL_ERROR 57139 } 57140 client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) 57141 if (*(*int32)(unsafe.Pointer(bp + 80 /* n */)) < 0) || (*(*int32)(unsafe.Pointer(bp + 80 /* n */)) >= threadset1[i].Fargc) { 57142 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+25341 /* "column number ou..." */, 0)) 57143 return TCL_ERROR 57144 } 57145 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, *(*uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688 + 880 /* &.colv */) + uintptr(*(*int32)(unsafe.Pointer(bp + 80 /* n */)))*8)), 0)) 57146 return TCL_OK 57147 } 57148 57149 // Usage: client_result ID 57150 // 57151 // Wait on the most recent operation to complete, then return the 57152 // result code from that operation. 57153 func tcl_client_result(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test7.c:407:26: */ 57154 bp := tls.Alloc(64) 57155 defer tls.Free(64) 57156 57157 var i int32 57158 var zName uintptr 57159 57160 if argc != 2 { 57161 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 57162 ts+25316 /* " ID" */, 0)) 57163 return TCL_ERROR 57164 } 57165 i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 57166 if i < 0 { 57167 return TCL_ERROR 57168 } 57169 if !(threadset1[i].Fbusy != 0) { 57170 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 57171 return TCL_ERROR 57172 } 57173 client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) 57174 zName = sqlite3.Xsqlite3ErrName(tls, threadset1[i].Frc) 57175 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, zName, 0)) 57176 return TCL_OK 57177 } 57178 57179 // Usage: client_error ID 57180 // 57181 // Wait on the most recent operation to complete, then return the 57182 // error string. 57183 func tcl_client_error(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test7.c:439:26: */ 57184 bp := tls.Alloc(64) 57185 defer tls.Free(64) 57186 57187 var i int32 57188 57189 if argc != 2 { 57190 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 57191 ts+25316 /* " ID" */, 0)) 57192 return TCL_ERROR 57193 } 57194 i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 57195 if i < 0 { 57196 return TCL_ERROR 57197 } 57198 if !(threadset1[i].Fbusy != 0) { 57199 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 57200 return TCL_ERROR 57201 } 57202 client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) 57203 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, threadset1[i].FzErr, 0)) 57204 return TCL_OK 57205 } 57206 57207 // This procedure runs in the thread to compile an SQL statement. 57208 func do_compile1(tls *libc.TLS, p uintptr) { /* test7.c:466:13: */ 57209 if (*Thread1)(unsafe.Pointer(p)).Fdb == uintptr(0) { 57210 (*Thread1)(unsafe.Pointer(p)).FzErr = libc.AssignPtrUintptr(p+64 /* &.zStaticErr */, ts+25368 /* "no database is o..." */) 57211 (*Thread1)(unsafe.Pointer(p)).Frc = SQLITE_ERROR 57212 return 57213 } 57214 if (*Thread1)(unsafe.Pointer(p)).FpStmt != 0 { 57215 sqlite3_client_finalize(tls, (*Thread1)(unsafe.Pointer(p)).FpStmt) 57216 (*Thread1)(unsafe.Pointer(p)).FpStmt = uintptr(0) 57217 } 57218 (*Thread1)(unsafe.Pointer(p)).Frc = sqlite3_client_prepare(tls, (*Thread1)(unsafe.Pointer(p)).Fdb, (*Thread1)(unsafe.Pointer(p)).FzArg, -1, (p + 48 /* &.pStmt */), uintptr(0)) 57219 } 57220 57221 // Usage: client_compile ID SQL 57222 // 57223 // Compile a new virtual machine. 57224 func tcl_client_compile(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test7.c:484:26: */ 57225 bp := tls.Alloc(56) 57226 defer tls.Free(56) 57227 57228 var i int32 57229 if argc != 3 { 57230 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 57231 ts+25388 /* " ID SQL" */, 0)) 57232 return TCL_ERROR 57233 } 57234 i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 57235 if i < 0 { 57236 return TCL_ERROR 57237 } 57238 if !(threadset1[i].Fbusy != 0) { 57239 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 57240 return TCL_ERROR 57241 } 57242 client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) 57243 threadset1[i].FxOp = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{do_compile1})) 57244 sqlite3.Xsqlite3_free(tls, threadset1[i].FzArg) 57245 threadset1[i].FzArg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+48, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) 57246 threadset1[i].Fopnum++ 57247 return TCL_OK 57248 } 57249 57250 // This procedure runs in the thread to step the virtual machine. 57251 func do_step1(tls *libc.TLS, p uintptr) { /* test7.c:513:13: */ 57252 var i int32 57253 if (*Thread1)(unsafe.Pointer(p)).FpStmt == uintptr(0) { 57254 (*Thread1)(unsafe.Pointer(p)).FzErr = libc.AssignPtrUintptr(p+64 /* &.zStaticErr */, ts+25396 /* "no virtual machi..." */) 57255 (*Thread1)(unsafe.Pointer(p)).Frc = SQLITE_ERROR 57256 return 57257 } 57258 (*Thread1)(unsafe.Pointer(p)).Frc = sqlite3_client_step(tls, (*Thread1)(unsafe.Pointer(p)).FpStmt) 57259 if (*Thread1)(unsafe.Pointer(p)).Frc == SQLITE_ROW { 57260 (*Thread1)(unsafe.Pointer(p)).Fargc = sqlite3.Xsqlite3_column_count(tls, (*Thread1)(unsafe.Pointer(p)).FpStmt) 57261 for i = 0; i < sqlite3.Xsqlite3_data_count(tls, (*Thread1)(unsafe.Pointer(p)).FpStmt); i++ { 57262 *(*uintptr)(unsafe.Pointer((p + 80 /* &.argv */) + uintptr(i)*8)) = sqlite3.Xsqlite3_column_text(tls, (*Thread1)(unsafe.Pointer(p)).FpStmt, i) 57263 } 57264 for i = 0; i < (*Thread1)(unsafe.Pointer(p)).Fargc; i++ { 57265 *(*uintptr)(unsafe.Pointer((p + 880 /* &.colv */) + uintptr(i)*8)) = sqlite3.Xsqlite3_column_name(tls, (*Thread1)(unsafe.Pointer(p)).FpStmt, i) 57266 } 57267 } 57268 } 57269 57270 // Usage: client_step ID 57271 // 57272 // Advance the virtual machine by one step 57273 func tcl_client_step(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test7.c:537:26: */ 57274 bp := tls.Alloc(48) 57275 defer tls.Free(48) 57276 57277 var i int32 57278 if argc != 2 { 57279 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 57280 ts+25425 /* " IDL" */, 0)) 57281 return TCL_ERROR 57282 } 57283 i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 57284 if i < 0 { 57285 return TCL_ERROR 57286 } 57287 if !(threadset1[i].Fbusy != 0) { 57288 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 57289 return TCL_ERROR 57290 } 57291 client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) 57292 threadset1[i].FxOp = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{do_step1})) 57293 threadset1[i].Fopnum++ 57294 return TCL_OK 57295 } 57296 57297 // This procedure runs in the thread to finalize a virtual machine. 57298 func do_finalize1(tls *libc.TLS, p uintptr) { /* test7.c:564:13: */ 57299 if (*Thread1)(unsafe.Pointer(p)).FpStmt == uintptr(0) { 57300 (*Thread1)(unsafe.Pointer(p)).FzErr = libc.AssignPtrUintptr(p+64 /* &.zStaticErr */, ts+25396 /* "no virtual machi..." */) 57301 (*Thread1)(unsafe.Pointer(p)).Frc = SQLITE_ERROR 57302 return 57303 } 57304 (*Thread1)(unsafe.Pointer(p)).Frc = sqlite3_client_finalize(tls, (*Thread1)(unsafe.Pointer(p)).FpStmt) 57305 (*Thread1)(unsafe.Pointer(p)).FpStmt = uintptr(0) 57306 } 57307 57308 // Usage: client_finalize ID 57309 // 57310 // Finalize the virtual machine. 57311 func tcl_client_finalize(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test7.c:579:26: */ 57312 bp := tls.Alloc(48) 57313 defer tls.Free(48) 57314 57315 var i int32 57316 if argc != 2 { 57317 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 57318 ts+25425 /* " IDL" */, 0)) 57319 return TCL_ERROR 57320 } 57321 i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 57322 if i < 0 { 57323 return TCL_ERROR 57324 } 57325 if !(threadset1[i].Fbusy != 0) { 57326 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 57327 return TCL_ERROR 57328 } 57329 client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) 57330 threadset1[i].FxOp = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{do_finalize1})) 57331 sqlite3.Xsqlite3_free(tls, threadset1[i].FzArg) 57332 threadset1[i].FzArg = uintptr(0) 57333 threadset1[i].Fopnum++ 57334 return TCL_OK 57335 } 57336 57337 // This procedure runs in the thread to reset a virtual machine. 57338 func do_reset(tls *libc.TLS, p uintptr) { /* test7.c:608:13: */ 57339 if (*Thread1)(unsafe.Pointer(p)).FpStmt == uintptr(0) { 57340 (*Thread1)(unsafe.Pointer(p)).FzErr = libc.AssignPtrUintptr(p+64 /* &.zStaticErr */, ts+25396 /* "no virtual machi..." */) 57341 (*Thread1)(unsafe.Pointer(p)).Frc = SQLITE_ERROR 57342 return 57343 } 57344 (*Thread1)(unsafe.Pointer(p)).Frc = sqlite3_client_reset(tls, (*Thread1)(unsafe.Pointer(p)).FpStmt) 57345 (*Thread1)(unsafe.Pointer(p)).FpStmt = uintptr(0) 57346 } 57347 57348 // Usage: client_reset ID 57349 // 57350 // Finalize the virtual machine. 57351 func tcl_client_reset(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test7.c:623:26: */ 57352 bp := tls.Alloc(48) 57353 defer tls.Free(48) 57354 57355 var i int32 57356 if argc != 2 { 57357 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 57358 ts+25425 /* " IDL" */, 0)) 57359 return TCL_ERROR 57360 } 57361 i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 57362 if i < 0 { 57363 return TCL_ERROR 57364 } 57365 if !(threadset1[i].Fbusy != 0) { 57366 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 57367 return TCL_ERROR 57368 } 57369 client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) 57370 threadset1[i].FxOp = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{do_reset})) 57371 sqlite3.Xsqlite3_free(tls, threadset1[i].FzArg) 57372 threadset1[i].FzArg = uintptr(0) 57373 threadset1[i].Fopnum++ 57374 return TCL_OK 57375 } 57376 57377 // Usage: client_swap ID ID 57378 // 57379 // Interchange the sqlite* pointer between two threads. 57380 func tcl_client_swap(tls *libc.TLS, NotUsed uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test7.c:654:26: */ 57381 bp := tls.Alloc(64) 57382 defer tls.Free(64) 57383 57384 var i int32 57385 var j int32 57386 var temp uintptr 57387 if argc != 3 { 57388 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 57389 ts+25430 /* " ID1 ID2" */, 0)) 57390 return TCL_ERROR 57391 } 57392 i = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 57393 if i < 0 { 57394 return TCL_ERROR 57395 } 57396 if !(threadset1[i].Fbusy != 0) { 57397 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+25320 /* "no such thread" */, 0)) 57398 return TCL_ERROR 57399 } 57400 client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(i)*1688)) 57401 j = parse_client_id(tls, interp, *(*uintptr)(unsafe.Pointer(argv + 2*8))) 57402 if j < 0 { 57403 return TCL_ERROR 57404 } 57405 if !(threadset1[j].Fbusy != 0) { 57406 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+25320 /* "no such thread" */, 0)) 57407 return TCL_ERROR 57408 } 57409 client_wait(tls, (uintptr(unsafe.Pointer(&threadset1)) + uintptr(j)*1688)) 57410 temp = threadset1[i].Fdb 57411 threadset1[i].Fdb = threadset1[j].Fdb 57412 threadset1[j].Fdb = temp 57413 return TCL_OK 57414 } 57415 57416 // Register commands with the TCL interpreter. 57417 func Sqlitetest7_Init(tls *libc.TLS, interp uintptr) int32 { /* test7.c:690:5: */ 57418 var i int32 57419 57420 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aCmd6)) / uint64(unsafe.Sizeof(struct { 57421 FzName uintptr 57422 FxProc uintptr 57423 }{}))); i++ { 57424 tcl.XTcl_CreateCommand(tls, interp, aCmd6[i].FzName, aCmd6[i].FxProc, uintptr(0), uintptr(0)) 57425 } 57426 return TCL_OK 57427 } 57428 57429 var aCmd6 = [13]struct { 57430 FzName uintptr 57431 FxProc uintptr 57432 }{ 57433 {FzName: ts + 26454 /* "client_create" */, FxProc: 0}, 57434 {FzName: ts + 26468 /* "client_wait" */, FxProc: 0}, 57435 {FzName: ts + 26480 /* "client_halt" */, FxProc: 0}, 57436 {FzName: ts + 26492 /* "client_argc" */, FxProc: 0}, 57437 {FzName: ts + 26504 /* "client_argv" */, FxProc: 0}, 57438 {FzName: ts + 26516 /* "client_colname" */, FxProc: 0}, 57439 {FzName: ts + 26531 /* "client_result" */, FxProc: 0}, 57440 {FzName: ts + 26545 /* "client_error" */, FxProc: 0}, 57441 {FzName: ts + 26558 /* "client_compile" */, FxProc: 0}, 57442 {FzName: ts + 26573 /* "client_step" */, FxProc: 0}, 57443 {FzName: ts + 26585 /* "client_reset" */, FxProc: 0}, 57444 {FzName: ts + 26598 /* "client_finalize" */, FxProc: 0}, 57445 {FzName: ts + 26614 /* "client_swap" */, FxProc: 0}, 57446 } /* test7.c:694:5 */ 57447 57448 // end block for C++ 57449 57450 // Local Variables: 57451 // mode: c 57452 // c-basic-offset: 4 57453 // fill-column: 78 57454 // End: 57455 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 57456 // This file is part of the GNU C Library. 57457 // 57458 // The GNU C Library is free software; you can redistribute it and/or 57459 // modify it under the terms of the GNU Lesser General Public 57460 // License as published by the Free Software Foundation; either 57461 // version 2.1 of the License, or (at your option) any later version. 57462 // 57463 // The GNU C Library is distributed in the hope that it will be useful, 57464 // but WITHOUT ANY WARRANTY; without even the implied warranty of 57465 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 57466 // Lesser General Public License for more details. 57467 // 57468 // You should have received a copy of the GNU Lesser General Public 57469 // License along with the GNU C Library; if not, see 57470 // <http://www.gnu.org/licenses/>. 57471 57472 // ISO C99 Standard: 7.20 General utilities <stdlib.h> 57473 57474 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 57475 // This file is part of the GNU C Library. 57476 // 57477 // The GNU C Library is free software; you can redistribute it and/or 57478 // modify it under the terms of the GNU Lesser General Public 57479 // License as published by the Free Software Foundation; either 57480 // version 2.1 of the License, or (at your option) any later version. 57481 // 57482 // The GNU C Library is distributed in the hope that it will be useful, 57483 // but WITHOUT ANY WARRANTY; without even the implied warranty of 57484 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 57485 // Lesser General Public License for more details. 57486 // 57487 // You should have received a copy of the GNU Lesser General Public 57488 // License along with the GNU C Library; if not, see 57489 // <http://www.gnu.org/licenses/>. 57490 57491 // ISO C99 Standard: 7.21 String handling <string.h> 57492 57493 type echo_vtab1 = struct { 57494 Fbase sqlite3_vtab 57495 Finterp uintptr 57496 Fdb uintptr 57497 FisPattern int32 57498 FinTransaction int32 57499 FzThis uintptr 57500 FzTableName uintptr 57501 FzLogName uintptr 57502 FnCol int32 57503 _ [4]byte 57504 FaIndex uintptr 57505 FaCol uintptr 57506 } /* test8.c:27:9 */ 57507 57508 // end block for C++ 57509 57510 // Local Variables: 57511 // mode: c 57512 // c-basic-offset: 4 57513 // fill-column: 78 57514 // End: 57515 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 57516 // This file is part of the GNU C Library. 57517 // 57518 // The GNU C Library is free software; you can redistribute it and/or 57519 // modify it under the terms of the GNU Lesser General Public 57520 // License as published by the Free Software Foundation; either 57521 // version 2.1 of the License, or (at your option) any later version. 57522 // 57523 // The GNU C Library is distributed in the hope that it will be useful, 57524 // but WITHOUT ANY WARRANTY; without even the implied warranty of 57525 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 57526 // Lesser General Public License for more details. 57527 // 57528 // You should have received a copy of the GNU Lesser General Public 57529 // License along with the GNU C Library; if not, see 57530 // <http://www.gnu.org/licenses/>. 57531 57532 // ISO C99 Standard: 7.20 General utilities <stdlib.h> 57533 57534 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 57535 // This file is part of the GNU C Library. 57536 // 57537 // The GNU C Library is free software; you can redistribute it and/or 57538 // modify it under the terms of the GNU Lesser General Public 57539 // License as published by the Free Software Foundation; either 57540 // version 2.1 of the License, or (at your option) any later version. 57541 // 57542 // The GNU C Library is distributed in the hope that it will be useful, 57543 // but WITHOUT ANY WARRANTY; without even the implied warranty of 57544 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 57545 // Lesser General Public License for more details. 57546 // 57547 // You should have received a copy of the GNU Lesser General Public 57548 // License along with the GNU C Library; if not, see 57549 // <http://www.gnu.org/licenses/>. 57550 57551 // ISO C99 Standard: 7.21 String handling <string.h> 57552 57553 type echo_vtab = echo_vtab1 /* test8.c:27:26 */ 57554 type echo_cursor1 = struct { 57555 Fbase sqlite3_vtab_cursor 57556 FpStmt uintptr 57557 } /* test8.c:28:9 */ 57558 57559 type echo_cursor = echo_cursor1 /* test8.c:28:28 */ 57560 57561 func simulateVtabError(tls *libc.TLS, p uintptr, zMethod uintptr) int32 { /* test8.c:97:12: */ 57562 bp := tls.Alloc(152) 57563 defer tls.Free(152) 57564 57565 var zErr uintptr 57566 // var zVarname [128]int8 at bp+24, 128 57567 57568 *(*int8)(unsafe.Pointer(bp + 24 /* &zVarname[0] */ + 127)) = int8(0) 57569 sqlite3.Xsqlite3_snprintf(tls, 127, bp+24 /* &zVarname[0] */, ts+26626 /* "echo_module_fail..." */, libc.VaList(bp, zMethod, (*echo_vtab)(unsafe.Pointer(p)).FzTableName)) 57570 zErr = tcl.XTcl_GetVar2(tls, (*echo_vtab)(unsafe.Pointer(p)).Finterp, bp+24 /* &zVarname[0] */, uintptr(0), TCL_GLOBAL_ONLY) 57571 if zErr != 0 { 57572 (*echo_vtab)(unsafe.Pointer(p)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+26650 /* "echo-vtab-error:..." */, libc.VaList(bp+16, zErr)) 57573 } 57574 return (libc.Bool32(zErr != uintptr(0))) 57575 } 57576 57577 // Convert an SQL-style quoted string into a normal string by removing 57578 // the quote characters. The conversion is done in-place. If the 57579 // input does not begin with a quote character, then this routine 57580 // is a no-op. 57581 // 57582 // Examples: 57583 // 57584 // "abc" becomes abc 57585 // 'xyz' becomes xyz 57586 // [pqr] becomes pqr 57587 // `mno` becomes mno 57588 func dequoteString(tls *libc.TLS, z uintptr) { /* test8.c:122:13: */ 57589 var quote int32 57590 var i int32 57591 var j int32 57592 if z == uintptr(0) { 57593 return 57594 } 57595 quote = int32(*(*int8)(unsafe.Pointer(z))) 57596 switch quote { 57597 case '\'': 57598 break 57599 case '"': 57600 break 57601 case '`': 57602 break // For MySQL compatibility 57603 case '[': 57604 quote = ']' 57605 break // For MS SqlServer compatibility 57606 default: 57607 return 57608 } 57609 i = 1 57610 j = 0 57611 for ; *(*int8)(unsafe.Pointer(z + uintptr(i))) != 0; i++ { 57612 if int32(*(*int8)(unsafe.Pointer(z + uintptr(i)))) == quote { 57613 if int32(*(*int8)(unsafe.Pointer(z + uintptr((i + 1))))) == quote { 57614 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&j, 1)))) = int8(quote) 57615 i++ 57616 } else { 57617 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&j, 1)))) = int8(0) 57618 break 57619 } 57620 } else { 57621 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&j, 1)))) = *(*int8)(unsafe.Pointer(z + uintptr(i))) 57622 } 57623 } 57624 } 57625 57626 // Retrieve the column names for the table named zTab via database 57627 // connection db. SQLITE_OK is returned on success, or an sqlite error 57628 // code otherwise. 57629 // 57630 // If successful, the number of columns is written to *pnCol. *paCol is 57631 // set to point at sqlite3_malloc()'d space containing the array of 57632 // nCol column names. The caller is responsible for calling sqlite3_free 57633 // on *paCol. 57634 func getColumnNames(tls *libc.TLS, db uintptr, zTab uintptr, paCol uintptr, pnCol uintptr) int32 { /* test8.c:159:12: */ 57635 bp := tls.Alloc(24) 57636 defer tls.Free(24) 57637 57638 var aCol uintptr 57639 var zSql uintptr 57640 // var pStmt uintptr at bp+16, 8 57641 57642 var rc int32 57643 var nCol int32 57644 var zName uintptr 57645 var ii int32 57646 var nBytes int32 57647 var zSpace uintptr 57648 aCol = uintptr(0) 57649 *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */)) = uintptr(0) 57650 rc = SQLITE_OK 57651 nCol = 0 57652 57653 // Prepare the statement "SELECT * FROM <tbl>". The column names 57654 // of the result set of the compiled SELECT will be the same as 57655 // the column names of table <tbl>. 57656 zSql = sqlite3.Xsqlite3_mprintf(tls, ts+26670 /* "SELECT * FROM %Q" */, libc.VaList(bp, zTab)) 57657 if !(!(zSql != 0)) { 57658 goto __1 57659 } 57660 rc = SQLITE_NOMEM 57661 goto out 57662 __1: 57663 ; 57664 rc = sqlite3.Xsqlite3_prepare(tls, db, zSql, -1, bp+16 /* &pStmt */, uintptr(0)) 57665 sqlite3.Xsqlite3_free(tls, zSql) 57666 57667 if !(rc == SQLITE_OK) { 57668 goto __2 57669 } 57670 nCol = sqlite3.Xsqlite3_column_count(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) 57671 57672 // Figure out how much space to allocate for the array of column names 57673 // (including space for the strings themselves). Then allocate it. 57674 nBytes = (int32(uint64(unsafe.Sizeof(uintptr(0))) * uint64(nCol))) 57675 ii = 0 57676 __3: 57677 if !(ii < nCol) { 57678 goto __5 57679 } 57680 zName = sqlite3.Xsqlite3_column_name(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */)), ii) 57681 if !(!(zName != 0)) { 57682 goto __6 57683 } 57684 rc = SQLITE_NOMEM 57685 goto out 57686 __6: 57687 ; 57688 nBytes = nBytes + (int32(libc.Xstrlen(tls, zName)) + 1) 57689 goto __4 57690 __4: 57691 ii++ 57692 goto __3 57693 goto __5 57694 __5: 57695 ; 57696 aCol = sqlite3.Xsqlite3MallocZero(tls, uint64(nBytes)) 57697 if !(!(aCol != 0)) { 57698 goto __7 57699 } 57700 rc = SQLITE_NOMEM 57701 goto out 57702 __7: 57703 ; 57704 57705 // Copy the column names into the allocated space and set up the 57706 // pointers in the aCol[] array. 57707 zSpace = (aCol + uintptr(nCol)*8) 57708 ii = 0 57709 __8: 57710 if !(ii < nCol) { 57711 goto __10 57712 } 57713 *(*uintptr)(unsafe.Pointer(aCol + uintptr(ii)*8)) = zSpace 57714 sqlite3.Xsqlite3_snprintf(tls, nBytes, zSpace, ts /* "%s" */, libc.VaList(bp+8, sqlite3.Xsqlite3_column_name(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */)), ii))) 57715 zSpace += (uintptr(int32(libc.Xstrlen(tls, zSpace)) + 1)) 57716 goto __9 57717 __9: 57718 ii++ 57719 goto __8 57720 goto __10 57721 __10: 57722 ; 57723 57724 __2: 57725 ; 57726 57727 *(*uintptr)(unsafe.Pointer(paCol)) = aCol 57728 *(*int32)(unsafe.Pointer(pnCol)) = nCol 57729 57730 out: 57731 sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) 57732 return rc 57733 } 57734 57735 // Parameter zTab is the name of a table in database db with nCol 57736 // columns. This function allocates an array of integers nCol in 57737 // size and populates it according to any implicit or explicit 57738 // indices on table zTab. 57739 // 57740 // If successful, SQLITE_OK is returned and *paIndex set to point 57741 // at the allocated array. Otherwise, an error code is returned. 57742 // 57743 // See comments associated with the member variable aIndex above 57744 // "struct echo_vtab" for details of the contents of the array. 57745 func getIndexArray(tls *libc.TLS, db uintptr, zTab uintptr, nCol int32, paIndex uintptr) int32 { /* test8.c:239:12: */ 57746 bp := tls.Alloc(32) 57747 defer tls.Free(32) 57748 57749 // var pStmt uintptr at bp+16, 8 57750 57751 var aIndex uintptr 57752 var rc int32 57753 var zSql uintptr 57754 var cid int32 57755 var zIdx uintptr 57756 // var pStmt2 uintptr at bp+24, 8 57757 57758 var rc2 int32 57759 *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */)) = uintptr(0) 57760 aIndex = uintptr(0) 57761 57762 // Allocate space for the index array 57763 aIndex = sqlite3.Xsqlite3MallocZero(tls, (uint64(uint64(unsafe.Sizeof(int32(0))) * uint64(nCol)))) 57764 if !(!(aIndex != 0)) { 57765 goto __1 57766 } 57767 rc = SQLITE_NOMEM 57768 goto get_index_array_out 57769 __1: 57770 ; 57771 57772 // Compile an sqlite pragma to loop through all indices on table zTab 57773 zSql = sqlite3.Xsqlite3_mprintf(tls, ts+26687 /* "PRAGMA index_lis..." */, libc.VaList(bp, zTab)) 57774 if !(!(zSql != 0)) { 57775 goto __2 57776 } 57777 rc = SQLITE_NOMEM 57778 goto get_index_array_out 57779 __2: 57780 ; 57781 rc = sqlite3.Xsqlite3_prepare(tls, db, zSql, -1, bp+16 /* &pStmt */, uintptr(0)) 57782 sqlite3.Xsqlite3_free(tls, zSql) 57783 57784 // For each index, figure out the left-most column and set the 57785 // corresponding entry in aIndex[] to 1. 57786 __3: 57787 if !((*(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */)) != 0) && (sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) == SQLITE_ROW)) { 57788 goto __4 57789 } 57790 zIdx = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */)), 1) 57791 *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt2 */)) = uintptr(0) 57792 if !(zIdx == uintptr(0)) { 57793 goto __5 57794 } 57795 goto __3 57796 __5: 57797 ; 57798 zSql = sqlite3.Xsqlite3_mprintf(tls, ts+26709 /* "PRAGMA index_inf..." */, libc.VaList(bp+8, zIdx)) 57799 if !(!(zSql != 0)) { 57800 goto __6 57801 } 57802 rc = SQLITE_NOMEM 57803 goto get_index_array_out 57804 __6: 57805 ; 57806 rc = sqlite3.Xsqlite3_prepare(tls, db, zSql, -1, bp+24 /* &pStmt2 */, uintptr(0)) 57807 sqlite3.Xsqlite3_free(tls, zSql) 57808 if !((*(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt2 */)) != 0) && (sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt2 */))) == SQLITE_ROW)) { 57809 goto __7 57810 } 57811 cid = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt2 */)), 1) 57812 57813 *(*int32)(unsafe.Pointer(aIndex + uintptr(cid)*4)) = 1 57814 __7: 57815 ; 57816 if !(*(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt2 */)) != 0) { 57817 goto __8 57818 } 57819 rc = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pStmt2 */))) 57820 __8: 57821 ; 57822 if !(rc != SQLITE_OK) { 57823 goto __9 57824 } 57825 goto get_index_array_out 57826 __9: 57827 ; 57828 goto __3 57829 __4: 57830 ; 57831 57832 get_index_array_out: 57833 if !(*(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */)) != 0) { 57834 goto __10 57835 } 57836 rc2 = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pStmt */))) 57837 if !(rc == SQLITE_OK) { 57838 goto __11 57839 } 57840 rc = rc2 57841 __11: 57842 ; 57843 __10: 57844 ; 57845 if !(rc != SQLITE_OK) { 57846 goto __12 57847 } 57848 sqlite3.Xsqlite3_free(tls, aIndex) 57849 aIndex = uintptr(0) 57850 __12: 57851 ; 57852 *(*uintptr)(unsafe.Pointer(paIndex)) = aIndex 57853 return rc 57854 } 57855 57856 // Global Tcl variable $echo_module is a list. This routine appends 57857 // the string element zArg to that list in interpreter interp. 57858 func appendToEchoModule(tls *libc.TLS, interp uintptr, zArg uintptr) { /* test8.c:313:13: */ 57859 var flags int32 = ((TCL_APPEND_VALUE | TCL_LIST_ELEMENT) | TCL_GLOBAL_ONLY) 57860 tcl.XTcl_SetVar2(tls, interp, ts+26731 /* "echo_module" */, uintptr(0), func() uintptr { 57861 if zArg != 0 { 57862 return zArg 57863 } 57864 return ts + 489 /* "" */ 57865 }(), flags) 57866 } 57867 57868 // This function is called from within the echo-modules xCreate and 57869 // xConnect methods. The argc and argv arguments are copies of those 57870 // passed to the calling method. This function is responsible for 57871 // calling sqlite3_declare_vtab() to declare the schema of the virtual 57872 // table being created or connected. 57873 // 57874 // If the constructor was passed just one argument, i.e.: 57875 // 57876 // CREATE TABLE t1 AS echo(t2); 57877 // 57878 // Then t2 is assumed to be the name of a *real* database table. The 57879 // schema of the virtual table is declared by passing a copy of the 57880 // CREATE TABLE statement for the real table to sqlite3_declare_vtab(). 57881 // Hence, the virtual table should have exactly the same column names and 57882 // types as the real table. 57883 func echoDeclareVtab(tls *libc.TLS, pVtab uintptr, db uintptr) int32 { /* test8.c:335:12: */ 57884 bp := tls.Alloc(8) 57885 defer tls.Free(8) 57886 57887 var rc int32 = SQLITE_OK 57888 57889 if (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName != 0 { 57890 *(*uintptr)(unsafe.Pointer(bp /* pStmt */)) = uintptr(0) 57891 rc = sqlite3.Xsqlite3_prepare(tls, db, 57892 ts+26743, /* "SELECT sql FROM ..." */ 57893 -1, bp /* &pStmt */, uintptr(0)) 57894 if rc == SQLITE_OK { 57895 sqlite3.Xsqlite3_bind_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), 1, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName, -1, uintptr(0)) 57896 if sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) == SQLITE_ROW { 57897 var rc2 int32 57898 var zCreateTable uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), 0) 57899 rc = sqlite3.Xsqlite3_declare_vtab(tls, db, zCreateTable) 57900 rc2 = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) 57901 if rc == SQLITE_OK { 57902 rc = rc2 57903 } 57904 } else { 57905 rc = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) 57906 if rc == SQLITE_OK { 57907 rc = SQLITE_ERROR 57908 } 57909 } 57910 if rc == SQLITE_OK { 57911 rc = getColumnNames(tls, db, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName, (pVtab + 88 /* &.aCol */), (pVtab + 72 /* &.nCol */)) 57912 } 57913 if rc == SQLITE_OK { 57914 rc = getIndexArray(tls, db, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName, (*echo_vtab)(unsafe.Pointer(pVtab)).FnCol, (pVtab + 80 /* &.aIndex */)) 57915 } 57916 } 57917 } 57918 57919 return rc 57920 } 57921 57922 // This function frees all runtime structures associated with the virtual 57923 // table pVtab. 57924 func echoDestructor(tls *libc.TLS, pVtab uintptr) int32 { /* test8.c:378:12: */ 57925 var p uintptr = pVtab 57926 sqlite3.Xsqlite3_free(tls, (*echo_vtab)(unsafe.Pointer(p)).FaIndex) 57927 sqlite3.Xsqlite3_free(tls, (*echo_vtab)(unsafe.Pointer(p)).FaCol) 57928 sqlite3.Xsqlite3_free(tls, (*echo_vtab)(unsafe.Pointer(p)).FzThis) 57929 sqlite3.Xsqlite3_free(tls, (*echo_vtab)(unsafe.Pointer(p)).FzTableName) 57930 sqlite3.Xsqlite3_free(tls, (*echo_vtab)(unsafe.Pointer(p)).FzLogName) 57931 sqlite3.Xsqlite3_free(tls, p) 57932 return 0 57933 } 57934 57935 type EchoModule1 = struct{ Finterp uintptr } /* test8.c:389:9 */ 57936 57937 type EchoModule = EchoModule1 /* test8.c:389:27 */ 57938 57939 // This function is called to do the work of the xConnect() method - 57940 // to allocate the required in-memory structures for a newly connected 57941 // virtual table. 57942 func echoConstructor(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* test8.c:399:12: */ 57943 bp := tls.Alloc(32) 57944 defer tls.Free(32) 57945 57946 var rc int32 57947 var i int32 57948 var pVtab uintptr 57949 57950 // Allocate the sqlite3_vtab/echo_vtab structure itself 57951 pVtab = sqlite3.Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(echo_vtab{}))) 57952 if !(pVtab != 0) { 57953 return SQLITE_NOMEM 57954 } 57955 (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp = (*EchoModule)(unsafe.Pointer(pAux)).Finterp 57956 (*echo_vtab)(unsafe.Pointer(pVtab)).Fdb = db 57957 57958 // Allocate echo_vtab.zThis 57959 (*echo_vtab)(unsafe.Pointer(pVtab)).FzThis = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(argv + 2*8)))) 57960 if !(int32((*echo_vtab)(unsafe.Pointer(pVtab)).FzThis) != 0) { 57961 echoDestructor(tls, pVtab) 57962 return SQLITE_NOMEM 57963 } 57964 57965 // Allocate echo_vtab.zTableName 57966 if argc > 3 { 57967 (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(argv + 3*8)))) 57968 dequoteString(tls, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName) 57969 if ((*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName != 0) && (int32(*(*int8)(unsafe.Pointer((*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName))) == '*') { 57970 var z uintptr = sqlite3.Xsqlite3_mprintf(tls, ts+26807 /* "%s%s" */, libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(argv + 2*8)), ((*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName+1))) 57971 sqlite3.Xsqlite3_free(tls, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName) 57972 (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName = z 57973 (*echo_vtab)(unsafe.Pointer(pVtab)).FisPattern = 1 57974 } 57975 if !(int32((*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName) != 0) { 57976 echoDestructor(tls, pVtab) 57977 return SQLITE_NOMEM 57978 } 57979 } 57980 57981 // Log the arguments to this function to Tcl var ::echo_module 57982 for i = 0; i < argc; i++ { 57983 appendToEchoModule(tls, (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) 57984 } 57985 57986 // Invoke sqlite3_declare_vtab and set up other members of the echo_vtab 57987 // structure. If an error occurs, delete the sqlite3_vtab structure and 57988 // return an error code. 57989 rc = echoDeclareVtab(tls, pVtab, db) 57990 if rc != SQLITE_OK { 57991 echoDestructor(tls, pVtab) 57992 return rc 57993 } 57994 57995 // Success. Set *ppVtab and return 57996 *(*uintptr)(unsafe.Pointer(ppVtab)) = (pVtab /* &.base */) 57997 return SQLITE_OK 57998 } 57999 58000 // Echo virtual table module xCreate method. 58001 func echoCreate(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* test8.c:464:12: */ 58002 bp := tls.Alloc(24) 58003 defer tls.Free(24) 58004 58005 var rc int32 = SQLITE_OK 58006 appendToEchoModule(tls, (*EchoModule)(unsafe.Pointer(pAux)).Finterp, ts+26812 /* "xCreate" */) 58007 rc = echoConstructor(tls, db, pAux, argc, argv, ppVtab, pzErr) 58008 58009 // If there were two arguments passed to the module at the SQL level 58010 // (i.e. "CREATE VIRTUAL TABLE tbl USING echo(arg1, arg2)"), then 58011 // the second argument is used as a table name. Attempt to create 58012 // such a table with a single column, "logmsg". This table will 58013 // be used to log calls to the xUpdate method. It will be deleted 58014 // when the virtual table is DROPed. 58015 // 58016 // Note: The main point of this is to test that we can drop tables 58017 // from within an xDestroy method call. 58018 if (rc == SQLITE_OK) && (argc == 5) { 58019 var zSql uintptr 58020 var pVtab uintptr = *(*uintptr)(unsafe.Pointer(ppVtab)) 58021 (*echo_vtab)(unsafe.Pointer(pVtab)).FzLogName = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(argv + 4*8)))) 58022 zSql = sqlite3.Xsqlite3_mprintf(tls, ts+26820 /* "CREATE TABLE %Q(..." */, libc.VaList(bp+8, (*echo_vtab)(unsafe.Pointer(pVtab)).FzLogName)) 58023 rc = sqlite3.Xsqlite3_exec(tls, db, zSql, uintptr(0), uintptr(0), uintptr(0)) 58024 sqlite3.Xsqlite3_free(tls, zSql) 58025 if rc != SQLITE_OK { 58026 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+16, sqlite3.Xsqlite3_errmsg(tls, db))) 58027 } 58028 } 58029 58030 if (*(*uintptr)(unsafe.Pointer(ppVtab)) != 0) && (rc != SQLITE_OK) { 58031 echoDestructor(tls, *(*uintptr)(unsafe.Pointer(ppVtab))) 58032 *(*uintptr)(unsafe.Pointer(ppVtab)) = uintptr(0) 58033 } 58034 58035 if rc == SQLITE_OK { 58036 (*echo_vtab)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(ppVtab)))).FinTransaction = 1 58037 } 58038 58039 return rc 58040 } 58041 58042 // Echo virtual table module xConnect method. 58043 func echoConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* test8.c:512:12: */ 58044 appendToEchoModule(tls, (*EchoModule)(unsafe.Pointer(pAux)).Finterp, ts+26844 /* "xConnect" */) 58045 return echoConstructor(tls, db, pAux, argc, argv, ppVtab, pzErr) 58046 } 58047 58048 // Echo virtual table module xDisconnect method. 58049 func echoDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* test8.c:526:12: */ 58050 appendToEchoModule(tls, (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp, ts+26853 /* "xDisconnect" */) 58051 return echoDestructor(tls, pVtab) 58052 } 58053 58054 // Echo virtual table module xDestroy method. 58055 func echoDestroy(tls *libc.TLS, pVtab uintptr) int32 { /* test8.c:534:12: */ 58056 bp := tls.Alloc(8) 58057 defer tls.Free(8) 58058 58059 var rc int32 = SQLITE_OK 58060 var p uintptr = pVtab 58061 appendToEchoModule(tls, (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp, ts+26865 /* "xDestroy" */) 58062 58063 // Drop the "log" table, if one exists (see echoCreate() for details) 58064 if (p != 0) && ((*echo_vtab)(unsafe.Pointer(p)).FzLogName != 0) { 58065 var zSql uintptr 58066 zSql = sqlite3.Xsqlite3_mprintf(tls, ts+26874 /* "DROP TABLE %Q" */, libc.VaList(bp, (*echo_vtab)(unsafe.Pointer(p)).FzLogName)) 58067 rc = sqlite3.Xsqlite3_exec(tls, (*echo_vtab)(unsafe.Pointer(p)).Fdb, zSql, uintptr(0), uintptr(0), uintptr(0)) 58068 sqlite3.Xsqlite3_free(tls, zSql) 58069 } 58070 58071 if rc == SQLITE_OK { 58072 rc = echoDestructor(tls, pVtab) 58073 } 58074 return rc 58075 } 58076 58077 // Echo virtual table module xOpen method. 58078 func echoOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* test8.c:556:12: */ 58079 var pCur uintptr 58080 if simulateVtabError(tls, pVTab, ts+26888 /* "xOpen" */) != 0 { 58081 return SQLITE_ERROR 58082 } 58083 pCur = sqlite3.Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(echo_cursor{}))) 58084 *(*uintptr)(unsafe.Pointer(ppCursor)) = pCur 58085 return func() int32 { 58086 if pCur != 0 { 58087 return SQLITE_OK 58088 } 58089 return SQLITE_NOMEM 58090 }() 58091 } 58092 58093 // Echo virtual table module xClose method. 58094 func echoClose(tls *libc.TLS, cur uintptr) int32 { /* test8.c:569:12: */ 58095 var rc int32 58096 var pCur uintptr = cur 58097 var pStmt uintptr = (*echo_cursor)(unsafe.Pointer(pCur)).FpStmt 58098 (*echo_cursor)(unsafe.Pointer(pCur)).FpStmt = uintptr(0) 58099 sqlite3.Xsqlite3_free(tls, pCur) 58100 rc = sqlite3.Xsqlite3_finalize(tls, pStmt) 58101 return rc 58102 } 58103 58104 // Return non-zero if the cursor does not currently point to a valid record 58105 // (i.e if the scan has finished), or zero otherwise. 58106 func echoEof(tls *libc.TLS, cur uintptr) int32 { /* test8.c:583:12: */ 58107 return func() int32 { 58108 if (*echo_cursor)(unsafe.Pointer(cur)).FpStmt != 0 { 58109 return 0 58110 } 58111 return 1 58112 }() 58113 } 58114 58115 // Echo virtual table module xNext method. 58116 func echoNext(tls *libc.TLS, cur uintptr) int32 { /* test8.c:590:12: */ 58117 var rc int32 = SQLITE_OK 58118 var pCur uintptr = cur 58119 58120 if simulateVtabError(tls, (*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab, ts+26894 /* "xNext" */) != 0 { 58121 return SQLITE_ERROR 58122 } 58123 58124 if (*echo_cursor)(unsafe.Pointer(pCur)).FpStmt != 0 { 58125 rc = sqlite3.Xsqlite3_step(tls, (*echo_cursor)(unsafe.Pointer(pCur)).FpStmt) 58126 if rc == SQLITE_ROW { 58127 rc = SQLITE_OK 58128 } else { 58129 rc = sqlite3.Xsqlite3_finalize(tls, (*echo_cursor)(unsafe.Pointer(pCur)).FpStmt) 58130 (*echo_cursor)(unsafe.Pointer(pCur)).FpStmt = uintptr(0) 58131 } 58132 } 58133 58134 return rc 58135 } 58136 58137 // Echo virtual table module xColumn method. 58138 func echoColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* test8.c:614:12: */ 58139 var iCol int32 = (i + 1) 58140 var pStmt uintptr = (*echo_cursor)(unsafe.Pointer(cur)).FpStmt 58141 58142 if simulateVtabError(tls, (*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab, ts+26900 /* "xColumn" */) != 0 { 58143 return SQLITE_ERROR 58144 } 58145 58146 if !(pStmt != 0) { 58147 sqlite3.Xsqlite3_result_null(tls, ctx) 58148 } else { 58149 58150 sqlite3.Xsqlite3_result_value(tls, ctx, sqlite3.Xsqlite3_column_value(tls, pStmt, iCol)) 58151 } 58152 return SQLITE_OK 58153 } 58154 58155 // Echo virtual table module xRowid method. 58156 func echoRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* test8.c:634:12: */ 58157 var pStmt uintptr = (*echo_cursor)(unsafe.Pointer(cur)).FpStmt 58158 58159 if simulateVtabError(tls, (*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab, ts+2165 /* "xRowid" */) != 0 { 58160 return SQLITE_ERROR 58161 } 58162 58163 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite3.Xsqlite3_column_int64(tls, pStmt, 0) 58164 return SQLITE_OK 58165 } 58166 58167 // Compute a simple hash of the null terminated string zString. 58168 // 58169 // This module uses only sqlite3_index_info.idxStr, not 58170 // sqlite3_index_info.idxNum. So to test idxNum, when idxStr is set 58171 // in echoBestIndex(), idxNum is set to the corresponding hash value. 58172 // In echoFilter(), code assert()s that the supplied idxNum value is 58173 // indeed the hash of the supplied idxStr. 58174 func hashString(tls *libc.TLS, zString uintptr) int32 { /* test8.c:654:12: */ 58175 var val u322 = u322(0) 58176 var ii int32 58177 for ii = 0; *(*int8)(unsafe.Pointer(zString + uintptr(ii))) != 0; ii++ { 58178 val = ((val << 3) + u322(int32(*(*int8)(unsafe.Pointer(zString + uintptr(ii)))))) 58179 } 58180 return (int32(val & u322(0x7fffffff))) 58181 } 58182 58183 // Echo virtual table module xFilter method. 58184 func echoFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* test8.c:666:12: */ 58185 var rc int32 58186 var i int32 58187 58188 var pCur uintptr = pVtabCursor 58189 var pVtab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab 58190 var db uintptr = (*echo_vtab)(unsafe.Pointer(pVtab)).Fdb 58191 58192 if simulateVtabError(tls, pVtab, ts+26908 /* "xFilter" */) != 0 { 58193 return SQLITE_ERROR 58194 } 58195 58196 // Check that idxNum matches idxStr 58197 58198 // Log arguments to the ::echo_module Tcl variable 58199 appendToEchoModule(tls, (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp, ts+26908 /* "xFilter" */) 58200 appendToEchoModule(tls, (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp, idxStr) 58201 for i = 0; i < argc; i++ { 58202 appendToEchoModule(tls, (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8)))) 58203 } 58204 58205 sqlite3.Xsqlite3_finalize(tls, (*echo_cursor)(unsafe.Pointer(pCur)).FpStmt) 58206 (*echo_cursor)(unsafe.Pointer(pCur)).FpStmt = uintptr(0) 58207 58208 // Prepare the SQL statement created by echoBestIndex and bind the 58209 // runtime parameters passed to this function to it. 58210 rc = sqlite3.Xsqlite3_prepare(tls, db, idxStr, -1, (pCur + 8 /* &.pStmt */), uintptr(0)) 58211 58212 for i = 0; (rc == SQLITE_OK) && (i < argc); i++ { 58213 rc = sqlite3.Xsqlite3_bind_value(tls, (*echo_cursor)(unsafe.Pointer(pCur)).FpStmt, (i + 1), *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) 58214 } 58215 58216 // If everything was successful, advance to the first row of the scan 58217 if rc == SQLITE_OK { 58218 rc = echoNext(tls, pVtabCursor) 58219 } 58220 58221 return rc 58222 } 58223 58224 // A helper function used by echoUpdate() and echoBestIndex() for 58225 // manipulating strings in concert with the sqlite3_mprintf() function. 58226 // 58227 // Parameter pzStr points to a pointer to a string allocated with 58228 // sqlite3_mprintf. The second parameter, zAppend, points to another 58229 // string. The two strings are concatenated together and *pzStr 58230 // set to point at the result. The initial buffer pointed to by *pzStr 58231 // is deallocated via sqlite3_free(). 58232 // 58233 // If the third argument, doFree, is true, then sqlite3_free() is 58234 // also called to free the buffer pointed to by zAppend. 58235 func string_concat(tls *libc.TLS, pzStr uintptr, zAppend uintptr, doFree int32, pRc uintptr) { /* test8.c:726:13: */ 58236 bp := tls.Alloc(24) 58237 defer tls.Free(24) 58238 58239 var zIn uintptr = *(*uintptr)(unsafe.Pointer(pzStr)) 58240 if (!(zAppend != 0) && (doFree != 0)) && (*(*int32)(unsafe.Pointer(pRc)) == SQLITE_OK) { 58241 *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM 58242 } 58243 if *(*int32)(unsafe.Pointer(pRc)) != SQLITE_OK { 58244 sqlite3.Xsqlite3_free(tls, zIn) 58245 zIn = uintptr(0) 58246 } else { 58247 if zIn != 0 { 58248 var zTemp uintptr = zIn 58249 zIn = sqlite3.Xsqlite3_mprintf(tls, ts+26807 /* "%s%s" */, libc.VaList(bp, zIn, zAppend)) 58250 sqlite3.Xsqlite3_free(tls, zTemp) 58251 } else { 58252 zIn = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+16, zAppend)) 58253 } 58254 if !(zIn != 0) { 58255 *(*int32)(unsafe.Pointer(pRc)) = SQLITE_NOMEM 58256 } 58257 } 58258 *(*uintptr)(unsafe.Pointer(pzStr)) = zIn 58259 if doFree != 0 { 58260 sqlite3.Xsqlite3_free(tls, zAppend) 58261 } 58262 } 58263 58264 // This function returns a pointer to an sqlite3_malloc()ed buffer 58265 // containing the select-list (the thing between keywords SELECT and FROM) 58266 // to query the underlying real table with for the scan described by 58267 // argument pIdxInfo. 58268 // 58269 // If the current SQLite version is earlier than 3.10.0, this is just "*" 58270 // (select all columns). Or, for version 3.10.0 and greater, the list of 58271 // columns identified by the pIdxInfo->colUsed mask. 58272 func echoSelectList(tls *libc.TLS, pTab uintptr, pIdxInfo uintptr) uintptr { /* test8.c:762:13: */ 58273 bp := tls.Alloc(24) 58274 defer tls.Free(24) 58275 58276 var zRet uintptr = uintptr(0) 58277 if sqlite3.Xsqlite3_libversion_number(tls) < 3010000 { 58278 zRet = sqlite3.Xsqlite3_mprintf(tls, ts+26916 /* ", *" */, 0) 58279 } else { 58280 var i int32 58281 for i = 0; i < (*echo_vtab)(unsafe.Pointer(pTab)).FnCol; i++ { 58282 if ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FcolUsed & (sqlite3_uint64(uint64(1)) << (func() int32 { 58283 if i >= 63 { 58284 return 63 58285 } 58286 return i 58287 }()))) != 0 { 58288 zRet = sqlite3.Xsqlite3_mprintf(tls, ts+26920 /* "%z, %s" */, libc.VaList(bp, zRet, *(*uintptr)(unsafe.Pointer((*echo_vtab)(unsafe.Pointer(pTab)).FaCol + uintptr(i)*8)))) 58289 } else { 58290 zRet = sqlite3.Xsqlite3_mprintf(tls, ts+26927 /* "%z, NULL" */, libc.VaList(bp+16, zRet)) 58291 } 58292 if !(zRet != 0) { 58293 break 58294 } 58295 } 58296 } 58297 return zRet 58298 } 58299 58300 // The echo module implements the subset of query constraints and sort 58301 // orders that may take advantage of SQLite indices on the underlying 58302 // real table. For example, if the real table is declared as: 58303 // 58304 // CREATE TABLE real(a, b, c); 58305 // CREATE INDEX real_index ON real(b); 58306 // 58307 // then the echo module handles WHERE or ORDER BY clauses that refer 58308 // to the column "b", but not "a" or "c". If a multi-column index is 58309 // present, only its left most column is considered. 58310 // 58311 // This xBestIndex method encodes the proposed search strategy as 58312 // an SQL query on the real table underlying the virtual echo module 58313 // table and stores the query in sqlite3_index_info.idxStr. The SQL 58314 // statement is of the form: 58315 // 58316 // SELECT rowid, * FROM <real-table> ?<where-clause>? ?<order-by-clause>? 58317 // 58318 // where the <where-clause> and <order-by-clause> are determined 58319 // by the contents of the structure pointed to by the pIdxInfo argument. 58320 func echoBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test8.c:802:12: */ 58321 bp := tls.Alloc(100) 58322 defer tls.Free(100) 58323 58324 var ii int32 58325 *(*uintptr)(unsafe.Pointer(bp + 88 /* zQuery */)) = uintptr(0) 58326 var zCol uintptr = uintptr(0) 58327 var zNew uintptr 58328 var nArg int32 = 0 58329 var zSep uintptr = ts + 8840 /* "WHERE" */ 58330 var pVtab uintptr = tab 58331 *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */)) = uintptr(0) 58332 var interp uintptr = (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp 58333 58334 var nRow int32 = 0 58335 var useIdx int32 = 0 58336 *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = SQLITE_OK 58337 var useCost int32 = 0 58338 var cost float64 = float64(0) 58339 var isIgnoreUsable int32 = 0 58340 if tcl.XTcl_GetVar2(tls, interp, ts+26936 /* "echo_module_igno..." */, uintptr(0), TCL_GLOBAL_ONLY) != 0 { 58341 isIgnoreUsable = 1 58342 } 58343 58344 if simulateVtabError(tls, pVtab, ts+26962 /* "xBestIndex" */) != 0 { 58345 return SQLITE_ERROR 58346 } 58347 58348 // Determine the number of rows in the table and store this value in local 58349 // variable nRow. The 'estimated-cost' of the scan will be the number of 58350 // rows in the table for a linear scan, or the log (base 2) of the 58351 // number of rows if the proposed scan uses an index. 58352 if tcl.XTcl_GetVar2(tls, interp, ts+26973 /* "echo_module_cost" */, uintptr(0), TCL_GLOBAL_ONLY) != 0 { 58353 cost = libc.Xatof(tls, tcl.XTcl_GetVar2(tls, interp, ts+26973 /* "echo_module_cost" */, uintptr(0), TCL_GLOBAL_ONLY)) 58354 useCost = 1 58355 } else { 58356 *(*uintptr)(unsafe.Pointer(bp + 88 /* zQuery */)) = sqlite3.Xsqlite3_mprintf(tls, ts+26990 /* "SELECT count(*) ..." */, libc.VaList(bp, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName)) 58357 if !(*(*uintptr)(unsafe.Pointer(bp + 88 /* zQuery */)) != 0) { 58358 return SQLITE_NOMEM 58359 } 58360 *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = sqlite3.Xsqlite3_prepare(tls, (*echo_vtab)(unsafe.Pointer(pVtab)).Fdb, *(*uintptr)(unsafe.Pointer(bp + 88 /* zQuery */)), -1, bp+80 /* &pStmt */, uintptr(0)) 58361 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* zQuery */))) 58362 if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) != SQLITE_OK { 58363 return *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) 58364 } 58365 sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */))) 58366 nRow = sqlite3.Xsqlite3_column_int(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */)), 0) 58367 *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pStmt */))) 58368 if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) != SQLITE_OK { 58369 return *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) 58370 } 58371 } 58372 58373 zCol = echoSelectList(tls, pVtab, pIdxInfo) 58374 if !(zCol != 0) { 58375 return SQLITE_NOMEM 58376 } 58377 *(*uintptr)(unsafe.Pointer(bp + 88 /* zQuery */)) = sqlite3.Xsqlite3_mprintf(tls, ts+27014 /* "SELECT rowid%z F..." */, libc.VaList(bp+8, zCol, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName)) 58378 if !(*(*uintptr)(unsafe.Pointer(bp + 88 /* zQuery */)) != 0) { 58379 return SQLITE_NOMEM 58380 } 58381 58382 for ii = 0; ii < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; ii++ { 58383 var pConstraint uintptr 58384 var pUsage uintptr 58385 var iCol int32 58386 58387 pConstraint = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12) 58388 pUsage = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8) 58389 58390 if !(isIgnoreUsable != 0) && !(int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fusable) != 0) { 58391 continue 58392 } 58393 58394 iCol = (*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).FiColumn 58395 if (iCol < 0) || (*(*int32)(unsafe.Pointer((*echo_vtab)(unsafe.Pointer(pVtab)).FaIndex + uintptr(iCol)*4)) != 0) { 58396 var zNewCol uintptr 58397 if iCol >= 0 { 58398 zNewCol = *(*uintptr)(unsafe.Pointer((*echo_vtab)(unsafe.Pointer(pVtab)).FaCol + uintptr(iCol)*8)) 58399 } else { 58400 zNewCol = ts + 27037 /* "rowid" */ 58401 } 58402 var zOp uintptr = uintptr(0) 58403 useIdx = 1 58404 switch int32((*sqlite3_index_constraint)(unsafe.Pointer(pConstraint)).Fop) { 58405 case SQLITE_INDEX_CONSTRAINT_EQ: 58406 zOp = ts + 27043 /* "=" */ 58407 break 58408 fallthrough 58409 case SQLITE_INDEX_CONSTRAINT_LT: 58410 zOp = ts + 27045 /* "<" */ 58411 break 58412 fallthrough 58413 case SQLITE_INDEX_CONSTRAINT_GT: 58414 zOp = ts + 27047 /* ">" */ 58415 break 58416 fallthrough 58417 case SQLITE_INDEX_CONSTRAINT_LE: 58418 zOp = ts + 27049 /* "<=" */ 58419 break 58420 fallthrough 58421 case SQLITE_INDEX_CONSTRAINT_GE: 58422 zOp = ts + 27052 /* ">=" */ 58423 break 58424 fallthrough 58425 case SQLITE_INDEX_CONSTRAINT_MATCH: 58426 // Purposely translate the MATCH operator into a LIKE, which 58427 // will be used by the next block of code to construct a new 58428 // query. It should also be noted here that the next block 58429 // of code requires the first letter of this operator to be 58430 // in upper-case to trigger the special MATCH handling (i.e. 58431 // wrapping the bound parameter with literal '%'s). 58432 zOp = ts + 27055 /* "LIKE" */ 58433 break 58434 fallthrough 58435 case SQLITE_INDEX_CONSTRAINT_LIKE: 58436 zOp = ts + 27060 /* "like" */ 58437 break 58438 fallthrough 58439 case SQLITE_INDEX_CONSTRAINT_GLOB: 58440 zOp = ts + 27065 /* "glob" */ 58441 break 58442 fallthrough 58443 case SQLITE_INDEX_CONSTRAINT_REGEXP: 58444 zOp = ts + 6345 /* "regexp" */ 58445 break 58446 } 58447 if zOp != 0 { 58448 if int32(*(*int8)(unsafe.Pointer(zOp))) == 'L' { 58449 zNew = sqlite3.Xsqlite3_mprintf(tls, ts+27070, /* " %s %s LIKE (SEL..." */ 58450 libc.VaList(bp+24, zSep, zNewCol)) 58451 } else { 58452 zNew = sqlite3.Xsqlite3_mprintf(tls, ts+27105 /* " %s %s %s ?" */, libc.VaList(bp+40, zSep, zNewCol, zOp)) 58453 } 58454 string_concat(tls, bp+88 /* &zQuery */, zNew, 1, bp+96 /* &rc */) 58455 zSep = ts + 8867 /* "AND" */ 58456 (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).FargvIndex = libc.PreIncInt32(&nArg, 1) 58457 (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).Fomit = uint8(1) 58458 } 58459 } 58460 } 58461 58462 // If there is only one term in the ORDER BY clause, and it is 58463 // on a column that this virtual table has an index for, then consume 58464 // the ORDER BY clause. 58465 if ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy == 1) && (((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).FiColumn < 0) || (*(*int32)(unsafe.Pointer((*echo_vtab)(unsafe.Pointer(pVtab)).FaIndex + uintptr((*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).FiColumn)*4)) != 0)) { 58466 var iCol int32 = (*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).FiColumn 58467 var zNewCol uintptr 58468 if iCol >= 0 { 58469 zNewCol = *(*uintptr)(unsafe.Pointer((*echo_vtab)(unsafe.Pointer(pVtab)).FaCol + uintptr(iCol)*8)) 58470 } else { 58471 zNewCol = ts + 27037 /* "rowid" */ 58472 } 58473 var zDir uintptr 58474 if (*sqlite3_index_orderby)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy)).Fdesc != 0 { 58475 zDir = ts + 27117 /* "DESC" */ 58476 } else { 58477 zDir = ts + 27122 /* "ASC" */ 58478 } 58479 zNew = sqlite3.Xsqlite3_mprintf(tls, ts+27126 /* " ORDER BY %s %s" */, libc.VaList(bp+64, zNewCol, zDir)) 58480 string_concat(tls, bp+88 /* &zQuery */, zNew, 1, bp+96 /* &rc */) 58481 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).ForderByConsumed = 1 58482 } 58483 58484 appendToEchoModule(tls, (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp, ts+26962 /* "xBestIndex" */) 58485 58486 appendToEchoModule(tls, (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp, *(*uintptr)(unsafe.Pointer(bp + 88 /* zQuery */))) 58487 58488 if !(*(*uintptr)(unsafe.Pointer(bp + 88 /* zQuery */)) != 0) { 58489 return *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) 58490 } 58491 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = hashString(tls, *(*uintptr)(unsafe.Pointer(bp + 88 /* zQuery */))) 58492 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = *(*uintptr)(unsafe.Pointer(bp + 88 /* zQuery */)) 58493 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FneedToFreeIdxStr = 1 58494 if useCost != 0 { 58495 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = cost 58496 } else if useIdx != 0 { 58497 // Approximation of log2(nRow). 58498 for ii = 0; uint64(ii) < ((uint64(unsafe.Sizeof(int32(0))) * uint64(8)) - uint64(1)); ii++ { 58499 if (nRow & (int32(1) << ii)) != 0 { 58500 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(ii) 58501 } 58502 } 58503 } else { 58504 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(nRow) 58505 } 58506 return *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) 58507 } 58508 58509 // The xUpdate method for echo module virtual tables. 58510 // 58511 // apData[0] apData[1] apData[2..] 58512 // 58513 // INTEGER DELETE 58514 // 58515 // INTEGER NULL (nCol args) UPDATE (do not set rowid) 58516 // INTEGER INTEGER (nCol args) UPDATE (with SET rowid = <arg1>) 58517 // 58518 // NULL NULL (nCol args) INSERT INTO (automatic rowid value) 58519 // NULL INTEGER (nCol args) INSERT (incl. rowid value) 58520 // 58521 func echoUpdate(tls *libc.TLS, tab uintptr, nData int32, apData uintptr, pRowid uintptr) int32 { /* test8.c:968:5: */ 58522 bp := tls.Alloc(136) 58523 defer tls.Free(136) 58524 58525 var pVtab uintptr = tab 58526 var db uintptr = (*echo_vtab)(unsafe.Pointer(pVtab)).Fdb 58527 *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = SQLITE_OK 58528 58529 *(*uintptr)(unsafe.Pointer(bp + 128 /* pStmt */)) = uintptr(0) 58530 *(*uintptr)(unsafe.Pointer(bp + 96 /* z */)) = uintptr(0) // SQL statement to execute 58531 var bindArgZero int32 = 0 // True to bind apData[0] to sql var no. nData 58532 var bindArgOne int32 = 0 // True to bind apData[1] to sql var no. 1 58533 var i int32 // Counter variable used by for loops 58534 58535 // Ticket #3083 - make sure we always start a transaction prior to 58536 // making any changes to a virtual table 58537 58538 if simulateVtabError(tls, pVtab, ts+27142 /* "xUpdate" */) != 0 { 58539 return SQLITE_ERROR 58540 } 58541 58542 // If apData[0] is an integer and nData>1 then do an UPDATE 58543 if (nData > 1) && (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apData))) == SQLITE_INTEGER) { 58544 var zSep uintptr = ts + 27150 /* " SET" */ 58545 *(*uintptr)(unsafe.Pointer(bp + 96 /* z */)) = sqlite3.Xsqlite3_mprintf(tls, ts+27155 /* "UPDATE %Q" */, libc.VaList(bp, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName)) 58546 if !(*(*uintptr)(unsafe.Pointer(bp + 96 /* z */)) != 0) { 58547 *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = SQLITE_NOMEM 58548 } 58549 58550 bindArgOne = (libc.Bool32((*(*uintptr)(unsafe.Pointer(apData + 1*8)) != 0) && (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apData + 1*8))) == SQLITE_INTEGER))) 58551 bindArgZero = 1 58552 58553 if bindArgOne != 0 { 58554 string_concat(tls, bp+96 /* &z */, ts+27165 /* " SET rowid=?1 " */, 0, bp+104 /* &rc */) 58555 zSep = ts + 4629 /* "," */ 58556 } 58557 for i = 2; i < nData; i++ { 58558 if *(*uintptr)(unsafe.Pointer(apData + uintptr(i)*8)) == uintptr(0) { 58559 continue 58560 } 58561 string_concat(tls, bp+96 /* &z */, sqlite3.Xsqlite3_mprintf(tls, 58562 ts+27180 /* "%s %Q=?%d" */, libc.VaList(bp+8, zSep, *(*uintptr)(unsafe.Pointer((*echo_vtab)(unsafe.Pointer(pVtab)).FaCol + uintptr((i-2))*8)), i)), 1, bp+104 /* &rc */) 58563 zSep = ts + 4629 /* "," */ 58564 } 58565 string_concat(tls, bp+96 /* &z */, sqlite3.Xsqlite3_mprintf(tls, ts+27190 /* " WHERE rowid=?%d" */, libc.VaList(bp+32, nData)), 1, bp+104 /* &rc */) 58566 } else if (nData == 1) && (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apData))) == SQLITE_INTEGER) { 58567 *(*uintptr)(unsafe.Pointer(bp + 96 /* z */)) = sqlite3.Xsqlite3_mprintf(tls, ts+27207 /* "DELETE FROM %Q W..." */, libc.VaList(bp+40, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName)) 58568 if !(*(*uintptr)(unsafe.Pointer(bp + 96 /* z */)) != 0) { 58569 *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = SQLITE_NOMEM 58570 } 58571 bindArgZero = 1 58572 } else if (nData > 2) && (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apData))) == SQLITE_NULL) { 58573 var ii int32 58574 *(*uintptr)(unsafe.Pointer(bp + 112 /* zInsert */)) = uintptr(0) 58575 *(*uintptr)(unsafe.Pointer(bp + 120 /* zValues */)) = uintptr(0) 58576 58577 *(*uintptr)(unsafe.Pointer(bp + 112 /* zInsert */)) = sqlite3.Xsqlite3_mprintf(tls, ts+27239 /* "INSERT INTO %Q (" */, libc.VaList(bp+48, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName)) 58578 if !(*(*uintptr)(unsafe.Pointer(bp + 112 /* zInsert */)) != 0) { 58579 *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = SQLITE_NOMEM 58580 } 58581 if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apData + 1*8))) == SQLITE_INTEGER { 58582 bindArgOne = 1 58583 *(*uintptr)(unsafe.Pointer(bp + 120 /* zValues */)) = sqlite3.Xsqlite3_mprintf(tls, ts+3276 /* "?" */, 0) 58584 string_concat(tls, bp+112 /* &zInsert */, ts+27037 /* "rowid" */, 0, bp+104 /* &rc */) 58585 } 58586 58587 for ii = 2; ii < nData; ii++ { 58588 string_concat(tls, bp+112, /* &zInsert */ 58589 sqlite3.Xsqlite3_mprintf(tls, ts+27256 /* "%s%Q" */, libc.VaList(bp+56, func() uintptr { 58590 if *(*uintptr)(unsafe.Pointer(bp + 120 /* zValues */)) != 0 { 58591 return ts + 90 /* ", " */ 58592 } 58593 return ts + 489 /* "" */ 58594 }(), *(*uintptr)(unsafe.Pointer((*echo_vtab)(unsafe.Pointer(pVtab)).FaCol + uintptr((ii-2))*8)))), 1, bp+104 /* &rc */) 58595 string_concat(tls, bp+120, /* &zValues */ 58596 sqlite3.Xsqlite3_mprintf(tls, ts+27261 /* "%s?%d" */, libc.VaList(bp+72, func() uintptr { 58597 if *(*uintptr)(unsafe.Pointer(bp + 120 /* zValues */)) != 0 { 58598 return ts + 90 /* ", " */ 58599 } 58600 return ts + 489 /* "" */ 58601 }(), ii)), 1, bp+104 /* &rc */) 58602 } 58603 58604 string_concat(tls, bp+96 /* &z */, *(*uintptr)(unsafe.Pointer(bp + 112 /* zInsert */)), 1, bp+104 /* &rc */) 58605 string_concat(tls, bp+96 /* &z */, ts+27267 /* ") VALUES(" */, 0, bp+104 /* &rc */) 58606 string_concat(tls, bp+96 /* &z */, *(*uintptr)(unsafe.Pointer(bp + 120 /* zValues */)), 1, bp+104 /* &rc */) 58607 string_concat(tls, bp+96 /* &z */, ts+490 /* ")" */, 0, bp+104 /* &rc */) 58608 } else { 58609 58610 return SQLITE_ERROR 58611 } 58612 58613 if *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) == SQLITE_OK { 58614 *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = sqlite3.Xsqlite3_prepare(tls, db, *(*uintptr)(unsafe.Pointer(bp + 96 /* z */)), -1, bp+128 /* &pStmt */, uintptr(0)) 58615 } 58616 58617 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 96 /* z */))) 58618 if *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) == SQLITE_OK { 58619 if bindArgZero != 0 { 58620 sqlite3.Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp + 128 /* pStmt */)), nData, *(*uintptr)(unsafe.Pointer(apData))) 58621 } 58622 if bindArgOne != 0 { 58623 sqlite3.Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp + 128 /* pStmt */)), 1, *(*uintptr)(unsafe.Pointer(apData + 1*8))) 58624 } 58625 for i = 2; (i < nData) && (*(*int32)(unsafe.Pointer(bp + 104 /* rc */)) == SQLITE_OK); i++ { 58626 if *(*uintptr)(unsafe.Pointer(apData + uintptr(i)*8)) != 0 { 58627 *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = sqlite3.Xsqlite3_bind_value(tls, *(*uintptr)(unsafe.Pointer(bp + 128 /* pStmt */)), i, *(*uintptr)(unsafe.Pointer(apData + uintptr(i)*8))) 58628 } 58629 } 58630 if *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) == SQLITE_OK { 58631 sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 128 /* pStmt */))) 58632 *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 128 /* pStmt */))) 58633 } else { 58634 sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 128 /* pStmt */))) 58635 } 58636 } 58637 58638 if (pRowid != 0) && (*(*int32)(unsafe.Pointer(bp + 104 /* rc */)) == SQLITE_OK) { 58639 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite3.Xsqlite3_last_insert_rowid(tls, db) 58640 } 58641 if *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) != SQLITE_OK { 58642 (*sqlite3_vtab)(unsafe.Pointer(tab)).FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+26650 /* "echo-vtab-error:..." */, libc.VaList(bp+88, sqlite3.Xsqlite3_errmsg(tls, db))) 58643 } 58644 58645 return *(*int32)(unsafe.Pointer(bp + 104 /* rc */)) 58646 } 58647 58648 // xBegin, xSync, xCommit and xRollback callbacks for echo module 58649 // virtual tables. Do nothing other than add the name of the callback 58650 // to the $::echo_module Tcl variable. 58651 func echoTransactionCall(tls *libc.TLS, tab uintptr, zCall uintptr) int32 { /* test8.c:1101:12: */ 58652 bp := tls.Alloc(8) 58653 defer tls.Free(8) 58654 58655 var z uintptr 58656 var pVtab uintptr = tab 58657 z = sqlite3.Xsqlite3_mprintf(tls, ts+27277 /* "echo(%s)" */, libc.VaList(bp, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName)) 58658 if z == uintptr(0) { 58659 return SQLITE_NOMEM 58660 } 58661 appendToEchoModule(tls, (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp, zCall) 58662 appendToEchoModule(tls, (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp, z) 58663 sqlite3.Xsqlite3_free(tls, z) 58664 return SQLITE_OK 58665 } 58666 58667 func echoBegin(tls *libc.TLS, tab uintptr) int32 { /* test8.c:1111:12: */ 58668 var rc int32 58669 var pVtab uintptr = tab 58670 var interp uintptr = (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp 58671 var zVal uintptr 58672 58673 // Ticket #3083 - do not start a transaction if we are already in 58674 // a transaction 58675 58676 if simulateVtabError(tls, pVtab, ts+27286 /* "xBegin" */) != 0 { 58677 return SQLITE_ERROR 58678 } 58679 58680 rc = echoTransactionCall(tls, tab, ts+27286 /* "xBegin" */) 58681 58682 if rc == SQLITE_OK { 58683 // Check if the $::echo_module_begin_fail variable is defined. If it is, 58684 // and it is set to the name of the real table underlying this virtual 58685 // echo module table, then cause this xSync operation to fail. 58686 zVal = tcl.XTcl_GetVar2(tls, interp, ts+27293 /* "echo_module_begi..." */, uintptr(0), TCL_GLOBAL_ONLY) 58687 if (zVal != 0) && (0 == libc.Xstrcmp(tls, zVal, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName)) { 58688 rc = SQLITE_ERROR 58689 } 58690 } 58691 if rc == SQLITE_OK { 58692 (*echo_vtab)(unsafe.Pointer(pVtab)).FinTransaction = 1 58693 } 58694 return rc 58695 } 58696 58697 func echoSync(tls *libc.TLS, tab uintptr) int32 { /* test8.c:1142:12: */ 58698 var rc int32 58699 var pVtab uintptr = tab 58700 var interp uintptr = (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp 58701 var zVal uintptr 58702 58703 // Ticket #3083 - Only call xSync if we have previously started a 58704 // transaction 58705 58706 if simulateVtabError(tls, pVtab, ts+27316 /* "xSync" */) != 0 { 58707 return SQLITE_ERROR 58708 } 58709 58710 rc = echoTransactionCall(tls, tab, ts+27316 /* "xSync" */) 58711 58712 if rc == SQLITE_OK { 58713 // Check if the $::echo_module_sync_fail variable is defined. If it is, 58714 // and it is set to the name of the real table underlying this virtual 58715 // echo module table, then cause this xSync operation to fail. 58716 zVal = tcl.XTcl_GetVar2(tls, interp, ts+27322 /* "echo_module_sync..." */, uintptr(0), TCL_GLOBAL_ONLY) 58717 if (zVal != 0) && (0 == libc.Xstrcmp(tls, zVal, (*echo_vtab)(unsafe.Pointer(pVtab)).FzTableName)) { 58718 rc = -1 58719 } 58720 } 58721 return rc 58722 } 58723 58724 func echoCommit(tls *libc.TLS, tab uintptr) int32 { /* test8.c:1170:12: */ 58725 var pVtab uintptr = tab 58726 var rc int32 58727 58728 // Ticket #3083 - Only call xCommit if we have previously started 58729 // a transaction 58730 58731 if simulateVtabError(tls, pVtab, ts+27344 /* "xCommit" */) != 0 { 58732 return SQLITE_ERROR 58733 } 58734 58735 sqlite3.Xsqlite3BeginBenignMalloc(tls) 58736 rc = echoTransactionCall(tls, tab, ts+27344 /* "xCommit" */) 58737 sqlite3.Xsqlite3EndBenignMalloc(tls) 58738 (*echo_vtab)(unsafe.Pointer(pVtab)).FinTransaction = 0 58739 return rc 58740 } 58741 58742 func echoRollback(tls *libc.TLS, tab uintptr) int32 { /* test8.c:1188:12: */ 58743 var rc int32 58744 var pVtab uintptr = tab 58745 58746 // Ticket #3083 - Only call xRollback if we have previously started 58747 // a transaction 58748 58749 rc = echoTransactionCall(tls, tab, ts+27352 /* "xRollback" */) 58750 (*echo_vtab)(unsafe.Pointer(pVtab)).FinTransaction = 0 58751 return rc 58752 } 58753 58754 // Implementation of "GLOB" function on the echo module. Pass 58755 // all arguments to the ::echo_glob_overload procedure of TCL 58756 // and return the result of that procedure as a string. 58757 func overloadedGlobFunction(tls *libc.TLS, pContext uintptr, nArg int32, apArg uintptr) { /* test8.c:1206:13: */ 58758 bp := tls.Alloc(216) 58759 defer tls.Free(216) 58760 58761 var interp uintptr = sqlite3.Xsqlite3_user_data(tls, pContext) 58762 // var str Tcl_DString at bp, 216 58763 58764 var i int32 58765 var rc int32 58766 tcl.XTcl_DStringInit(tls, bp /* &str */) 58767 tcl.XTcl_DStringAppendElement(tls, bp /* &str */, ts+27362 /* "::echo_glob_over..." */) 58768 for i = 0; i < nArg; i++ { 58769 tcl.XTcl_DStringAppendElement(tls, bp /* &str */, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(i)*8)))) 58770 } 58771 rc = tcl.XTcl_Eval(tls, interp, (*Tcl_DString)(unsafe.Pointer(bp /* &str */)).Fstring) 58772 tcl.XTcl_DStringFree(tls, bp /* &str */) 58773 if rc != 0 { 58774 sqlite3.Xsqlite3_result_error(tls, pContext, tcl.XTcl_GetStringResult(tls, interp), -1) 58775 } else { 58776 sqlite3.Xsqlite3_result_text(tls, pContext, tcl.XTcl_GetStringResult(tls, interp), 58777 -1, libc.UintptrFromInt32(-1)) 58778 } 58779 tcl.XTcl_ResetResult(tls, interp) 58780 } 58781 58782 // This is the xFindFunction implementation for the echo module. 58783 // SQLite calls this routine when the first argument of a function 58784 // is a column of an echo virtual table. This routine can optionally 58785 // override the implementation of that function. It will choose to 58786 // do so if the function is named "glob", and a TCL command named 58787 // ::echo_glob_overload exists. 58788 func echoFindFunction(tls *libc.TLS, vtab uintptr, nArg int32, zFuncName uintptr, pxFunc uintptr, ppArg uintptr) int32 { /* test8.c:1239:12: */ 58789 bp := tls.Alloc(64) 58790 defer tls.Free(64) 58791 58792 var pVtab uintptr = vtab 58793 var interp uintptr = (*echo_vtab)(unsafe.Pointer(pVtab)).Finterp 58794 // var info Tcl_CmdInfo at bp, 64 58795 58796 if libc.Xstrcmp(tls, zFuncName, ts+27065 /* "glob" */) != 0 { 58797 return 0 58798 } 58799 if tcl.XTcl_GetCommandInfo(tls, interp, ts+27362 /* "::echo_glob_over..." */, bp /* &info */) == 0 { 58800 return 0 58801 } 58802 *(*uintptr)(unsafe.Pointer(pxFunc)) = *(*uintptr)(unsafe.Pointer(&struct { 58803 f func(*libc.TLS, uintptr, int32, uintptr) 58804 }{overloadedGlobFunction})) 58805 *(*uintptr)(unsafe.Pointer(ppArg)) = interp 58806 return 1 58807 } 58808 58809 func echoRename(tls *libc.TLS, vtab uintptr, zNewName uintptr) int32 { /* test8.c:1260:12: */ 58810 bp := tls.Alloc(24) 58811 defer tls.Free(24) 58812 58813 var rc int32 = SQLITE_OK 58814 var p uintptr = vtab 58815 58816 if simulateVtabError(tls, p, ts+27383 /* "xRename" */) != 0 { 58817 return SQLITE_ERROR 58818 } 58819 58820 if (*echo_vtab)(unsafe.Pointer(p)).FisPattern != 0 { 58821 var nThis int32 = int32(libc.Xstrlen(tls, (*echo_vtab)(unsafe.Pointer(p)).FzThis)) 58822 var zSql uintptr = sqlite3.Xsqlite3_mprintf(tls, ts+27391, /* "ALTER TABLE %s R..." */ 58823 libc.VaList(bp, (*echo_vtab)(unsafe.Pointer(p)).FzTableName, zNewName, ((*echo_vtab)(unsafe.Pointer(p)).FzTableName+uintptr(nThis)))) 58824 rc = sqlite3.Xsqlite3_exec(tls, (*echo_vtab)(unsafe.Pointer(p)).Fdb, zSql, uintptr(0), uintptr(0), uintptr(0)) 58825 sqlite3.Xsqlite3_free(tls, zSql) 58826 } 58827 58828 return rc 58829 } 58830 58831 func echoSavepoint(tls *libc.TLS, pVTab uintptr, iSavepoint int32) int32 { /* test8.c:1280:12: */ 58832 58833 return SQLITE_OK 58834 } 58835 58836 func echoRelease(tls *libc.TLS, pVTab uintptr, iSavepoint int32) int32 { /* test8.c:1285:12: */ 58837 58838 return SQLITE_OK 58839 } 58840 58841 func echoRollbackTo(tls *libc.TLS, pVTab uintptr, iSavepoint int32) int32 { /* test8.c:1290:12: */ 58842 58843 return SQLITE_OK 58844 } 58845 58846 // A virtual table module that merely "echos" the contents of another 58847 // table (like an SQL VIEW). 58848 var echoModule = sqlite3_module{ 58849 FiVersion: 1, // iVersion 58850 FxCreate: 0, 58851 FxConnect: 0, 58852 FxBestIndex: 0, 58853 FxDisconnect: 0, 58854 FxDestroy: 0, 58855 FxOpen: 0, // xOpen - open a cursor 58856 FxClose: 0, // xClose - close a cursor 58857 FxFilter: 0, // xFilter - configure scan constraints 58858 FxNext: 0, // xNext - advance a cursor 58859 FxEof: 0, // xEof 58860 FxColumn: 0, // xColumn - read data 58861 FxRowid: 0, // xRowid - read data 58862 FxUpdate: 0, // xUpdate - write data 58863 FxBegin: 0, // xBegin - begin transaction 58864 FxSync: 0, // xSync - sync transaction 58865 FxCommit: 0, // xCommit - commit transaction 58866 FxRollback: 0, // xRollback - rollback transaction 58867 FxFindFunction: 0, // xFindFunction - function overloading 58868 FxRename: 0, // xRename - rename the table 58869 } /* test8.c:1299:23 */ 58870 58871 var echoModuleV2 = sqlite3_module{ 58872 FiVersion: 2, // iVersion 58873 FxCreate: 0, 58874 FxConnect: 0, 58875 FxBestIndex: 0, 58876 FxDisconnect: 0, 58877 FxDestroy: 0, 58878 FxOpen: 0, // xOpen - open a cursor 58879 FxClose: 0, // xClose - close a cursor 58880 FxFilter: 0, // xFilter - configure scan constraints 58881 FxNext: 0, // xNext - advance a cursor 58882 FxEof: 0, // xEof 58883 FxColumn: 0, // xColumn - read data 58884 FxRowid: 0, // xRowid - read data 58885 FxUpdate: 0, // xUpdate - write data 58886 FxBegin: 0, // xBegin - begin transaction 58887 FxSync: 0, // xSync - sync transaction 58888 FxCommit: 0, // xCommit - commit transaction 58889 FxRollback: 0, // xRollback - rollback transaction 58890 FxFindFunction: 0, // xFindFunction - function overloading 58891 FxRename: 0, // xRename - rename the table 58892 FxSavepoint: 0, 58893 FxRelease: 0, 58894 FxRollbackTo: 0, 58895 } /* test8.c:1322:23 */ 58896 58897 func moduleDestroy(tls *libc.TLS, p uintptr) { /* test8.c:1354:13: */ 58898 sqlite3.Xsqlite3_free(tls, p) 58899 } 58900 58901 // Register the echo virtual table module. 58902 func register_echo_module(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test8.c:1361:26: */ 58903 bp := tls.Alloc(8) 58904 defer tls.Free(8) 58905 58906 var rc int32 58907 // var db uintptr at bp, 8 58908 58909 var pMod uintptr 58910 if objc != 2 { 58911 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 58912 return TCL_ERROR 58913 } 58914 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 58915 return TCL_ERROR 58916 } 58917 58918 // Virtual table module "echo" 58919 pMod = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(EchoModule{}))) 58920 (*EchoModule)(unsafe.Pointer(pMod)).Finterp = interp 58921 rc = sqlite3.Xsqlite3_create_module_v2(tls, 58922 *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+27421 /* "echo" */, uintptr(unsafe.Pointer(&echoModule)), pMod, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{moduleDestroy}))) 58923 58924 // Virtual table module "echo_v2" 58925 if rc == SQLITE_OK { 58926 pMod = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(EchoModule{}))) 58927 (*EchoModule)(unsafe.Pointer(pMod)).Finterp = interp 58928 rc = sqlite3.Xsqlite3_create_module_v2(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+27426, /* "echo_v2" */ 58929 uintptr(unsafe.Pointer(&echoModuleV2)), pMod, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{moduleDestroy}))) 58930 } 58931 58932 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 58933 return TCL_OK 58934 } 58935 58936 // Tcl interface to sqlite3_declare_vtab, invoked as follows from Tcl: 58937 // 58938 // sqlite3_declare_vtab DB SQL 58939 func declare_vtab(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test8.c:1401:26: */ 58940 bp := tls.Alloc(8) 58941 defer tls.Free(8) 58942 58943 // var db uintptr at bp, 8 58944 58945 var rc int32 58946 if objc != 3 { 58947 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+27434 /* "DB SQL" */) 58948 return TCL_ERROR 58949 } 58950 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 58951 return TCL_ERROR 58952 } 58953 rc = sqlite3.Xsqlite3_declare_vtab(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)))) 58954 if rc != SQLITE_OK { 58955 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp /* db */))), uintptr(1)) 58956 return TCL_ERROR 58957 } 58958 return TCL_OK 58959 } 58960 58961 // Register commands with the TCL interpreter. 58962 func Sqlitetest8_Init(tls *libc.TLS, interp uintptr) int32 { /* test8.c:1427:5: */ 58963 var i int32 58964 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aObjCmd2)) / uint64(unsafe.Sizeof(struct { 58965 FzName uintptr 58966 FxProc uintptr 58967 FclientData uintptr 58968 }{}))); i++ { 58969 tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd2[i].FzName, 58970 aObjCmd2[i].FxProc, aObjCmd2[i].FclientData, uintptr(0)) 58971 } 58972 return TCL_OK 58973 } 58974 58975 var aObjCmd2 = [2]struct { 58976 FzName uintptr 58977 FxProc uintptr 58978 FclientData uintptr 58979 }{ 58980 {FzName: ts + 27441 /* "register_echo_mo..." */, FxProc: 0}, 58981 {FzName: ts + 27462 /* "sqlite3_declare_..." */, FxProc: 0}, 58982 } /* test8.c:1433:5 */ 58983 58984 // end block for C++ 58985 58986 // Local Variables: 58987 // mode: c 58988 // c-basic-offset: 4 58989 // fill-column: 78 58990 // End: 58991 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 58992 // This file is part of the GNU C Library. 58993 // 58994 // The GNU C Library is free software; you can redistribute it and/or 58995 // modify it under the terms of the GNU Lesser General Public 58996 // License as published by the Free Software Foundation; either 58997 // version 2.1 of the License, or (at your option) any later version. 58998 // 58999 // The GNU C Library is distributed in the hope that it will be useful, 59000 // but WITHOUT ANY WARRANTY; without even the implied warranty of 59001 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 59002 // Lesser General Public License for more details. 59003 // 59004 // You should have received a copy of the GNU Lesser General Public 59005 // License along with the GNU C Library; if not, see 59006 // <http://www.gnu.org/licenses/>. 59007 59008 // ISO C99 Standard: 7.20 General utilities <stdlib.h> 59009 59010 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 59011 // This file is part of the GNU C Library. 59012 // 59013 // The GNU C Library is free software; you can redistribute it and/or 59014 // modify it under the terms of the GNU Lesser General Public 59015 // License as published by the Free Software Foundation; either 59016 // version 2.1 of the License, or (at your option) any later version. 59017 // 59018 // The GNU C Library is distributed in the hope that it will be useful, 59019 // but WITHOUT ANY WARRANTY; without even the implied warranty of 59020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 59021 // Lesser General Public License for more details. 59022 // 59023 // You should have received a copy of the GNU Lesser General Public 59024 // License along with the GNU C Library; if not, see 59025 // <http://www.gnu.org/licenses/>. 59026 59027 // ISO C99 Standard: 7.21 String handling <string.h> 59028 59029 // c_collation_test 59030 func c_collation_test(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test9.c:29:26: */ 59031 bp := tls.Alloc(32) 59032 defer tls.Free(32) 59033 59034 var zErrFunction uintptr 59035 // var db uintptr at bp+24, 8 59036 59037 var rc int32 59038 zErrFunction = ts + 27483 /* "N/A" */ 59039 if !(objc != 1) { 59040 goto __1 59041 } 59042 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 59043 return TCL_ERROR 59044 __1: 59045 ; 59046 59047 // Open a database. 59048 rc = sqlite3.Xsqlite3_open(tls, ts+1662 /* ":memory:" */, bp+24 /* &db */) 59049 if !(rc != SQLITE_OK) { 59050 goto __2 59051 } 59052 zErrFunction = ts + 20981 /* "sqlite3_open" */ 59053 goto error_out 59054 __2: 59055 ; 59056 59057 rc = sqlite3.Xsqlite3_create_collation(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */)), ts+13096 /* "collate" */, 456, uintptr(0), uintptr(0)) 59058 if !(rc != SQLITE_MISUSE) { 59059 goto __3 59060 } 59061 sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */))) 59062 zErrFunction = ts + 27487 /* "sqlite3_create_c..." */ 59063 goto error_out 59064 __3: 59065 ; 59066 59067 sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */))) 59068 return TCL_OK 59069 59070 error_out: 59071 tcl.XTcl_ResetResult(tls, interp) 59072 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+27512 /* "Error testing fu..." */, zErrFunction, 0)) 59073 return TCL_ERROR 59074 } 59075 59076 // c_realloc_test 59077 func c_realloc_test(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test9.c:70:26: */ 59078 bp := tls.Alloc(24) 59079 defer tls.Free(24) 59080 59081 var p uintptr 59082 var zErrFunction uintptr 59083 zErrFunction = ts + 27483 /* "N/A" */ 59084 59085 if !(objc != 1) { 59086 goto __1 59087 } 59088 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 59089 return TCL_ERROR 59090 __1: 59091 ; 59092 59093 p = sqlite3.Xsqlite3_malloc(tls, 5) 59094 if !(!(p != 0)) { 59095 goto __2 59096 } 59097 zErrFunction = ts + 27537 /* "sqlite3_malloc" */ 59098 goto error_out 59099 __2: 59100 ; 59101 59102 // Test that realloc()ing a block of memory to a negative size is 59103 // the same as free()ing that memory. 59104 p = sqlite3.Xsqlite3_realloc(tls, p, -1) 59105 if !(p != 0) { 59106 goto __3 59107 } 59108 zErrFunction = ts + 27552 /* "sqlite3_realloc" */ 59109 goto error_out 59110 __3: 59111 ; 59112 59113 return TCL_OK 59114 59115 error_out: 59116 tcl.XTcl_ResetResult(tls, interp) 59117 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+27512 /* "Error testing fu..." */, zErrFunction, 0)) 59118 return TCL_ERROR 59119 } 59120 59121 // c_misuse_test 59122 func c_misuse_test(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test9.c:111:26: */ 59123 bp := tls.Alloc(40) 59124 defer tls.Free(40) 59125 59126 var zErrFunction uintptr 59127 // var db uintptr at bp+24, 8 59128 59129 // var pStmt uintptr at bp+32, 8 59130 59131 var rc int32 59132 zErrFunction = ts + 27483 /* "N/A" */ 59133 *(*uintptr)(unsafe.Pointer(bp + 24 /* db */)) = uintptr(0) 59134 59135 if !(objc != 1) { 59136 goto __1 59137 } 59138 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 59139 return TCL_ERROR 59140 __1: 59141 ; 59142 59143 // Open a database. Then close it again. We need to do this so that 59144 // we have a "closed database handle" to pass to various API functions. 59145 rc = sqlite3.Xsqlite3_open(tls, ts+1662 /* ":memory:" */, bp+24 /* &db */) 59146 if !(rc != SQLITE_OK) { 59147 goto __2 59148 } 59149 zErrFunction = ts + 20981 /* "sqlite3_open" */ 59150 goto error_out 59151 __2: 59152 ; 59153 sqlite3.Xsqlite3_close(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */))) 59154 59155 rc = sqlite3.Xsqlite3_errcode(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */))) 59156 if !(rc != SQLITE_MISUSE) { 59157 goto __3 59158 } 59159 zErrFunction = ts + 20908 /* "sqlite3_errcode" */ 59160 goto error_out 59161 __3: 59162 ; 59163 59164 *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)) = uintptr(1234) 59165 rc = sqlite3.Xsqlite3_prepare(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */)), uintptr(0), 0, bp+32 /* &pStmt */, uintptr(0)) 59166 if !(rc != SQLITE_MISUSE) { 59167 goto __4 59168 } 59169 zErrFunction = ts + 21062 /* "sqlite3_prepare" */ 59170 goto error_out 59171 __4: 59172 ; 59173 // Verify that pStmt is zeroed even on a MISUSE error 59174 59175 *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)) = uintptr(1234) 59176 rc = sqlite3.Xsqlite3_prepare_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */)), uintptr(0), 0, bp+32 /* &pStmt */, uintptr(0)) 59177 if !(rc != SQLITE_MISUSE) { 59178 goto __5 59179 } 59180 zErrFunction = ts + 21096 /* "sqlite3_prepare_..." */ 59181 goto error_out 59182 __5: 59183 ; 59184 59185 *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)) = uintptr(1234) 59186 rc = sqlite3.Xsqlite3_prepare16(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */)), uintptr(0), 0, bp+32 /* &pStmt */, uintptr(0)) 59187 if !(rc != SQLITE_MISUSE) { 59188 goto __6 59189 } 59190 zErrFunction = ts + 21078 /* "sqlite3_prepare1..." */ 59191 goto error_out 59192 __6: 59193 ; 59194 59195 *(*uintptr)(unsafe.Pointer(bp + 32 /* pStmt */)) = uintptr(1234) 59196 rc = sqlite3.Xsqlite3_prepare16_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* db */)), uintptr(0), 0, bp+32 /* &pStmt */, uintptr(0)) 59197 if !(rc != SQLITE_MISUSE) { 59198 goto __7 59199 } 59200 zErrFunction = ts + 21158 /* "sqlite3_prepare1..." */ 59201 goto error_out 59202 __7: 59203 ; 59204 59205 return TCL_OK 59206 59207 error_out: 59208 tcl.XTcl_ResetResult(tls, interp) 59209 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+27512 /* "Error testing fu..." */, zErrFunction, 0)) 59210 return TCL_ERROR 59211 } 59212 59213 // Register commands with the TCL interpreter. 59214 func Sqlitetest9_Init(tls *libc.TLS, interp uintptr) int32 { /* test9.c:188:5: */ 59215 var i int32 59216 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aObjCmd3)) / uint64(unsafe.Sizeof(struct { 59217 FzName uintptr 59218 FxProc uintptr 59219 FclientData uintptr 59220 }{}))); i++ { 59221 tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd3[i].FzName, 59222 aObjCmd3[i].FxProc, aObjCmd3[i].FclientData, uintptr(0)) 59223 } 59224 return TCL_OK 59225 } 59226 59227 var aObjCmd3 = [3]struct { 59228 FzName uintptr 59229 FxProc uintptr 59230 FclientData uintptr 59231 }{ 59232 {FzName: ts + 27568 /* "c_misuse_test" */, FxProc: 0}, 59233 {FzName: ts + 27582 /* "c_realloc_test" */, FxProc: 0}, 59234 {FzName: ts + 27597 /* "c_collation_test" */, FxProc: 0}, 59235 } /* test9.c:193:5 */ 59236 59237 // end block for C++ 59238 59239 // Local Variables: 59240 // mode: c 59241 // c-basic-offset: 4 59242 // fill-column: 78 59243 // End: 59244 59245 // This routine registers the custom TCL commands defined in this 59246 // module. This should be the only procedure visible from outside 59247 // of this module. 59248 func Sqlitetestasync_Init(tls *libc.TLS, interp uintptr) int32 { /* test_async.c:238:5: */ 59249 return TCL_OK 59250 } 59251 59252 // The following macros redefine the API routines so that they are 59253 // redirected through the global sqlite3_api structure. 59254 // 59255 // This header file is also used by the loadext.c source file 59256 // (part of the main SQLite library - not an extension) so that 59257 // it can get access to the sqlite3_api_routines structure 59258 // definition. But the main library does not want to redefine 59259 // the API. So the redefinition macros are only valid if the 59260 // SQLITE_CORE macros is undefined. 59261 59262 // This case when the file is being statically linked into the 59263 // application 59264 59265 // tclcmd: sqlite3_reset_auto_extension 59266 // 59267 // Reset all auto-extensions 59268 func resetAutoExtObjCmd(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_autoext.c:196:26: */ 59269 sqlite3.Xsqlite3_reset_auto_extension(tls) 59270 return SQLITE_OK 59271 } 59272 59273 // This procedure registers the TCL procs defined in this file. 59274 func Sqlitetest_autoext_Init(tls *libc.TLS, interp uintptr) int32 { /* test_autoext.c:210:5: */ 59275 tcl.XTcl_CreateObjCommand(tls, interp, ts+27614, /* "sqlite3_reset_au..." */ 59276 *(*uintptr)(unsafe.Pointer(&struct { 59277 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 59278 }{resetAutoExtObjCmd})), uintptr(0), uintptr(0)) 59279 return TCL_OK 59280 } 59281 59282 func backupTestCmd(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_backup.c:33:26: */ 59283 bp := tls.Alloc(196) 59284 defer tls.Free(196) 59285 59286 *(*[5]BackupSubCommand)(unsafe.Pointer(bp /* aSub */)) = [5]BackupSubCommand{ 59287 {FzCmd: ts + 10122 /* "step" */, FnArg: 1, FzArg: ts + 27643 /* "npage" */}, 59288 {FzCmd: ts + 27649 /* "finish" */, FeCmd: uint32(1) /* BACKUP_FINISH */, FzArg: ts + 489 /* "" */}, 59289 {FzCmd: ts + 27656 /* "remaining" */, FeCmd: uint32(2) /* BACKUP_REMAINING */, FzArg: ts + 489 /* "" */}, 59290 {FzCmd: ts + 27666 /* "pagecount" */, FeCmd: uint32(3) /* BACKUP_PAGECOUNT */, FzArg: ts + 489 /* "" */}, 59291 {}, 59292 } 59293 59294 var p uintptr = clientData 59295 // var iCmd int32 at bp+120, 4 59296 59297 var rc int32 59298 59299 rc = tcl.XTcl_GetIndexFromObjStruct(tls, 59300 interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &aSub[0] */, int32(unsafe.Sizeof(BackupSubCommand{})), ts+11375 /* "option" */, 0, bp+120 /* &iCmd */) 59301 if rc != TCL_OK { 59302 return rc 59303 } 59304 if objc != (2 + (*BackupSubCommand)(unsafe.Pointer(bp /* &aSub */ +uintptr(*(*int32)(unsafe.Pointer(bp + 120 /* iCmd */)))*24)).FnArg) { 59305 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, (*BackupSubCommand)(unsafe.Pointer(bp /* &aSub */ +uintptr(*(*int32)(unsafe.Pointer(bp + 120 /* iCmd */)))*24)).FzArg) 59306 return TCL_ERROR 59307 } 59308 59309 switch (*BackupSubCommand)(unsafe.Pointer(bp /* &aSub */ + uintptr(*(*int32)(unsafe.Pointer(bp + 120 /* iCmd */)))*24)).FeCmd { 59310 59311 case uint32(1) /* BACKUP_FINISH */ : 59312 { 59313 var zCmdName uintptr 59314 // var cmdInfo Tcl_CmdInfo at bp+128, 64 59315 59316 zCmdName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))) 59317 tcl.XTcl_GetCommandInfo(tls, interp, zCmdName, bp+128 /* &cmdInfo */) 59318 (*Tcl_CmdInfo)(unsafe.Pointer(bp + 128 /* &cmdInfo */)).FdeleteProc = uintptr(0) 59319 tcl.XTcl_SetCommandInfo(tls, interp, zCmdName, bp+128 /* &cmdInfo */) 59320 tcl.XTcl_DeleteCommand(tls, interp, zCmdName) 59321 59322 rc = sqlite3.Xsqlite3_backup_finish(tls, p) 59323 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 59324 break 59325 59326 } 59327 59328 case uint32(0) /* BACKUP_STEP */ : 59329 { 59330 // var nPage int32 at bp+192, 4 59331 59332 if TCL_OK != tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+192 /* &nPage */) { 59333 return TCL_ERROR 59334 } 59335 rc = sqlite3.Xsqlite3_backup_step(tls, p, *(*int32)(unsafe.Pointer(bp + 192 /* nPage */))) 59336 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 59337 break 59338 59339 } 59340 59341 case uint32(2) /* BACKUP_REMAINING */ : 59342 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_backup_remaining(tls, p))) 59343 break 59344 59345 case uint32(3) /* BACKUP_PAGECOUNT */ : 59346 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_backup_pagecount(tls, p))) 59347 break 59348 } 59349 59350 return TCL_OK 59351 } 59352 59353 type BackupSubCommand = struct { 59354 FzCmd uintptr 59355 FeCmd uint32 59356 FnArg int32 59357 FzArg uintptr 59358 } /* test_backup.c:42:3 */ 59359 59360 func backupTestFinish(tls *libc.TLS, clientData ClientData) { /* test_backup.c:108:27: */ 59361 var pBackup uintptr = clientData 59362 sqlite3.Xsqlite3_backup_finish(tls, pBackup) 59363 } 59364 59365 // sqlite3_backup CMDNAME DESTHANDLE DESTNAME SRCHANDLE SRCNAME 59366 // 59367 func backupTestInit(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_backup.c:117:26: */ 59368 bp := tls.Alloc(32) 59369 defer tls.Free(32) 59370 59371 var pBackup uintptr 59372 // var pDestDb uintptr at bp+16, 8 59373 59374 // var pSrcDb uintptr at bp+24, 8 59375 59376 var zDestName uintptr 59377 var zSrcName uintptr 59378 var zCmd uintptr 59379 59380 if objc != 6 { 59381 tcl.XTcl_WrongNumArgs(tls, 59382 interp, 1, objv, ts+27676 /* "CMDNAME DESTHAND..." */) 59383 return TCL_ERROR 59384 } 59385 59386 zCmd = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 59387 getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), bp+16 /* &pDestDb */) 59388 zDestName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 59389 getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8))), bp+24 /* &pSrcDb */) 59390 zSrcName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 5*8))) 59391 59392 pBackup = sqlite3.Xsqlite3_backup_init(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pDestDb */)), zDestName, *(*uintptr)(unsafe.Pointer(bp + 24 /* pSrcDb */)), zSrcName) 59393 if !(pBackup != 0) { 59394 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+27722 /* "sqlite3_backup_i..." */, 0)) 59395 return TCL_ERROR 59396 } 59397 59398 tcl.XTcl_CreateObjCommand(tls, interp, zCmd, *(*uintptr)(unsafe.Pointer(&struct { 59399 f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 59400 }{backupTestCmd})), pBackup, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, ClientData) }{backupTestFinish}))) 59401 tcl.XTcl_SetObjResult(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 59402 return TCL_OK 59403 } 59404 59405 func Sqlitetestbackup_Init(tls *libc.TLS, interp uintptr) int32 { /* test_backup.c:154:5: */ 59406 tcl.XTcl_CreateObjCommand(tls, interp, ts+27751 /* "sqlite3_backup" */, *(*uintptr)(unsafe.Pointer(&struct { 59407 f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 59408 }{backupTestInit})), uintptr(0), uintptr(0)) 59409 return TCL_OK 59410 } 59411 59412 // end block for C++ 59413 59414 // Local Variables: 59415 // mode: c 59416 // c-basic-offset: 4 59417 // fill-column: 78 59418 // End: 59419 59420 type tcl_vtab1 = struct { 59421 Fbase sqlite3_vtab 59422 Finterp uintptr 59423 FpCmd uintptr 59424 Fdb uintptr 59425 } /* test_bestindex.c:104:9 */ 59426 59427 // end block for C++ 59428 59429 // Local Variables: 59430 // mode: c 59431 // c-basic-offset: 4 59432 // fill-column: 78 59433 // End: 59434 59435 type tcl_vtab = tcl_vtab1 /* test_bestindex.c:104:25 */ 59436 type tcl_cursor1 = struct { 59437 Fbase sqlite3_vtab_cursor 59438 FpStmt uintptr 59439 } /* test_bestindex.c:105:9 */ 59440 59441 type tcl_cursor = tcl_cursor1 /* test_bestindex.c:105:27 */ 59442 59443 // Dequote string z in place. 59444 func tclDequote(tls *libc.TLS, z uintptr) { /* test_bestindex.c:126:13: */ 59445 var q int8 = *(*int8)(unsafe.Pointer(z)) 59446 59447 // Set stack variable q to the close-quote character 59448 if (((int32(q) == '[') || (int32(q) == '\'')) || (int32(q) == '"')) || (int32(q) == '`') { 59449 var iIn int32 = 1 59450 var iOut int32 = 0 59451 if int32(q) == '[' { 59452 q = int8(']') 59453 } 59454 59455 for *(*int8)(unsafe.Pointer(z + uintptr(iIn))) != 0 { 59456 if int32(*(*int8)(unsafe.Pointer(z + uintptr(iIn)))) == int32(q) { 59457 if int32(*(*int8)(unsafe.Pointer(z + uintptr((iIn + 1))))) != int32(q) { 59458 // Character iIn was the close quote. 59459 iIn++ 59460 break 59461 } else { 59462 // Character iIn and iIn+1 form an escaped quote character. Skip 59463 // the input cursor past both and copy a single quote character 59464 // to the output buffer. 59465 iIn = iIn + (2) 59466 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&iOut, 1)))) = q 59467 } 59468 } else { 59469 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&iOut, 1)))) = *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&iIn, 1)))) 59470 } 59471 } 59472 59473 *(*int8)(unsafe.Pointer(z + uintptr(iOut))) = int8(0) 59474 } 59475 } 59476 59477 // This function is the implementation of both the xConnect and xCreate 59478 // methods of the fs virtual table. 59479 // 59480 // The argv[] array contains the following: 59481 // 59482 // argv[0] -> module name ("fs") 59483 // argv[1] -> database name 59484 // argv[2] -> table name 59485 // argv[...] -> other module argument fields. 59486 func tclConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* test_bestindex.c:168:12: */ 59487 bp := tls.Alloc(8) 59488 defer tls.Free(8) 59489 59490 var interp uintptr = pAux 59491 var pTab uintptr = uintptr(0) 59492 var zCmd uintptr = uintptr(0) 59493 var pScript uintptr = uintptr(0) 59494 var rc int32 = SQLITE_OK 59495 59496 if argc != 4 { 59497 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+27766 /* "wrong number of ..." */, 0) 59498 return SQLITE_ERROR 59499 } 59500 59501 zCmd = sqlite3.Xsqlite3_malloc64(tls, (uint64(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) + uint64(1)))) 59502 pTab = sqlite3.Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(tcl_vtab{}))) 59503 if (zCmd != 0) && (pTab != 0) { 59504 libc.Xmemcpy(tls, zCmd, *(*uintptr)(unsafe.Pointer(argv + 3*8)), (libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) + uint64(1))) 59505 tclDequote(tls, zCmd) 59506 libc.Xmemset(tls, pTab, 0, uint64(unsafe.Sizeof(tcl_vtab{}))) 59507 59508 (*tcl_vtab)(unsafe.Pointer(pTab)).FpCmd = tcl.XTcl_NewStringObj(tls, zCmd, -1) 59509 (*tcl_vtab)(unsafe.Pointer(pTab)).Finterp = interp 59510 (*tcl_vtab)(unsafe.Pointer(pTab)).Fdb = db 59511 (*Tcl_Obj)(unsafe.Pointer((*tcl_vtab)(unsafe.Pointer(pTab)).FpCmd)).FrefCount++ 59512 59513 pScript = tcl.XTcl_DuplicateObj(tls, (*tcl_vtab)(unsafe.Pointer(pTab)).FpCmd) 59514 (*Tcl_Obj)(unsafe.Pointer(pScript)).FrefCount++ 59515 tcl.XTcl_ListObjAppendElement(tls, interp, pScript, tcl.XTcl_NewStringObj(tls, ts+26844 /* "xConnect" */, -1)) 59516 59517 rc = tcl.XTcl_EvalObjEx(tls, interp, pScript, TCL_EVAL_GLOBAL) 59518 if rc != TCL_OK { 59519 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, tcl.XTcl_GetStringResult(tls, interp))) 59520 rc = SQLITE_ERROR 59521 } else { 59522 rc = sqlite3.Xsqlite3_declare_vtab(tls, db, tcl.XTcl_GetStringResult(tls, interp)) 59523 } 59524 59525 if rc != SQLITE_OK { 59526 sqlite3.Xsqlite3_free(tls, pTab) 59527 pTab = uintptr(0) 59528 } 59529 } else { 59530 rc = SQLITE_NOMEM 59531 } 59532 59533 sqlite3.Xsqlite3_free(tls, zCmd) 59534 *(*uintptr)(unsafe.Pointer(ppVtab)) = (pTab /* &.base */) 59535 return rc 59536 } 59537 59538 // The xDisconnect and xDestroy methods are also the same 59539 func tclDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* test_bestindex.c:224:12: */ 59540 var pTab uintptr = pVtab 59541 for ok := true; ok; ok = 0 != 0 { 59542 var _objPtr uintptr = (*tcl_vtab)(unsafe.Pointer(pTab)).FpCmd 59543 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 59544 tcl.XTclFreeObj(tls, _objPtr) 59545 } 59546 } 59547 sqlite3.Xsqlite3_free(tls, pTab) 59548 return SQLITE_OK 59549 } 59550 59551 // Open a new tcl cursor. 59552 func tclOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* test_bestindex.c:234:12: */ 59553 var pCur uintptr 59554 pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(tcl_cursor{}))) 59555 if pCur == uintptr(0) { 59556 return SQLITE_NOMEM 59557 } 59558 libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(tcl_cursor{}))) 59559 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) 59560 return SQLITE_OK 59561 } 59562 59563 // Close a tcl cursor. 59564 func tclClose(tls *libc.TLS, cur uintptr) int32 { /* test_bestindex.c:246:12: */ 59565 var pCur uintptr = cur 59566 if pCur != 0 { 59567 sqlite3.Xsqlite3_finalize(tls, (*tcl_cursor)(unsafe.Pointer(pCur)).FpStmt) 59568 sqlite3.Xsqlite3_free(tls, pCur) 59569 } 59570 return SQLITE_OK 59571 } 59572 59573 func tclNext(tls *libc.TLS, pVtabCursor uintptr) int32 { /* test_bestindex.c:255:12: */ 59574 bp := tls.Alloc(8) 59575 defer tls.Free(8) 59576 59577 var pCsr uintptr = pVtabCursor 59578 if (*tcl_cursor)(unsafe.Pointer(pCsr)).FpStmt != 0 { 59579 var pTab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab 59580 var rc int32 = sqlite3.Xsqlite3_step(tls, (*tcl_cursor)(unsafe.Pointer(pCsr)).FpStmt) 59581 if rc != SQLITE_ROW { 59582 var zErr uintptr 59583 rc = sqlite3.Xsqlite3_finalize(tls, (*tcl_cursor)(unsafe.Pointer(pCsr)).FpStmt) 59584 (*tcl_cursor)(unsafe.Pointer(pCsr)).FpStmt = uintptr(0) 59585 if rc != SQLITE_OK { 59586 zErr = sqlite3.Xsqlite3_errmsg(tls, (*tcl_vtab)(unsafe.Pointer(pTab)).Fdb) 59587 (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zErr)) 59588 } 59589 } 59590 } 59591 return SQLITE_OK 59592 } 59593 59594 func tclFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* test_bestindex.c:273:12: */ 59595 bp := tls.Alloc(48) 59596 defer tls.Free(48) 59597 59598 var pCsr uintptr = pVtabCursor 59599 var pTab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab 59600 var interp uintptr = (*tcl_vtab)(unsafe.Pointer(pTab)).Finterp 59601 var pScript uintptr 59602 var pArg uintptr 59603 var ii int32 59604 var rc int32 59605 59606 pScript = tcl.XTcl_DuplicateObj(tls, (*tcl_vtab)(unsafe.Pointer(pTab)).FpCmd) 59607 (*Tcl_Obj)(unsafe.Pointer(pScript)).FrefCount++ 59608 tcl.XTcl_ListObjAppendElement(tls, interp, pScript, tcl.XTcl_NewStringObj(tls, ts+26908 /* "xFilter" */, -1)) 59609 tcl.XTcl_ListObjAppendElement(tls, interp, pScript, tcl.XTcl_NewIntObj(tls, idxNum)) 59610 if idxStr != 0 { 59611 tcl.XTcl_ListObjAppendElement(tls, interp, pScript, tcl.XTcl_NewStringObj(tls, idxStr, -1)) 59612 } else { 59613 tcl.XTcl_ListObjAppendElement(tls, interp, pScript, tcl.XTcl_NewStringObj(tls, ts+489 /* "" */, -1)) 59614 } 59615 59616 pArg = tcl.XTcl_NewObj(tls) 59617 (*Tcl_Obj)(unsafe.Pointer(pArg)).FrefCount++ 59618 for ii = 0; ii < argc; ii++ { 59619 var zVal uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(ii)*8))) 59620 var pVal uintptr 59621 if zVal == uintptr(0) { 59622 pVal = tcl.XTcl_NewObj(tls) 59623 } else { 59624 pVal = tcl.XTcl_NewStringObj(tls, zVal, -1) 59625 } 59626 tcl.XTcl_ListObjAppendElement(tls, interp, pArg, pVal) 59627 } 59628 tcl.XTcl_ListObjAppendElement(tls, interp, pScript, pArg) 59629 for ok := true; ok; ok = 0 != 0 { 59630 var _objPtr uintptr = pArg 59631 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 59632 tcl.XTclFreeObj(tls, _objPtr) 59633 } 59634 } 59635 59636 rc = tcl.XTcl_EvalObjEx(tls, interp, pScript, TCL_EVAL_GLOBAL) 59637 if rc != TCL_OK { 59638 var zErr uintptr = tcl.XTcl_GetStringResult(tls, interp) 59639 rc = SQLITE_ERROR 59640 (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zErr)) 59641 } else { 59642 // Analyze the scripts return value. The return value should be a tcl 59643 // list object with an even number of elements. The first element of each 59644 // pair must be one of: 59645 // 59646 // "sql" (SQL statement to return data) 59647 var pRes uintptr = tcl.XTcl_GetObjResult(tls, interp) 59648 *(*uintptr)(unsafe.Pointer(bp + 40 /* apElem */)) = uintptr(0) 59649 // var nElem int32 at bp+32, 4 59650 59651 rc = tcl.XTcl_ListObjGetElements(tls, interp, pRes, bp+32 /* &nElem */, bp+40 /* &apElem */) 59652 if rc != TCL_OK { 59653 var zErr uintptr = tcl.XTcl_GetStringResult(tls, interp) 59654 rc = SQLITE_ERROR 59655 (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+8, zErr)) 59656 } else { 59657 for ii = 0; (rc == SQLITE_OK) && (ii < *(*int32)(unsafe.Pointer(bp + 32 /* nElem */))); ii = ii + (2) { 59658 var zCmd uintptr = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 40 /* apElem */)) + uintptr(ii)*8))) 59659 var p uintptr = *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 40 /* apElem */)) + uintptr((ii+1))*8)) 59660 if sqlite3.Xsqlite3_stricmp(tls, ts+1808 /* "sql" */, zCmd) == 0 { 59661 var zSql uintptr = tcl.XTcl_GetString(tls, p) 59662 rc = sqlite3.Xsqlite3_prepare_v2(tls, (*tcl_vtab)(unsafe.Pointer(pTab)).Fdb, zSql, -1, (pCsr + 8 /* &.pStmt */), uintptr(0)) 59663 if rc != SQLITE_OK { 59664 var zErr uintptr = sqlite3.Xsqlite3_errmsg(tls, (*tcl_vtab)(unsafe.Pointer(pTab)).Fdb) 59665 (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+27792 /* "unexpected: %s" */, libc.VaList(bp+16, zErr)) 59666 } 59667 } else { 59668 rc = SQLITE_ERROR 59669 (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+27792 /* "unexpected: %s" */, libc.VaList(bp+24, zCmd)) 59670 } 59671 } 59672 } 59673 } 59674 59675 if rc == SQLITE_OK { 59676 rc = tclNext(tls, pVtabCursor) 59677 } 59678 return rc 59679 } 59680 59681 func tclColumn(tls *libc.TLS, pVtabCursor uintptr, ctx uintptr, i int32) int32 { /* test_bestindex.c:356:12: */ 59682 var pCsr uintptr = pVtabCursor 59683 sqlite3.Xsqlite3_result_value(tls, ctx, sqlite3.Xsqlite3_column_value(tls, (*tcl_cursor)(unsafe.Pointer(pCsr)).FpStmt, (i+1))) 59684 return SQLITE_OK 59685 } 59686 59687 func tclRowid(tls *libc.TLS, pVtabCursor uintptr, pRowid uintptr) int32 { /* test_bestindex.c:366:12: */ 59688 var pCsr uintptr = pVtabCursor 59689 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite3.Xsqlite3_column_int64(tls, (*tcl_cursor)(unsafe.Pointer(pCsr)).FpStmt, 0) 59690 return SQLITE_OK 59691 } 59692 59693 func tclEof(tls *libc.TLS, pVtabCursor uintptr) int32 { /* test_bestindex.c:372:12: */ 59694 var pCsr uintptr = pVtabCursor 59695 return (libc.Bool32((*tcl_cursor)(unsafe.Pointer(pCsr)).FpStmt == uintptr(0))) 59696 } 59697 59698 func tclBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_bestindex.c:377:12: */ 59699 bp := tls.Alloc(76) 59700 defer tls.Free(76) 59701 59702 var pTab uintptr = tab 59703 var interp uintptr = (*tcl_vtab)(unsafe.Pointer(pTab)).Finterp 59704 var pArg uintptr 59705 var pScript uintptr 59706 var ii int32 59707 var rc int32 = SQLITE_OK 59708 59709 pScript = tcl.XTcl_DuplicateObj(tls, (*tcl_vtab)(unsafe.Pointer(pTab)).FpCmd) 59710 (*Tcl_Obj)(unsafe.Pointer(pScript)).FrefCount++ 59711 tcl.XTcl_ListObjAppendElement(tls, interp, pScript, tcl.XTcl_NewStringObj(tls, ts+26962 /* "xBestIndex" */, -1)) 59712 59713 pArg = tcl.XTcl_NewObj(tls) 59714 (*Tcl_Obj)(unsafe.Pointer(pArg)).FrefCount++ 59715 for ii = 0; ii < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; ii++ { 59716 var pCons uintptr = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12) 59717 var pElem uintptr = tcl.XTcl_NewObj(tls) 59718 var zOp uintptr = ts + 3276 /* "?" */ 59719 59720 (*Tcl_Obj)(unsafe.Pointer(pElem)).FrefCount++ 59721 59722 switch int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) { 59723 case SQLITE_INDEX_CONSTRAINT_EQ: 59724 zOp = ts + 27807 /* "eq" */ 59725 break 59726 case SQLITE_INDEX_CONSTRAINT_GT: 59727 zOp = ts + 27810 /* "gt" */ 59728 break 59729 case SQLITE_INDEX_CONSTRAINT_LE: 59730 zOp = ts + 27813 /* "le" */ 59731 break 59732 case SQLITE_INDEX_CONSTRAINT_LT: 59733 zOp = ts + 27816 /* "lt" */ 59734 break 59735 case SQLITE_INDEX_CONSTRAINT_GE: 59736 zOp = ts + 27819 /* "ge" */ 59737 break 59738 case SQLITE_INDEX_CONSTRAINT_MATCH: 59739 zOp = ts + 27822 /* "match" */ 59740 break 59741 case SQLITE_INDEX_CONSTRAINT_LIKE: 59742 zOp = ts + 27060 /* "like" */ 59743 break 59744 case SQLITE_INDEX_CONSTRAINT_GLOB: 59745 zOp = ts + 27065 /* "glob" */ 59746 break 59747 case SQLITE_INDEX_CONSTRAINT_REGEXP: 59748 zOp = ts + 6345 /* "regexp" */ 59749 break 59750 case SQLITE_INDEX_CONSTRAINT_NE: 59751 zOp = ts + 27828 /* "ne" */ 59752 break 59753 case SQLITE_INDEX_CONSTRAINT_ISNOT: 59754 zOp = ts + 27831 /* "isnot" */ 59755 break 59756 case SQLITE_INDEX_CONSTRAINT_ISNOTNULL: 59757 zOp = ts + 27837 /* "isnotnull" */ 59758 break 59759 case SQLITE_INDEX_CONSTRAINT_ISNULL: 59760 zOp = ts + 27847 /* "isnull" */ 59761 break 59762 case SQLITE_INDEX_CONSTRAINT_IS: 59763 zOp = ts + 5722 /* "is" */ 59764 break 59765 } 59766 59767 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pElem, tcl.XTcl_NewStringObj(tls, ts+27854 /* "op" */, -1)) 59768 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pElem, tcl.XTcl_NewStringObj(tls, zOp, -1)) 59769 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pElem, tcl.XTcl_NewStringObj(tls, ts+27857 /* "column" */, -1)) 59770 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pElem, tcl.XTcl_NewIntObj(tls, (*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn)) 59771 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pElem, tcl.XTcl_NewStringObj(tls, ts+27864 /* "usable" */, -1)) 59772 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pElem, tcl.XTcl_NewIntObj(tls, int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fusable))) 59773 59774 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pArg, pElem) 59775 for ok := true; ok; ok = 0 != 0 { 59776 var _objPtr uintptr = pElem 59777 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 59778 tcl.XTclFreeObj(tls, _objPtr) 59779 } 59780 } 59781 } 59782 59783 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pScript, pArg) 59784 for ok1 := true; ok1; ok1 = 0 != 0 { 59785 var _objPtr uintptr = pArg 59786 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 59787 tcl.XTclFreeObj(tls, _objPtr) 59788 } 59789 } 59790 59791 pArg = tcl.XTcl_NewObj(tls) 59792 (*Tcl_Obj)(unsafe.Pointer(pArg)).FrefCount++ 59793 for ii = 0; ii < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnOrderBy; ii++ { 59794 var pOrder uintptr = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaOrderBy + uintptr(ii)*8) 59795 var pElem uintptr = tcl.XTcl_NewObj(tls) 59796 (*Tcl_Obj)(unsafe.Pointer(pElem)).FrefCount++ 59797 59798 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pElem, tcl.XTcl_NewStringObj(tls, ts+27857 /* "column" */, -1)) 59799 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pElem, tcl.XTcl_NewIntObj(tls, (*sqlite3_index_orderby)(unsafe.Pointer(pOrder)).FiColumn)) 59800 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pElem, tcl.XTcl_NewStringObj(tls, ts+27871 /* "desc" */, -1)) 59801 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pElem, tcl.XTcl_NewIntObj(tls, int32((*sqlite3_index_orderby)(unsafe.Pointer(pOrder)).Fdesc))) 59802 59803 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pArg, pElem) 59804 for ok2 := true; ok2; ok2 = 0 != 0 { 59805 var _objPtr uintptr = pElem 59806 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 59807 tcl.XTclFreeObj(tls, _objPtr) 59808 } 59809 } 59810 } 59811 59812 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pScript, pArg) 59813 for ok3 := true; ok3; ok3 = 0 != 0 { 59814 var _objPtr uintptr = pArg 59815 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 59816 tcl.XTclFreeObj(tls, _objPtr) 59817 } 59818 } 59819 59820 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pScript, tcl.XTcl_NewWideIntObj(tls, int64((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FcolUsed))) 59821 59822 rc = tcl.XTcl_EvalObjEx(tls, interp, pScript, TCL_EVAL_GLOBAL) 59823 for ok4 := true; ok4; ok4 = 0 != 0 { 59824 var _objPtr uintptr = pScript 59825 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 59826 tcl.XTclFreeObj(tls, _objPtr) 59827 } 59828 } 59829 if rc != TCL_OK { 59830 var zErr uintptr = tcl.XTcl_GetStringResult(tls, interp) 59831 rc = SQLITE_ERROR 59832 (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, zErr)) 59833 } else { 59834 // Analyze the scripts return value. The return value should be a tcl 59835 // list object with an even number of elements. The first element of each 59836 // pair must be one of: 59837 // 59838 // "orderby" (value of orderByConsumed flag) 59839 // "cost" (value of estimatedCost field) 59840 // "rows" (value of estimatedRows field) 59841 // "use" (index of used constraint in aConstraint[]) 59842 // "idxnum" (value of idxNum field) 59843 // "idxstr" (value of idxStr field) 59844 // "omit" (index of omitted constraint in aConstraint[]) 59845 var pRes uintptr = tcl.XTcl_GetObjResult(tls, interp) 59846 *(*uintptr)(unsafe.Pointer(bp + 56 /* apElem */)) = uintptr(0) 59847 // var nElem int32 at bp+48, 4 59848 59849 rc = tcl.XTcl_ListObjGetElements(tls, interp, pRes, bp+48 /* &nElem */, bp+56 /* &apElem */) 59850 if rc != TCL_OK { 59851 var zErr uintptr = tcl.XTcl_GetStringResult(tls, interp) 59852 rc = SQLITE_ERROR 59853 (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+8, zErr)) 59854 } else { 59855 var iArgv int32 = 1 59856 for ii = 0; (rc == SQLITE_OK) && (ii < *(*int32)(unsafe.Pointer(bp + 48 /* nElem */))); ii = ii + (2) { 59857 var zCmd uintptr = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 56 /* apElem */)) + uintptr(ii)*8))) 59858 var p uintptr = *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 56 /* apElem */)) + uintptr((ii+1))*8)) 59859 if sqlite3.Xsqlite3_stricmp(tls, ts+27876 /* "cost" */, zCmd) == 0 { 59860 rc = tcl.XTcl_GetDoubleFromObj(tls, interp, p, (pIdxInfo + 64 /* &.estimatedCost */)) 59861 } else if sqlite3.Xsqlite3_stricmp(tls, ts+27881 /* "orderby" */, zCmd) == 0 { 59862 rc = tcl.XTcl_GetIntFromObj(tls, interp, p, (pIdxInfo + 60 /* &.orderByConsumed */)) 59863 } else if sqlite3.Xsqlite3_stricmp(tls, ts+27889 /* "idxnum" */, zCmd) == 0 { 59864 rc = tcl.XTcl_GetIntFromObj(tls, interp, p, (pIdxInfo + 40 /* &.idxNum */)) 59865 } else if sqlite3.Xsqlite3_stricmp(tls, ts+27896 /* "idxstr" */, zCmd) == 0 { 59866 sqlite3.Xsqlite3_free(tls, (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr) 59867 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+16, tcl.XTcl_GetString(tls, p))) 59868 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FneedToFreeIdxStr = 1 59869 } else if sqlite3.Xsqlite3_stricmp(tls, ts+27903 /* "rows" */, zCmd) == 0 { 59870 *(*Tcl_WideInt)(unsafe.Pointer(bp + 64 /* x */)) = int64(0) 59871 rc = tcl.XTcl_GetWideIntFromObj(tls, interp, p, bp+64 /* &x */) 59872 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = sqlite3_int64(tRowcnt(*(*Tcl_WideInt)(unsafe.Pointer(bp + 64 /* x */)))) 59873 } else if (sqlite3.Xsqlite3_stricmp(tls, ts+27908 /* "use" */, zCmd) == 0) || 59874 (sqlite3.Xsqlite3_stricmp(tls, ts+27912 /* "omit" */, zCmd) == 0) { 59875 // var iCons int32 at bp+72, 4 59876 59877 rc = tcl.XTcl_GetIntFromObj(tls, interp, p, bp+72 /* &iCons */) 59878 if rc == SQLITE_OK { 59879 if (*(*int32)(unsafe.Pointer(bp + 72 /* iCons */)) < 0) || (*(*int32)(unsafe.Pointer(bp + 72 /* iCons */)) >= (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) { 59880 rc = SQLITE_ERROR 59881 (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+27917 /* "unexpected: %d" */, libc.VaList(bp+24, *(*int32)(unsafe.Pointer(bp + 72 /* iCons */)))) 59882 } else { 59883 var bOmit int32 = (libc.Bool32((int32(*(*int8)(unsafe.Pointer(zCmd))) == 'o') || (int32(*(*int8)(unsafe.Pointer(zCmd))) == 'O'))) 59884 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(*(*int32)(unsafe.Pointer(bp + 72 /* iCons */)))*8)).FargvIndex = libc.PostIncInt32(&iArgv, 1) 59885 (*sqlite3_index_constraint_usage)(unsafe.Pointer((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(*(*int32)(unsafe.Pointer(bp + 72 /* iCons */)))*8)).Fomit = uint8(bOmit) 59886 } 59887 } 59888 } else { 59889 rc = SQLITE_ERROR 59890 (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+27792 /* "unexpected: %s" */, libc.VaList(bp+32, zCmd)) 59891 } 59892 if (rc != SQLITE_OK) && ((*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg == uintptr(0)) { 59893 var zErr uintptr = tcl.XTcl_GetStringResult(tls, interp) 59894 (*tcl_vtab)(unsafe.Pointer(pTab)).Fbase.FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+40, zErr)) 59895 } 59896 } 59897 } 59898 } 59899 59900 return rc 59901 } 59902 59903 // A virtual table module that provides read-only access to a 59904 // Tcl global variable namespace. 59905 var tclModule = sqlite3_module{ // iVersion 59906 FxCreate: 0, 59907 FxConnect: 0, 59908 FxBestIndex: 0, 59909 FxDisconnect: 0, 59910 FxDestroy: 0, 59911 FxOpen: 0, // xOpen - open a cursor 59912 FxClose: 0, // xClose - close a cursor 59913 FxFilter: 0, // xFilter - configure scan constraints 59914 FxNext: 0, // xNext - advance a cursor 59915 FxEof: 0, // xEof - check for end of scan 59916 FxColumn: 0, // xColumn - read data 59917 FxRowid: 0, // xRename 59918 } /* test_bestindex.c:549:23 */ 59919 59920 // Register the echo virtual table module. 59921 func register_tcl_module(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_bestindex.c:580:26: */ 59922 bp := tls.Alloc(8) 59923 defer tls.Free(8) 59924 59925 // var db uintptr at bp, 8 59926 59927 if objc != 2 { 59928 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 59929 return TCL_ERROR 59930 } 59931 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 59932 return TCL_ERROR 59933 } 59934 sqlite3.Xsqlite3_create_module(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+27932 /* "tcl" */, uintptr(unsafe.Pointer(&tclModule)), interp) 59935 return TCL_OK 59936 } 59937 59938 // Register commands with the TCL interpreter. 59939 func Sqlitetesttcl_Init(tls *libc.TLS, interp uintptr) int32 { /* test_bestindex.c:604:5: */ 59940 var i int32 59941 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aObjCmd4)) / uint64(unsafe.Sizeof(struct { 59942 FzName uintptr 59943 FxProc uintptr 59944 FclientData uintptr 59945 }{}))); i++ { 59946 tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd4[i].FzName, 59947 aObjCmd4[i].FxProc, aObjCmd4[i].FclientData, uintptr(0)) 59948 } 59949 return TCL_OK 59950 } 59951 59952 var aObjCmd4 = [1]struct { 59953 FzName uintptr 59954 FxProc uintptr 59955 FclientData uintptr 59956 }{ 59957 {FzName: ts + 27936 /* "register_tcl_mod..." */, FxProc: 0}, 59958 } /* test_bestindex.c:610:5 */ 59959 59960 // Return a pointer to a buffer containing a text representation of the 59961 // pointer passed as the only argument. The original pointer may be extracted 59962 // from the text using sqlite3TestTextToPtr(). 59963 func ptrToText(tls *libc.TLS, p uintptr) uintptr { /* test_blob.c:37:13: */ 59964 bp := tls.Alloc(8) 59965 defer tls.Free(8) 59966 59967 sqlite3.Xsqlite3_snprintf(tls, (int32(uint64(unsafe.Sizeof(buf)) - uint64(1))), uintptr(unsafe.Pointer(&buf)), ts+13023 /* "%p" */, libc.VaList(bp, p)) 59968 return uintptr(unsafe.Pointer(&buf)) 59969 } 59970 59971 var buf [100]int8 /* test_blob.c:38:15: */ 59972 59973 // Attempt to extract a blob handle (type sqlite3_blob*) from the Tcl 59974 // object passed as the second argument. If successful, set *ppBlob to 59975 // point to the blob handle and return TCL_OK. Otherwise, store an error 59976 // message in the tcl interpreter and return TCL_ERROR. The final value 59977 // of *ppBlob is undefined in this case. 59978 // 59979 // If the object contains a string that begins with "incrblob_", then it 59980 // is assumed to be the name of a Tcl channel opened using the [db incrblob] 59981 // command (see tclsqlite.c). Otherwise, it is assumed to be a pointer 59982 // encoded using the ptrToText() routine or similar. 59983 func blobHandleFromObj1(tls *libc.TLS, interp uintptr, pObj uintptr, ppBlob uintptr) int32 { /* test_blob.c:55:12: */ 59984 bp := tls.Alloc(8) 59985 defer tls.Free(8) 59986 59987 var z uintptr 59988 // var n int32 at bp, 4 59989 59990 z = tcl.XTcl_GetStringFromObj(tls, pObj, bp /* &n */) 59991 if *(*int32)(unsafe.Pointer(bp /* n */)) == 0 { 59992 *(*uintptr)(unsafe.Pointer(ppBlob)) = uintptr(0) 59993 } else if (*(*int32)(unsafe.Pointer(bp /* n */)) > 9) && (0 == libc.Xmemcmp(tls, ts+27956 /* "incrblob_" */, z, uint64(9))) { 59994 // var notUsed int32 at bp+4, 4 59995 59996 var channel Tcl_Channel 59997 var instanceData ClientData 59998 59999 channel = tcl.XTcl_GetChannel(tls, interp, z, bp+4 /* ¬Used */) 60000 if !(channel != 0) { 60001 return TCL_ERROR 60002 } 60003 60004 tcl.XTcl_Flush(tls, channel) 60005 tcl.XTcl_Seek(tls, channel, int64(0), SEEK_SET) 60006 60007 instanceData = tcl.XTcl_GetChannelInstanceData(tls, channel) 60008 *(*uintptr)(unsafe.Pointer(ppBlob)) = *(*uintptr)(unsafe.Pointer(instanceData)) 60009 } else { 60010 *(*uintptr)(unsafe.Pointer(ppBlob)) = sqlite3TestTextToPtr(tls, z) 60011 } 60012 60013 return TCL_OK 60014 } 60015 60016 // Like Tcl_GetString(), except that if the string is 0 bytes in size, a 60017 // NULL Pointer is returned. 60018 func blobStringFromObj(tls *libc.TLS, pObj uintptr) uintptr { /* test_blob.c:90:13: */ 60019 bp := tls.Alloc(4) 60020 defer tls.Free(4) 60021 60022 // var n int32 at bp, 4 60023 60024 var z uintptr 60025 z = tcl.XTcl_GetStringFromObj(tls, pObj, bp /* &n */) 60026 return func() uintptr { 60027 if *(*int32)(unsafe.Pointer(bp /* n */)) != 0 { 60028 return z 60029 } 60030 return uintptr(0) 60031 }() 60032 } 60033 60034 // sqlite3_blob_open DB DATABASE TABLE COLUMN ROWID FLAGS VARNAME 60035 // 60036 // Tcl test harness for the sqlite3_blob_open() function. 60037 func test_blob_open(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_blob.c:102:26: */ 60038 bp := tls.Alloc(40) 60039 defer tls.Free(40) 60040 60041 // var db uintptr at bp+8, 8 60042 60043 var zDb uintptr 60044 var zTable uintptr 60045 var zColumn uintptr 60046 // var iRowid Tcl_WideInt at bp+16, 8 60047 60048 // var flags int32 at bp, 4 60049 60050 var zVarname uintptr 60051 // var nVarname int32 at bp+24, 4 60052 60053 *(*uintptr)(unsafe.Pointer(bp + 32 /* pBlob */)) = bp /* &flags */ // Non-zero initialization 60054 var rc int32 60055 60056 if objc != 8 { 60057 var zUsage uintptr = ts + 27966 /* "DB DATABASE TABL..." */ 60058 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, zUsage) 60059 return TCL_ERROR 60060 } 60061 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+8 /* &db */) != 0 { 60062 return TCL_ERROR 60063 } 60064 zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 60065 zTable = blobStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 60066 zColumn = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8))) 60067 if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 5*8)), bp+16 /* &iRowid */) != 0 { 60068 return TCL_ERROR 60069 } 60070 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 6*8)), bp /* &flags */) != 0 { 60071 return TCL_ERROR 60072 } 60073 zVarname = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 7*8)), bp+24 /* &nVarname */) 60074 60075 if *(*int32)(unsafe.Pointer(bp + 24 /* nVarname */)) > 0 { 60076 rc = sqlite3.Xsqlite3_blob_open(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* db */)), zDb, zTable, zColumn, *(*Tcl_WideInt)(unsafe.Pointer(bp + 16 /* iRowid */)), *(*int32)(unsafe.Pointer(bp /* flags */)), bp+32 /* &pBlob */) 60077 tcl.XTcl_SetVar2(tls, interp, zVarname, uintptr(0), ptrToText(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pBlob */))), 0) 60078 } else { 60079 rc = sqlite3.Xsqlite3_blob_open(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* db */)), zDb, zTable, zColumn, *(*Tcl_WideInt)(unsafe.Pointer(bp + 16 /* iRowid */)), *(*int32)(unsafe.Pointer(bp /* flags */)), uintptr(0)) 60080 } 60081 60082 if rc == SQLITE_OK { 60083 tcl.XTcl_ResetResult(tls, interp) 60084 } else { 60085 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 60086 return TCL_ERROR 60087 } 60088 return TCL_OK 60089 } 60090 60091 // sqlite3_blob_close HANDLE 60092 func test_blob_close(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_blob.c:153:26: */ 60093 bp := tls.Alloc(8) 60094 defer tls.Free(8) 60095 60096 // var pBlob uintptr at bp, 8 60097 60098 var rc int32 60099 60100 if objc != 2 { 60101 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+28011 /* "HANDLE" */) 60102 return TCL_ERROR 60103 } 60104 60105 if blobHandleFromObj1(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &pBlob */) != 0 { 60106 return TCL_ERROR 60107 } 60108 rc = sqlite3.Xsqlite3_blob_close(tls, *(*uintptr)(unsafe.Pointer(bp /* pBlob */))) 60109 60110 if rc != 0 { 60111 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 60112 } else { 60113 tcl.XTcl_ResetResult(tls, interp) 60114 } 60115 return TCL_OK 60116 } 60117 60118 // sqlite3_blob_bytes HANDLE 60119 func test_blob_bytes(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_blob.c:181:26: */ 60120 bp := tls.Alloc(8) 60121 defer tls.Free(8) 60122 60123 // var pBlob uintptr at bp, 8 60124 60125 var nByte int32 60126 60127 if objc != 2 { 60128 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+28011 /* "HANDLE" */) 60129 return TCL_ERROR 60130 } 60131 60132 if blobHandleFromObj1(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &pBlob */) != 0 { 60133 return TCL_ERROR 60134 } 60135 nByte = sqlite3.Xsqlite3_blob_bytes(tls, *(*uintptr)(unsafe.Pointer(bp /* pBlob */))) 60136 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, nByte)) 60137 60138 return TCL_OK 60139 } 60140 60141 // sqlite3_blob_read CHANNEL OFFSET N 60142 // 60143 // This command is used to test the sqlite3_blob_read() in ways that 60144 // the Tcl channel interface does not. The first argument should 60145 // be the name of a valid channel created by the [incrblob] method 60146 // of a database handle. This function calls sqlite3_blob_read() 60147 // to read N bytes from offset OFFSET from the underlying SQLite 60148 // blob handle. 60149 // 60150 // On success, a byte-array object containing the read data is 60151 // returned. On failure, the interpreter result is set to the 60152 // text representation of the returned error code (i.e. "SQLITE_NOMEM") 60153 // and a Tcl exception is thrown. 60154 func test_blob_read(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_blob.c:217:26: */ 60155 bp := tls.Alloc(32) 60156 defer tls.Free(32) 60157 60158 // var pBlob uintptr at bp+16, 8 60159 60160 // var nByte int32 at bp+28, 4 60161 60162 // var iOffset int32 at bp+24, 4 60163 60164 var zBuf uintptr = uintptr(0) 60165 var rc int32 60166 60167 if objc != 4 { 60168 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+28018 /* "CHANNEL OFFSET N" */) 60169 return TCL_ERROR 60170 } 60171 60172 if blobHandleFromObj1(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+16 /* &pBlob */) != 0 { 60173 return TCL_ERROR 60174 } 60175 if (TCL_OK != tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+24 /* &iOffset */)) || 60176 (TCL_OK != tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+28 /* &nByte */)) { 60177 return TCL_ERROR 60178 } 60179 60180 if *(*int32)(unsafe.Pointer(bp + 28 /* nByte */)) > 0 { 60181 zBuf = tcl.XTcl_AttemptAlloc(tls, uint32(*(*int32)(unsafe.Pointer(bp + 28 /* nByte */)))) 60182 if zBuf == uintptr(0) { 60183 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+28035 /* "out of memory in..." */, 0)) 60184 return TCL_ERROR 60185 } 60186 } 60187 rc = sqlite3.Xsqlite3_blob_read(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* pBlob */)), zBuf, *(*int32)(unsafe.Pointer(bp + 28 /* nByte */)), *(*int32)(unsafe.Pointer(bp + 24 /* iOffset */))) 60188 if rc == SQLITE_OK { 60189 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewByteArrayObj(tls, zBuf, *(*int32)(unsafe.Pointer(bp + 28 /* nByte */)))) 60190 } else { 60191 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 60192 } 60193 tcl.XTcl_Free(tls, zBuf) 60194 60195 return func() int32 { 60196 if rc == SQLITE_OK { 60197 return TCL_OK 60198 } 60199 return TCL_ERROR 60200 }() 60201 } 60202 60203 // sqlite3_blob_write HANDLE OFFSET DATA ?NDATA? 60204 // 60205 // This command is used to test the sqlite3_blob_write() in ways that 60206 // the Tcl channel interface does not. The first argument should 60207 // be the name of a valid channel created by the [incrblob] method 60208 // of a database handle. This function calls sqlite3_blob_write() 60209 // to write the DATA byte-array to the underlying SQLite blob handle. 60210 // at offset OFFSET. 60211 // 60212 // On success, an empty string is returned. On failure, the interpreter 60213 // result is set to the text representation of the returned error code 60214 // (i.e. "SQLITE_NOMEM") and a Tcl exception is thrown. 60215 func test_blob_write(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_blob.c:273:26: */ 60216 bp := tls.Alloc(16) 60217 defer tls.Free(16) 60218 60219 // var pBlob uintptr at bp, 8 60220 60221 // var iOffset int32 at bp+8, 4 60222 60223 var rc int32 60224 var zBuf uintptr 60225 // var nBuf int32 at bp+12, 4 60226 60227 if (objc != 4) && (objc != 5) { 60228 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+28096 /* "HANDLE OFFSET DA..." */) 60229 return TCL_ERROR 60230 } 60231 60232 if blobHandleFromObj1(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &pBlob */) != 0 { 60233 return TCL_ERROR 60234 } 60235 if TCL_OK != tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &iOffset */) { 60236 return TCL_ERROR 60237 } 60238 60239 zBuf = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+12 /* &nBuf */) 60240 if (objc == 5) && (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+12 /* &nBuf */) != 0) { 60241 return TCL_ERROR 60242 } 60243 rc = sqlite3.Xsqlite3_blob_write(tls, *(*uintptr)(unsafe.Pointer(bp /* pBlob */)), zBuf, *(*int32)(unsafe.Pointer(bp + 12 /* nBuf */)), *(*int32)(unsafe.Pointer(bp + 8 /* iOffset */))) 60244 if rc != SQLITE_OK { 60245 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 60246 } 60247 60248 return func() int32 { 60249 if rc == SQLITE_OK { 60250 return TCL_OK 60251 } 60252 return TCL_ERROR 60253 }() 60254 } 60255 60256 // Register commands with the TCL interpreter. 60257 func Sqlitetest_blob_Init(tls *libc.TLS, interp uintptr) int32 { /* test_blob.c:312:5: */ 60258 var i int32 60259 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aObjCmd5)) / uint64(unsafe.Sizeof(struct { 60260 FzName uintptr 60261 FxProc uintptr 60262 }{}))); i++ { 60263 tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd5[i].FzName, aObjCmd5[i].FxProc, uintptr(0), uintptr(0)) 60264 } 60265 return TCL_OK 60266 } 60267 60268 var aObjCmd5 = [5]struct { 60269 FzName uintptr 60270 FxProc uintptr 60271 }{ 60272 {FzName: ts + 28123 /* "sqlite3_blob_ope..." */, FxProc: 0}, 60273 {FzName: ts + 28141 /* "sqlite3_blob_clo..." */, FxProc: 0}, 60274 {FzName: ts + 28160 /* "sqlite3_blob_byt..." */, FxProc: 0}, 60275 {FzName: ts + 28179 /* "sqlite3_blob_rea..." */, FxProc: 0}, 60276 {FzName: ts + 28197 /* "sqlite3_blob_wri..." */, FxProc: 0}, 60277 } /* test_blob.c:317:5 */ 60278 60279 // end block for C++ 60280 60281 // Local Variables: 60282 // mode: c 60283 // c-basic-offset: 4 60284 // fill-column: 78 60285 // End: 60286 60287 // Usage: sqlite3_shared_cache_report 60288 // 60289 // Return a list of file that are shared and the number of 60290 // references to each file. 60291 func sqlite3BtreeSharedCacheReport(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_btree.c:29:19: */ 60292 var pBt uintptr 60293 var pRet uintptr = tcl.XTcl_NewObj(tls) 60294 for pBt = sqlite3.Xsqlite3SharedCacheList; pBt != 0; pBt = (*BtShared)(unsafe.Pointer(pBt)).FpNext { 60295 var zFile uintptr = sqlite3.Xsqlite3PagerFilename(tls, (*BtShared)(unsafe.Pointer(pBt)).FpPager, 1) 60296 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewStringObj(tls, zFile, -1)) 60297 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewIntObj(tls, (*BtShared)(unsafe.Pointer(pBt)).FnRef)) 60298 } 60299 tcl.XTcl_SetObjResult(tls, interp, pRet) 60300 return TCL_OK 60301 } 60302 60303 // Print debugging information about all cursors to standard output. 60304 func sqlite3BtreeCursorList(tls *libc.TLS, p uintptr) { /* test_btree.c:52:6: */ 60305 } 60306 60307 // end block for C++ 60308 60309 // Local Variables: 60310 // mode: c 60311 // c-basic-offset: 4 60312 // fill-column: 78 60313 // End: 60314 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 60315 // This file is part of the GNU C Library. 60316 // 60317 // The GNU C Library is free software; you can redistribute it and/or 60318 // modify it under the terms of the GNU Lesser General Public 60319 // License as published by the Free Software Foundation; either 60320 // version 2.1 of the License, or (at your option) any later version. 60321 // 60322 // The GNU C Library is distributed in the hope that it will be useful, 60323 // but WITHOUT ANY WARRANTY; without even the implied warranty of 60324 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 60325 // Lesser General Public License for more details. 60326 // 60327 // You should have received a copy of the GNU Lesser General Public 60328 // License along with the GNU C Library; if not, see 60329 // <http://www.gnu.org/licenses/>. 60330 60331 // ISO C99 Standard: 7.20 General utilities <stdlib.h> 60332 60333 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 60334 // This file is part of the GNU C Library. 60335 // 60336 // The GNU C Library is free software; you can redistribute it and/or 60337 // modify it under the terms of the GNU Lesser General Public 60338 // License as published by the Free Software Foundation; either 60339 // version 2.1 of the License, or (at your option) any later version. 60340 // 60341 // The GNU C Library is distributed in the hope that it will be useful, 60342 // but WITHOUT ANY WARRANTY; without even the implied warranty of 60343 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 60344 // Lesser General Public License for more details. 60345 // 60346 // You should have received a copy of the GNU Lesser General Public 60347 // License along with the GNU C Library; if not, see 60348 // <http://www.gnu.org/licenses/>. 60349 60350 // ISO C99 Standard: 7.21 String handling <string.h> 60351 60352 // Macro to stringify the results of the evaluation a pre-processor 60353 // macro. i.e. so that STRINGVALUE(SQLITE_NOMEM) -> "7". 60354 60355 // This routine sets entries in the global ::sqlite_options() array variable 60356 // according to the compile-time configuration of the database. Test 60357 // procedures use this to determine when tests should be omitted. 60358 func set_options(tls *libc.TLS, interp uintptr) { /* test_config.c:47:13: */ 60359 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28231 /* "malloc_usable_si..." */, ts+28250, /* "1" */ 60360 TCL_GLOBAL_ONLY) 60361 60362 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28252 /* "rowid32" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60363 60364 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28260 /* "casesensitivelik..." */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60365 60366 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28278 /* "curdir" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60367 60368 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28285 /* "win32malloc" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60369 60370 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28297 /* "debug" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60371 60372 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28303 /* "default_ckptfull..." */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60373 60374 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28325 /* "direct_read" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60375 60376 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28337 /* "dirsync" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60377 60378 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28345 /* "lfs" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60379 60380 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28349 /* "pagecache_overfl..." */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60381 60382 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28374 /* "mmap" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60383 60384 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28379, /* "worker_threads" */ 60385 ts+28394 /* "8" */, TCL_GLOBAL_ONLY) 60386 60387 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28396 /* "memdebug" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60388 60389 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28405 /* "8_3_names" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60390 60391 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28415 /* "cursorhints" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60392 60393 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28427 /* "hiddencolumns" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60394 60395 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+13154 /* "deserialize" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60396 60397 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28441 /* "mathlib" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60398 60399 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28449 /* "mem3" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60400 60401 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28454 /* "mem5" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60402 60403 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28459 /* "offset_sql_func" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60404 60405 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+13262 /* "preupdate" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60406 60407 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28475 /* "snapshot" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60408 60409 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28484 /* "mutex" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60410 60411 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28490 /* "mutex_noop" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60412 60413 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28501 /* "altertable" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60414 60415 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+1818 /* "analyze" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60416 60417 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28512 /* "api_armor" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60418 60419 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28522 /* "atomicwrite" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60420 60421 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28534 /* "json1" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60422 60423 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28540 /* "has_codec" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60424 60425 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28550 /* "like_match_blobs" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60426 60427 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28567 /* "attach" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60428 60429 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28574 /* "auth" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60430 60431 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28579 /* "autoinc" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60432 60433 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+12735 /* "autoindex" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60434 60435 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28587 /* "autoreset" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60436 60437 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28597 /* "autovacuum" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60438 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28608, /* "default_autovacu..." */ 60439 ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60440 60441 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28627 /* "between_opt" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60442 60443 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28639 /* "builtin_test" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60444 60445 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28652 /* "bloblit" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60446 60447 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28660 /* "cast" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60448 60449 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28665 /* "check" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60450 60451 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28671 /* "cte" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60452 60453 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28675 /* "columnmetadata" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60454 60455 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28690 /* "oversize_cell_ch..." */, ts+13875, /* "0" */ 60456 TCL_GLOBAL_ONLY) 60457 60458 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28710 /* "compileoption_di..." */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60459 60460 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+13133 /* "complete" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60461 60462 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28730 /* "compound" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60463 60464 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28739 /* "conflict" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60465 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28748 /* "crashtest" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60466 60467 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28758 /* "datetime" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60468 60469 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28767 /* "decltype" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60470 60471 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28776 /* "deprecated" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60472 60473 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28787 /* "diskio" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60474 60475 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+4845 /* "explain" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60476 60477 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28794 /* "floatingpoint" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60478 60479 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28808 /* "foreignkey" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60480 60481 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28819 /* "fts1" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60482 60483 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28824 /* "fts2" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60484 60485 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28829 /* "fts3" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60486 60487 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28834 /* "fts5" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60488 60489 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28839 /* "fts3_unicode" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60490 60491 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28852 /* "fts4_deferred" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60492 60493 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28866 /* "gettable" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60494 60495 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28875 /* "icu" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60496 60497 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28879 /* "icu_collations" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60498 60499 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+10526 /* "incrblob" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60500 60501 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28894 /* "integrityck" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60502 60503 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28906 /* "legacyformat" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60504 60505 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28919 /* "like_opt" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60506 60507 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28928 /* "load_ext" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60508 60509 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28937 /* "localtime" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60510 60511 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28947 /* "lookaside" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60512 60513 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28957, /* "long_double" */ 60514 func() uintptr { 60515 if uint64(unsafe.Sizeof(float64(0))) > uint64(unsafe.Sizeof(float64(0))) { 60516 return ts + 28250 /* "1" */ 60517 } 60518 return ts + 13875 /* "0" */ 60519 }(), 60520 TCL_GLOBAL_ONLY) 60521 60522 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28969 /* "memorydb" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60523 60524 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28978 /* "memorymanage" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60525 60526 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+28991 /* "mergesort" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60527 60528 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29001 /* "null_trim" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60529 60530 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29011 /* "or_opt" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60531 60532 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29018 /* "rbu" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60533 60534 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29022 /* "pager_pragmas" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60535 60536 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29036 /* "pragma" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60537 60538 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+10201 /* "progress" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60539 60540 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29043 /* "reindex" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60541 60542 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29051 /* "rtree" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60543 60544 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29057 /* "rtree_int_only" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60545 60546 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29072 /* "schema_pragmas" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60547 60548 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29087 /* "schema_version" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60549 60550 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29102 /* "session" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60551 60552 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+18460 /* "stat4" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60553 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29110 /* "stmtvtab" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60554 60555 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29119 /* "scanstatus" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60556 60557 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29130 /* "lock_proxy_pragm..." */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60558 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29149 /* "prefer_proxy_loc..." */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60559 60560 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29170 /* "shared_cache" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60561 60562 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29183 /* "subquery" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60563 60564 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29192 /* "tclvar" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60565 60566 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29199, /* "threadsafe" */ 60567 func() uintptr { 60568 if 1 != 0 { 60569 return ts + 28250 /* "1" */ 60570 } 60571 return ts + 13875 /* "0" */ 60572 }(), TCL_GLOBAL_ONLY) 60573 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29210, /* "threadsafe1" */ 60574 func() uintptr { 60575 if SQLITE_THREADSAFE == 1 { 60576 return ts + 28250 /* "1" */ 60577 } 60578 return ts + 13875 /* "0" */ 60579 }(), TCL_GLOBAL_ONLY) 60580 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29222, /* "threadsafe2" */ 60581 func() uintptr { 60582 if SQLITE_THREADSAFE == 2 { 60583 return ts + 28250 /* "1" */ 60584 } 60585 return ts + 13875 /* "0" */ 60586 }(), TCL_GLOBAL_ONLY) 60587 60588 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29234 /* "tempdb" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60589 60590 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+13347 /* "trace" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60591 60592 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29241 /* "trigger" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60593 60594 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29249 /* "truncate_opt" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60595 60596 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+15410 /* "utf16" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60597 60598 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29262 /* "vacuum" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60599 60600 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29269 /* "view" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60601 60602 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29274 /* "vtab" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60603 60604 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29279 /* "wal" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60605 60606 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29283 /* "wsd" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60607 60608 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29287 /* "update_delete_li..." */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60609 60610 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+13374 /* "unlock_notify" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60611 60612 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29307 /* "fast_secure_dele..." */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60613 60614 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29326 /* "secure_delete" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60615 60616 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29340 /* "userauth" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60617 60618 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29349 /* "multiplex_ext_ov..." */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60619 60620 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29373 /* "yytrackmaxstackd..." */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60621 60622 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29394 /* "sqllog" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60623 60624 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29401 /* "uri_00_error" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60625 60626 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29414 /* "normalize" */, ts+13875 /* "0" */, TCL_GLOBAL_ONLY) 60627 60628 tcl.XTcl_SetVar2(tls, interp, ts+28216 /* "sqlite_options" */, ts+29424 /* "windowfunc" */, ts+28250 /* "1" */, TCL_GLOBAL_ONLY) 60629 60630 { 60631 tcl.XTcl_LinkVar(tls, interp, ts+29435 /* "SQLITE_MAX_LENGT..." */, uintptr(unsafe.Pointer(&cv_MAX_LENGTH)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60632 } 60633 60634 { 60635 tcl.XTcl_LinkVar(tls, interp, ts+29453 /* "SQLITE_MAX_COLUM..." */, uintptr(unsafe.Pointer(&cv_MAX_COLUMN)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60636 } 60637 60638 { 60639 tcl.XTcl_LinkVar(tls, interp, ts+29471 /* "SQLITE_MAX_SQL_L..." */, uintptr(unsafe.Pointer(&cv_MAX_SQL_LENGTH)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60640 } 60641 60642 { 60643 tcl.XTcl_LinkVar(tls, interp, ts+29493 /* "SQLITE_MAX_EXPR_..." */, uintptr(unsafe.Pointer(&cv_MAX_EXPR_DEPTH)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60644 } 60645 60646 { 60647 tcl.XTcl_LinkVar(tls, interp, ts+29515 /* "SQLITE_MAX_COMPO..." */, uintptr(unsafe.Pointer(&cv_MAX_COMPOUND_SELECT)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60648 } 60649 60650 { 60651 tcl.XTcl_LinkVar(tls, interp, ts+29542 /* "SQLITE_MAX_VDBE_..." */, uintptr(unsafe.Pointer(&cv_MAX_VDBE_OP)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60652 } 60653 60654 { 60655 tcl.XTcl_LinkVar(tls, interp, ts+29561 /* "SQLITE_MAX_FUNCT..." */, uintptr(unsafe.Pointer(&cv_MAX_FUNCTION_ARG)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60656 } 60657 60658 { 60659 tcl.XTcl_LinkVar(tls, interp, ts+29585 /* "SQLITE_MAX_VARIA..." */, uintptr(unsafe.Pointer(&cv_MAX_VARIABLE_NUMBER)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60660 } 60661 60662 { 60663 tcl.XTcl_LinkVar(tls, interp, ts+29612 /* "SQLITE_MAX_PAGE_..." */, uintptr(unsafe.Pointer(&cv_MAX_PAGE_SIZE)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60664 } 60665 60666 { 60667 tcl.XTcl_LinkVar(tls, interp, ts+29633 /* "SQLITE_MAX_PAGE_..." */, uintptr(unsafe.Pointer(&cv_MAX_PAGE_COUNT)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60668 } 60669 60670 { 60671 tcl.XTcl_LinkVar(tls, interp, ts+29655 /* "SQLITE_MAX_LIKE_..." */, uintptr(unsafe.Pointer(&cv_MAX_LIKE_PATTERN_LENGTH)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60672 } 60673 60674 { 60675 tcl.XTcl_LinkVar(tls, interp, ts+29686 /* "SQLITE_MAX_TRIGG..." */, uintptr(unsafe.Pointer(&cv_MAX_TRIGGER_DEPTH)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60676 } 60677 60678 { 60679 tcl.XTcl_LinkVar(tls, interp, ts+29711 /* "SQLITE_DEFAULT_C..." */, uintptr(unsafe.Pointer(&cv_DEFAULT_CACHE_SIZE)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60680 } 60681 60682 { 60683 tcl.XTcl_LinkVar(tls, interp, ts+29737 /* "SQLITE_DEFAULT_P..." */, uintptr(unsafe.Pointer(&cv_DEFAULT_PAGE_SIZE)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60684 } 60685 60686 { 60687 tcl.XTcl_LinkVar(tls, interp, ts+29762 /* "SQLITE_DEFAULT_F..." */, uintptr(unsafe.Pointer(&cv_DEFAULT_FILE_FORMAT)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60688 } 60689 60690 { 60691 tcl.XTcl_LinkVar(tls, interp, ts+29789 /* "SQLITE_DEFAULT_S..." */, uintptr(unsafe.Pointer(&cv_DEFAULT_SYNCHRONOUS)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60692 } 60693 60694 { 60695 tcl.XTcl_LinkVar(tls, interp, ts+29816 /* "SQLITE_DEFAULT_W..." */, uintptr(unsafe.Pointer(&cv_DEFAULT_WAL_SYNCHRONOUS)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60696 } 60697 60698 { 60699 tcl.XTcl_LinkVar(tls, interp, ts+29847 /* "SQLITE_MAX_ATTAC..." */, uintptr(unsafe.Pointer(&cv_MAX_ATTACHED)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60700 } 60701 60702 { 60703 tcl.XTcl_LinkVar(tls, interp, ts+29867 /* "SQLITE_MAX_DEFAU..." */, uintptr(unsafe.Pointer(&cv_MAX_DEFAULT_PAGE_SIZE)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60704 } 60705 60706 { 60707 tcl.XTcl_LinkVar(tls, interp, ts+29896 /* "SQLITE_MAX_WORKE..." */, uintptr(unsafe.Pointer(&cv_MAX_WORKER_THREADS)), (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60708 } 60709 60710 { 60711 tcl.XTcl_LinkVar(tls, interp, ts+29922 /* "TEMP_STORE" */, uintptr(unsafe.Pointer(&cv_TEMP_STORE)), 60712 (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60713 60714 } 60715 60716 { 60717 tcl.XTcl_LinkVar(tls, interp, ts+29933 /* "__GNUC__" */, uintptr(unsafe.Pointer(&cv___GNUC__)), 60718 (TCL_LINK_INT | TCL_LINK_READ_ONLY)) 60719 60720 } 60721 } 60722 60723 var cv_MAX_LENGTH int32 = SQLITE_MAX_LENGTH /* test_config.c:778:3 */ 60724 var cv_MAX_COLUMN int32 = SQLITE_MAX_COLUMN /* test_config.c:779:3 */ 60725 var cv_MAX_SQL_LENGTH int32 = SQLITE_MAX_SQL_LENGTH /* test_config.c:780:3 */ 60726 var cv_MAX_EXPR_DEPTH int32 = SQLITE_MAX_EXPR_DEPTH /* test_config.c:781:3 */ 60727 var cv_MAX_COMPOUND_SELECT int32 = SQLITE_MAX_COMPOUND_SELECT /* test_config.c:782:3 */ 60728 var cv_MAX_VDBE_OP int32 = SQLITE_MAX_VDBE_OP /* test_config.c:783:3 */ 60729 var cv_MAX_FUNCTION_ARG int32 = SQLITE_MAX_FUNCTION_ARG /* test_config.c:784:3 */ 60730 var cv_MAX_VARIABLE_NUMBER int32 = SQLITE_MAX_VARIABLE_NUMBER /* test_config.c:785:3 */ 60731 var cv_MAX_PAGE_SIZE int32 = SQLITE_MAX_PAGE_SIZE /* test_config.c:786:3 */ 60732 var cv_MAX_PAGE_COUNT int32 = SQLITE_MAX_PAGE_COUNT /* test_config.c:787:3 */ 60733 var cv_MAX_LIKE_PATTERN_LENGTH int32 = SQLITE_MAX_LIKE_PATTERN_LENGTH /* test_config.c:788:3 */ 60734 var cv_MAX_TRIGGER_DEPTH int32 = SQLITE_MAX_TRIGGER_DEPTH /* test_config.c:789:3 */ 60735 var cv_DEFAULT_CACHE_SIZE int32 = -2000 /* test_config.c:790:3 */ 60736 var cv_DEFAULT_PAGE_SIZE int32 = SQLITE_DEFAULT_PAGE_SIZE /* test_config.c:791:3 */ 60737 var cv_DEFAULT_FILE_FORMAT int32 = SQLITE_DEFAULT_FILE_FORMAT /* test_config.c:792:3 */ 60738 var cv_DEFAULT_SYNCHRONOUS int32 = SQLITE_DEFAULT_SYNCHRONOUS /* test_config.c:793:3 */ 60739 var cv_DEFAULT_WAL_SYNCHRONOUS int32 = SQLITE_DEFAULT_SYNCHRONOUS /* test_config.c:794:3 */ 60740 var cv_MAX_ATTACHED int32 = SQLITE_MAX_ATTACHED /* test_config.c:795:3 */ 60741 var cv_MAX_DEFAULT_PAGE_SIZE int32 = SQLITE_MAX_DEFAULT_PAGE_SIZE /* test_config.c:796:3 */ 60742 var cv_MAX_WORKER_THREADS int32 = SQLITE_MAX_WORKER_THREADS /* test_config.c:797:3 */ 60743 var cv_TEMP_STORE int32 = SQLITE_TEMP_STORE /* test_config.c:800:22 */ 60744 var cv___GNUC__ int32 = 1 /* test_config.c:814:22 */ 60745 60746 // Register commands with the TCL interpreter. 60747 func Sqliteconfig_Init(tls *libc.TLS, interp uintptr) int32 { /* test_config.c:825:5: */ 60748 set_options(tls, interp) 60749 return TCL_OK 60750 } 60751 60752 // 60753 // END OF REGISTRATION API 60754 // 60755 60756 //******* End of fts5.h ******** 60757 60758 // The following #defines are copied from test_multiplex.c 60759 60760 // This routine is a copy of (most of) the code from SQLite function 60761 // sqlite3FileSuffix3(). It modifies the filename in buffer z in the 60762 // same way as SQLite does when in 8.3 filenames mode. 60763 func sqlite3Delete83Name(tls *libc.TLS, z uintptr) { /* test_delete.c:46:13: */ 60764 var i int32 60765 var sz int32 60766 sz = int32(libc.Xstrlen(tls, z)) 60767 for i = (sz - 1); ((i > 0) && (int32(*(*int8)(unsafe.Pointer(z + uintptr(i)))) != '/')) && (int32(*(*int8)(unsafe.Pointer(z + uintptr(i)))) != '.'); i-- { 60768 } 60769 if (int32(*(*int8)(unsafe.Pointer(z + uintptr(i)))) == '.') && (sz > (i + 4)) { 60770 libc.Xmemmove(tls, (z + uintptr((i + 1))), (z + uintptr((sz - 3))), uint64(4)) 60771 } 60772 } 60773 60774 // zFile is a filename. Assuming no error occurs, if this file exists, 60775 // set *pbExists to true and unlink it. Or, if the file does not exist, 60776 // set *pbExists to false before returning. 60777 // 60778 // If an error occurs, non-zero is returned. Or, if no error occurs, zero. 60779 func sqlite3DeleteUnlinkIfExists(tls *libc.TLS, pVfs uintptr, zFile uintptr, pbExists uintptr) int32 { /* test_delete.c:60:12: */ 60780 var rc int32 = SQLITE_ERROR 60781 60782 rc = libc.Xaccess(tls, zFile, F_OK) 60783 if rc != 0 { 60784 if (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) == ENOENT { 60785 if pbExists != 0 { 60786 *(*int32)(unsafe.Pointer(pbExists)) = 0 60787 } 60788 rc = SQLITE_OK 60789 } 60790 } else { 60791 if pbExists != 0 { 60792 *(*int32)(unsafe.Pointer(pbExists)) = 1 60793 } 60794 rc = libc.Xunlink(tls, zFile) 60795 } 60796 return rc 60797 } 60798 60799 // Delete the database file identified by the string argument passed to this 60800 // function. The string must contain a filename, not an SQLite URI. 60801 func sqlite3_delete_database(tls *libc.TLS, zFile uintptr) int32 { /* test_delete.c:95:16: */ 60802 bp := tls.Alloc(156) 60803 defer tls.Free(156) 60804 60805 var zBuf uintptr // Buffer to sprintf() filenames to 60806 var nBuf int32 // Size of buffer in bytes 60807 var rc int32 = 0 // System error code 60808 var i int32 // Iterate through azFmt[] and aMFile[] 60809 60810 *(*[4]uintptr)(unsafe.Pointer(bp + 24 /* azFmt */)) = [4]uintptr{ts /* "%s" */, ts + 29942 /* "%s-journal" */, ts + 29953 /* "%s-wal" */, ts + 29960 /* "%s-shm" */} 60811 60812 *(*[6]MFile)(unsafe.Pointer(bp + 56 /* aMFile */)) = [6]MFile{ 60813 {FzFmt: ts + 29967 /* "%s%03d" */}, 60814 {FzFmt: ts + 29974 /* "%s-journal%03d" */}, 60815 {FzFmt: ts + 29989 /* "%s-wal%03d" */}, 60816 {FzFmt: ts + 29967 /* "%s%03d" */, Fb83: 1}, 60817 {FzFmt: ts + 29974 /* "%s-journal%03d" */, FiOffset: SQLITE_MULTIPLEX_JOURNAL_8_3_OFFSET, Fb83: 1}, 60818 {FzFmt: ts + 29989 /* "%s-wal%03d" */, FiOffset: SQLITE_MULTIPLEX_WAL_8_3_OFFSET, Fb83: 1}, 60819 } 60820 60821 var pVfs uintptr = uintptr(0) 60822 60823 // Allocate a buffer large enough for any of the files that need to be 60824 // deleted. 60825 nBuf = (int32(libc.Xstrlen(tls, zFile)) + 100) 60826 zBuf = sqlite3.Xsqlite3_malloc(tls, nBuf) 60827 if zBuf == uintptr(0) { 60828 return SQLITE_NOMEM 60829 } 60830 60831 // Delete both the regular and 8.3 filenames versions of the database, 60832 // journal, wal and shm files. 60833 for i = 0; (rc == 0) && (uint64(i) < (uint64(unsafe.Sizeof([4]uintptr{})) / uint64(unsafe.Sizeof(uintptr(0))))); i++ { 60834 sqlite3.Xsqlite3_snprintf(tls, nBuf, zBuf, *(*uintptr)(unsafe.Pointer(bp + 24 /* &azFmt[0] */ + uintptr(i)*8)), libc.VaList(bp, zFile)) 60835 rc = sqlite3DeleteUnlinkIfExists(tls, pVfs, zBuf, uintptr(0)) 60836 if (rc == 0) && (i != 0) { 60837 sqlite3Delete83Name(tls, zBuf) 60838 rc = sqlite3DeleteUnlinkIfExists(tls, pVfs, zBuf, uintptr(0)) 60839 } 60840 } 60841 60842 // Delete any multiplexor files 60843 for i = 0; (rc == 0) && (uint64(i) < (uint64(unsafe.Sizeof([6]MFile{})) / uint64(unsafe.Sizeof(MFile{})))); i++ { 60844 var p uintptr = (bp + 56 /* &aMFile */ + uintptr(i)*16) 60845 var iChunk int32 60846 for iChunk = 1; iChunk <= MX_CHUNK_NUMBER; iChunk++ { 60847 // var bExists int32 at bp+152, 4 60848 60849 sqlite3.Xsqlite3_snprintf(tls, nBuf, zBuf, (*MFile)(unsafe.Pointer(p)).FzFmt, libc.VaList(bp+8, zFile, (iChunk+(*MFile)(unsafe.Pointer(p)).FiOffset))) 60850 if (*MFile)(unsafe.Pointer(p)).Fb83 != 0 { 60851 sqlite3Delete83Name(tls, zBuf) 60852 } 60853 rc = sqlite3DeleteUnlinkIfExists(tls, pVfs, zBuf, bp+152 /* &bExists */) 60854 if (*(*int32)(unsafe.Pointer(bp + 152 /* bExists */)) == 0) || (rc != 0) { 60855 break 60856 } 60857 } 60858 } 60859 60860 sqlite3.Xsqlite3_free(tls, zBuf) 60861 return func() int32 { 60862 if rc != 0 { 60863 return SQLITE_ERROR 60864 } 60865 return SQLITE_OK 60866 }() 60867 } 60868 60869 type MFile = struct { 60870 FzFmt uintptr 60871 FiOffset int32 60872 Fb83 int32 60873 } /* test_delete.c:105:3 */ 60874 60875 // end block for C++ 60876 60877 // Local Variables: 60878 // mode: c 60879 // c-basic-offset: 4 60880 // fill-column: 78 60881 // End: 60882 60883 func Sqlitetest_demovfs_Init(tls *libc.TLS, interp uintptr) int32 { /* test_demovfs.c:686:5: */ 60884 return TCL_OK 60885 } 60886 60887 // Maximum pathname length supported by the devsym backend. 60888 60889 // Name used to identify this VFS. 60890 60891 type devsym_file1 = struct { 60892 Fbase sqlite3_file 60893 FpReal uintptr 60894 } /* test_devsym.c:33:9 */ 60895 60896 // Maximum pathname length supported by the devsym backend. 60897 60898 // Name used to identify this VFS. 60899 60900 type devsym_file = devsym_file1 /* test_devsym.c:33:28 */ 60901 60902 type DevsymGlobal = struct { 60903 FpVfs uintptr 60904 FiDeviceChar int32 60905 FiSectorSize int32 60906 FnWriteCrash int32 60907 _ [4]byte 60908 } /* test_devsym.c:76:1 */ 60909 60910 var g1 = DevsymGlobal{FiSectorSize: 512} /* test_devsym.c:82:21 */ 60911 60912 // Close an devsym-file. 60913 func devsymClose(tls *libc.TLS, pFile uintptr) int32 { /* test_devsym.c:87:12: */ 60914 var p uintptr = pFile 60915 sqlite3.Xsqlite3OsClose(tls, (*devsym_file)(unsafe.Pointer(p)).FpReal) 60916 return SQLITE_OK 60917 } 60918 60919 // Read data from an devsym-file. 60920 func devsymRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test_devsym.c:96:12: */ 60921 var p uintptr = pFile 60922 return sqlite3.Xsqlite3OsRead(tls, (*devsym_file)(unsafe.Pointer(p)).FpReal, zBuf, iAmt, iOfst) 60923 } 60924 60925 // Write data to an devsym-file. 60926 func devsymWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test_devsym.c:109:12: */ 60927 var p uintptr = pFile 60928 return sqlite3.Xsqlite3OsWrite(tls, (*devsym_file)(unsafe.Pointer(p)).FpReal, zBuf, iAmt, iOfst) 60929 } 60930 60931 // Truncate an devsym-file. 60932 func devsymTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { /* test_devsym.c:122:12: */ 60933 var p uintptr = pFile 60934 return sqlite3.Xsqlite3OsTruncate(tls, (*devsym_file)(unsafe.Pointer(p)).FpReal, size) 60935 } 60936 60937 // Sync an devsym-file. 60938 func devsymSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* test_devsym.c:130:12: */ 60939 var p uintptr = pFile 60940 return sqlite3.Xsqlite3OsSync(tls, (*devsym_file)(unsafe.Pointer(p)).FpReal, flags) 60941 } 60942 60943 // Return the current file-size of an devsym-file. 60944 func devsymFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { /* test_devsym.c:138:12: */ 60945 var p uintptr = pFile 60946 return sqlite3.Xsqlite3OsFileSize(tls, (*devsym_file)(unsafe.Pointer(p)).FpReal, pSize) 60947 } 60948 60949 // Lock an devsym-file. 60950 func devsymLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_devsym.c:146:12: */ 60951 var p uintptr = pFile 60952 return sqlite3.Xsqlite3OsLock(tls, (*devsym_file)(unsafe.Pointer(p)).FpReal, eLock) 60953 } 60954 60955 // Unlock an devsym-file. 60956 func devsymUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_devsym.c:154:12: */ 60957 var p uintptr = pFile 60958 return sqlite3.Xsqlite3OsUnlock(tls, (*devsym_file)(unsafe.Pointer(p)).FpReal, eLock) 60959 } 60960 60961 // Check if another file-handle holds a RESERVED lock on an devsym-file. 60962 func devsymCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int32 { /* test_devsym.c:162:12: */ 60963 var p uintptr = pFile 60964 return sqlite3.Xsqlite3OsCheckReservedLock(tls, (*devsym_file)(unsafe.Pointer(p)).FpReal, pResOut) 60965 } 60966 60967 // File control method. For custom operations on an devsym-file. 60968 func devsymFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 { /* test_devsym.c:170:12: */ 60969 var p uintptr = pFile 60970 return sqlite3.Xsqlite3OsFileControl(tls, (*devsym_file)(unsafe.Pointer(p)).FpReal, op, pArg) 60971 } 60972 60973 // Return the sector-size in bytes for an devsym-file. 60974 func devsymSectorSize(tls *libc.TLS, pFile uintptr) int32 { /* test_devsym.c:178:12: */ 60975 return g1.FiSectorSize 60976 } 60977 60978 // Return the device characteristic flags supported by an devsym-file. 60979 func devsymDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { /* test_devsym.c:185:12: */ 60980 return g1.FiDeviceChar 60981 } 60982 60983 // Shared-memory methods are all pass-thrus. 60984 func devsymShmLock(tls *libc.TLS, pFile uintptr, ofst int32, n int32, flags int32) int32 { /* test_devsym.c:192:12: */ 60985 var p uintptr = pFile 60986 return (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*devsym_file)(unsafe.Pointer(p)).FpReal)).FpMethods + 112 /* &.xShmLock */))))(tls, (*devsym_file)(unsafe.Pointer(p)).FpReal, ofst, n, flags) 60987 } 60988 60989 func devsymShmMap(tls *libc.TLS, pFile uintptr, iRegion int32, szRegion int32, isWrite int32, pp uintptr) int32 { /* test_devsym.c:196:12: */ 60990 var p uintptr = pFile 60991 return (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*devsym_file)(unsafe.Pointer(p)).FpReal)).FpMethods + 104 /* &.xShmMap */))))(tls, (*devsym_file)(unsafe.Pointer(p)).FpReal, iRegion, szRegion, isWrite, libc.AtomicLoadUintptr(&pp)) 60992 } 60993 60994 func devsymShmBarrier(tls *libc.TLS, pFile uintptr) { /* test_devsym.c:206:13: */ 60995 var p uintptr = pFile 60996 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*devsym_file)(unsafe.Pointer(p)).FpReal)).FpMethods + 120 /* &.xShmBarrier */))))(tls, (*devsym_file)(unsafe.Pointer(p)).FpReal) 60997 } 60998 60999 func devsymShmUnmap(tls *libc.TLS, pFile uintptr, delFlag int32) int32 { /* test_devsym.c:210:12: */ 61000 var p uintptr = pFile 61001 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*devsym_file)(unsafe.Pointer(p)).FpReal)).FpMethods + 128 /* &.xShmUnmap */))))(tls, (*devsym_file)(unsafe.Pointer(p)).FpReal, delFlag) 61002 } 61003 61004 // Open an devsym file handle. 61005 func devsymOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags int32, pOutFlags uintptr) int32 { /* test_devsym.c:220:12: */ 61006 var rc int32 61007 var p uintptr = pFile 61008 (*devsym_file)(unsafe.Pointer(p)).FpReal = (p + 1*16) 61009 rc = sqlite3.Xsqlite3OsOpen(tls, g1.FpVfs, zName, (*devsym_file)(unsafe.Pointer(p)).FpReal, flags, pOutFlags) 61010 if (*sqlite3_file)(unsafe.Pointer((*devsym_file)(unsafe.Pointer(p)).FpReal)).FpMethods != 0 { 61011 (*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&devsym_io_methods)) 61012 } 61013 return rc 61014 } 61015 61016 var devsym_io_methods = sqlite3_io_methods{ 61017 FiVersion: 2, // iVersion 61018 FxClose: 0, // xClose 61019 FxRead: 0, // xRead 61020 FxWrite: 0, // xWrite 61021 FxTruncate: 0, // xTruncate 61022 FxSync: 0, // xSync 61023 FxFileSize: 0, // xFileSize 61024 FxLock: 0, // xLock 61025 FxUnlock: 0, // xUnlock 61026 FxCheckReservedLock: 0, // xCheckReservedLock 61027 FxFileControl: 0, // xFileControl 61028 FxSectorSize: 0, // xSectorSize 61029 FxDeviceCharacteristics: 0, // xDeviceCharacteristics 61030 FxShmMap: 0, // xShmMap 61031 FxShmLock: 0, // xShmLock 61032 FxShmBarrier: 0, // xShmBarrier 61033 FxShmUnmap: 0, // xShmUnmap 61034 } /* test_devsym.c:227:27 */ 61035 61036 // Delete the file located at zPath. If the dirSync argument is true, 61037 // ensure the file-system modifications are synced to disk before 61038 // returning. 61039 func devsymDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) int32 { /* test_devsym.c:262:12: */ 61040 return sqlite3.Xsqlite3OsDelete(tls, g1.FpVfs, zPath, dirSync) 61041 } 61042 61043 // Test for access permissions. Return true if the requested permission 61044 // is available, or false otherwise. 61045 func devsymAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut uintptr) int32 { /* test_devsym.c:270:12: */ 61046 return sqlite3.Xsqlite3OsAccess(tls, g1.FpVfs, zPath, flags, pResOut) 61047 } 61048 61049 // Populate buffer zOut with the full canonical pathname corresponding 61050 // to the pathname in zPath. zOut is guaranteed to point to a buffer 61051 // of at least (DEVSYM_MAX_PATHNAME+1) bytes. 61052 func devsymFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zOut uintptr) int32 { /* test_devsym.c:284:12: */ 61053 return sqlite3.Xsqlite3OsFullPathname(tls, g1.FpVfs, zPath, nOut, zOut) 61054 } 61055 61056 // Populate the buffer pointed to by zBufOut with nByte bytes of 61057 // random data. 61058 func devsymRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uintptr) int32 { /* test_devsym.c:329:12: */ 61059 return sqlite3.Xsqlite3OsRandomness(tls, g1.FpVfs, nByte, zBufOut) 61060 } 61061 61062 // Sleep for nMicro microseconds. Return the number of microseconds 61063 // actually slept. 61064 func devsymSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) int32 { /* test_devsym.c:337:12: */ 61065 return sqlite3.Xsqlite3OsSleep(tls, g1.FpVfs, nMicro) 61066 } 61067 61068 // Return the current time as a Julian Day number in *pTimeOut. 61069 func devsymCurrentTime(tls *libc.TLS, pVfs uintptr, pTimeOut uintptr) int32 { /* test_devsym.c:344:12: */ 61070 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((g1.FpVfs + 120 /* &.xCurrentTime */))))(tls, g1.FpVfs, pTimeOut) 61071 } 61072 61073 // Return the sector-size in bytes for an writecrash-file. 61074 func writecrashSectorSize(tls *libc.TLS, pFile uintptr) int32 { /* test_devsym.c:351:12: */ 61075 var p uintptr = pFile 61076 return sqlite3.Xsqlite3OsSectorSize(tls, (*devsym_file)(unsafe.Pointer(p)).FpReal) 61077 } 61078 61079 // Return the device characteristic flags supported by an writecrash-file. 61080 func writecrashDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { /* test_devsym.c:359:12: */ 61081 var p uintptr = pFile 61082 return sqlite3.Xsqlite3OsDeviceCharacteristics(tls, (*devsym_file)(unsafe.Pointer(p)).FpReal) 61083 } 61084 61085 // Write data to an writecrash-file. 61086 func writecrashWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test_devsym.c:367:12: */ 61087 var p uintptr = pFile 61088 if g1.FnWriteCrash > 0 { 61089 g1.FnWriteCrash-- 61090 if g1.FnWriteCrash == 0 { 61091 libc.Xabort(tls) 61092 } 61093 } 61094 return sqlite3.Xsqlite3OsWrite(tls, (*devsym_file)(unsafe.Pointer(p)).FpReal, zBuf, iAmt, iOfst) 61095 } 61096 61097 // Open an writecrash file handle. 61098 func writecrashOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags int32, pOutFlags uintptr) int32 { /* test_devsym.c:384:12: */ 61099 var rc int32 61100 var p uintptr = pFile 61101 (*devsym_file)(unsafe.Pointer(p)).FpReal = (p + 1*16) 61102 rc = sqlite3.Xsqlite3OsOpen(tls, g1.FpVfs, zName, (*devsym_file)(unsafe.Pointer(p)).FpReal, flags, pOutFlags) 61103 if (*sqlite3_file)(unsafe.Pointer((*devsym_file)(unsafe.Pointer(p)).FpReal)).FpMethods != 0 { 61104 (*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&writecrash_io_methods)) 61105 } 61106 return rc 61107 } 61108 61109 var writecrash_io_methods = sqlite3_io_methods{ 61110 FiVersion: 2, // iVersion 61111 FxClose: 0, // xClose 61112 FxRead: 0, // xRead 61113 FxWrite: 0, // xWrite 61114 FxTruncate: 0, // xTruncate 61115 FxSync: 0, // xSync 61116 FxFileSize: 0, // xFileSize 61117 FxLock: 0, // xLock 61118 FxUnlock: 0, // xUnlock 61119 FxCheckReservedLock: 0, // xCheckReservedLock 61120 FxFileControl: 0, // xFileControl 61121 FxSectorSize: 0, // xSectorSize 61122 FxDeviceCharacteristics: 0, // xDeviceCharacteristics 61123 FxShmMap: 0, // xShmMap 61124 FxShmLock: 0, // xShmLock 61125 FxShmBarrier: 0, // xShmBarrier 61126 FxShmUnmap: 0, // xShmUnmap 61127 } /* test_devsym.c:391:27 */ 61128 61129 var devsym_vfs = sqlite3_vfs{ 61130 FiVersion: 2, // iVersion 61131 FszOsFile: int32(unsafe.Sizeof(devsym_file{})), // szOsFile 61132 FmxPathname: DEVSYM_MAX_PATHNAME, // pNext 61133 FzName: ts + 30000, /* "devsym" */ // pAppData 61134 FxOpen: 0, // xOpen 61135 FxDelete: 0, // xDelete 61136 FxAccess: 0, // xAccess 61137 FxFullPathname: 0, // xDlClose 61138 FxRandomness: 0, // xRandomness 61139 FxSleep: 0, // xSleep 61140 FxCurrentTime: 0, // xCurrentTimeInt64 61141 } /* test_devsym.c:421:20 */ 61142 61143 var writecrash_vfs = sqlite3_vfs{ 61144 FiVersion: 2, // iVersion 61145 FszOsFile: int32(unsafe.Sizeof(devsym_file{})), // szOsFile 61146 FmxPathname: DEVSYM_MAX_PATHNAME, // pNext 61147 FzName: ts + 30007, /* "writecrash" */ // pAppData 61148 FxOpen: 0, // xOpen 61149 FxDelete: 0, // xDelete 61150 FxAccess: 0, // xAccess 61151 FxFullPathname: 0, // xDlClose 61152 FxRandomness: 0, // xRandomness 61153 FxSleep: 0, // xSleep 61154 FxCurrentTime: 0, // xCurrentTimeInt64 61155 } /* test_devsym.c:450:20 */ 61156 61157 // This procedure registers the devsym vfs with SQLite. If the argument is 61158 // true, the devsym vfs becomes the new default vfs. It is the only publicly 61159 // available function in this file. 61160 func devsym_register(tls *libc.TLS, iDeviceChar int32, iSectorSize int32) { /* test_devsym.c:485:6: */ 61161 61162 if g1.FpVfs == uintptr(0) { 61163 g1.FpVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 61164 *(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_vfs)) + 4 /* &.szOsFile */)) += ((*sqlite3_vfs)(unsafe.Pointer(g1.FpVfs)).FszOsFile) 61165 *(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_vfs)) + 4 /* &.szOsFile */)) += ((*sqlite3_vfs)(unsafe.Pointer(g1.FpVfs)).FszOsFile) 61166 sqlite3.Xsqlite3_vfs_register(tls, uintptr(unsafe.Pointer(&devsym_vfs)), 0) 61167 sqlite3.Xsqlite3_vfs_register(tls, uintptr(unsafe.Pointer(&writecrash_vfs)), 0) 61168 } 61169 if iDeviceChar >= 0 { 61170 g1.FiDeviceChar = iDeviceChar 61171 } else { 61172 g1.FiDeviceChar = 0 61173 } 61174 if iSectorSize >= 0 { 61175 g1.FiSectorSize = iSectorSize 61176 } else { 61177 g1.FiSectorSize = 512 61178 } 61179 } 61180 61181 func devsym_unregister(tls *libc.TLS) { /* test_devsym.c:506:6: */ 61182 sqlite3.Xsqlite3_vfs_unregister(tls, uintptr(unsafe.Pointer(&devsym_vfs))) 61183 sqlite3.Xsqlite3_vfs_unregister(tls, uintptr(unsafe.Pointer(&writecrash_vfs))) 61184 g1.FpVfs = uintptr(0) 61185 g1.FiDeviceChar = 0 61186 g1.FiSectorSize = 0 61187 } 61188 61189 func devsym_crash_on_write(tls *libc.TLS, nWrite int32) { /* test_devsym.c:514:6: */ 61190 if g1.FpVfs == uintptr(0) { 61191 g1.FpVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 61192 *(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_vfs)) + 4 /* &.szOsFile */)) += ((*sqlite3_vfs)(unsafe.Pointer(g1.FpVfs)).FszOsFile) 61193 *(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_vfs)) + 4 /* &.szOsFile */)) += ((*sqlite3_vfs)(unsafe.Pointer(g1.FpVfs)).FszOsFile) 61194 sqlite3.Xsqlite3_vfs_register(tls, uintptr(unsafe.Pointer(&devsym_vfs)), 0) 61195 sqlite3.Xsqlite3_vfs_register(tls, uintptr(unsafe.Pointer(&writecrash_vfs)), 0) 61196 } 61197 g1.FnWriteCrash = nWrite 61198 } 61199 61200 // The next short section of defines are only done when not running on Windows 61201 // or some other strange platform. 61202 61203 type Tcl_StatBuf = stat /* tcl.h:470:25 */ 61204 61205 // Note stat64 is the same shape as stat. 61206 type stat64 = struct { 61207 Fst_dev uint64 61208 Fst_ino uint64 61209 Fst_nlink uint64 61210 Fst_mode uint32 61211 Fst_uid uint32 61212 Fst_gid uint32 61213 F__glibc_reserved0 int32 61214 Fst_rdev uint64 61215 Fst_size int64 61216 Fst_atim struct { 61217 Ftv_sec int64 61218 Ftv_nsec int64 61219 } 61220 Fst_mtim struct { 61221 Ftv_sec int64 61222 Ftv_nsec int64 61223 } 61224 Fst_ctim struct { 61225 Ftv_sec int64 61226 Ftv_nsec int64 61227 } 61228 Fst_blksize int64 61229 Fst_blocks int64 61230 F__glibc_reserved [3]int64 61231 } /* stat.h:147:1 */ 61232 61233 // statx-related definitions and declarations. 61234 // Copyright (C) 2018 Free Software Foundation, Inc. 61235 // This file is part of the GNU C Library. 61236 // 61237 // The GNU C Library is free software; you can redistribute it and/or 61238 // modify it under the terms of the GNU Lesser General Public 61239 // License as published by the Free Software Foundation; either 61240 // version 2.1 of the License, or (at your option) any later version. 61241 // 61242 // The GNU C Library is distributed in the hope that it will be useful, 61243 // but WITHOUT ANY WARRANTY; without even the implied warranty of 61244 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 61245 // Lesser General Public License for more details. 61246 // 61247 // You should have received a copy of the GNU Lesser General Public 61248 // License along with the GNU C Library; if not, see 61249 // <http://www.gnu.org/licenses/>. 61250 61251 // This interface is based on <linux/stat.h> in Linux. 61252 61253 type statx_timestamp = struct { 61254 Ftv_sec int64 61255 Ftv_nsec uint32 61256 F__statx_timestamp_pad1 [1]int32 61257 } /* statx.h:25:1 */ 61258 61259 // Warning: The kernel may add additional fields to this struct in the 61260 // future. Only use this struct for calling the statx function, not 61261 // for storing data. (Expansion will be controlled by the mask 61262 // argument of the statx function.) 61263 type statx = struct { 61264 Fstx_mask uint32 61265 Fstx_blksize uint32 61266 Fstx_attributes uint64 61267 Fstx_nlink uint32 61268 Fstx_uid uint32 61269 Fstx_gid uint32 61270 Fstx_mode uint16 61271 F__statx_pad1 [1]uint16 61272 Fstx_ino uint64 61273 Fstx_size uint64 61274 Fstx_blocks uint64 61275 Fstx_attributes_mask uint64 61276 Fstx_atime struct { 61277 Ftv_sec int64 61278 Ftv_nsec uint32 61279 F__statx_timestamp_pad1 [1]int32 61280 } 61281 Fstx_btime struct { 61282 Ftv_sec int64 61283 Ftv_nsec uint32 61284 F__statx_timestamp_pad1 [1]int32 61285 } 61286 Fstx_ctime struct { 61287 Ftv_sec int64 61288 Ftv_nsec uint32 61289 F__statx_timestamp_pad1 [1]int32 61290 } 61291 Fstx_mtime struct { 61292 Ftv_sec int64 61293 Ftv_nsec uint32 61294 F__statx_timestamp_pad1 [1]int32 61295 } 61296 Fstx_rdev_major uint32 61297 Fstx_rdev_minor uint32 61298 Fstx_dev_major uint32 61299 Fstx_dev_minor uint32 61300 F__statx_pad2 [14]uint64 61301 } /* statx.h:36:1 */ 61302 61303 type flock64 = struct { 61304 Fl_type int16 61305 Fl_whence int16 61306 _ [4]byte 61307 Fl_start int64 61308 Fl_len int64 61309 Fl_pid int32 61310 _ [4]byte 61311 } /* fcntl.h:52:1 */ 61312 61313 // Include generic Linux declarations. 61314 // O_*, F_*, FD_* bit values for Linux. 61315 // Copyright (C) 2001-2018 Free Software Foundation, Inc. 61316 // This file is part of the GNU C Library. 61317 // 61318 // The GNU C Library is free software; you can redistribute it and/or 61319 // modify it under the terms of the GNU Lesser General Public 61320 // License as published by the Free Software Foundation; either 61321 // version 2.1 of the License, or (at your option) any later version. 61322 // 61323 // The GNU C Library is distributed in the hope that it will be useful, 61324 // but WITHOUT ANY WARRANTY; without even the implied warranty of 61325 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 61326 // Lesser General Public License for more details. 61327 // 61328 // You should have received a copy of the GNU Lesser General Public 61329 // License along with the GNU C Library; if not, see 61330 // <http://www.gnu.org/licenses/>. 61331 61332 // This file contains shared definitions between Linux architectures 61333 // and is included by <bits/fcntl.h> to declare them. The various 61334 // #ifndef cases allow the architecture specific file to define those 61335 // values with different values. 61336 // 61337 // A minimal <bits/fcntl.h> contains just: 61338 // 61339 // struct flock {...} 61340 // #ifdef __USE_LARGEFILE64 61341 // struct flock64 {...} 61342 // #endif 61343 // #include <bits/fcntl-linux.h> 61344 61345 // Define struct iovec. 61346 // Copyright (C) 1996-2018 Free Software Foundation, Inc. 61347 // This file is part of the GNU C Library. 61348 // 61349 // The GNU C Library is free software; you can redistribute it and/or 61350 // modify it under the terms of the GNU Lesser General Public 61351 // License as published by the Free Software Foundation; either 61352 // version 2.1 of the License, or (at your option) any later version. 61353 // 61354 // The GNU C Library is distributed in the hope that it will be useful, 61355 // but WITHOUT ANY WARRANTY; without even the implied warranty of 61356 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 61357 // Lesser General Public License for more details. 61358 // 61359 // You should have received a copy of the GNU Lesser General Public 61360 // License along with the GNU C Library; if not, see 61361 // <http://www.gnu.org/licenses/>. 61362 61363 // Copyright (C) 1989-2018 Free Software Foundation, Inc. 61364 // 61365 // This file is part of GCC. 61366 // 61367 // GCC is free software; you can redistribute it and/or modify 61368 // it under the terms of the GNU General Public License as published by 61369 // the Free Software Foundation; either version 3, or (at your option) 61370 // any later version. 61371 // 61372 // GCC is distributed in the hope that it will be useful, 61373 // but WITHOUT ANY WARRANTY; without even the implied warranty of 61374 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 61375 // GNU General Public License for more details. 61376 // 61377 // Under Section 7 of GPL version 3, you are granted additional 61378 // permissions described in the GCC Runtime Library Exception, version 61379 // 3.1, as published by the Free Software Foundation. 61380 // 61381 // You should have received a copy of the GNU General Public License and 61382 // a copy of the GCC Runtime Library Exception along with this program; 61383 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 61384 // <http://www.gnu.org/licenses/>. 61385 61386 // ISO C Standard: 7.17 Common definitions <stddef.h> 61387 61388 // Any one of these symbols __need_* means that GNU libc 61389 // wants us just to define one data type. So don't define 61390 // the symbols that indicate this file's entire job has been done. 61391 61392 // This avoids lossage on SunOS but only if stdtypes.h comes first. 61393 // There's no way to win with the other order! Sun lossage. 61394 61395 // On 4.3bsd-net2, make sure ansi.h is included, so we have 61396 // one less case to deal with in the following. 61397 // On FreeBSD 5, machine/ansi.h does not exist anymore... 61398 61399 // In 4.3bsd-net2, machine/ansi.h defines these symbols, which are 61400 // defined if the corresponding type is *not* defined. 61401 // FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_. 61402 // NetBSD defines _I386_ANSI_H_ and _X86_64_ANSI_H_ instead of _ANSI_H_ 61403 61404 // Sequent's header files use _PTRDIFF_T_ in some conflicting way. 61405 // Just ignore it. 61406 61407 // On VxWorks, <type/vxTypesBase.h> may have defined macros like 61408 // _TYPE_size_t which will typedef size_t. fixincludes patched the 61409 // vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is 61410 // not defined, and so that defining this macro defines _GCC_SIZE_T. 61411 // If we find that the macros are still defined at this point, we must 61412 // invoke them so that the type is defined as expected. 61413 61414 // In case nobody has defined these types, but we aren't running under 61415 // GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and 61416 // __WCHAR_TYPE__ have reasonable values. This can happen if the 61417 // parts of GCC is compiled by an older compiler, that actually 61418 // include gstddef.h, such as collect2. 61419 61420 // Signed type of difference of two pointers. 61421 61422 // Define this type if we are doing the whole job, 61423 // or if we want this type in particular. 61424 61425 // If this symbol has done its job, get rid of it. 61426 61427 // Unsigned type of `sizeof' something. 61428 61429 // Define this type if we are doing the whole job, 61430 // or if we want this type in particular. 61431 61432 // Wide character type. 61433 // Locale-writers should change this as necessary to 61434 // be big enough to hold unique values not between 0 and 127, 61435 // and not (wchar_t) -1, for each defined multibyte character. 61436 61437 // Define this type if we are doing the whole job, 61438 // or if we want this type in particular. 61439 61440 // In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. 61441 // are already defined. 61442 // BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. 61443 // NetBSD 5 requires the I386_ANSI_H and X86_64_ANSI_H checks here. 61444 61445 // A null pointer constant. 61446 61447 // Offset of member MEMBER in a struct of type TYPE. 61448 61449 // Structure for scatter/gather I/O. 61450 type iovec = struct { 61451 Fiov_base uintptr 61452 Fiov_len size_t 61453 } /* struct_iovec.h:26:1 */ 61454 61455 // Structure to use with F_GETOWN_EX and F_SETOWN_EX. 61456 type f_owner_ex = struct { 61457 Ftype uint32 61458 Fpid int32 61459 } /* fcntl-linux.h:274:1 */ 61460 61461 // Types of seals. 61462 61463 // Hint values for F_{GET,SET}_RW_HINT. 61464 61465 // Define some more compatibility macros to be backward compatible with 61466 // BSD systems which did not managed to hide these kernel macros. 61467 61468 // Advise to `posix_fadvise'. 61469 61470 // Flags for SYNC_FILE_RANGE. 61471 61472 // Flags for SPLICE and VMSPLICE. 61473 61474 // Flags for fallocate. 61475 // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note 61476 61477 // FALLOC_FL_COLLAPSE_RANGE is used to remove a range of a file 61478 // without leaving a hole in the file. The contents of the file beyond 61479 // the range being removed is appended to the start offset of the range 61480 // being removed (i.e. the hole that was punched is "collapsed"), 61481 // resulting in a file layout that looks like the range that was 61482 // removed never existed. As such collapsing a range of a file changes 61483 // the size of the file, reducing it by the same length of the range 61484 // that has been removed by the operation. 61485 // 61486 // Different filesystems may implement different limitations on the 61487 // granularity of the operation. Most will limit operations to 61488 // filesystem block size boundaries, but this boundary may be larger or 61489 // smaller depending on the filesystem and/or the configuration of the 61490 // filesystem or file. 61491 // 61492 // Attempting to collapse a range that crosses the end of the file is 61493 // considered an illegal operation - just use ftruncate(2) if you need 61494 // to collapse a range that crosses EOF. 61495 61496 // FALLOC_FL_ZERO_RANGE is used to convert a range of file to zeros preferably 61497 // without issuing data IO. Blocks should be preallocated for the regions that 61498 // span holes in the file, and the entire range is preferable converted to 61499 // unwritten extents - even though file system may choose to zero out the 61500 // extent or do whatever which will result in reading zeros from the range 61501 // while the range remains allocated for the file. 61502 // 61503 // This can be also used to preallocate blocks past EOF in the same way as 61504 // with fallocate. Flag FALLOC_FL_KEEP_SIZE should cause the inode 61505 // size to remain the same. 61506 61507 // FALLOC_FL_INSERT_RANGE is use to insert space within the file size without 61508 // overwriting any existing data. The contents of the file beyond offset are 61509 // shifted towards right by len bytes to create a hole. As such, this 61510 // operation will increase the size of the file by len bytes. 61511 // 61512 // Different filesystems may implement different limitations on the granularity 61513 // of the operation. Most will limit operations to filesystem block size 61514 // boundaries, but this boundary may be larger or smaller depending on 61515 // the filesystem and/or the configuration of the filesystem or file. 61516 // 61517 // Attempting to insert space using this flag at OR beyond the end of 61518 // the file is considered an illegal operation - just use ftruncate(2) or 61519 // fallocate(2) with mode 0 for such type of operations. 61520 61521 // FALLOC_FL_UNSHARE_RANGE is used to unshare shared blocks within the 61522 // file size without overwriting any existing data. The purpose of this 61523 // call is to preemptively reallocate any blocks that are subject to 61524 // copy-on-write. 61525 // 61526 // Different filesystems may implement different limitations on the 61527 // granularity of the operation. Most will limit operations to filesystem 61528 // block size boundaries, but this boundary may be larger or smaller 61529 // depending on the filesystem and/or the configuration of the filesystem 61530 // or file. 61531 // 61532 // This flag can only be used with allocate-mode fallocate, which is 61533 // to say that it cannot be used with the punch, zero, collapse, or 61534 // insert range modes. 61535 61536 // File handle structure. 61537 type file_handle = struct { 61538 _ [0]uint32 61539 Fhandle_bytes uint32 61540 Fhandle_type int32 61541 } /* fcntl-linux.h:350:1 */ 61542 61543 type dirent64 = struct { 61544 Fd_ino uint64 61545 Fd_off int64 61546 Fd_reclen uint16 61547 Fd_type uint8 61548 Fd_name [256]int8 61549 _ [5]byte 61550 } /* dirent.h:37:1 */ 61551 61552 type fs_vtab1 = struct { 61553 Fbase sqlite3_vtab 61554 Fdb uintptr 61555 FzDb uintptr 61556 FzTbl uintptr 61557 } /* test_fs.c:96:9 */ 61558 61559 type fs_vtab = fs_vtab1 /* test_fs.c:96:24 */ 61560 type fs_cursor1 = struct { 61561 Fbase sqlite3_vtab_cursor 61562 FpStmt uintptr 61563 FzBuf uintptr 61564 FnBuf int32 61565 FnAlloc int32 61566 } /* test_fs.c:97:9 */ 61567 61568 type fs_cursor = fs_cursor1 /* test_fs.c:97:26 */ 61569 61570 // ************************************************************************ 61571 // 61572 // Start of fsdir implementation. 61573 type FsdirVtab1 = struct{ Fbase sqlite3_vtab } /* test_fs.c:121:9 */ 61574 61575 // ************************************************************************ 61576 // 61577 // Start of fsdir implementation. 61578 type FsdirVtab = FsdirVtab1 /* test_fs.c:121:26 */ 61579 type FsdirCsr1 = struct { 61580 Fbase sqlite3_vtab_cursor 61581 FzDir uintptr 61582 FpDir uintptr 61583 FiRowid sqlite3_int64 61584 FpEntry uintptr 61585 } /* test_fs.c:122:9 */ 61586 61587 type FsdirCsr = FsdirCsr1 /* test_fs.c:122:25 */ 61588 61589 // This function is the implementation of both the xConnect and xCreate 61590 // methods of the fsdir virtual table. 61591 // 61592 // The argv[] array contains the following: 61593 // 61594 // argv[0] -> module name ("fs") 61595 // argv[1] -> database name 61596 // argv[2] -> table name 61597 // argv[...] -> other module argument fields. 61598 func fsdirConnect1(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* test_fs.c:146:12: */ 61599 var pTab uintptr 61600 61601 if argc != 3 { 61602 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+27766 /* "wrong number of ..." */, 0) 61603 return SQLITE_ERROR 61604 } 61605 61606 pTab = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(FsdirVtab{}))) 61607 if !(pTab != 0) { 61608 return SQLITE_NOMEM 61609 } 61610 libc.Xmemset(tls, pTab, 0, uint64(unsafe.Sizeof(FsdirVtab{}))) 61611 61612 *(*uintptr)(unsafe.Pointer(ppVtab)) = (pTab /* &.base */) 61613 sqlite3.Xsqlite3_declare_vtab(tls, db, ts+30018 /* "CREATE TABLE xyz..." */) 61614 61615 return SQLITE_OK 61616 } 61617 61618 // xDestroy/xDisconnect implementation. 61619 func fsdirDisconnect1(tls *libc.TLS, pVtab uintptr) int32 { /* test_fs.c:173:12: */ 61620 sqlite3.Xsqlite3_free(tls, pVtab) 61621 return SQLITE_OK 61622 } 61623 61624 // xBestIndex implementation. The only constraint supported is: 61625 // 61626 // (dir = ?) 61627 func fsdirBestIndex1(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_fs.c:183:12: */ 61628 var ii int32 61629 61630 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 1000000000.0 61631 61632 for ii = 0; ii < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; ii++ { 61633 var p uintptr = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12) 61634 if (((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0)) && (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { 61635 var pUsage uintptr 61636 pUsage = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8) 61637 (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).Fomit = uint8(1) 61638 (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).FargvIndex = 1 61639 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 1 61640 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 1.0 61641 break 61642 } 61643 } 61644 61645 return SQLITE_OK 61646 } 61647 61648 // xOpen implementation. 61649 // 61650 // Open a new fsdir cursor. 61651 func fsdirOpen1(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* test_fs.c:209:12: */ 61652 var pCur uintptr 61653 // Allocate an extra 256 bytes because it is undefined how big dirent.d_name 61654 // is and we need enough space. Linux provides plenty already, but 61655 // Solaris only provides one byte. 61656 pCur = sqlite3.Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(FsdirCsr{})) + uint64(256)))) 61657 if pCur == uintptr(0) { 61658 return SQLITE_NOMEM 61659 } 61660 libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(FsdirCsr{}))) 61661 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) 61662 return SQLITE_OK 61663 } 61664 61665 // Close a fsdir cursor. 61666 func fsdirClose1(tls *libc.TLS, cur uintptr) int32 { /* test_fs.c:224:12: */ 61667 var pCur uintptr = cur 61668 if (*FsdirCsr)(unsafe.Pointer(pCur)).FpDir != 0 { 61669 libc.Xclosedir(tls, (*FsdirCsr)(unsafe.Pointer(pCur)).FpDir) 61670 } 61671 sqlite3.Xsqlite3_free(tls, (*FsdirCsr)(unsafe.Pointer(pCur)).FzDir) 61672 sqlite3.Xsqlite3_free(tls, pCur) 61673 return SQLITE_OK 61674 } 61675 61676 // Skip the cursor to the next entry. 61677 func fsdirNext1(tls *libc.TLS, cur uintptr) int32 { /* test_fs.c:235:12: */ 61678 var pCsr uintptr = cur 61679 61680 if (*FsdirCsr)(unsafe.Pointer(pCsr)).FpDir != 0 { 61681 (*FsdirCsr)(unsafe.Pointer(pCsr)).FpEntry = libc.Xreaddir(tls, (*FsdirCsr)(unsafe.Pointer(pCsr)).FpDir) 61682 if (*FsdirCsr)(unsafe.Pointer(pCsr)).FpEntry == uintptr(0) { 61683 libc.Xclosedir(tls, (*FsdirCsr)(unsafe.Pointer(pCsr)).FpDir) 61684 (*FsdirCsr)(unsafe.Pointer(pCsr)).FpDir = uintptr(0) 61685 } 61686 (*FsdirCsr)(unsafe.Pointer(pCsr)).FiRowid++ 61687 } 61688 61689 return SQLITE_OK 61690 } 61691 61692 // xFilter method implementation. 61693 func fsdirFilter1(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* test_fs.c:253:12: */ 61694 var pCsr uintptr = pVtabCursor 61695 var zDir uintptr 61696 var nDir int32 61697 61698 if (idxNum != 1) || (argc != 1) { 61699 return SQLITE_ERROR 61700 } 61701 61702 (*FsdirCsr)(unsafe.Pointer(pCsr)).FiRowid = int64(0) 61703 sqlite3.Xsqlite3_free(tls, (*FsdirCsr)(unsafe.Pointer(pCsr)).FzDir) 61704 if (*FsdirCsr)(unsafe.Pointer(pCsr)).FpDir != 0 { 61705 libc.Xclosedir(tls, (*FsdirCsr)(unsafe.Pointer(pCsr)).FpDir) 61706 (*FsdirCsr)(unsafe.Pointer(pCsr)).FpDir = uintptr(0) 61707 } 61708 61709 zDir = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 61710 nDir = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) 61711 (*FsdirCsr)(unsafe.Pointer(pCsr)).FzDir = sqlite3.Xsqlite3_malloc(tls, (nDir + 1)) 61712 if (*FsdirCsr)(unsafe.Pointer(pCsr)).FzDir == uintptr(0) { 61713 return SQLITE_NOMEM 61714 } 61715 libc.Xmemcpy(tls, (*FsdirCsr)(unsafe.Pointer(pCsr)).FzDir, zDir, (uint64(nDir + 1))) 61716 61717 (*FsdirCsr)(unsafe.Pointer(pCsr)).FpDir = libc.Xopendir(tls, (*FsdirCsr)(unsafe.Pointer(pCsr)).FzDir) 61718 return fsdirNext1(tls, pVtabCursor) 61719 } 61720 61721 // xEof method implementation. 61722 func fsdirEof1(tls *libc.TLS, cur uintptr) int32 { /* test_fs.c:287:12: */ 61723 var pCsr uintptr = cur 61724 return (libc.Bool32((*FsdirCsr)(unsafe.Pointer(pCsr)).FpDir == uintptr(0))) 61725 } 61726 61727 // xColumn method implementation. 61728 func fsdirColumn1(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* test_fs.c:295:12: */ 61729 var pCsr uintptr = cur 61730 switch i { 61731 case 0: // dir 61732 sqlite3.Xsqlite3_result_text(tls, ctx, (*FsdirCsr)(unsafe.Pointer(pCsr)).FzDir, -1, uintptr(0)) 61733 break 61734 61735 case 1: // name 61736 sqlite3.Xsqlite3_result_text(tls, ctx, (*FsdirCsr)(unsafe.Pointer(pCsr)).FpEntry+19 /* &.d_name */, -1, libc.UintptrFromInt32(-1)) 61737 break 61738 61739 default: 61740 61741 } 61742 61743 return SQLITE_OK 61744 } 61745 61746 // xRowid method implementation. 61747 func fsdirRowid1(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* test_fs.c:316:12: */ 61748 var pCsr uintptr = cur 61749 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*FsdirCsr)(unsafe.Pointer(pCsr)).FiRowid 61750 return SQLITE_OK 61751 } 61752 61753 // 61754 // End of fsdir implementation. 61755 // 61756 61757 // ************************************************************************ 61758 // 61759 // Start of fstree implementation. 61760 type FstreeVtab1 = struct { 61761 Fbase sqlite3_vtab 61762 Fdb uintptr 61763 } /* test_fs.c:328:9 */ 61764 61765 // 61766 // End of fsdir implementation. 61767 // 61768 61769 // ************************************************************************ 61770 // 61771 // Start of fstree implementation. 61772 type FstreeVtab = FstreeVtab1 /* test_fs.c:328:27 */ 61773 type FstreeCsr1 = struct { 61774 Fbase sqlite3_vtab_cursor 61775 FpStmt uintptr 61776 Ffd int32 61777 _ [4]byte 61778 } /* test_fs.c:329:9 */ 61779 61780 type FstreeCsr = FstreeCsr1 /* test_fs.c:329:26 */ 61781 61782 // This function is the implementation of both the xConnect and xCreate 61783 // methods of the fstree virtual table. 61784 // 61785 // The argv[] array contains the following: 61786 // 61787 // argv[0] -> module name ("fs") 61788 // argv[1] -> database name 61789 // argv[2] -> table name 61790 // argv[...] -> other module argument fields. 61791 func fstreeConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* test_fs.c:352:12: */ 61792 var pTab uintptr 61793 61794 if argc != 3 { 61795 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+27766 /* "wrong number of ..." */, 0) 61796 return SQLITE_ERROR 61797 } 61798 61799 pTab = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(FstreeVtab{}))) 61800 if !(pTab != 0) { 61801 return SQLITE_NOMEM 61802 } 61803 libc.Xmemset(tls, pTab, 0, uint64(unsafe.Sizeof(FstreeVtab{}))) 61804 (*FstreeVtab)(unsafe.Pointer(pTab)).Fdb = db 61805 61806 *(*uintptr)(unsafe.Pointer(ppVtab)) = (pTab /* &.base */) 61807 sqlite3.Xsqlite3_declare_vtab(tls, db, ts+30047 /* "CREATE TABLE xyz..." */) 61808 61809 return SQLITE_OK 61810 } 61811 61812 // xDestroy/xDisconnect implementation. 61813 func fstreeDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* test_fs.c:380:12: */ 61814 sqlite3.Xsqlite3_free(tls, pVtab) 61815 return SQLITE_OK 61816 } 61817 61818 // xBestIndex implementation. The only constraint supported is: 61819 // 61820 // (dir = ?) 61821 func fstreeBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_fs.c:390:12: */ 61822 var ii int32 61823 61824 for ii = 0; ii < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; ii++ { 61825 var p uintptr = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12) 61826 if (((*sqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0)) && (((int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_GLOB) || 61827 (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_LIKE)) || 61828 (int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ)) { 61829 var pUsage uintptr 61830 pUsage = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8) 61831 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = int32((*sqlite3_index_constraint)(unsafe.Pointer(p)).Fop) 61832 (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).FargvIndex = 1 61833 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 100000.0 61834 return SQLITE_OK 61835 } 61836 } 61837 61838 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 1000000000.0 61839 return SQLITE_OK 61840 } 61841 61842 // xOpen implementation. 61843 // 61844 // Open a new fstree cursor. 61845 func fstreeOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* test_fs.c:418:12: */ 61846 var pCur uintptr 61847 pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(FstreeCsr{}))) 61848 if pCur == uintptr(0) { 61849 return SQLITE_NOMEM 61850 } 61851 libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(FstreeCsr{}))) 61852 (*FstreeCsr)(unsafe.Pointer(pCur)).Ffd = -1 61853 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) 61854 return SQLITE_OK 61855 } 61856 61857 func fstreeCloseFd(tls *libc.TLS, pCsr uintptr) { /* test_fs.c:428:13: */ 61858 if (*FstreeCsr)(unsafe.Pointer(pCsr)).Ffd >= 0 { 61859 libc.Xclose(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).Ffd) 61860 (*FstreeCsr)(unsafe.Pointer(pCsr)).Ffd = -1 61861 } 61862 } 61863 61864 // Close a fstree cursor. 61865 func fstreeClose(tls *libc.TLS, cur uintptr) int32 { /* test_fs.c:438:12: */ 61866 var pCsr uintptr = cur 61867 sqlite3.Xsqlite3_finalize(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt) 61868 fstreeCloseFd(tls, pCsr) 61869 sqlite3.Xsqlite3_free(tls, pCsr) 61870 return SQLITE_OK 61871 } 61872 61873 // Skip the cursor to the next entry. 61874 func fstreeNext(tls *libc.TLS, cur uintptr) int32 { /* test_fs.c:449:12: */ 61875 var pCsr uintptr = cur 61876 var rc int32 61877 61878 fstreeCloseFd(tls, pCsr) 61879 rc = sqlite3.Xsqlite3_step(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt) 61880 if rc != SQLITE_ROW { 61881 rc = sqlite3.Xsqlite3_finalize(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt) 61882 (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt = uintptr(0) 61883 } else { 61884 rc = SQLITE_OK 61885 (*FstreeCsr)(unsafe.Pointer(pCsr)).Ffd = libc.Xopen(tls, sqlite3.Xsqlite3_column_text(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt, 0), O_RDONLY, 0) 61886 } 61887 61888 return rc 61889 } 61890 61891 // xFilter method implementation. 61892 func fstreeFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* test_fs.c:469:12: */ 61893 bp := tls.Alloc(2) 61894 defer tls.Free(2) 61895 61896 var pCsr uintptr = pVtabCursor 61897 var pTab uintptr = (*FstreeCsr)(unsafe.Pointer(pCsr)).Fbase.FpVtab 61898 var rc int32 61899 var zSql uintptr = ts + 30083 /* "WITH r(d) AS ( ..." */ 61900 var zRoot uintptr 61901 var nRoot int32 61902 var zPrefix uintptr 61903 var nPrefix int32 61904 var zDir uintptr 61905 var nDir int32 61906 *(*[2]int8)(unsafe.Pointer(bp /* aWild */)) = [2]int8{int8(0), int8(0)} 61907 61908 zRoot = ts + 30315 /* "/" */ 61909 nRoot = 1 61910 zPrefix = ts + 489 /* "" */ 61911 nPrefix = 0 61912 61913 zDir = zRoot 61914 nDir = nRoot 61915 61916 fstreeCloseFd(tls, pCsr) 61917 sqlite3.Xsqlite3_finalize(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt) 61918 (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt = uintptr(0) 61919 rc = sqlite3.Xsqlite3_prepare_v2(tls, (*FstreeVtab)(unsafe.Pointer(pTab)).Fdb, zSql, -1, (pCsr + 8 /* &.pStmt */), uintptr(0)) 61920 if rc != SQLITE_OK { 61921 return rc 61922 } 61923 61924 if idxNum != 0 { 61925 var zQuery uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 61926 switch idxNum { 61927 case SQLITE_INDEX_CONSTRAINT_GLOB: 61928 *(*int8)(unsafe.Pointer(bp /* &aWild[0] */)) = int8('*') 61929 *(*int8)(unsafe.Pointer(bp /* &aWild[0] */ + 1)) = int8('?') 61930 break 61931 fallthrough 61932 case SQLITE_INDEX_CONSTRAINT_LIKE: 61933 *(*int8)(unsafe.Pointer(bp /* &aWild[0] */)) = int8('_') 61934 *(*int8)(unsafe.Pointer(bp /* &aWild[0] */ + 1)) = int8('%') 61935 break 61936 } 61937 61938 if sqlite3.Xsqlite3_strnicmp(tls, zQuery, zPrefix, nPrefix) == 0 { 61939 var i int32 61940 for i = nPrefix; *(*int8)(unsafe.Pointer(zQuery + uintptr(i))) != 0; i++ { 61941 if (int32(*(*int8)(unsafe.Pointer(zQuery + uintptr(i)))) == int32(*(*int8)(unsafe.Pointer(bp /* &aWild[0] */)))) || (int32(*(*int8)(unsafe.Pointer(zQuery + uintptr(i)))) == int32(*(*int8)(unsafe.Pointer(bp /* &aWild[0] */ + 1)))) { 61942 break 61943 } 61944 if int32(*(*int8)(unsafe.Pointer(zQuery + uintptr(i)))) == '/' { 61945 nDir = i 61946 } 61947 } 61948 zDir = zQuery 61949 } 61950 } 61951 if nDir == 0 { 61952 nDir = 1 61953 } 61954 61955 sqlite3.Xsqlite3_bind_text(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt, 1, zDir, nDir, libc.UintptrFromInt32(-1)) 61956 sqlite3.Xsqlite3_bind_text(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt, 2, zRoot, nRoot, libc.UintptrFromInt32(-1)) 61957 sqlite3.Xsqlite3_bind_text(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt, 3, zPrefix, nPrefix, libc.UintptrFromInt32(-1)) 61958 61959 return fstreeNext(tls, pVtabCursor) 61960 } 61961 61962 // xEof method implementation. 61963 func fstreeEof(tls *libc.TLS, cur uintptr) int32 { /* test_fs.c:557:12: */ 61964 var pCsr uintptr = cur 61965 return (libc.Bool32((*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt == uintptr(0))) 61966 } 61967 61968 // xColumn method implementation. 61969 func fstreeColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* test_fs.c:565:12: */ 61970 bp := tls.Alloc(144) 61971 defer tls.Free(144) 61972 61973 var pCsr uintptr = cur 61974 if i == 0 { // path 61975 sqlite3.Xsqlite3_result_value(tls, ctx, sqlite3.Xsqlite3_column_value(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).FpStmt, 0)) 61976 } else { 61977 // var sBuf stat at bp, 144 61978 61979 libc.Xfstat(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).Ffd, bp /* &sBuf */) 61980 61981 if (((*stat)(unsafe.Pointer(bp /* &sBuf */)).Fst_mode) & uint32(0170000)) == (uint32(0100000)) { 61982 if i == 1 { 61983 sqlite3.Xsqlite3_result_int64(tls, ctx, int64((*stat)(unsafe.Pointer(bp /* &sBuf */)).Fst_size)) 61984 } else { 61985 var nRead int32 61986 var aBuf uintptr = sqlite3.Xsqlite3_malloc(tls, (int32((*stat)(unsafe.Pointer(bp /* &sBuf */)).Fst_mode + uint32(1)))) 61987 if !(aBuf != 0) { 61988 return SQLITE_NOMEM 61989 } 61990 nRead = int32(libc.Xread(tls, (*FstreeCsr)(unsafe.Pointer(pCsr)).Ffd, aBuf, uint64((*stat)(unsafe.Pointer(bp /* &sBuf */)).Fst_mode))) 61991 if uint32(nRead) != (*stat)(unsafe.Pointer(bp /* &sBuf */)).Fst_mode { 61992 return SQLITE_IOERR 61993 } 61994 sqlite3.Xsqlite3_result_blob(tls, ctx, aBuf, nRead, libc.UintptrFromInt32(-1)) 61995 sqlite3.Xsqlite3_free(tls, aBuf) 61996 } 61997 } 61998 } 61999 62000 return SQLITE_OK 62001 } 62002 62003 // xRowid method implementation. 62004 func fstreeRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* test_fs.c:596:12: */ 62005 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = int64(0) 62006 return SQLITE_OK 62007 } 62008 62009 // 62010 // End of fstree implementation. 62011 // 62012 62013 // This function is the implementation of both the xConnect and xCreate 62014 // methods of the fs virtual table. 62015 // 62016 // The argv[] array contains the following: 62017 // 62018 // argv[0] -> module name ("fs") 62019 // argv[1] -> database name 62020 // argv[2] -> table name 62021 // argv[...] -> other module argument fields. 62022 func fsConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* test_fs.c:618:12: */ 62023 var pVtab uintptr 62024 var nByte int32 62025 var zTbl uintptr 62026 var zDb uintptr = *(*uintptr)(unsafe.Pointer(argv + 1*8)) 62027 62028 if argc != 4 { 62029 *(*uintptr)(unsafe.Pointer(pzErr)) = sqlite3.Xsqlite3_mprintf(tls, ts+27766 /* "wrong number of ..." */, 0) 62030 return SQLITE_ERROR 62031 } 62032 zTbl = *(*uintptr)(unsafe.Pointer(argv + 3*8)) 62033 62034 nByte = (int32((((uint64(unsafe.Sizeof(fs_vtab{})) + uint64(int32(libc.Xstrlen(tls, zTbl)))) + uint64(1)) + uint64(int32(libc.Xstrlen(tls, zDb)))) + uint64(1))) 62035 pVtab = sqlite3.Xsqlite3MallocZero(tls, uint64(nByte)) 62036 if !(pVtab != 0) { 62037 return SQLITE_NOMEM 62038 } 62039 62040 (*fs_vtab)(unsafe.Pointer(pVtab)).FzTbl = (pVtab + 1*48) 62041 (*fs_vtab)(unsafe.Pointer(pVtab)).FzDb = ((*fs_vtab)(unsafe.Pointer(pVtab)).FzTbl + uintptr((libc.Xstrlen(tls, zTbl) + uint64(1)))) 62042 (*fs_vtab)(unsafe.Pointer(pVtab)).Fdb = db 62043 libc.Xmemcpy(tls, (*fs_vtab)(unsafe.Pointer(pVtab)).FzTbl, zTbl, libc.Xstrlen(tls, zTbl)) 62044 libc.Xmemcpy(tls, (*fs_vtab)(unsafe.Pointer(pVtab)).FzDb, zDb, libc.Xstrlen(tls, zDb)) 62045 *(*uintptr)(unsafe.Pointer(ppVtab)) = (pVtab /* &.base */) 62046 sqlite3.Xsqlite3_declare_vtab(tls, db, ts+30317 /* "CREATE TABLE x(p..." */) 62047 62048 return SQLITE_OK 62049 } 62050 62051 // Note that for this virtual table, the xCreate and xConnect 62052 // methods are identical. 62053 62054 func fsDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* test_fs.c:653:12: */ 62055 sqlite3.Xsqlite3_free(tls, pVtab) 62056 return SQLITE_OK 62057 } 62058 62059 // The xDisconnect and xDestroy methods are also the same 62060 62061 // Open a new fs cursor. 62062 func fsOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* test_fs.c:662:12: */ 62063 var pCur uintptr 62064 pCur = sqlite3.Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(fs_cursor{}))) 62065 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) 62066 return SQLITE_OK 62067 } 62068 62069 // Close a fs cursor. 62070 func fsClose(tls *libc.TLS, cur uintptr) int32 { /* test_fs.c:672:12: */ 62071 var pCur uintptr = cur 62072 sqlite3.Xsqlite3_finalize(tls, (*fs_cursor)(unsafe.Pointer(pCur)).FpStmt) 62073 sqlite3.Xsqlite3_free(tls, (*fs_cursor)(unsafe.Pointer(pCur)).FzBuf) 62074 sqlite3.Xsqlite3_free(tls, pCur) 62075 return SQLITE_OK 62076 } 62077 62078 func fsNext(tls *libc.TLS, cur uintptr) int32 { /* test_fs.c:680:12: */ 62079 var pCur uintptr = cur 62080 var rc int32 62081 62082 rc = sqlite3.Xsqlite3_step(tls, (*fs_cursor)(unsafe.Pointer(pCur)).FpStmt) 62083 if (rc == SQLITE_ROW) || (rc == SQLITE_DONE) { 62084 rc = SQLITE_OK 62085 } 62086 62087 return rc 62088 } 62089 62090 func fsFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* test_fs.c:690:12: */ 62091 bp := tls.Alloc(32) 62092 defer tls.Free(32) 62093 62094 var rc int32 62095 var pCur uintptr = pVtabCursor 62096 var p uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab 62097 62098 if idxNum == 1 { 62099 var zStmt uintptr = sqlite3.Xsqlite3_mprintf(tls, 62100 ts+30354 /* "SELECT * FROM %Q..." */, libc.VaList(bp, (*fs_vtab)(unsafe.Pointer(p)).FzDb, (*fs_vtab)(unsafe.Pointer(p)).FzTbl)) 62101 if !(zStmt != 0) { 62102 return SQLITE_NOMEM 62103 } 62104 rc = sqlite3.Xsqlite3_prepare_v2(tls, (*fs_vtab)(unsafe.Pointer(p)).Fdb, zStmt, -1, (pCur + 8 /* &.pStmt */), uintptr(0)) 62105 sqlite3.Xsqlite3_free(tls, zStmt) 62106 if rc == SQLITE_OK { 62107 sqlite3.Xsqlite3_bind_value(tls, (*fs_cursor)(unsafe.Pointer(pCur)).FpStmt, 1, *(*uintptr)(unsafe.Pointer(argv))) 62108 } 62109 } else { 62110 var zStmt uintptr = sqlite3.Xsqlite3_mprintf(tls, ts+3278 /* "SELECT * FROM %Q..." */, libc.VaList(bp+16, (*fs_vtab)(unsafe.Pointer(p)).FzDb, (*fs_vtab)(unsafe.Pointer(p)).FzTbl)) 62111 if !(zStmt != 0) { 62112 return SQLITE_NOMEM 62113 } 62114 rc = sqlite3.Xsqlite3_prepare_v2(tls, (*fs_vtab)(unsafe.Pointer(p)).Fdb, zStmt, -1, (pCur + 8 /* &.pStmt */), uintptr(0)) 62115 sqlite3.Xsqlite3_free(tls, zStmt) 62116 } 62117 62118 if rc == SQLITE_OK { 62119 rc = fsNext(tls, pVtabCursor) 62120 } 62121 return rc 62122 } 62123 62124 func fsColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* test_fs.c:722:12: */ 62125 bp := tls.Alloc(144) 62126 defer tls.Free(144) 62127 62128 var pCur uintptr = cur 62129 62130 if i == 0 { 62131 sqlite3.Xsqlite3_result_value(tls, ctx, sqlite3.Xsqlite3_column_value(tls, (*fs_cursor)(unsafe.Pointer(pCur)).FpStmt, 0)) 62132 } else { 62133 var zFile uintptr = sqlite3.Xsqlite3_column_text(tls, (*fs_cursor)(unsafe.Pointer(pCur)).FpStmt, 1) 62134 // var sbuf stat at bp, 144 62135 62136 var fd int32 62137 var n int32 62138 fd = libc.Xopen(tls, zFile, O_RDONLY, 0) 62139 if fd < 0 { 62140 return SQLITE_IOERR 62141 } 62142 libc.Xfstat(tls, fd, bp /* &sbuf */) 62143 62144 if (*stat)(unsafe.Pointer(bp /* &sbuf */)).Fst_size >= int64((*fs_cursor)(unsafe.Pointer(pCur)).FnAlloc) { 62145 var nNew sqlite3_int64 = (sqlite3_int64((*stat)(unsafe.Pointer(bp /* &sbuf */)).Fst_size * int64(2))) 62146 var zNew uintptr 62147 if nNew < int64(1024) { 62148 nNew = int64(1024) 62149 } 62150 62151 zNew = sqlite3.Xsqlite3Realloc(tls, (*fs_cursor)(unsafe.Pointer(pCur)).FzBuf, uint64(nNew)) 62152 if zNew == uintptr(0) { 62153 libc.Xclose(tls, fd) 62154 return SQLITE_NOMEM 62155 } 62156 (*fs_cursor)(unsafe.Pointer(pCur)).FzBuf = zNew 62157 (*fs_cursor)(unsafe.Pointer(pCur)).FnAlloc = int32(nNew) 62158 } 62159 62160 n = int32(libc.Xread(tls, fd, (*fs_cursor)(unsafe.Pointer(pCur)).FzBuf, uint64((*stat)(unsafe.Pointer(bp /* &sbuf */)).Fst_size))) 62161 libc.Xclose(tls, fd) 62162 if int64(n) != (*stat)(unsafe.Pointer(bp /* &sbuf */)).Fst_size { 62163 return SQLITE_ERROR 62164 } 62165 (*fs_cursor)(unsafe.Pointer(pCur)).FnBuf = int32((*stat)(unsafe.Pointer(bp /* &sbuf */)).Fst_size) 62166 *(*int8)(unsafe.Pointer((*fs_cursor)(unsafe.Pointer(pCur)).FzBuf + uintptr((*fs_cursor)(unsafe.Pointer(pCur)).FnBuf))) = int8(0) 62167 62168 sqlite3.Xsqlite3_result_text(tls, ctx, (*fs_cursor)(unsafe.Pointer(pCur)).FzBuf, -1, libc.UintptrFromInt32(-1)) 62169 } 62170 return SQLITE_OK 62171 } 62172 62173 func fsRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* test_fs.c:763:12: */ 62174 var pCur uintptr = cur 62175 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite3.Xsqlite3_column_int64(tls, (*fs_cursor)(unsafe.Pointer(pCur)).FpStmt, 0) 62176 return SQLITE_OK 62177 } 62178 62179 func fsEof(tls *libc.TLS, cur uintptr) int32 { /* test_fs.c:769:12: */ 62180 var pCur uintptr = cur 62181 return (libc.Bool32(sqlite3.Xsqlite3_data_count(tls, (*fs_cursor)(unsafe.Pointer(pCur)).FpStmt) == 0)) 62182 } 62183 62184 func fsBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_fs.c:774:12: */ 62185 var ii int32 62186 62187 for ii = 0; ii < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; ii++ { 62188 var pCons uintptr = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12) 62189 if (((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn < 0) && ((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fusable != 0)) && 62190 (int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) { 62191 var pUsage uintptr 62192 pUsage = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8) 62193 (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).Fomit = uint8(0) 62194 (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).FargvIndex = 1 62195 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = 1 62196 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 1.0 62197 break 62198 } 62199 } 62200 62201 return SQLITE_OK 62202 } 62203 62204 // A virtual table module that provides read-only access to a 62205 // Tcl global variable namespace. 62206 var fsModule = sqlite3_module{ // iVersion 62207 FxCreate: 0, 62208 FxConnect: 0, 62209 FxBestIndex: 0, 62210 FxDisconnect: 0, 62211 FxDestroy: 0, 62212 FxOpen: 0, // xOpen - open a cursor 62213 FxClose: 0, // xClose - close a cursor 62214 FxFilter: 0, // xFilter - configure scan constraints 62215 FxNext: 0, // xNext - advance a cursor 62216 FxEof: 0, // xEof - check for end of scan 62217 FxColumn: 0, // xColumn - read data 62218 FxRowid: 0, // xRename 62219 } /* test_fs.c:798:23 */ 62220 62221 var fsdirModule = sqlite3_module{ // iVersion 62222 FxCreate: 0, // xCreate 62223 FxConnect: 0, // xConnect 62224 FxBestIndex: 0, // xBestIndex 62225 FxDisconnect: 0, // xDisconnect 62226 FxDestroy: 0, // xDestroy 62227 FxOpen: 0, // xOpen - open a cursor 62228 FxClose: 0, // xClose - close a cursor 62229 FxFilter: 0, // xFilter - configure scan constraints 62230 FxNext: 0, // xNext - advance a cursor 62231 FxEof: 0, // xEof - check for end of scan 62232 FxColumn: 0, // xColumn - read data 62233 FxRowid: 0, // xRename 62234 } /* test_fs.c:821:23 */ 62235 62236 var fstreeModule = sqlite3_module{ // iVersion 62237 FxCreate: 0, // xCreate 62238 FxConnect: 0, // xConnect 62239 FxBestIndex: 0, // xBestIndex 62240 FxDisconnect: 0, // xDisconnect 62241 FxDestroy: 0, // xDestroy 62242 FxOpen: 0, // xOpen - open a cursor 62243 FxClose: 0, // xClose - close a cursor 62244 FxFilter: 0, // xFilter - configure scan constraints 62245 FxNext: 0, // xNext - advance a cursor 62246 FxEof: 0, // xEof - check for end of scan 62247 FxColumn: 0, // xColumn - read data 62248 FxRowid: 0, // xRename 62249 } /* test_fs.c:844:23 */ 62250 62251 // Register the echo virtual table module. 62252 func register_fs_module(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_fs.c:875:26: */ 62253 bp := tls.Alloc(8) 62254 defer tls.Free(8) 62255 62256 // var db uintptr at bp, 8 62257 62258 if objc != 2 { 62259 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 62260 return TCL_ERROR 62261 } 62262 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 62263 return TCL_ERROR 62264 } 62265 sqlite3.Xsqlite3_create_module(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+30388 /* "fs" */, uintptr(unsafe.Pointer(&fsModule)), interp) 62266 sqlite3.Xsqlite3_create_module(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+5196 /* "fsdir" */, uintptr(unsafe.Pointer(&fsdirModule)), uintptr(0)) 62267 sqlite3.Xsqlite3_create_module(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+30391 /* "fstree" */, uintptr(unsafe.Pointer(&fstreeModule)), uintptr(0)) 62268 return TCL_OK 62269 } 62270 62271 // Register commands with the TCL interpreter. 62272 func Sqlitetestfs_Init(tls *libc.TLS, interp uintptr) int32 { /* test_fs.c:901:5: */ 62273 var i int32 62274 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aObjCmd6)) / uint64(unsafe.Sizeof(struct { 62275 FzName uintptr 62276 FxProc uintptr 62277 FclientData uintptr 62278 }{}))); i++ { 62279 tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd6[i].FzName, 62280 aObjCmd6[i].FxProc, aObjCmd6[i].FclientData, uintptr(0)) 62281 } 62282 return TCL_OK 62283 } 62284 62285 var aObjCmd6 = [1]struct { 62286 FzName uintptr 62287 FxProc uintptr 62288 FclientData uintptr 62289 }{ 62290 {FzName: ts + 30398 /* "register_fs_modu..." */, FxProc: 0}, 62291 } /* test_fs.c:907:5 */ 62292 62293 // Some versions of <linux/posix_types.h> define this macros. 62294 // It's easier to assume 8-bit bytes than to get CHAR_BIT. 62295 62296 // fd_set for select and pselect. 62297 type fd_set2 = struct{ F__fds_bits [16]int64 } /* select.h:70:5 */ 62298 62299 // Allocate nByte bytes of space using sqlite3_malloc(). If the 62300 // allocation fails, call sqlite3_result_error_nomem() to notify 62301 // the database handle that malloc() has failed. 62302 func testContextMalloc(tls *libc.TLS, context uintptr, nByte int32) uintptr { /* test_func.c:33:13: */ 62303 var z uintptr = sqlite3.Xsqlite3_malloc(tls, nByte) 62304 if !(z != 0) && (nByte > 0) { 62305 sqlite3.Xsqlite3_result_error_nomem(tls, context) 62306 } 62307 return z 62308 } 62309 62310 // This function generates a string of random characters. Used for 62311 // generating test data. 62312 func randStr(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test_func.c:45:13: */ 62313 bp := tls.Alloc(1004) 62314 defer tls.Free(1004) 62315 62316 var iMin int32 62317 var iMax int32 62318 var n int32 62319 // var r int32 at bp, 4 62320 62321 var i int32 62322 // var zBuf [1000]uint8 at bp+4, 1000 62323 62324 // It used to be possible to call randstr() with any number of arguments, 62325 // but now it is registered with SQLite as requiring exactly 2. 62326 62327 iMin = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))) 62328 if iMin < 0 { 62329 iMin = 0 62330 } 62331 if uint64(iMin) >= uint64(unsafe.Sizeof([1000]uint8{})) { 62332 iMin = (int32(uint64(unsafe.Sizeof([1000]uint8{})) - uint64(1))) 62333 } 62334 iMax = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 62335 if iMax < iMin { 62336 iMax = iMin 62337 } 62338 if uint64(iMax) >= uint64(unsafe.Sizeof([1000]uint8{})) { 62339 iMax = (int32(uint64(unsafe.Sizeof([1000]uint8{})) - uint64(1))) 62340 } 62341 n = iMin 62342 if iMax > iMin { 62343 sqlite3.Xsqlite3_randomness(tls, int32(unsafe.Sizeof(int32(0))), bp /* &r */) 62344 *(*int32)(unsafe.Pointer(bp /* r */)) &= 0x7fffffff 62345 n = n + (*(*int32)(unsafe.Pointer(bp /* r */)) % ((iMax + 1) - iMin)) 62346 } 62347 62348 sqlite3.Xsqlite3_randomness(tls, n, bp+4 /* &zBuf[0] */) 62349 for i = 0; i < n; i++ { 62350 *(*uint8)(unsafe.Pointer(bp + 4 /* &zBuf[0] */ + uintptr(i))) = zSrc[(uint64(*(*uint8)(unsafe.Pointer(bp + 4 /* &zBuf[0] */ + uintptr(i)))) % (uint64(unsafe.Sizeof(zSrc)) - uint64(1)))] 62351 } 62352 *(*uint8)(unsafe.Pointer(bp + 4 /* &zBuf[0] */ + uintptr(n))) = uint8(0) 62353 sqlite3.Xsqlite3_result_text(tls, context, bp+4 /* zBuf */, n, libc.UintptrFromInt32(-1)) 62354 } 62355 62356 var zSrc = *(*[79]uint8)(unsafe.Pointer(ts + 30417 /* "abcdefghijklmnop..." */)) /* test_func.c:46:30 */ 62357 62358 // The following two SQL functions are used to test returning a text 62359 // result with a destructor. Function 'test_destructor' takes one argument 62360 // and returns the same argument interpreted as TEXT. A destructor is 62361 // passed with the sqlite3_result_text() call. 62362 // 62363 // SQL function 'test_destructor_count' returns the number of outstanding 62364 // allocations made by 'test_destructor'; 62365 // 62366 // WARNING: Not threadsafe. 62367 var test_destructor_count_var int32 = 0 /* test_func.c:91:12 */ 62368 62369 func destructor(tls *libc.TLS, p uintptr) { /* test_func.c:92:13: */ 62370 var zVal uintptr = p 62371 62372 zVal-- 62373 sqlite3.Xsqlite3_free(tls, zVal) 62374 test_destructor_count_var-- 62375 } 62376 62377 func test_destructor(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* test_func.c:99:13: */ 62378 var zVal uintptr 62379 var len int32 62380 62381 test_destructor_count_var++ 62382 62383 if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { 62384 return 62385 } 62386 len = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) 62387 zVal = testContextMalloc(tls, pCtx, (len + 3)) 62388 if !(zVal != 0) { 62389 return 62390 } 62391 *(*int8)(unsafe.Pointer(zVal + uintptr((len + 1)))) = int8(0) 62392 *(*int8)(unsafe.Pointer(zVal + uintptr((len + 2)))) = int8(0) 62393 zVal++ 62394 libc.Xmemcpy(tls, zVal, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))), uint64(len)) 62395 sqlite3.Xsqlite3_result_text(tls, pCtx, zVal, -1, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{destructor}))) 62396 } 62397 62398 func test_destructor16(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* test_func.c:122:13: */ 62399 var zVal uintptr 62400 var len int32 62401 62402 test_destructor_count_var++ 62403 62404 if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { 62405 return 62406 } 62407 len = sqlite3.Xsqlite3_value_bytes16(tls, *(*uintptr)(unsafe.Pointer(argv))) 62408 zVal = testContextMalloc(tls, pCtx, (len + 3)) 62409 if !(zVal != 0) { 62410 return 62411 } 62412 *(*int8)(unsafe.Pointer(zVal + uintptr((len + 1)))) = int8(0) 62413 *(*int8)(unsafe.Pointer(zVal + uintptr((len + 2)))) = int8(0) 62414 zVal++ 62415 libc.Xmemcpy(tls, zVal, sqlite3.Xsqlite3_value_text16(tls, *(*uintptr)(unsafe.Pointer(argv))), uint64(len)) 62416 sqlite3.Xsqlite3_result_text16(tls, pCtx, zVal, -1, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{destructor}))) 62417 } 62418 62419 func test_destructor_count(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* test_func.c:145:13: */ 62420 sqlite3.Xsqlite3_result_int(tls, pCtx, test_destructor_count_var) 62421 } 62422 62423 func test_agg_errmsg16_step(tls *libc.TLS, a uintptr, b int32, c uintptr) { /* test_func.c:165:13: */ 62424 } 62425 62426 func test_agg_errmsg16_final(tls *libc.TLS, ctx uintptr) { /* test_func.c:167:13: */ 62427 var z uintptr 62428 var db uintptr = sqlite3.Xsqlite3_context_db_handle(tls, ctx) 62429 sqlite3.Xsqlite3_aggregate_context(tls, ctx, 2048) 62430 z = sqlite3.Xsqlite3_errmsg16(tls, db) 62431 sqlite3.Xsqlite3_result_text16(tls, ctx, z, -1, libc.UintptrFromInt32(-1)) 62432 } 62433 62434 // Routines for testing the sqlite3_get_auxdata() and sqlite3_set_auxdata() 62435 // interface. 62436 // 62437 // The test_auxdata() SQL function attempts to register each of its arguments 62438 // as auxiliary data. If there are no prior registrations of aux data for 62439 // that argument (meaning the argument is not a constant or this is its first 62440 // call) then the result for that argument is 0. If there is a prior 62441 // registration, the result for that argument is 1. The overall result 62442 // is the individual argument results separated by spaces. 62443 func free_test_auxdata(tls *libc.TLS, p uintptr) { /* test_func.c:188:13: */ 62444 sqlite3.Xsqlite3_free(tls, p) 62445 } 62446 62447 func test_auxdata(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* test_func.c:189:13: */ 62448 var i int32 62449 var zRet uintptr = testContextMalloc(tls, pCtx, (nArg * 2)) 62450 if !(zRet != 0) { 62451 return 62452 } 62453 libc.Xmemset(tls, zRet, 0, (uint64(nArg * 2))) 62454 for i = 0; i < nArg; i++ { 62455 var z uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) 62456 if z != 0 { 62457 var n int32 62458 var zAux uintptr = sqlite3.Xsqlite3_get_auxdata(tls, pCtx, i) 62459 if zAux != 0 { 62460 *(*int8)(unsafe.Pointer(zRet + uintptr((i * 2)))) = int8('1') 62461 62462 } else { 62463 *(*int8)(unsafe.Pointer(zRet + uintptr((i * 2)))) = int8('0') 62464 } 62465 n = (int32(libc.Xstrlen(tls, z)) + 1) 62466 zAux = testContextMalloc(tls, pCtx, n) 62467 if zAux != 0 { 62468 libc.Xmemcpy(tls, zAux, z, uint64(n)) 62469 sqlite3.Xsqlite3_set_auxdata(tls, pCtx, i, zAux, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{free_test_auxdata}))) 62470 } 62471 *(*int8)(unsafe.Pointer(zRet + uintptr(((i * 2) + 1)))) = int8(' ') 62472 } 62473 } 62474 sqlite3.Xsqlite3_result_text(tls, pCtx, zRet, ((2 * nArg) - 1), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{free_test_auxdata}))) 62475 } 62476 62477 // A function to test error reporting from user functions. This function 62478 // returns a copy of its first argument as the error message. If the 62479 // second argument exists, it becomes the error code. 62480 func test_error(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* test_func.c:226:13: */ 62481 sqlite3.Xsqlite3_result_error(tls, pCtx, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))), -1) 62482 if nArg == 2 { 62483 sqlite3.Xsqlite3_result_error_code(tls, pCtx, sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)))) 62484 } 62485 } 62486 62487 // Implementation of the counter(X) function. If X is an integer 62488 // constant, then the first invocation will return X. The second X+1. 62489 // and so forth. Can be used (for example) to provide a sequence number 62490 // in a result set. 62491 func counterFunc(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* test_func.c:243:13: */ 62492 var pCounter uintptr = sqlite3.Xsqlite3_get_auxdata(tls, pCtx, 0) 62493 if pCounter == uintptr(0) { 62494 pCounter = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(int32(0)))) 62495 if pCounter == uintptr(0) { 62496 sqlite3.Xsqlite3_result_error_nomem(tls, pCtx) 62497 return 62498 } 62499 *(*int32)(unsafe.Pointer(pCounter)) = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))) 62500 sqlite3.Xsqlite3_set_auxdata(tls, pCtx, 0, pCounter, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) 62501 } else { 62502 *(*int32)(unsafe.Pointer(pCounter))++ 62503 } 62504 sqlite3.Xsqlite3_result_int(tls, pCtx, *(*int32)(unsafe.Pointer(pCounter))) 62505 } 62506 62507 // This function takes two arguments. It performance UTF-8/16 type 62508 // conversions on the first argument then returns a copy of the second 62509 // argument. 62510 // 62511 // This function is used in cases such as the following: 62512 // 62513 // SELECT test_isolation(x,x) FROM t1; 62514 // 62515 // We want to verify that the type conversions that occur on the 62516 // first argument do not invalidate the second argument. 62517 func test_isolation(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* test_func.c:276:13: */ 62518 sqlite3.Xsqlite3_value_text16(tls, *(*uintptr)(unsafe.Pointer(argv))) 62519 sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 62520 sqlite3.Xsqlite3_value_text16(tls, *(*uintptr)(unsafe.Pointer(argv))) 62521 sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 62522 sqlite3.Xsqlite3_result_value(tls, pCtx, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 62523 } 62524 62525 // Invoke an SQL statement recursively. The function result is the 62526 // first column of the first row of the result set. 62527 func test_eval(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* test_func.c:294:13: */ 62528 bp := tls.Alloc(16) 62529 defer tls.Free(16) 62530 62531 // var pStmt uintptr at bp+8, 8 62532 62533 var rc int32 62534 var db uintptr = sqlite3.Xsqlite3_context_db_handle(tls, pCtx) 62535 var zSql uintptr 62536 62537 zSql = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 62538 rc = sqlite3.Xsqlite3_prepare_v2(tls, db, zSql, -1, bp+8 /* &pStmt */, uintptr(0)) 62539 if rc == SQLITE_OK { 62540 rc = sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) 62541 if rc == SQLITE_ROW { 62542 sqlite3.Xsqlite3_result_value(tls, pCtx, sqlite3.Xsqlite3_column_value(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */)), 0)) 62543 } 62544 rc = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp + 8 /* pStmt */))) 62545 } 62546 if rc != 0 { 62547 var zErr uintptr 62548 62549 zErr = sqlite3.Xsqlite3_mprintf(tls, ts+30496 /* "sqlite3_prepare_..." */, libc.VaList(bp, sqlite3.Xsqlite3_errmsg(tls, db))) 62550 sqlite3.Xsqlite3_result_text(tls, pCtx, zErr, -1, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) 62551 sqlite3.Xsqlite3_result_error_code(tls, pCtx, rc) 62552 } 62553 } 62554 62555 // convert one character from hex to binary 62556 func testHexChar(tls *libc.TLS, c int8) int32 { /* test_func.c:326:12: */ 62557 if (int32(c) >= '0') && (int32(c) <= '9') { 62558 return (int32(c) - '0') 62559 } else if (int32(c) >= 'a') && (int32(c) <= 'f') { 62560 return ((int32(c) - 'a') + 10) 62561 } else if (int32(c) >= 'A') && (int32(c) <= 'F') { 62562 return ((int32(c) - 'A') + 10) 62563 } 62564 return 0 62565 } 62566 62567 // Convert hex to binary. 62568 func testHexToBin(tls *libc.TLS, zIn uintptr, zOut uintptr) { /* test_func.c:340:13: */ 62569 for (*(*int8)(unsafe.Pointer(zIn)) != 0) && (*(*int8)(unsafe.Pointer(zIn + 1)) != 0) { 62570 *(*int8)(unsafe.Pointer(libc.PostIncUintptr(&zOut, 1))) = (int8((testHexChar(tls, *(*int8)(unsafe.Pointer(zIn))) << 4) + testHexChar(tls, *(*int8)(unsafe.Pointer(zIn + 1))))) 62571 zIn += uintptr(2) 62572 } 62573 } 62574 62575 // hex_to_utf16be(HEX) 62576 // 62577 // Convert the input string from HEX into binary. Then return the 62578 // result using sqlite3_result_text16le(). 62579 func testHexToUtf16be(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* test_func.c:354:13: */ 62580 var n int32 62581 var zIn uintptr 62582 var zOut uintptr 62583 62584 n = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) 62585 zIn = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 62586 zOut = sqlite3.Xsqlite3_malloc(tls, (n / 2)) 62587 if zOut == uintptr(0) { 62588 sqlite3.Xsqlite3_result_error_nomem(tls, pCtx) 62589 } else { 62590 testHexToBin(tls, zIn, zOut) 62591 sqlite3.Xsqlite3_result_text16be(tls, pCtx, zOut, (n / 2), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) 62592 } 62593 } 62594 62595 // hex_to_utf8(HEX) 62596 // 62597 // Convert the input string from HEX into binary. Then return the 62598 // result using sqlite3_result_text16le(). 62599 func testHexToUtf8(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* test_func.c:381:13: */ 62600 var n int32 62601 var zIn uintptr 62602 var zOut uintptr 62603 62604 n = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) 62605 zIn = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 62606 zOut = sqlite3.Xsqlite3_malloc(tls, (n / 2)) 62607 if zOut == uintptr(0) { 62608 sqlite3.Xsqlite3_result_error_nomem(tls, pCtx) 62609 } else { 62610 testHexToBin(tls, zIn, zOut) 62611 sqlite3.Xsqlite3_result_text(tls, pCtx, zOut, (n / 2), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) 62612 } 62613 } 62614 62615 // hex_to_utf16le(HEX) 62616 // 62617 // Convert the input string from HEX into binary. Then return the 62618 // result using sqlite3_result_text16le(). 62619 func testHexToUtf16le(tls *libc.TLS, pCtx uintptr, nArg int32, argv uintptr) { /* test_func.c:408:13: */ 62620 var n int32 62621 var zIn uintptr 62622 var zOut uintptr 62623 62624 n = sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(argv))) 62625 zIn = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 62626 zOut = sqlite3.Xsqlite3_malloc(tls, (n / 2)) 62627 if zOut == uintptr(0) { 62628 sqlite3.Xsqlite3_result_error_nomem(tls, pCtx) 62629 } else { 62630 testHexToBin(tls, zIn, zOut) 62631 sqlite3.Xsqlite3_result_text16le(tls, pCtx, zOut, (n / 2), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) 62632 } 62633 } 62634 62635 // SQL function: real2hex(X) 62636 // 62637 // If argument X is a real number, then convert it into a string which is 62638 // the big-endian hexadecimal representation of the ieee754 encoding of 62639 // that number. If X is not a real number, return NULL. 62640 func real2hex(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test_func.c:436:13: */ 62641 bp := tls.Alloc(28) 62642 defer tls.Free(28) 62643 62644 // var v struct {Fi sqlite3_uint64;} at bp, 8 62645 62646 // var zOut [20]int8 at bp+8, 20 62647 62648 var i int32 62649 var bigEndian int32 62650 *(*sqlite3_uint64)(unsafe.Pointer(bp /* &v */)) = uint64(1) 62651 bigEndian = (libc.Bool32(int32(*(*uint8)(unsafe.Pointer((bp /* &v */ /* &.x */)))) == 0)) 62652 *(*float64)(unsafe.Pointer(bp /* &v */)) = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(argv))) 62653 for i = 0; i < 8; i++ { 62654 if bigEndian != 0 { 62655 *(*int8)(unsafe.Pointer(bp + 8 /* &zOut[0] */ + uintptr((i * 2)))) = *(*int8)(unsafe.Pointer(ts + 30527 /* "0123456789abcdef" */ + uintptr((int32(*(*uint8)(unsafe.Pointer((bp /* &v */ /* &.x */) + uintptr(i)))) >> 4)))) 62656 *(*int8)(unsafe.Pointer(bp + 8 /* &zOut[0] */ + uintptr(((i * 2) + 1)))) = *(*int8)(unsafe.Pointer(ts + 30527 /* "0123456789abcdef" */ + uintptr((int32(*(*uint8)(unsafe.Pointer((bp /* &v */ /* &.x */) + uintptr(i)))) & 0xf)))) 62657 } else { 62658 *(*int8)(unsafe.Pointer(bp + 8 /* &zOut[0] */ + uintptr((14 - (i * 2))))) = *(*int8)(unsafe.Pointer(ts + 30527 /* "0123456789abcdef" */ + uintptr((int32(*(*uint8)(unsafe.Pointer((bp /* &v */ /* &.x */) + uintptr(i)))) >> 4)))) 62659 *(*int8)(unsafe.Pointer(bp + 8 /* &zOut[0] */ + uintptr(((14 - (i * 2)) + 1)))) = *(*int8)(unsafe.Pointer(ts + 30527 /* "0123456789abcdef" */ + uintptr((int32(*(*uint8)(unsafe.Pointer((bp /* &v */ /* &.x */) + uintptr(i)))) & 0xf)))) 62660 } 62661 } 62662 *(*int8)(unsafe.Pointer(bp + 8 /* &zOut[0] */ + 16)) = int8(0) 62663 sqlite3.Xsqlite3_result_text(tls, context, bp+8 /* &zOut[0] */, -1, libc.UintptrFromInt32(-1)) 62664 } 62665 62666 // test_extract(record, field) 62667 // 62668 // This function implements an SQL user-function that accepts a blob 62669 // containing a formatted database record as the first argument. The 62670 // second argument is the index of the field within that record to 62671 // extract and return. 62672 func test_extract(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test_func.c:473:13: */ 62673 bp := tls.Alloc(72) 62674 defer tls.Free(72) 62675 62676 var db uintptr = sqlite3.Xsqlite3_context_db_handle(tls, context) 62677 var pRec uintptr 62678 var pEndHdr uintptr // Points to one byte past record header 62679 var pHdr uintptr // Current point in record header 62680 var pBody uintptr // Current point in record data 62681 // var nHdr u64 at bp, 8 62682 // Bytes in record header 62683 var iIdx int32 // Required field 62684 var iCurrent int32 = 0 // Current field 62685 62686 pRec = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) 62687 iIdx = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 62688 62689 pHdr = (pRec + uintptr(sqlite3.Xsqlite3GetVarint(tls, pRec, bp /* &nHdr */))) 62690 pBody = libc.AssignUintptr(&pEndHdr, (pRec + uintptr(*(*u64)(unsafe.Pointer(bp /* nHdr */))))) 62691 62692 for iCurrent = 0; (pHdr < pEndHdr) && (iCurrent <= iIdx); iCurrent++ { 62693 // var iSerialType u64 at bp+64, 8 62694 62695 // var mem Mem at bp+8, 56 62696 62697 libc.Xmemset(tls, bp+8 /* &mem */, 0, uint64(unsafe.Sizeof(Mem{}))) 62698 (*Mem)(unsafe.Pointer(bp + 8 /* &mem */)).Fdb = db 62699 (*Mem)(unsafe.Pointer(bp + 8 /* &mem */)).Fenc = (*sqlite31)(unsafe.Pointer(db)).Fenc 62700 pHdr += uintptr(sqlite3.Xsqlite3GetVarint(tls, pHdr, bp+64 /* &iSerialType */)) 62701 pBody += uintptr(sqlite3.Xsqlite3VdbeSerialGet(tls, pBody, u322(*(*u64)(unsafe.Pointer(bp + 64 /* iSerialType */))), bp+8 /* &mem */)) 62702 62703 if iCurrent == iIdx { 62704 sqlite3.Xsqlite3_result_value(tls, context, bp+8 /* &mem */) 62705 } 62706 62707 if (*Mem)(unsafe.Pointer(bp+8 /* &mem */)).FszMalloc != 0 { 62708 sqlite3.Xsqlite3DbFree(tls, db, (*Mem)(unsafe.Pointer(bp+8 /* &mem */)).FzMalloc) 62709 } 62710 } 62711 } 62712 62713 // test_decode(record) 62714 // 62715 // This function implements an SQL user-function that accepts a blob 62716 // containing a formatted database record as its only argument. It returns 62717 // a tcl list (type SQLITE_TEXT) containing each of the values stored 62718 // in the record. 62719 func test_decode(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test_func.c:520:13: */ 62720 bp := tls.Alloc(123) 62721 defer tls.Free(123) 62722 62723 var db uintptr = sqlite3.Xsqlite3_context_db_handle(tls, context) 62724 var pRec uintptr 62725 var pEndHdr uintptr // Points to one byte past record header 62726 var pHdr uintptr // Current point in record header 62727 var pBody uintptr // Current point in record data 62728 // var nHdr u64 at bp+32, 8 62729 // Bytes in record header 62730 var pRet uintptr // Return value 62731 62732 pRet = tcl.XTcl_NewObj(tls) 62733 (*Tcl_Obj)(unsafe.Pointer(pRet)).FrefCount++ 62734 62735 pRec = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(argv))) 62736 62737 pHdr = (pRec + uintptr(sqlite3.Xsqlite3GetVarint(tls, pRec, bp+32 /* &nHdr */))) 62738 pBody = libc.AssignUintptr(&pEndHdr, (pRec + uintptr(*(*u64)(unsafe.Pointer(bp + 32 /* nHdr */))))) 62739 for pHdr < pEndHdr { 62740 var pVal uintptr = uintptr(0) 62741 // var iSerialType u64 at bp+96, 8 62742 62743 // var mem Mem at bp+40, 56 62744 62745 libc.Xmemset(tls, bp+40 /* &mem */, 0, uint64(unsafe.Sizeof(Mem{}))) 62746 (*Mem)(unsafe.Pointer(bp + 40 /* &mem */)).Fdb = db 62747 (*Mem)(unsafe.Pointer(bp + 40 /* &mem */)).Fenc = (*sqlite31)(unsafe.Pointer(db)).Fenc 62748 pHdr += uintptr(sqlite3.Xsqlite3GetVarint(tls, pHdr, bp+96 /* &iSerialType */)) 62749 pBody += uintptr(sqlite3.Xsqlite3VdbeSerialGet(tls, pBody, u322(*(*u64)(unsafe.Pointer(bp + 96 /* iSerialType */))), bp+40 /* &mem */)) 62750 62751 switch sqlite3.Xsqlite3_value_type(tls, bp+40 /* &mem */) { 62752 case SQLITE_TEXT: 62753 pVal = tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, bp+40 /* &mem */), -1) 62754 break 62755 62756 case SQLITE_BLOB: 62757 { 62758 *(*[16]int8)(unsafe.Pointer(bp + 107 /* hexdigit */)) = [16]int8{ 62759 int8('0'), int8('1'), int8('2'), int8('3'), int8('4'), int8('5'), int8('6'), int8('7'), 62760 int8('8'), int8('9'), int8('a'), int8('b'), int8('c'), int8('d'), int8('e'), int8('f'), 62761 } 62762 var n int32 = sqlite3.Xsqlite3_value_bytes(tls, bp+40 /* &mem */) 62763 var z uintptr = sqlite3.Xsqlite3_value_blob(tls, bp+40 /* &mem */) 62764 var i int32 62765 pVal = tcl.XTcl_NewStringObj(tls, ts+30544 /* "x'" */, -1) 62766 for i = 0; i < n; i++ { 62767 // var hex [3]int8 at bp+104, 3 62768 62769 *(*int8)(unsafe.Pointer(bp + 104 /* &hex[0] */)) = *(*int8)(unsafe.Pointer(bp + 107 /* &hexdigit[0] */ + uintptr(((int32(*(*u8)(unsafe.Pointer(z + uintptr(i)))) >> 4) & 0x0F)))) 62770 *(*int8)(unsafe.Pointer(bp + 104 /* &hex[0] */ + 1)) = *(*int8)(unsafe.Pointer(bp + 107 /* &hexdigit[0] */ + uintptr((int32(*(*u8)(unsafe.Pointer(z + uintptr(i)))) & 0x0F)))) 62771 *(*int8)(unsafe.Pointer(bp + 104 /* &hex[0] */ + 2)) = int8(0) 62772 tcl.XTcl_AppendStringsToObj(tls, pVal, libc.VaList(bp, bp+104 /* &hex[0] */, 0)) 62773 } 62774 tcl.XTcl_AppendStringsToObj(tls, pVal, libc.VaList(bp+16, ts+5495 /* "'" */, 0)) 62775 break 62776 62777 } 62778 62779 case SQLITE_FLOAT: 62780 pVal = tcl.XTcl_NewDoubleObj(tls, sqlite3.Xsqlite3_value_double(tls, bp+40 /* &mem */)) 62781 break 62782 62783 case SQLITE_INTEGER: 62784 pVal = tcl.XTcl_NewWideIntObj(tls, sqlite3.Xsqlite3_value_int64(tls, bp+40 /* &mem */)) 62785 break 62786 62787 case SQLITE_NULL: 62788 pVal = tcl.XTcl_NewStringObj(tls, ts+5717 /* "NULL" */, -1) 62789 break 62790 62791 default: 62792 62793 } 62794 62795 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pRet, pVal) 62796 62797 if (*Mem)(unsafe.Pointer(bp+40 /* &mem */)).FszMalloc != 0 { 62798 sqlite3.Xsqlite3DbFree(tls, db, (*Mem)(unsafe.Pointer(bp+40 /* &mem */)).FzMalloc) 62799 } 62800 } 62801 62802 sqlite3.Xsqlite3_result_text(tls, context, tcl.XTcl_GetString(tls, pRet), -1, libc.UintptrFromInt32(-1)) 62803 for ok := true; ok; ok = 0 != 0 { 62804 var _objPtr uintptr = pRet 62805 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 62806 tcl.XTclFreeObj(tls, _objPtr) 62807 } 62808 } 62809 } 62810 62811 // test_zeroblob(N) 62812 // 62813 // The implementation of scalar SQL function "test_zeroblob()". This is 62814 // similar to the built-in zeroblob() function, except that it does not 62815 // check that the integer parameter is within range before passing it 62816 // to sqlite3_result_zeroblob(). 62817 func test_zeroblob(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test_func.c:612:13: */ 62818 var nZero int32 = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))) 62819 sqlite3.Xsqlite3_result_zeroblob(tls, context, nZero) 62820 } 62821 62822 // test_getsubtype(V) 62823 // 62824 // Return the subtype for value V. 62825 func test_getsubtype(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test_func.c:625:13: */ 62826 sqlite3.Xsqlite3_result_int(tls, context, int32(sqlite3.Xsqlite3_value_subtype(tls, *(*uintptr)(unsafe.Pointer(argv))))) 62827 } 62828 62829 // test_frombind(A,B,C,...) 62830 // 62831 // Return an integer bitmask that has a bit set for every argument 62832 // (up to the first 63 arguments) that originates from a bind a parameter. 62833 func test_frombind(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test_func.c:638:13: */ 62834 var m sqlite3_uint64 = uint64(0) 62835 var i int32 62836 for i = 0; (i < argc) && (i < 63); i++ { 62837 if sqlite3.Xsqlite3_value_frombind(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) != 0 { 62838 m = m | (sqlite3_uint64((uint64(1))) << i) 62839 } 62840 } 62841 sqlite3.Xsqlite3_result_int64(tls, context, sqlite3_int64(m)) 62842 } 62843 62844 // test_setsubtype(V, T) 62845 // 62846 // Return the value V with its subtype changed to T 62847 func test_setsubtype(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test_func.c:655:13: */ 62848 sqlite3.Xsqlite3_result_value(tls, context, *(*uintptr)(unsafe.Pointer(argv))) 62849 sqlite3.Xsqlite3_result_subtype(tls, context, uint32(sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))))) 62850 } 62851 62852 func registerTestFunctions(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pThunk uintptr) int32 { /* test_func.c:664:12: */ 62853 var i int32 62854 62855 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aFuncs)) / uint64(unsafe.Sizeof(struct { 62856 FzName uintptr 62857 FnArg int8 62858 _ [3]byte 62859 FeTextRep uint32 62860 FxFunc uintptr 62861 }{}))); i++ { 62862 sqlite3.Xsqlite3_create_function(tls, db, aFuncs[i].FzName, int32(aFuncs[i].FnArg), 62863 int32(aFuncs[i].FeTextRep), uintptr(0), aFuncs[i].FxFunc, uintptr(0), uintptr(0)) 62864 } 62865 62866 sqlite3.Xsqlite3_create_function(tls, db, ts+30547 /* "test_agg_errmsg1..." */, 0, SQLITE_ANY, uintptr(0), uintptr(0), 62867 *(*uintptr)(unsafe.Pointer(&struct { 62868 f func(*libc.TLS, uintptr, int32, uintptr) 62869 }{test_agg_errmsg16_step})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{test_agg_errmsg16_final}))) 62870 62871 return SQLITE_OK 62872 } 62873 62874 var aFuncs = [20]struct { 62875 FzName uintptr 62876 FnArg int8 62877 _ [3]byte 62878 FeTextRep uint32 62879 FxFunc uintptr 62880 }{ 62881 {FzName: ts + 30565 /* "randstr" */, FnArg: int8(2), FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62882 {FzName: ts + 30573 /* "test_destructor" */, FnArg: int8(1), FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62883 {FzName: ts + 30589 /* "test_destructor1..." */, FnArg: int8(1), FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62884 {FzName: ts + 30607 /* "hex_to_utf16be" */, FnArg: int8(1), FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62885 {FzName: ts + 30622 /* "hex_to_utf16le" */, FnArg: int8(1), FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62886 {FzName: ts + 30637 /* "hex_to_utf8" */, FnArg: int8(1), FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62887 {FzName: ts + 30649 /* "test_destructor_..." */, FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62888 {FzName: ts + 30671 /* "test_auxdata" */, FnArg: int8(-1), FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62889 {FzName: ts + 30684 /* "test_error" */, FnArg: int8(1), FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62890 {FzName: ts + 30684 /* "test_error" */, FnArg: int8(2), FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62891 {FzName: ts + 30695 /* "test_eval" */, FnArg: int8(1), FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62892 {FzName: ts + 30705 /* "test_isolation" */, FnArg: int8(2), FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62893 {FzName: ts + 30720 /* "test_counter" */, FnArg: int8(1), FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62894 {FzName: ts + 30733 /* "real2hex" */, FnArg: int8(1), FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62895 {FzName: ts + 30742 /* "test_decode" */, FnArg: int8(1), FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62896 {FzName: ts + 30754 /* "test_extract" */, FnArg: int8(2), FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62897 {FzName: ts + 30767 /* "test_zeroblob" */, FnArg: int8(1), FeTextRep: (uint32(SQLITE_UTF8 | SQLITE_DETERMINISTIC)), FxFunc: 0}, 62898 {FzName: ts + 30781 /* "test_getsubtype" */, FnArg: int8(1), FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62899 {FzName: ts + 30797 /* "test_setsubtype" */, FnArg: int8(2), FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62900 {FzName: ts + 30813 /* "test_frombind" */, FnArg: int8(-1), FeTextRep: uint32(SQLITE_UTF8), FxFunc: 0}, 62901 } /* test_func.c:674:5 */ 62902 62903 // TCLCMD: autoinstall_test_functions 62904 // 62905 // Invoke this TCL command to use sqlite3_auto_extension() to cause 62906 // the standard set of test functions to be loaded into each new 62907 // database connection. 62908 func autoinstall_test_funcs(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_func.c:718:26: */ 62909 var rc int32 = sqlite3.Xsqlite3_auto_extension(tls, *(*uintptr)(unsafe.Pointer(&struct { 62910 f func(*libc.TLS, uintptr, uintptr, uintptr) int32 62911 }{registerTestFunctions}))) 62912 if rc == SQLITE_OK { 62913 rc = sqlite3.Xsqlite3_auto_extension(tls, *(*uintptr)(unsafe.Pointer(&struct { 62914 f func(*libc.TLS, uintptr, uintptr, uintptr) int32 62915 }{Md5_Register}))) 62916 } 62917 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) 62918 return TCL_OK 62919 } 62920 62921 // A bogus step function and finalizer function. 62922 func tStep(tls *libc.TLS, a uintptr, b int32, c uintptr) { /* test_func.c:736:13: */ 62923 } 62924 62925 func tFinal(tls *libc.TLS, a uintptr) { /* test_func.c:737:13: */ 62926 } 62927 62928 // tclcmd: abuse_create_function 62929 // 62930 // Make various calls to sqlite3_create_function that do not have valid 62931 // parameters. Verify that the error condition is detected and reported. 62932 func abuse_create_function(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_func.c:746:26: */ 62933 bp := tls.Alloc(24) 62934 defer tls.Free(24) 62935 62936 // var db uintptr at bp+16, 8 62937 62938 var rc int32 62939 var mxArg int32 62940 62941 if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+16 /* &db */) != 0) { 62942 goto __1 62943 } 62944 return TCL_ERROR 62945 __1: 62946 ; 62947 62948 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30827 /* "tx" */, 1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 62949 f func(*libc.TLS, uintptr, int32, uintptr) 62950 }{tStep})), *(*uintptr)(unsafe.Pointer(&struct { 62951 f func(*libc.TLS, uintptr, int32, uintptr) 62952 }{tStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{tFinal}))) 62953 if !(rc != SQLITE_MISUSE) { 62954 goto __2 62955 } 62956 goto abuse_err 62957 __2: 62958 ; 62959 62960 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30827 /* "tx" */, 1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 62961 f func(*libc.TLS, uintptr, int32, uintptr) 62962 }{tStep})), *(*uintptr)(unsafe.Pointer(&struct { 62963 f func(*libc.TLS, uintptr, int32, uintptr) 62964 }{tStep})), uintptr(0)) 62965 if !(rc != SQLITE_MISUSE) { 62966 goto __3 62967 } 62968 goto abuse_err 62969 __3: 62970 ; 62971 62972 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30827 /* "tx" */, 1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 62973 f func(*libc.TLS, uintptr, int32, uintptr) 62974 }{tStep})), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{tFinal}))) 62975 if !(rc != SQLITE_MISUSE) { 62976 goto __4 62977 } 62978 goto abuse_err 62979 __4: 62980 ; 62981 62982 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30827 /* "tx" */, 1, SQLITE_UTF8, uintptr(0), uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{tFinal}))) 62983 if !(rc != SQLITE_MISUSE) { 62984 goto __5 62985 } 62986 goto abuse_err 62987 __5: 62988 ; 62989 62990 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30827 /* "tx" */, 1, SQLITE_UTF8, uintptr(0), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 62991 f func(*libc.TLS, uintptr, int32, uintptr) 62992 }{tStep})), uintptr(0)) 62993 if !(rc != SQLITE_MISUSE) { 62994 goto __6 62995 } 62996 goto abuse_err 62997 __6: 62998 ; 62999 63000 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30827 /* "tx" */, -2, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 63001 f func(*libc.TLS, uintptr, int32, uintptr) 63002 }{tStep})), uintptr(0), uintptr(0)) 63003 if !(rc != SQLITE_MISUSE) { 63004 goto __7 63005 } 63006 goto abuse_err 63007 __7: 63008 ; 63009 63010 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), ts+30827 /* "tx" */, 128, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 63011 f func(*libc.TLS, uintptr, int32, uintptr) 63012 }{tStep})), uintptr(0), uintptr(0)) 63013 if !(rc != SQLITE_MISUSE) { 63014 goto __8 63015 } 63016 goto abuse_err 63017 __8: 63018 ; 63019 63020 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), 63021 63022 ts+30830, /* "funcxx_123456789..." */ 63023 1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 63024 f func(*libc.TLS, uintptr, int32, uintptr) 63025 }{tStep})), uintptr(0), uintptr(0)) 63026 if !(rc != SQLITE_MISUSE) { 63027 goto __9 63028 } 63029 goto abuse_err 63030 __9: 63031 ; 63032 63033 // This last function registration should actually work. Generate 63034 // a no-op function (that always returns NULL) and which has the 63035 // maximum-length function name and the maximum number of parameters. 63036 sqlite3.Xsqlite3_limit(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), SQLITE_LIMIT_FUNCTION_ARG, 10000) 63037 mxArg = sqlite3.Xsqlite3_limit(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), SQLITE_LIMIT_FUNCTION_ARG, -1) 63038 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), 63039 63040 ts+31087, /* "nullx_123456789_..." */ 63041 mxArg, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 63042 f func(*libc.TLS, uintptr, int32, uintptr) 63043 }{tStep})), uintptr(0), uintptr(0)) 63044 if !(rc != SQLITE_OK) { 63045 goto __10 63046 } 63047 goto abuse_err 63048 __10: 63049 ; 63050 63051 return TCL_OK 63052 63053 abuse_err: 63054 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+31343, /* "sqlite3_create_f..." */ 63055 uintptr(0))) 63056 return TCL_ERROR 63057 } 63058 63059 // SQLite user defined function to use with matchinfo() to calculate the 63060 // relevancy of an FTS match. The value returned is the relevancy score 63061 // (a real value greater than or equal to zero). A larger value indicates 63062 // a more relevant document. 63063 // 63064 // The overall relevancy returned is the sum of the relevancies of each 63065 // column value in the FTS table. The relevancy of a column value is the 63066 // sum of the following for each reportable phrase in the FTS query: 63067 // 63068 // (<hit count> / <global hit count>) * <column weight> 63069 // 63070 // where <hit count> is the number of instances of the phrase in the 63071 // column value of the current row and <global hit count> is the number 63072 // of instances of the phrase in the same column of all rows in the FTS 63073 // table. The <column weight> is a weighting factor assigned to each 63074 // column by the caller (see below). 63075 // 63076 // The first argument to this function must be the return value of the FTS 63077 // matchinfo() function. Following this must be one argument for each column 63078 // of the FTS table containing a numeric weight factor for the corresponding 63079 // column. Example: 63080 // 63081 // CREATE VIRTUAL TABLE documents USING fts3(title, content) 63082 // 63083 // The following query returns the docids of documents that match the full-text 63084 // query <query> sorted from most to least relevant. When calculating 63085 // relevance, query term instances in the 'title' column are given twice the 63086 // weighting of those in the 'content' column. 63087 // 63088 // SELECT docid FROM documents 63089 // WHERE documents MATCH <query> 63090 // ORDER BY rank(matchinfo(documents), 1.0, 0.5) DESC 63091 func rankfunc(tls *libc.TLS, pCtx uintptr, nVal int32, apVal uintptr) { /* test_func.c:847:13: */ 63092 var aMatchinfo uintptr // Return value of matchinfo() 63093 var nMatchinfo int32 // Number of elements in aMatchinfo[] 63094 var nCol int32 // Number of columns in the table 63095 var nPhrase int32 // Number of phrases in the query 63096 var iPhrase int32 // Current phrase 63097 var score float64 63098 var nHitCount int32 63099 var nGlobalHitCount int32 63100 var weight float64 63101 var iCol int32 // Current column 63102 63103 // Now iterate through each column in the users query. For each column, 63104 // increment the relevancy score by: 63105 // 63106 // (<hit count> / <global hit count>) * <column weight> 63107 // 63108 // aPhraseinfo[] points to the start of the data for phrase iPhrase. So 63109 // the hit count and global hit counts for each column are found in 63110 // aPhraseinfo[iCol*3] and aPhraseinfo[iCol*3+1], respectively. 63111 var aPhraseinfo uintptr 63112 nCol = 0 63113 nPhrase = 0 63114 score = 0.0 // Value to return 63115 63116 // Check that the number of arguments passed to this function is correct. 63117 // If not, jump to wrong_number_args. Set aMatchinfo to point to the array 63118 // of unsigned integer values returned by FTS function matchinfo. Set 63119 // nPhrase to contain the number of reportable phrases in the users full-text 63120 // query, and nCol to the number of columns in the table. Then check that the 63121 // size of the matchinfo blob is as expected. Return an error if it is not. 63122 if !(nVal < 1) { 63123 goto __1 63124 } 63125 goto wrong_number_args 63126 __1: 63127 ; 63128 aMatchinfo = sqlite3.Xsqlite3_value_blob(tls, *(*uintptr)(unsafe.Pointer(apVal))) 63129 nMatchinfo = (int32(uint64(sqlite3.Xsqlite3_value_bytes(tls, *(*uintptr)(unsafe.Pointer(apVal)))) / uint64(unsafe.Sizeof(int32(0))))) 63130 if !(nMatchinfo >= 2) { 63131 goto __2 63132 } 63133 nPhrase = *(*int32)(unsafe.Pointer(aMatchinfo)) 63134 nCol = *(*int32)(unsafe.Pointer(aMatchinfo + 1*4)) 63135 __2: 63136 ; 63137 if !(nMatchinfo != (2 + ((3 * nCol) * nPhrase))) { 63138 goto __3 63139 } 63140 sqlite3.Xsqlite3_result_error(tls, pCtx, 63141 ts+31386 /* "invalid matchinf..." */, -1) 63142 return 63143 __3: 63144 ; 63145 if !(nVal != (1 + nCol)) { 63146 goto __4 63147 } 63148 goto wrong_number_args 63149 __4: 63150 ; 63151 63152 // Iterate through each phrase in the users query. 63153 iPhrase = 0 63154 __5: 63155 if !(iPhrase < nPhrase) { 63156 goto __7 63157 } // Current column 63158 63159 // Now iterate through each column in the users query. For each column, 63160 // increment the relevancy score by: 63161 // 63162 // (<hit count> / <global hit count>) * <column weight> 63163 // 63164 // aPhraseinfo[] points to the start of the data for phrase iPhrase. So 63165 // the hit count and global hit counts for each column are found in 63166 // aPhraseinfo[iCol*3] and aPhraseinfo[iCol*3+1], respectively. 63167 aPhraseinfo = (aMatchinfo + uintptr((2+((iPhrase*nCol)*3)))*4) 63168 iCol = 0 63169 __8: 63170 if !(iCol < nCol) { 63171 goto __10 63172 } 63173 nHitCount = *(*int32)(unsafe.Pointer(aPhraseinfo + uintptr((3*iCol))*4)) 63174 nGlobalHitCount = *(*int32)(unsafe.Pointer(aPhraseinfo + uintptr(((3*iCol)+1))*4)) 63175 weight = sqlite3.Xsqlite3_value_double(tls, *(*uintptr)(unsafe.Pointer(apVal + uintptr((iCol+1))*8))) 63176 if !(nHitCount > 0) { 63177 goto __11 63178 } 63179 score = score + ((float64(nHitCount) / float64(nGlobalHitCount)) * weight) 63180 __11: 63181 ; 63182 goto __9 63183 __9: 63184 iCol++ 63185 goto __8 63186 goto __10 63187 __10: 63188 ; 63189 goto __6 63190 __6: 63191 iPhrase++ 63192 goto __5 63193 goto __7 63194 __7: 63195 ; 63196 63197 sqlite3.Xsqlite3_result_double(tls, pCtx, score) 63198 return 63199 63200 // Jump here if the wrong number of arguments are passed to this function 63201 wrong_number_args: 63202 sqlite3.Xsqlite3_result_error(tls, pCtx, ts+31435 /* "wrong number of ..." */, -1) 63203 } 63204 63205 func install_fts3_rank_function(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_func.c:910:26: */ 63206 bp := tls.Alloc(8) 63207 defer tls.Free(8) 63208 63209 // var db uintptr at bp, 8 63210 63211 if objc != 2 { 63212 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 63213 return TCL_ERROR 63214 } 63215 63216 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 63217 return TCL_ERROR 63218 } 63219 sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+31480 /* "rank" */, -1, SQLITE_UTF8, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 63220 f func(*libc.TLS, uintptr, int32, uintptr) 63221 }{rankfunc})), uintptr(0), uintptr(0)) 63222 return TCL_OK 63223 } 63224 63225 // Register commands with the TCL interpreter. 63226 func Sqlitetest_func_Init(tls *libc.TLS, interp uintptr) int32 { /* test_func.c:933:5: */ 63227 var i int32 63228 63229 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aObjCmd7)) / uint64(unsafe.Sizeof(struct { 63230 FzName uintptr 63231 FxProc uintptr 63232 }{}))); i++ { 63233 tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd7[i].FzName, aObjCmd7[i].FxProc, uintptr(0), uintptr(0)) 63234 } 63235 sqlite3.Xsqlite3_initialize(tls) 63236 sqlite3.Xsqlite3_auto_extension(tls, *(*uintptr)(unsafe.Pointer(&struct { 63237 f func(*libc.TLS, uintptr, uintptr, uintptr) int32 63238 }{registerTestFunctions}))) 63239 sqlite3.Xsqlite3_auto_extension(tls, *(*uintptr)(unsafe.Pointer(&struct { 63240 f func(*libc.TLS, uintptr, uintptr, uintptr) int32 63241 }{Md5_Register}))) 63242 return TCL_OK 63243 } 63244 63245 var aObjCmd7 = [3]struct { 63246 FzName uintptr 63247 FxProc uintptr 63248 }{ 63249 {FzName: ts + 31485 /* "autoinstall_test..." */, FxProc: 0}, 63250 {FzName: ts + 31512 /* "abuse_create_fun..." */, FxProc: 0}, 63251 {FzName: ts + 31534 /* "install_fts3_ran..." */, FxProc: 0}, 63252 } /* test_func.c:937:5 */ 63253 63254 // Some versions of <linux/posix_types.h> define this macros. 63255 // It's easier to assume 8-bit bytes than to get CHAR_BIT. 63256 63257 // fd_set for select and pselect. 63258 type fd_set3 = struct{ Ffds_bits [16]int64 } /* select.h:70:5 */ 63259 63260 // end block for C++ 63261 63262 // Local Variables: 63263 // mode: c 63264 // c-basic-offset: 4 63265 // fill-column: 78 63266 // End: 63267 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 63268 // This file is part of the GNU C Library. 63269 // 63270 // The GNU C Library is free software; you can redistribute it and/or 63271 // modify it under the terms of the GNU Lesser General Public 63272 // License as published by the Free Software Foundation; either 63273 // version 2.1 of the License, or (at your option) any later version. 63274 // 63275 // The GNU C Library is distributed in the hope that it will be useful, 63276 // but WITHOUT ANY WARRANTY; without even the implied warranty of 63277 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 63278 // Lesser General Public License for more details. 63279 // 63280 // You should have received a copy of the GNU Lesser General Public 63281 // License along with the GNU C Library; if not, see 63282 // <http://www.gnu.org/licenses/>. 63283 63284 // ISO C99 Standard: 7.20 General utilities <stdlib.h> 63285 63286 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 63287 // This file is part of the GNU C Library. 63288 // 63289 // The GNU C Library is free software; you can redistribute it and/or 63290 // modify it under the terms of the GNU Lesser General Public 63291 // License as published by the Free Software Foundation; either 63292 // version 2.1 of the License, or (at your option) any later version. 63293 // 63294 // The GNU C Library is distributed in the hope that it will be useful, 63295 // but WITHOUT ANY WARRANTY; without even the implied warranty of 63296 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 63297 // Lesser General Public License for more details. 63298 // 63299 // You should have received a copy of the GNU Lesser General Public 63300 // License along with the GNU C Library; if not, see 63301 // <http://www.gnu.org/licenses/>. 63302 63303 // ISO C99 Standard: 7.21 String handling <string.h> 63304 63305 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 63306 // This file is part of the GNU C Library. 63307 // 63308 // The GNU C Library is free software; you can redistribute it and/or 63309 // modify it under the terms of the GNU Lesser General Public 63310 // License as published by the Free Software Foundation; either 63311 // version 2.1 of the License, or (at your option) any later version. 63312 // 63313 // The GNU C Library is distributed in the hope that it will be useful, 63314 // but WITHOUT ANY WARRANTY; without even the implied warranty of 63315 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 63316 // Lesser General Public License for more details. 63317 // 63318 // You should have received a copy of the GNU Lesser General Public 63319 // License along with the GNU C Library; if not, see 63320 // <http://www.gnu.org/licenses/>. 63321 63322 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 63323 63324 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 63325 // This file is part of the GNU C Library. 63326 // 63327 // The GNU C Library is free software; you can redistribute it and/or 63328 // modify it under the terms of the GNU Lesser General Public 63329 // License as published by the Free Software Foundation; either 63330 // version 2.1 of the License, or (at your option) any later version. 63331 // 63332 // The GNU C Library is distributed in the hope that it will be useful, 63333 // but WITHOUT ANY WARRANTY; without even the implied warranty of 63334 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 63335 // Lesser General Public License for more details. 63336 // 63337 // You should have received a copy of the GNU Lesser General Public 63338 // License along with the GNU C Library; if not, see 63339 // <http://www.gnu.org/licenses/>. 63340 63341 // void assert (int expression); 63342 // 63343 // If NDEBUG is defined, do nothing. 63344 // If not, and EXPRESSION is zero, print an error message and abort. 63345 63346 // void assert_perror (int errnum); 63347 // 63348 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 63349 // error message with the error text for ERRNUM and abort. 63350 // (This is a GNU extension.) 63351 63352 // Convert binary to hex. The input zBuf[] contains N bytes of 63353 // binary data. zBuf[] is 2*n+1 bytes long. Overwrite zBuf[] 63354 // with a hexadecimal representation of its original binary input. 63355 func sqlite3TestBinToHex(tls *libc.TLS, zBuf uintptr, N int32) { /* test_hexio.c:36:6: */ 63356 bp := tls.Alloc(17) 63357 defer tls.Free(17) 63358 63359 *(*[17]uint8)(unsafe.Pointer(bp /* zHex */)) = *(*[17]uint8)(unsafe.Pointer(ts + 31561 /* "0123456789ABCDEF" */)) 63360 var i int32 63361 var j int32 63362 var c uint8 63363 i = (N * 2) 63364 *(*uint8)(unsafe.Pointer(zBuf + uintptr(libc.PostDecInt32(&i, 1)))) = uint8(0) 63365 for j = (N - 1); j >= 0; j-- { 63366 c = *(*uint8)(unsafe.Pointer(zBuf + uintptr(j))) 63367 *(*uint8)(unsafe.Pointer(zBuf + uintptr(libc.PostDecInt32(&i, 1)))) = *(*uint8)(unsafe.Pointer(bp /* &zHex[0] */ + uintptr((int32(c) & 0xf)))) 63368 *(*uint8)(unsafe.Pointer(zBuf + uintptr(libc.PostDecInt32(&i, 1)))) = *(*uint8)(unsafe.Pointer(bp /* &zHex[0] */ + uintptr((int32(c) >> 4)))) 63369 } 63370 63371 } 63372 63373 // Convert hex to binary. The input zIn[] contains N bytes of 63374 // hexadecimal. Convert this into binary and write aOut[] with 63375 // the binary data. Spaces in the original input are ignored. 63376 // Return the number of bytes of binary rendered. 63377 func sqlite3TestHexToBin(tls *libc.TLS, zIn uintptr, N int32, aOut uintptr) int32 { /* test_hexio.c:56:5: */ 63378 bp := tls.Alloc(256) 63379 defer tls.Free(256) 63380 63381 *(*[256]uint8)(unsafe.Pointer(bp /* aMap */)) = [256]uint8{ 63382 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), 63383 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), 63384 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), 63385 uint8(1), uint8(2), uint8(3), uint8(4), uint8(5), uint8(6), uint8(7), uint8(8), uint8(9), uint8(10), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), 63386 uint8(0), uint8(11), uint8(12), uint8(13), uint8(14), uint8(15), uint8(16), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), 63387 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), 63388 uint8(0), uint8(11), uint8(12), uint8(13), uint8(14), uint8(15), uint8(16), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), uint8(0), 63389 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), 63390 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), 63391 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), 63392 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), 63393 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), 63394 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), 63395 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), 63396 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), 63397 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), 63398 } 63399 var i int32 63400 var j int32 63401 var hi int32 = 1 63402 var c uint8 63403 63404 for i = libc.AssignInt32(&j, 0); i < N; i++ { 63405 c = *(*uint8)(unsafe.Pointer(bp /* &aMap[0] */ + uintptr(*(*uint8)(unsafe.Pointer(zIn + uintptr(i)))))) 63406 if int32(c) == 0 { 63407 continue 63408 } 63409 if hi != 0 { 63410 *(*uint8)(unsafe.Pointer(aOut + uintptr(j))) = (uint8((int32(c) - 1) << 4)) 63411 hi = 0 63412 } else { 63413 *(*uint8)(unsafe.Pointer(aOut + uintptr(libc.PostIncInt32(&j, 1)))) |= uint8((int32(c) - 1)) 63414 hi = 1 63415 } 63416 } 63417 return j 63418 } 63419 63420 // Usage: hexio_read FILENAME OFFSET AMT 63421 // 63422 // Read AMT bytes from file FILENAME beginning at OFFSET from the 63423 // beginning of the file. Convert that information to hexadecimal 63424 // and return the resulting HEX string. 63425 func hexio_read(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_hexio.c:101:26: */ 63426 bp := tls.Alloc(48) 63427 defer tls.Free(48) 63428 63429 // var offset int32 at bp+40, 4 63430 63431 // var amt int32 at bp+44, 4 63432 63433 var got int32 63434 var zFile uintptr 63435 var zBuf uintptr 63436 var in uintptr 63437 63438 if objc != 4 { 63439 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31578 /* "FILENAME OFFSET ..." */) 63440 return TCL_ERROR 63441 } 63442 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &offset */) != 0 { 63443 return TCL_ERROR 63444 } 63445 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+44 /* &amt */) != 0 { 63446 return TCL_ERROR 63447 } 63448 zFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 63449 zBuf = sqlite3.Xsqlite3_malloc(tls, ((*(*int32)(unsafe.Pointer(bp + 44 /* amt */)) * 2) + 1)) 63450 if zBuf == uintptr(0) { 63451 return TCL_ERROR 63452 } 63453 in = libc.Xfopen(tls, zFile, ts+4273 /* "rb" */) 63454 if in == uintptr(0) { 63455 in = libc.Xfopen(tls, zFile, ts+31598 /* "r" */) 63456 } 63457 if in == uintptr(0) { 63458 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+31600 /* "cannot open inpu..." */, zFile, 0)) 63459 return TCL_ERROR 63460 } 63461 libc.Xfseek(tls, in, int64(*(*int32)(unsafe.Pointer(bp + 40 /* offset */))), SEEK_SET) 63462 got = int32(libc.Xfread(tls, zBuf, uint64(1), uint64(*(*int32)(unsafe.Pointer(bp + 44 /* amt */))), in)) 63463 libc.Xfclose(tls, in) 63464 if got < 0 { 63465 got = 0 63466 } 63467 sqlite3TestBinToHex(tls, zBuf, got) 63468 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, zBuf, 0)) 63469 sqlite3.Xsqlite3_free(tls, zBuf) 63470 return TCL_OK 63471 } 63472 63473 // Usage: hexio_write FILENAME OFFSET DATA 63474 // 63475 // Write DATA into file FILENAME beginning at OFFSET from the 63476 // beginning of the file. DATA is expressed in hexadecimal. 63477 func hexio_write(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_hexio.c:151:26: */ 63478 bp := tls.Alloc(32) 63479 defer tls.Free(32) 63480 63481 // var offset int32 at bp+24, 4 63482 63483 // var nIn int32 at bp+28, 4 63484 63485 var nOut int32 63486 var written int32 63487 var zFile uintptr 63488 var zIn uintptr 63489 var aOut uintptr 63490 var out uintptr 63491 63492 if objc != 4 { 63493 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31624 /* "FILENAME OFFSET ..." */) 63494 return TCL_ERROR 63495 } 63496 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+24 /* &offset */) != 0 { 63497 return TCL_ERROR 63498 } 63499 zFile = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 63500 zIn = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+28 /* &nIn */) 63501 aOut = sqlite3.Xsqlite3_malloc(tls, (1 + (*(*int32)(unsafe.Pointer(bp + 28 /* nIn */)) / 2))) 63502 if aOut == uintptr(0) { 63503 return TCL_ERROR 63504 } 63505 nOut = sqlite3TestHexToBin(tls, zIn, *(*int32)(unsafe.Pointer(bp + 28 /* nIn */)), aOut) 63506 out = libc.Xfopen(tls, zFile, ts+31648 /* "r+b" */) 63507 if out == uintptr(0) { 63508 out = libc.Xfopen(tls, zFile, ts+31652 /* "r+" */) 63509 } 63510 if out == uintptr(0) { 63511 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+31655 /* "cannot open outp..." */, zFile, 0)) 63512 return TCL_ERROR 63513 } 63514 libc.Xfseek(tls, out, int64(*(*int32)(unsafe.Pointer(bp + 24 /* offset */))), SEEK_SET) 63515 written = int32(libc.Xfwrite(tls, aOut, uint64(1), uint64(nOut), out)) 63516 sqlite3.Xsqlite3_free(tls, aOut) 63517 libc.Xfclose(tls, out) 63518 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, written)) 63519 return TCL_OK 63520 } 63521 63522 // USAGE: hexio_get_int HEXDATA 63523 // 63524 // Interpret the HEXDATA argument as a big-endian integer. Return 63525 // the value of that integer. HEXDATA can contain between 2 and 8 63526 // hexadecimal digits. 63527 func hexio_get_int(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_hexio.c:199:26: */ 63528 bp := tls.Alloc(8) 63529 defer tls.Free(8) 63530 63531 var val int32 63532 // var nIn int32 at bp, 4 63533 63534 var nOut int32 63535 var zIn uintptr 63536 var aOut uintptr 63537 // var aNum [4]uint8 at bp+4, 4 63538 63539 if objc != 2 { 63540 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31680 /* "HEXDATA" */) 63541 return TCL_ERROR 63542 } 63543 zIn = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &nIn */) 63544 aOut = sqlite3.Xsqlite3_malloc(tls, (1 + (*(*int32)(unsafe.Pointer(bp /* nIn */)) / 2))) 63545 if aOut == uintptr(0) { 63546 return TCL_ERROR 63547 } 63548 nOut = sqlite3TestHexToBin(tls, zIn, *(*int32)(unsafe.Pointer(bp /* nIn */)), aOut) 63549 if nOut >= 4 { 63550 libc.Xmemcpy(tls, bp+4 /* &aNum[0] */, aOut, uint64(4)) 63551 } else { 63552 libc.Xmemset(tls, bp+4 /* &aNum[0] */, 0, uint64(unsafe.Sizeof([4]uint8{}))) 63553 libc.Xmemcpy(tls, (bp + 4 /* &aNum */ + uintptr((4 - nOut))), aOut, uint64(nOut)) 63554 } 63555 sqlite3.Xsqlite3_free(tls, aOut) 63556 val = ((((int32(*(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */))) << 24) | (int32(*(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + 1))) << 16)) | (int32(*(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + 2))) << 8)) | int32(*(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + 3)))) 63557 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, val)) 63558 return TCL_OK 63559 } 63560 63561 // USAGE: hexio_render_int16 INTEGER 63562 // 63563 // Render INTEGER has a 16-bit big-endian integer in hexadecimal. 63564 func hexio_render_int16(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_hexio.c:239:26: */ 63565 bp := tls.Alloc(14) 63566 defer tls.Free(14) 63567 63568 // var val int32 at bp, 4 63569 63570 // var aNum [10]uint8 at bp+4, 10 63571 63572 if objc != 2 { 63573 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2274 /* "INTEGER" */) 63574 return TCL_ERROR 63575 } 63576 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &val */) != 0 { 63577 return TCL_ERROR 63578 } 63579 *(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */)) = (uint8(*(*int32)(unsafe.Pointer(bp /* val */)) >> 8)) 63580 *(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + 1)) = uint8(*(*int32)(unsafe.Pointer(bp /* val */))) 63581 sqlite3TestBinToHex(tls, bp+4 /* &aNum[0] */, 2) 63582 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, bp+4 /* aNum */, 4)) 63583 return TCL_OK 63584 } 63585 63586 // USAGE: hexio_render_int32 INTEGER 63587 // 63588 // Render INTEGER has a 32-bit big-endian integer in hexadecimal. 63589 func hexio_render_int32(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_hexio.c:266:26: */ 63590 bp := tls.Alloc(14) 63591 defer tls.Free(14) 63592 63593 // var val int32 at bp, 4 63594 63595 // var aNum [10]uint8 at bp+4, 10 63596 63597 if objc != 2 { 63598 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2274 /* "INTEGER" */) 63599 return TCL_ERROR 63600 } 63601 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &val */) != 0 { 63602 return TCL_ERROR 63603 } 63604 *(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */)) = (uint8(*(*int32)(unsafe.Pointer(bp /* val */)) >> 24)) 63605 *(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + 1)) = (uint8(*(*int32)(unsafe.Pointer(bp /* val */)) >> 16)) 63606 *(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + 2)) = (uint8(*(*int32)(unsafe.Pointer(bp /* val */)) >> 8)) 63607 *(*uint8)(unsafe.Pointer(bp + 4 /* &aNum[0] */ + 3)) = uint8(*(*int32)(unsafe.Pointer(bp /* val */))) 63608 sqlite3TestBinToHex(tls, bp+4 /* &aNum[0] */, 4) 63609 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, bp+4 /* aNum */, 8)) 63610 return TCL_OK 63611 } 63612 63613 // USAGE: utf8_to_utf8 HEX 63614 // 63615 // The argument is a UTF8 string represented in hexadecimal. 63616 // The UTF8 might not be well-formed. Run this string through 63617 // sqlite3Utf8to8() convert it back to hex and return the result. 63618 func utf8_to_utf8(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_hexio.c:296:26: */ 63619 bp := tls.Alloc(16) 63620 defer tls.Free(16) 63621 63622 tcl.XTcl_AppendResult(tls, interp, 63623 libc.VaList(bp, ts+31688 /* "[utf8_to_utf8] u..." */, 0)) 63624 return TCL_ERROR 63625 } 63626 63627 func getFts3Varint(tls *libc.TLS, p uintptr, v uintptr) int32 { /* test_hexio.c:328:12: */ 63628 var q uintptr = p 63629 var x sqlite_uint64 = uint64(0) 63630 var y sqlite_uint64 = uint64(1) 63631 for (int32(*(*uint8)(unsafe.Pointer(q))) & 0x80) == 0x80 { 63632 x = x + (y * (sqlite_uint64(int32(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&q, 1)))) & 0x7f))) 63633 y <<= 7 63634 } 63635 x = x + (y * (sqlite_uint64(*(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&q, 1)))))) 63636 *(*sqlite_int64)(unsafe.Pointer(v)) = sqlite_int64(x) 63637 return (int32((int64(q) - int64(p)) / 1)) 63638 } 63639 63640 func putFts3Varint(tls *libc.TLS, p uintptr, v sqlite_int64) int32 { /* test_hexio.c:340:12: */ 63641 var q uintptr = p 63642 var vu sqlite_uint64 = sqlite_uint64(v) 63643 for ok := true; ok; ok = (vu != uint64(0)) { 63644 *(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&q, 1))) = (uint8((vu & uint64(0x7f)) | uint64(0x80))) 63645 vu >>= 7 63646 } 63647 *(*uint8)(unsafe.Pointer(q + libc.UintptrFromInt32(-1))) &= uint8((0x7f)) // turn off high bit in final byte 63648 63649 return (int32((int64(q) - int64(p)) / 1)) 63650 } 63651 63652 // USAGE: read_fts3varint BLOB VARNAME 63653 // 63654 // Read a varint from the start of BLOB. Set variable VARNAME to contain 63655 // the interpreted value. Return the number of bytes of BLOB consumed. 63656 func read_fts3varint(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_hexio.c:358:26: */ 63657 bp := tls.Alloc(16) 63658 defer tls.Free(16) 63659 63660 // var nBlob int32 at bp, 4 63661 63662 var zBlob uintptr 63663 // var iVal sqlite3_int64 at bp+8, 8 63664 63665 var nVal int32 63666 63667 if objc != 3 { 63668 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31742 /* "BLOB VARNAME" */) 63669 return TCL_ERROR 63670 } 63671 zBlob = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &nBlob */) 63672 63673 nVal = getFts3Varint(tls, zBlob, bp+8 /* &iVal */) 63674 tcl.XTcl_ObjSetVar2(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(0), tcl.XTcl_NewWideIntObj(tls, *(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* iVal */))), 0) 63675 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, nVal)) 63676 return TCL_OK 63677 } 63678 63679 // USAGE: make_fts3record ARGLIST 63680 func make_fts3record(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_hexio.c:384:26: */ 63681 bp := tls.Alloc(28) 63682 defer tls.Free(28) 63683 63684 *(*uintptr)(unsafe.Pointer(bp + 8 /* aArg */)) = uintptr(0) 63685 *(*int32)(unsafe.Pointer(bp /* nArg */)) = 0 63686 var aOut uintptr = uintptr(0) 63687 var nOut int32 = 0 63688 var nAlloc int32 = 0 63689 var i int32 63690 63691 if objc != 2 { 63692 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+31755 /* "LIST" */) 63693 return TCL_ERROR 63694 } 63695 if tcl.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &nArg */, bp+8 /* &aArg */) != 0 { 63696 return TCL_ERROR 63697 } 63698 63699 for i = 0; i < *(*int32)(unsafe.Pointer(bp /* nArg */)); i++ { 63700 // var iVal sqlite3_int64 at bp+16, 8 63701 63702 if TCL_OK == tcl.XTcl_GetWideIntFromObj(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* aArg */)) + uintptr(i)*8)), bp+16 /* &iVal */) { 63703 if (nOut + 10) > nAlloc { 63704 var nNew int32 63705 if nAlloc != 0 { 63706 nNew = (nAlloc * 2) 63707 } else { 63708 nNew = 128 63709 } 63710 var aNew uintptr = sqlite3.Xsqlite3_realloc(tls, aOut, nNew) 63711 if aNew == uintptr(0) { 63712 sqlite3.Xsqlite3_free(tls, aOut) 63713 return TCL_ERROR 63714 } 63715 aOut = aNew 63716 nAlloc = nNew 63717 } 63718 nOut = nOut + (putFts3Varint(tls, (aOut + uintptr(nOut)), *(*sqlite3_int64)(unsafe.Pointer(bp + 16 /* iVal */)))) 63719 } else { 63720 *(*int32)(unsafe.Pointer(bp + 24 /* nVal */)) = 0 63721 var zVal uintptr = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* aArg */)) + uintptr(i)*8)), bp+24 /* &nVal */) 63722 for (nOut + *(*int32)(unsafe.Pointer(bp + 24 /* nVal */))) > nAlloc { 63723 var nNew int32 63724 if nAlloc != 0 { 63725 nNew = (nAlloc * 2) 63726 } else { 63727 nNew = 128 63728 } 63729 var aNew uintptr = sqlite3.Xsqlite3_realloc(tls, aOut, nNew) 63730 if aNew == uintptr(0) { 63731 sqlite3.Xsqlite3_free(tls, aOut) 63732 return TCL_ERROR 63733 } 63734 aOut = aNew 63735 nAlloc = nNew 63736 } 63737 libc.Xmemcpy(tls, (aOut + uintptr(nOut)), zVal, uint64(*(*int32)(unsafe.Pointer(bp + 24 /* nVal */)))) 63738 nOut = nOut + (*(*int32)(unsafe.Pointer(bp + 24 /* nVal */))) 63739 } 63740 } 63741 63742 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewByteArrayObj(tls, aOut, nOut)) 63743 sqlite3.Xsqlite3_free(tls, aOut) 63744 return TCL_OK 63745 } 63746 63747 // Register commands with the TCL interpreter. 63748 func Sqlitetest_hexio_Init(tls *libc.TLS, interp uintptr) int32 { /* test_hexio.c:446:5: */ 63749 var i int32 63750 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aObjCmd8)) / uint64(unsafe.Sizeof(struct { 63751 FzName uintptr 63752 FxProc uintptr 63753 }{}))); i++ { 63754 tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd8[i].FzName, aObjCmd8[i].FxProc, uintptr(0), uintptr(0)) 63755 } 63756 return TCL_OK 63757 } 63758 63759 var aObjCmd8 = [8]struct { 63760 FzName uintptr 63761 FxProc uintptr 63762 }{ 63763 {FzName: ts + 31760 /* "hexio_read" */, FxProc: 0}, 63764 {FzName: ts + 31771 /* "hexio_write" */, FxProc: 0}, 63765 {FzName: ts + 31783 /* "hexio_get_int" */, FxProc: 0}, 63766 {FzName: ts + 31797 /* "hexio_render_int..." */, FxProc: 0}, 63767 {FzName: ts + 31816 /* "hexio_render_int..." */, FxProc: 0}, 63768 {FzName: ts + 31835 /* "utf8_to_utf8" */, FxProc: 0}, 63769 {FzName: ts + 31848 /* "read_fts3varint" */, FxProc: 0}, 63770 {FzName: ts + 31864 /* "make_fts3record" */, FxProc: 0}, 63771 } /* test_hexio.c:450:5 */ 63772 63773 // end block for C++ 63774 63775 // Local Variables: 63776 // mode: c 63777 // c-basic-offset: 4 63778 // fill-column: 78 63779 // End: 63780 63781 type Wrapped = struct { 63782 Fpcache sqlite3_pcache_methods2 63783 Fmem sqlite3_mem_methods 63784 Fmutex sqlite3_mutex_methods 63785 Fmem_init int32 63786 Fmem_fail int32 63787 Fmutex_init int32 63788 Fmutex_fail int32 63789 Fpcache_init int32 63790 Fpcache_fail int32 63791 } /* test_init.c:36:8 */ 63792 63793 // end block for C++ 63794 63795 // Local Variables: 63796 // mode: c 63797 // c-basic-offset: 4 63798 // fill-column: 78 63799 // End: 63800 63801 var wrapped Wrapped /* test_init.c:47:3: */ 63802 63803 func wrMemInit(tls *libc.TLS, pAppData uintptr) int32 { /* test_init.c:49:12: */ 63804 var rc int32 63805 if wrapped.Fmem_fail != 0 { 63806 rc = SQLITE_ERROR 63807 } else { 63808 rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 104 /* &.mem */ + 40 /* &.xInit */))))(tls, wrapped.Fmem.FpAppData) 63809 } 63810 if rc == SQLITE_OK { 63811 wrapped.Fmem_init = 1 63812 } 63813 return rc 63814 } 63815 63816 func wrMemShutdown(tls *libc.TLS, pAppData uintptr) { /* test_init.c:61:13: */ 63817 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 104 /* &.mem */ + 48 /* &.xShutdown */))))(tls, wrapped.Fmem.FpAppData) 63818 wrapped.Fmem_init = 0 63819 } 63820 63821 func wrMemMalloc(tls *libc.TLS, n int32) uintptr { /* test_init.c:65:13: */ 63822 return (*(*func(*libc.TLS, int32) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 104 /* &.mem */ /* &.xMalloc */))))(tls, n) 63823 } 63824 63825 func wrMemFree(tls *libc.TLS, p uintptr) { /* test_init.c:66:13: */ 63826 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 104 /* &.mem */ + 8 /* &.xFree */))))(tls, p) 63827 } 63828 63829 func wrMemRealloc(tls *libc.TLS, p uintptr, n int32) uintptr { /* test_init.c:67:13: */ 63830 return (*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 104 /* &.mem */ + 16 /* &.xRealloc */))))(tls, p, n) 63831 } 63832 63833 func wrMemSize(tls *libc.TLS, p uintptr) int32 { /* test_init.c:68:12: */ 63834 return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 104 /* &.mem */ + 24 /* &.xSize */))))(tls, p) 63835 } 63836 63837 func wrMemRoundup(tls *libc.TLS, n int32) int32 { /* test_init.c:69:12: */ 63838 return (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 104 /* &.mem */ + 32 /* &.xRoundup */))))(tls, n) 63839 } 63840 63841 func wrMutexInit(tls *libc.TLS) int32 { /* test_init.c:72:12: */ 63842 var rc int32 63843 if wrapped.Fmutex_fail != 0 { 63844 rc = SQLITE_ERROR 63845 } else { 63846 rc = (*(*func(*libc.TLS) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 168 /* &.mutex */ /* &.xMutexInit */))))(tls) 63847 } 63848 if rc == SQLITE_OK { 63849 wrapped.Fmutex_init = 1 63850 } 63851 return rc 63852 } 63853 63854 func wrMutexEnd(tls *libc.TLS) int32 { /* test_init.c:84:12: */ 63855 (*(*func(*libc.TLS) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 168 /* &.mutex */ + 8 /* &.xMutexEnd */))))(tls) 63856 wrapped.Fmutex_init = 0 63857 return SQLITE_OK 63858 } 63859 63860 func wrMutexAlloc(tls *libc.TLS, e int32) uintptr { /* test_init.c:89:22: */ 63861 return (*(*func(*libc.TLS, int32) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 168 /* &.mutex */ + 16 /* &.xMutexAlloc */))))(tls, e) 63862 } 63863 63864 func wrMutexFree(tls *libc.TLS, p uintptr) { /* test_init.c:92:13: */ 63865 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 168 /* &.mutex */ + 24 /* &.xMutexFree */))))(tls, p) 63866 } 63867 63868 func wrMutexEnter(tls *libc.TLS, p uintptr) { /* test_init.c:95:13: */ 63869 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 168 /* &.mutex */ + 32 /* &.xMutexEnter */))))(tls, p) 63870 } 63871 63872 func wrMutexTry(tls *libc.TLS, p uintptr) int32 { /* test_init.c:98:12: */ 63873 return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 168 /* &.mutex */ + 40 /* &.xMutexTry */))))(tls, p) 63874 } 63875 63876 func wrMutexLeave(tls *libc.TLS, p uintptr) { /* test_init.c:101:13: */ 63877 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 168 /* &.mutex */ + 48 /* &.xMutexLeave */))))(tls, p) 63878 } 63879 63880 func wrMutexHeld(tls *libc.TLS, p uintptr) int32 { /* test_init.c:104:12: */ 63881 return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 168 /* &.mutex */ + 56 /* &.xMutexHeld */))))(tls, p) 63882 } 63883 63884 func wrMutexNotheld(tls *libc.TLS, p uintptr) int32 { /* test_init.c:107:12: */ 63885 return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) + 168 /* &.mutex */ + 64 /* &.xMutexNotheld */))))(tls, p) 63886 } 63887 63888 func wrPCacheInit(tls *libc.TLS, pArg uintptr) int32 { /* test_init.c:113:12: */ 63889 var rc int32 63890 if wrapped.Fpcache_fail != 0 { 63891 rc = SQLITE_ERROR 63892 } else { 63893 rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) /* &.pcache */ + 16 /* &.xInit */))))(tls, wrapped.Fpcache.FpArg) 63894 } 63895 if rc == SQLITE_OK { 63896 wrapped.Fpcache_init = 1 63897 } 63898 return rc 63899 } 63900 63901 func wrPCacheShutdown(tls *libc.TLS, pArg uintptr) { /* test_init.c:125:13: */ 63902 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) /* &.pcache */ + 24 /* &.xShutdown */))))(tls, wrapped.Fpcache.FpArg) 63903 wrapped.Fpcache_init = 0 63904 } 63905 63906 func wrPCacheCreate(tls *libc.TLS, a int32, b int32, c int32) uintptr { /* test_init.c:130:23: */ 63907 return (*(*func(*libc.TLS, int32, int32, int32) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) /* &.pcache */ + 32 /* &.xCreate */))))(tls, a, b, c) 63908 } 63909 63910 func wrPCacheCachesize(tls *libc.TLS, p uintptr, n int32) { /* test_init.c:133:13: */ 63911 (*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) /* &.pcache */ + 40 /* &.xCachesize */))))(tls, p, n) 63912 } 63913 63914 func wrPCachePagecount(tls *libc.TLS, p uintptr) int32 { /* test_init.c:136:12: */ 63915 return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) /* &.pcache */ + 48 /* &.xPagecount */))))(tls, p) 63916 } 63917 63918 func wrPCacheFetch(tls *libc.TLS, p uintptr, a uint32, b int32) uintptr { /* test_init.c:139:28: */ 63919 return (*(*func(*libc.TLS, uintptr, uint32, int32) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) /* &.pcache */ + 56 /* &.xFetch */))))(tls, p, a, b) 63920 } 63921 63922 func wrPCacheUnpin(tls *libc.TLS, p uintptr, a uintptr, b int32) { /* test_init.c:142:13: */ 63923 (*(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) /* &.pcache */ + 64 /* &.xUnpin */))))(tls, p, a, b) 63924 } 63925 63926 func wrPCacheRekey(tls *libc.TLS, p uintptr, a uintptr, b uint32, c uint32) { /* test_init.c:145:13: */ 63927 (*(*func(*libc.TLS, uintptr, uintptr, uint32, uint32))(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) /* &.pcache */ + 72 /* &.xRekey */))))(tls, p, a, b, c) 63928 } 63929 63930 func wrPCacheTruncate(tls *libc.TLS, p uintptr, a uint32) { /* test_init.c:153:13: */ 63931 (*(*func(*libc.TLS, uintptr, uint32))(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) /* &.pcache */ + 80 /* &.xTruncate */))))(tls, p, a) 63932 } 63933 63934 func wrPCacheDestroy(tls *libc.TLS, p uintptr) { /* test_init.c:156:13: */ 63935 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((uintptr(unsafe.Pointer(&wrapped)) /* &.pcache */ + 88 /* &.xDestroy */))))(tls, p) 63936 } 63937 63938 func installInitWrappers(tls *libc.TLS) { /* test_init.c:160:13: */ 63939 bp := tls.Alloc(288) 63940 defer tls.Free(288) 63941 63942 *(*sqlite3_mutex_methods)(unsafe.Pointer(bp + 48 /* mutexmethods */)) = sqlite3_mutex_methods{ 63943 FxMutexInit: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS) int32 }{wrMutexInit})), FxMutexEnd: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS) int32 }{wrMutexEnd})), FxMutexAlloc: *(*uintptr)(unsafe.Pointer(&struct { 63944 f func(*libc.TLS, int32) uintptr 63945 }{wrMutexAlloc})), 63946 FxMutexFree: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{wrMutexFree})), FxMutexEnter: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{wrMutexEnter})), FxMutexTry: *(*uintptr)(unsafe.Pointer(&struct { 63947 f func(*libc.TLS, uintptr) int32 63948 }{wrMutexTry})), 63949 FxMutexLeave: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{wrMutexLeave})), FxMutexHeld: *(*uintptr)(unsafe.Pointer(&struct { 63950 f func(*libc.TLS, uintptr) int32 63951 }{wrMutexHeld})), FxMutexNotheld: *(*uintptr)(unsafe.Pointer(&struct { 63952 f func(*libc.TLS, uintptr) int32 63953 }{wrMutexNotheld})), 63954 } 63955 *(*sqlite3_pcache_methods2)(unsafe.Pointer(bp + 184 /* pcachemethods */)) = sqlite3_pcache_methods2{ 63956 FiVersion: 1, 63957 FxInit: *(*uintptr)(unsafe.Pointer(&struct { 63958 f func(*libc.TLS, uintptr) int32 63959 }{wrPCacheInit})), FxShutdown: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{wrPCacheShutdown})), FxCreate: *(*uintptr)(unsafe.Pointer(&struct { 63960 f func(*libc.TLS, int32, int32, int32) uintptr 63961 }{wrPCacheCreate})), 63962 FxCachesize: *(*uintptr)(unsafe.Pointer(&struct { 63963 f func(*libc.TLS, uintptr, int32) 63964 }{wrPCacheCachesize})), FxPagecount: *(*uintptr)(unsafe.Pointer(&struct { 63965 f func(*libc.TLS, uintptr) int32 63966 }{wrPCachePagecount})), FxFetch: *(*uintptr)(unsafe.Pointer(&struct { 63967 f func(*libc.TLS, uintptr, uint32, int32) uintptr 63968 }{wrPCacheFetch})), 63969 FxUnpin: *(*uintptr)(unsafe.Pointer(&struct { 63970 f func(*libc.TLS, uintptr, uintptr, int32) 63971 }{wrPCacheUnpin})), FxRekey: *(*uintptr)(unsafe.Pointer(&struct { 63972 f func(*libc.TLS, uintptr, uintptr, uint32, uint32) 63973 }{wrPCacheRekey})), FxTruncate: *(*uintptr)(unsafe.Pointer(&struct { 63974 f func(*libc.TLS, uintptr, uint32) 63975 }{wrPCacheTruncate})), 63976 FxDestroy: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{wrPCacheDestroy})), 63977 } 63978 *(*sqlite3_mem_methods)(unsafe.Pointer(bp + 120 /* memmethods */)) = sqlite3_mem_methods{ 63979 FxMalloc: *(*uintptr)(unsafe.Pointer(&struct { 63980 f func(*libc.TLS, int32) uintptr 63981 }{wrMemMalloc})), FxFree: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{wrMemFree})), FxRealloc: *(*uintptr)(unsafe.Pointer(&struct { 63982 f func(*libc.TLS, uintptr, int32) uintptr 63983 }{wrMemRealloc})), 63984 FxSize: *(*uintptr)(unsafe.Pointer(&struct { 63985 f func(*libc.TLS, uintptr) int32 63986 }{wrMemSize})), FxRoundup: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, int32) int32 }{wrMemRoundup})), FxInit: *(*uintptr)(unsafe.Pointer(&struct { 63987 f func(*libc.TLS, uintptr) int32 63988 }{wrMemInit})), 63989 FxShutdown: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{wrMemShutdown})), 63990 } 63991 63992 libc.Xmemset(tls, uintptr(unsafe.Pointer(&wrapped)), 0, uint64(unsafe.Sizeof(wrapped))) 63993 63994 sqlite3.Xsqlite3_shutdown(tls) 63995 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_GETMUTEX, libc.VaList(bp, (uintptr(unsafe.Pointer(&wrapped))+168 /* &.mutex */))) 63996 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_GETMALLOC, libc.VaList(bp+8, (uintptr(unsafe.Pointer(&wrapped))+104 /* &.mem */))) 63997 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_GETPCACHE2, libc.VaList(bp+16, (uintptr(unsafe.Pointer(&wrapped)) /* &.pcache */))) 63998 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MUTEX, libc.VaList(bp+24, bp+48 /* &mutexmethods */)) 63999 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MALLOC, libc.VaList(bp+32, bp+120 /* &memmethods */)) 64000 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_PCACHE2, libc.VaList(bp+40, bp+184 /* &pcachemethods */)) 64001 } 64002 64003 func init_wrapper_install(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_init.c:191:26: */ 64004 bp := tls.Alloc(24) 64005 defer tls.Free(24) 64006 64007 var i int32 64008 installInitWrappers(tls) 64009 for i = 1; i < objc; i++ { 64010 var z uintptr = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8))) 64011 if libc.Xstrcmp(tls, z, ts+31880 /* "mem" */) == 0 { 64012 wrapped.Fmem_fail = 1 64013 } else if libc.Xstrcmp(tls, z, ts+28484 /* "mutex" */) == 0 { 64014 wrapped.Fmutex_fail = 1 64015 } else if libc.Xstrcmp(tls, z, ts+31884 /* "pcache" */) == 0 { 64016 wrapped.Fpcache_fail = 1 64017 } else { 64018 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+31891 /* "Unknown argument..." */, z, ts+11636 /* "\"" */)) 64019 return TCL_ERROR 64020 } 64021 } 64022 return TCL_OK 64023 } 64024 64025 func init_wrapper_uninstall(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_init.c:215:26: */ 64026 bp := tls.Alloc(24) 64027 defer tls.Free(24) 64028 64029 if objc != 1 { 64030 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 64031 return TCL_ERROR 64032 } 64033 64034 sqlite3.Xsqlite3_shutdown(tls) 64035 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MUTEX, libc.VaList(bp, (uintptr(unsafe.Pointer(&wrapped))+168 /* &.mutex */))) 64036 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MALLOC, libc.VaList(bp+8, (uintptr(unsafe.Pointer(&wrapped))+104 /* &.mem */))) 64037 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_PCACHE2, libc.VaList(bp+16, (uintptr(unsafe.Pointer(&wrapped)) /* &.pcache */))) 64038 return TCL_OK 64039 } 64040 64041 func init_wrapper_clear(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_init.c:233:26: */ 64042 if objc != 1 { 64043 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 64044 return TCL_ERROR 64045 } 64046 64047 wrapped.Fmem_fail = 0 64048 wrapped.Fmutex_fail = 0 64049 wrapped.Fpcache_fail = 0 64050 return TCL_OK 64051 } 64052 64053 func init_wrapper_query(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_init.c:250:26: */ 64054 var pRet uintptr 64055 64056 if objc != 1 { 64057 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 64058 return TCL_ERROR 64059 } 64060 64061 pRet = tcl.XTcl_NewObj(tls) 64062 if wrapped.Fmutex_init != 0 { 64063 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewStringObj(tls, ts+28484 /* "mutex" */, -1)) 64064 } 64065 if wrapped.Fmem_init != 0 { 64066 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewStringObj(tls, ts+31880 /* "mem" */, -1)) 64067 } 64068 if wrapped.Fpcache_init != 0 { 64069 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewStringObj(tls, ts+31884 /* "pcache" */, -1)) 64070 } 64071 64072 tcl.XTcl_SetObjResult(tls, interp, pRet) 64073 return TCL_OK 64074 } 64075 64076 func Sqlitetest_init_Init(tls *libc.TLS, interp uintptr) int32 { /* test_init.c:278:5: */ 64077 var i int32 64078 64079 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aObjCmd9)) / uint64(unsafe.Sizeof(struct { 64080 FzName uintptr 64081 FxProc uintptr 64082 }{}))); i++ { 64083 tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd9[i].FzName, aObjCmd9[i].FxProc, uintptr(0), uintptr(0)) 64084 } 64085 64086 return TCL_OK 64087 } 64088 64089 var aObjCmd9 = [4]struct { 64090 FzName uintptr 64091 FxProc uintptr 64092 }{ 64093 {FzName: ts + 31911 /* "init_wrapper_ins..." */, FxProc: 0}, 64094 {FzName: ts + 31932 /* "init_wrapper_que..." */, FxProc: 0}, 64095 {FzName: ts + 31951 /* "init_wrapper_uni..." */, FxProc: 0}, 64096 {FzName: ts + 31974 /* "init_wrapper_cle..." */, FxProc: 0}, 64097 } /* test_init.c:282:5 */ 64098 64099 // 64100 // END OF REGISTRATION API 64101 // 64102 64103 //******* End of fts5.h ******** 64104 64105 // Make sure we can call this stuff from C++. 64106 64107 // An sqlite3_intarray is an abstract type to stores an instance of 64108 // an integer array. 64109 type sqlite3_intarray1 = struct { 64110 Fn int32 64111 _ [4]byte 64112 Fa uintptr 64113 FxFree uintptr 64114 } /* test_intarray.h:99:9 */ 64115 64116 // 64117 // END OF REGISTRATION API 64118 // 64119 64120 //******* End of fts5.h ******** 64121 64122 // Make sure we can call this stuff from C++. 64123 64124 // An sqlite3_intarray is an abstract type to stores an instance of 64125 // an integer array. 64126 type sqlite3_intarray = sqlite3_intarray1 /* test_intarray.h:99:33 */ 64127 64128 // Objects used internally by the virtual table implementation 64129 type intarray_vtab1 = struct { 64130 Fbase sqlite3_vtab 64131 FpContent uintptr 64132 } /* test_intarray.c:41:9 */ 64133 64134 // Objects used internally by the virtual table implementation 64135 type intarray_vtab = intarray_vtab1 /* test_intarray.c:41:30 */ 64136 type intarray_cursor1 = struct { 64137 Fbase sqlite3_vtab_cursor 64138 Fi int32 64139 _ [4]byte 64140 } /* test_intarray.c:42:9 */ 64141 64142 type intarray_cursor = intarray_cursor1 /* test_intarray.c:42:32 */ 64143 64144 // None of this works unless we have virtual tables. 64145 64146 // Free an sqlite3_intarray object. 64147 func intarrayFree(tls *libc.TLS, p uintptr) { /* test_intarray.c:64:13: */ 64148 if (*sqlite3_intarray)(unsafe.Pointer(p)).FxFree != 0 { 64149 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((p + 16 /* &.xFree */))))(tls, (*sqlite3_intarray)(unsafe.Pointer(p)).Fa) 64150 } 64151 sqlite3.Xsqlite3_free(tls, p) 64152 } 64153 64154 // Table destructor for the intarray module. 64155 func intarrayDestroy(tls *libc.TLS, p uintptr) int32 { /* test_intarray.c:74:12: */ 64156 var pVtab uintptr = p 64157 sqlite3.Xsqlite3_free(tls, pVtab) 64158 return 0 64159 } 64160 64161 // Table constructor for the intarray module. 64162 func intarrayCreate(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* test_intarray.c:83:12: */ 64163 var rc int32 = SQLITE_NOMEM 64164 var pVtab uintptr = sqlite3.Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(intarray_vtab{}))) 64165 64166 if pVtab != 0 { 64167 libc.Xmemset(tls, pVtab, 0, uint64(unsafe.Sizeof(intarray_vtab{}))) 64168 (*intarray_vtab)(unsafe.Pointer(pVtab)).FpContent = pAux 64169 rc = sqlite3.Xsqlite3_declare_vtab(tls, db, ts+31993 /* "CREATE TABLE x(v..." */) 64170 } 64171 *(*uintptr)(unsafe.Pointer(ppVtab)) = pVtab 64172 return rc 64173 } 64174 64175 // Open a new cursor on the intarray table. 64176 func intarrayOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* test_intarray.c:106:12: */ 64177 var rc int32 = SQLITE_NOMEM 64178 var pCur uintptr 64179 pCur = sqlite3.Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(intarray_cursor{}))) 64180 if pCur != 0 { 64181 libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(intarray_cursor{}))) 64182 *(*uintptr)(unsafe.Pointer(ppCursor)) = pCur 64183 rc = SQLITE_OK 64184 } 64185 return rc 64186 } 64187 64188 // Close a intarray table cursor. 64189 func intarrayClose(tls *libc.TLS, cur uintptr) int32 { /* test_intarray.c:121:12: */ 64190 var pCur uintptr = cur 64191 sqlite3.Xsqlite3_free(tls, pCur) 64192 return SQLITE_OK 64193 } 64194 64195 // Retrieve a column of data. 64196 func intarrayColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* test_intarray.c:130:12: */ 64197 var pCur uintptr = cur 64198 var pVtab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab 64199 if ((*intarray_cursor)(unsafe.Pointer(pCur)).Fi >= 0) && ((*intarray_cursor)(unsafe.Pointer(pCur)).Fi < (*sqlite3_intarray)(unsafe.Pointer((*intarray_vtab)(unsafe.Pointer(pVtab)).FpContent)).Fn) { 64200 sqlite3.Xsqlite3_result_int64(tls, ctx, *(*sqlite3_int64)(unsafe.Pointer((*sqlite3_intarray)(unsafe.Pointer((*intarray_vtab)(unsafe.Pointer(pVtab)).FpContent)).Fa + uintptr((*intarray_cursor)(unsafe.Pointer(pCur)).Fi)*8))) 64201 } 64202 return SQLITE_OK 64203 } 64204 64205 // Retrieve the current rowid. 64206 func intarrayRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* test_intarray.c:142:12: */ 64207 var pCur uintptr = cur 64208 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite_int64((*intarray_cursor)(unsafe.Pointer(pCur)).Fi) 64209 return SQLITE_OK 64210 } 64211 64212 func intarrayEof(tls *libc.TLS, cur uintptr) int32 { /* test_intarray.c:148:12: */ 64213 var pCur uintptr = cur 64214 var pVtab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab 64215 return (libc.Bool32((*intarray_cursor)(unsafe.Pointer(pCur)).Fi >= (*sqlite3_intarray)(unsafe.Pointer((*intarray_vtab)(unsafe.Pointer(pVtab)).FpContent)).Fn)) 64216 } 64217 64218 // Advance the cursor to the next row. 64219 func intarrayNext(tls *libc.TLS, cur uintptr) int32 { /* test_intarray.c:157:12: */ 64220 var pCur uintptr = cur 64221 (*intarray_cursor)(unsafe.Pointer(pCur)).Fi++ 64222 return SQLITE_OK 64223 } 64224 64225 // Reset a intarray table cursor. 64226 func intarrayFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* test_intarray.c:166:12: */ 64227 var pCur uintptr = pVtabCursor 64228 (*intarray_cursor)(unsafe.Pointer(pCur)).Fi = 0 64229 return SQLITE_OK 64230 } 64231 64232 // Analyse the WHERE condition. 64233 func intarrayBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_intarray.c:179:12: */ 64234 return SQLITE_OK 64235 } 64236 64237 // A virtual table module that merely echos method calls into TCL 64238 // variables. 64239 var intarrayModule = sqlite3_module{ // iVersion 64240 FxCreate: 0, // xCreate - create a new virtual table 64241 FxConnect: 0, // xConnect - connect to an existing vtab 64242 FxBestIndex: 0, // xBestIndex - find the best query index 64243 FxDisconnect: 0, // xDisconnect - disconnect a vtab 64244 FxDestroy: 0, // xDestroy - destroy a vtab 64245 FxOpen: 0, // xOpen - open a cursor 64246 FxClose: 0, // xClose - close a cursor 64247 FxFilter: 0, // xFilter - configure scan constraints 64248 FxNext: 0, // xNext - advance a cursor 64249 FxEof: 0, // xEof 64250 FxColumn: 0, // xColumn - read data 64251 FxRowid: 0, // xRename 64252 } /* test_intarray.c:187:23 */ 64253 64254 // Invoke this routine to create a specific instance of an intarray object. 64255 // The new intarray object is returned by the 3rd parameter. 64256 // 64257 // Each intarray object corresponds to a virtual table in the TEMP table 64258 // with a name of zName. 64259 // 64260 // Destroy the intarray object by dropping the virtual table. If not done 64261 // explicitly by the application, the virtual table will be dropped implicitly 64262 // by the system when the database connection is closed. 64263 func sqlite3_intarray_create(tls *libc.TLS, db uintptr, zName uintptr, ppReturn uintptr) int32 { /* test_intarray.c:223:16: */ 64264 bp := tls.Alloc(16) 64265 defer tls.Free(16) 64266 64267 var rc int32 = SQLITE_OK 64268 var p uintptr 64269 64270 *(*uintptr)(unsafe.Pointer(ppReturn)) = libc.AssignUintptr(&p, sqlite3.Xsqlite3_malloc64(tls, uint64(unsafe.Sizeof(sqlite3_intarray{})))) 64271 if p == uintptr(0) { 64272 return SQLITE_NOMEM 64273 } 64274 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(sqlite3_intarray{}))) 64275 rc = sqlite3.Xsqlite3_create_module_v2(tls, db, zName, uintptr(unsafe.Pointer(&intarrayModule)), p, 64276 *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{intarrayFree}))) 64277 if rc == SQLITE_OK { 64278 var zSql uintptr 64279 zSql = sqlite3.Xsqlite3_mprintf(tls, ts+32035, /* "CREATE VIRTUAL T..." */ 64280 libc.VaList(bp, zName, zName)) 64281 rc = sqlite3.Xsqlite3_exec(tls, db, zSql, uintptr(0), uintptr(0), uintptr(0)) 64282 sqlite3.Xsqlite3_free(tls, zSql) 64283 } 64284 return rc 64285 } 64286 64287 // Bind a new array array of integers to a specific intarray object. 64288 // 64289 // The array of integers bound must be unchanged for the duration of 64290 // any query against the corresponding virtual table. If the integer 64291 // array does change or is deallocated undefined behavior will result. 64292 func sqlite3_intarray_bind(tls *libc.TLS, pIntArray uintptr, nElements int32, aElements uintptr, xFree uintptr) int32 { /* test_intarray.c:257:16: */ 64293 if (*sqlite3_intarray)(unsafe.Pointer(pIntArray)).FxFree != 0 { 64294 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((pIntArray + 16 /* &.xFree */))))(tls, (*sqlite3_intarray)(unsafe.Pointer(pIntArray)).Fa) 64295 } 64296 (*sqlite3_intarray)(unsafe.Pointer(pIntArray)).Fn = nElements 64297 (*sqlite3_intarray)(unsafe.Pointer(pIntArray)).Fa = aElements 64298 (*sqlite3_intarray)(unsafe.Pointer(pIntArray)).FxFree = xFree 64299 return SQLITE_OK 64300 } 64301 64302 // sqlite3_intarray_create DB NAME 64303 // 64304 // Invoke the sqlite3_intarray_create interface. A string that becomes 64305 // the first parameter to sqlite3_intarray_bind. 64306 func test_intarray_create(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_intarray.c:300:26: */ 64307 bp := tls.Alloc(148) 64308 defer tls.Free(148) 64309 64310 // var db uintptr at bp+32, 8 64311 64312 var zName uintptr 64313 // var pArray uintptr at bp+40, 8 64314 64315 var rc int32 = SQLITE_OK 64316 // var zPtr [100]int8 at bp+48, 100 64317 64318 if objc != 3 { 64319 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 64320 return TCL_ERROR 64321 } 64322 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0 { 64323 return TCL_ERROR 64324 } 64325 zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 64326 rc = sqlite3_intarray_create(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), zName, bp+40 /* &pArray */) 64327 if rc != SQLITE_OK { 64328 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0))) 64329 return TCL_ERROR 64330 } 64331 sqlite3TestMakePointerStr(tls, interp, bp+48 /* &zPtr[0] */, *(*uintptr)(unsafe.Pointer(bp + 40 /* pArray */))) 64332 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, bp+48 /* &zPtr[0] */, uintptr(0))) 64333 return TCL_OK 64334 } 64335 64336 // sqlite3_intarray_bind INTARRAY ?VALUE ...? 64337 // 64338 // Invoke the sqlite3_intarray_bind interface on the given array of integers. 64339 func test_intarray_bind(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_intarray.c:335:26: */ 64340 bp := tls.Alloc(40) 64341 defer tls.Free(40) 64342 64343 var pArray uintptr 64344 var rc int32 = SQLITE_OK 64345 var i int32 64346 var n int32 64347 var a uintptr 64348 64349 if objc < 2 { 64350 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32073 /* "INTARRAY" */) 64351 return TCL_ERROR 64352 } 64353 pArray = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 64354 n = (objc - 2) 64355 a = sqlite3.Xsqlite3_malloc64(tls, (uint64(uint64(unsafe.Sizeof(sqlite3_int64(0))) * uint64(n)))) 64356 if a == uintptr(0) { 64357 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+32082 /* "SQLITE_NOMEM" */, uintptr(0))) 64358 return TCL_ERROR 64359 } 64360 for i = 0; i < n; i++ { 64361 *(*Tcl_WideInt)(unsafe.Pointer(bp + 32 /* x */)) = int64(0) 64362 tcl.XTcl_GetWideIntFromObj(tls, uintptr(0), *(*uintptr)(unsafe.Pointer(objv + uintptr((i+2))*8)), bp+32 /* &x */) 64363 *(*sqlite3_int64)(unsafe.Pointer(a + uintptr(i)*8)) = *(*Tcl_WideInt)(unsafe.Pointer(bp + 32 /* x */)) 64364 } 64365 rc = sqlite3_intarray_bind(tls, pArray, n, a, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) 64366 if rc != SQLITE_OK { 64367 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0))) 64368 return TCL_ERROR 64369 } 64370 return TCL_OK 64371 } 64372 64373 // Register commands with the TCL interpreter. 64374 func Sqlitetestintarray_Init(tls *libc.TLS, interp uintptr) int32 { /* test_intarray.c:375:5: */ 64375 var i int32 64376 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aObjCmd10)) / uint64(unsafe.Sizeof(struct { 64377 FzName uintptr 64378 FxProc uintptr 64379 FclientData uintptr 64380 }{}))); i++ { 64381 tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd10[i].FzName, 64382 aObjCmd10[i].FxProc, aObjCmd10[i].FclientData, uintptr(0)) 64383 } 64384 return TCL_OK 64385 } 64386 64387 var aObjCmd10 = [2]struct { 64388 FzName uintptr 64389 FxProc uintptr 64390 FclientData uintptr 64391 }{ 64392 {FzName: ts + 32095 /* "sqlite3_intarray..." */, FxProc: 0}, 64393 {FzName: ts + 32119 /* "sqlite3_intarray..." */, FxProc: 0}, 64394 } /* test_intarray.c:380:5 */ 64395 64396 // Maximum pathname length supported by the jt backend. 64397 64398 // Name used to identify this VFS. 64399 64400 type jt_file1 = struct { 64401 Fbase sqlite3_file 64402 FzName uintptr 64403 Fflags int32 64404 FeLock int32 64405 FnPage u322 64406 FnPagesize u322 64407 FpWritable uintptr 64408 FaCksum uintptr 64409 FnSync int32 64410 _ [4]byte 64411 FiMaxOff sqlite3_int64 64412 FpNext uintptr 64413 FpReal uintptr 64414 } /* test_journal.c:111:9 */ 64415 64416 // Maximum pathname length supported by the jt backend. 64417 64418 // Name used to identify this VFS. 64419 64420 type jt_file = jt_file1 /* test_journal.c:111:24 */ 64421 64422 var jt_vfs = sqlite3_vfs{ 64423 FiVersion: 2, // iVersion 64424 FszOsFile: int32(unsafe.Sizeof(jt_file{})), // szOsFile 64425 FmxPathname: JT_MAX_PATHNAME, // pNext 64426 FzName: ts + 32141, /* "jt" */ // pAppData 64427 FxOpen: 0, // xOpen 64428 FxDelete: 0, // xDelete 64429 FxAccess: 0, // xAccess 64430 FxFullPathname: 0, // xFullPathname 64431 FxDlOpen: 0, // xDlOpen 64432 FxDlError: 0, // xDlError 64433 FxDlSym: 0, // xDlSym 64434 FxDlClose: 0, // xDlClose 64435 FxRandomness: 0, // xRandomness 64436 FxSleep: 0, // xSleep 64437 FxCurrentTime: 0, // xCurrentTime 64438 FxGetLastError: 0, // xGetLastError 64439 FxCurrentTimeInt64: 0, // xCurrentTimeInt64 64440 } /* test_journal.c:165:20 */ 64441 64442 var jt_io_methods = sqlite3_io_methods{ 64443 FiVersion: 1, // iVersion 64444 FxClose: 0, // xClose 64445 FxRead: 0, // xRead 64446 FxWrite: 0, // xWrite 64447 FxTruncate: 0, // xTruncate 64448 FxSync: 0, // xSync 64449 FxFileSize: 0, // xFileSize 64450 FxLock: 0, // xLock 64451 FxUnlock: 0, // xUnlock 64452 FxCheckReservedLock: 0, // xCheckReservedLock 64453 FxFileControl: 0, // xFileControl 64454 FxSectorSize: 0, // xSectorSize 64455 FxDeviceCharacteristics: 0, // xDeviceCharacteristics 64456 } /* test_journal.c:187:27 */ 64457 64458 type JtGlobal = struct { 64459 FpVfs uintptr 64460 FpList uintptr 64461 } /* test_journal.c:203:1 */ 64462 64463 var g2 = JtGlobal{} /* test_journal.c:207:24 */ 64464 64465 // Functions to obtain and relinquish a mutex to protect g.pList. The 64466 // STATIC_PRNG mutex is reused, purely for the sake of convenience. 64467 func enterJtMutex(tls *libc.TLS) { /* test_journal.c:213:13: */ 64468 sqlite3.Xsqlite3_mutex_enter(tls, sqlite3.Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_STATIC_PRNG)) 64469 } 64470 64471 func leaveJtMutex(tls *libc.TLS) { /* test_journal.c:216:13: */ 64472 sqlite3.Xsqlite3_mutex_leave(tls, sqlite3.Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_STATIC_PRNG)) 64473 } 64474 64475 func stop_ioerr_simulation(tls *libc.TLS, piSave uintptr, piSave2 uintptr) { /* test_journal.c:222:13: */ 64476 *(*int32)(unsafe.Pointer(piSave)) = libc.AtomicLoadInt32(&sqlite3.Xsqlite3_io_error_pending) 64477 *(*int32)(unsafe.Pointer(piSave2)) = sqlite3.Xsqlite3_io_error_hit 64478 libc.AtomicStoreInt32(&sqlite3.Xsqlite3_io_error_pending, int32(-1)) 64479 sqlite3.Xsqlite3_io_error_hit = 0 64480 } 64481 64482 func start_ioerr_simulation(tls *libc.TLS, iSave int32, iSave2 int32) { /* test_journal.c:228:13: */ 64483 libc.AtomicStoreInt32(&sqlite3.Xsqlite3_io_error_pending, int32(iSave)) 64484 sqlite3.Xsqlite3_io_error_hit = iSave2 64485 } 64486 64487 // The jt_file pointed to by the argument may or may not be a file-handle 64488 // open on a main database file. If it is, and a transaction is currently 64489 // opened on the file, then discard all transaction related data. 64490 func closeTransaction(tls *libc.TLS, p uintptr) { /* test_journal.c:238:13: */ 64491 sqlite3.Xsqlite3BitvecDestroy(tls, (*jt_file)(unsafe.Pointer(p)).FpWritable) 64492 sqlite3.Xsqlite3_free(tls, (*jt_file)(unsafe.Pointer(p)).FaCksum) 64493 (*jt_file)(unsafe.Pointer(p)).FpWritable = uintptr(0) 64494 (*jt_file)(unsafe.Pointer(p)).FaCksum = uintptr(0) 64495 (*jt_file)(unsafe.Pointer(p)).FnSync = 0 64496 } 64497 64498 // Close an jt-file. 64499 func jtClose(tls *libc.TLS, pFile uintptr) int32 { /* test_journal.c:249:12: */ 64500 var pp uintptr 64501 var p uintptr = pFile 64502 64503 closeTransaction(tls, p) 64504 enterJtMutex(tls) 64505 if (*jt_file)(unsafe.Pointer(p)).FzName != 0 { 64506 for pp = (uintptr(unsafe.Pointer(&g2)) + 8 /* &.pList */); *(*uintptr)(unsafe.Pointer(pp)) != p; pp = (*(*uintptr)(unsafe.Pointer(pp)) + 64 /* &.pNext */) { 64507 } 64508 *(*uintptr)(unsafe.Pointer(pp)) = (*jt_file)(unsafe.Pointer(p)).FpNext 64509 } 64510 leaveJtMutex(tls) 64511 sqlite3.Xsqlite3OsClose(tls, (*jt_file)(unsafe.Pointer(p)).FpReal) 64512 return SQLITE_OK 64513 } 64514 64515 // Read data from an jt-file. 64516 func jtRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test_journal.c:267:12: */ 64517 var p uintptr = pFile 64518 return sqlite3.Xsqlite3OsRead(tls, (*jt_file)(unsafe.Pointer(p)).FpReal, zBuf, iAmt, iOfst) 64519 } 64520 64521 // 64522 // Parameter zJournal is the name of a journal file that is currently 64523 // open. This function locates and returns the handle opened on the 64524 // corresponding database file by the pager that currently has the 64525 // journal file opened. This file-handle is identified by the 64526 // following properties: 64527 // 64528 // a) SQLITE_OPEN_MAIN_DB was specified when the file was opened. 64529 // 64530 // b) The file-name specified when the file was opened matches 64531 // all but the final 8 characters of the journal file name. 64532 // 64533 // c) There is currently a reserved lock on the file. This 64534 // condition is waived if the noLock argument is non-zero. 64535 // 64536 func locateDatabaseHandle(tls *libc.TLS, zJournal uintptr, noLock int32) uintptr { /* test_journal.c:292:16: */ 64537 var pMain uintptr = uintptr(0) 64538 enterJtMutex(tls) 64539 for pMain = g2.FpList; pMain != 0; pMain = (*jt_file)(unsafe.Pointer(pMain)).FpNext { 64540 var nName int32 = (int32(libc.Xstrlen(tls, zJournal) - libc.Xstrlen(tls, ts+32144 /* "-journal" */))) 64541 if (((((*jt_file)(unsafe.Pointer(pMain)).Fflags & SQLITE_OPEN_MAIN_DB) != 0) && 64542 (int32(libc.Xstrlen(tls, (*jt_file)(unsafe.Pointer(pMain)).FzName)) == nName)) && 64543 (0 == libc.Xmemcmp(tls, (*jt_file)(unsafe.Pointer(pMain)).FzName, zJournal, uint64(nName)))) && 64544 (((*jt_file)(unsafe.Pointer(pMain)).FeLock >= SQLITE_LOCK_RESERVED) || (noLock != 0)) { 64545 break 64546 } 64547 } 64548 leaveJtMutex(tls) 64549 return pMain 64550 } 64551 64552 // Parameter z points to a buffer of 4 bytes in size containing a 64553 // unsigned 32-bit integer stored in big-endian format. Decode the 64554 // integer and return its value. 64555 func decodeUint32(tls *libc.TLS, z uintptr) u322 { /* test_journal.c:314:12: */ 64556 return (u322((((int32(*(*uint8)(unsafe.Pointer(z))) << 24) + (int32(*(*uint8)(unsafe.Pointer(z + 1))) << 16)) + (int32(*(*uint8)(unsafe.Pointer(z + 2))) << 8)) + int32(*(*uint8)(unsafe.Pointer(z + 3))))) 64557 } 64558 64559 // Calculate a checksum from the buffer of length n bytes pointed to 64560 // by parameter z. 64561 func genCksum(tls *libc.TLS, z uintptr, n int32) u322 { /* test_journal.c:322:12: */ 64562 var i int32 64563 var cksum u322 = u322(0) 64564 for i = 0; i < n; i++ { 64565 cksum = ((cksum + u322(*(*uint8)(unsafe.Pointer(z + uintptr(i))))) + (cksum << 3)) 64566 } 64567 return cksum 64568 } 64569 64570 // The first argument, zBuf, points to a buffer containing a 28 byte 64571 // serialized journal header. This function deserializes four of the 64572 // integer fields contained in the journal header and writes their 64573 // values to the output variables. 64574 // 64575 // SQLITE_OK is returned if the journal-header is successfully 64576 // decoded. Otherwise, SQLITE_ERROR. 64577 func decodeJournalHdr(tls *libc.TLS, zBuf uintptr, pnRec uintptr, pnPage uintptr, pnSector uintptr, pnPagesize uintptr) int32 { /* test_journal.c:340:12: */ 64578 bp := tls.Alloc(8) 64579 defer tls.Free(8) 64580 64581 *(*[8]uint8)(unsafe.Pointer(bp /* aMagic */)) = [8]uint8{uint8(0xd9), uint8(0xd5), uint8(0x05), uint8(0xf9), uint8(0x20), uint8(0xa1), uint8(0x63), uint8(0xd7)} 64582 if libc.Xmemcmp(tls, bp /* &aMagic[0] */, zBuf, uint64(8)) != 0 { 64583 return SQLITE_ERROR 64584 } 64585 if pnRec != 0 { 64586 *(*u322)(unsafe.Pointer(pnRec)) = decodeUint32(tls, (zBuf + 8)) 64587 } 64588 if pnPage != 0 { 64589 *(*u322)(unsafe.Pointer(pnPage)) = decodeUint32(tls, (zBuf + 16)) 64590 } 64591 if pnSector != 0 { 64592 *(*u322)(unsafe.Pointer(pnSector)) = decodeUint32(tls, (zBuf + 20)) 64593 } 64594 if pnPagesize != 0 { 64595 *(*u322)(unsafe.Pointer(pnPagesize)) = decodeUint32(tls, (zBuf + 24)) 64596 } 64597 return SQLITE_OK 64598 } 64599 64600 // This function is called when a new transaction is opened, just after 64601 // the first journal-header is written to the journal file. 64602 func openTransaction(tls *libc.TLS, pMain uintptr, pJournal uintptr) int32 { /* test_journal.c:360:12: */ 64603 bp := tls.Alloc(8) 64604 defer tls.Free(8) 64605 64606 var aData uintptr 64607 var p uintptr = (*jt_file)(unsafe.Pointer(pMain)).FpReal 64608 var rc int32 = SQLITE_OK 64609 64610 closeTransaction(tls, pMain) 64611 aData = sqlite3.Xsqlite3_malloc(tls, int32((*jt_file)(unsafe.Pointer(pMain)).FnPagesize)) 64612 (*jt_file)(unsafe.Pointer(pMain)).FpWritable = sqlite3.Xsqlite3BitvecCreate(tls, (*jt_file)(unsafe.Pointer(pMain)).FnPage) 64613 (*jt_file)(unsafe.Pointer(pMain)).FaCksum = sqlite3.Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(u322(0))) * (uint64((*jt_file)(unsafe.Pointer(pMain)).FnPage + u322(1)))))) 64614 (*jt_file)(unsafe.Pointer(pJournal)).FiMaxOff = int64(0) 64615 64616 if (!(int32((*jt_file)(unsafe.Pointer(pMain)).FpWritable) != 0) || !(int32((*jt_file)(unsafe.Pointer(pMain)).FaCksum) != 0)) || !(aData != 0) { 64617 rc = (SQLITE_IOERR | (int32(12) << 8)) 64618 } else if (*jt_file)(unsafe.Pointer(pMain)).FnPage > u322(0) { 64619 var iTrunk u322 64620 // var iSave int32 at bp, 4 64621 64622 // var iSave2 int32 at bp+4, 4 64623 64624 stop_ioerr_simulation(tls, bp /* &iSave */, bp+4 /* &iSave2 */) 64625 64626 // Read the database free-list. Add the page-number for each free-list 64627 // leaf to the jt_file.pWritable bitvec. 64628 rc = sqlite3.Xsqlite3OsRead(tls, p, aData, int32((*jt_file)(unsafe.Pointer(pMain)).FnPagesize), int64(0)) 64629 if rc == SQLITE_OK { 64630 var nDbsize u322 = decodeUint32(tls, (aData + 28)) 64631 if (nDbsize > u322(0)) && (libc.Xmemcmp(tls, (aData+24), (aData+92), uint64(4)) == 0) { 64632 var iPg u322 64633 for iPg = (nDbsize + u322(1)); iPg <= (*jt_file)(unsafe.Pointer(pMain)).FnPage; iPg++ { 64634 sqlite3.Xsqlite3BitvecSet(tls, (*jt_file)(unsafe.Pointer(pMain)).FpWritable, iPg) 64635 } 64636 } 64637 } 64638 iTrunk = decodeUint32(tls, (aData + 32)) 64639 for (rc == SQLITE_OK) && (iTrunk > u322(0)) { 64640 var nLeaf u322 64641 var iLeaf u322 64642 var iOff sqlite3_int64 = ((i64(iTrunk - u322(1))) * i64((*jt_file)(unsafe.Pointer(pMain)).FnPagesize)) 64643 rc = sqlite3.Xsqlite3OsRead(tls, p, aData, int32((*jt_file)(unsafe.Pointer(pMain)).FnPagesize), iOff) 64644 nLeaf = decodeUint32(tls, (aData + 4)) 64645 for iLeaf = u322(0); (rc == SQLITE_OK) && (iLeaf < nLeaf); iLeaf++ { 64646 var pgno u322 = decodeUint32(tls, (aData + uintptr((u322(8) + (u322(4) * iLeaf))))) 64647 sqlite3.Xsqlite3BitvecSet(tls, (*jt_file)(unsafe.Pointer(pMain)).FpWritable, pgno) 64648 } 64649 iTrunk = decodeUint32(tls, aData) 64650 } 64651 64652 // Calculate and store a checksum for each page in the database file. 64653 if rc == SQLITE_OK { 64654 var ii int32 64655 for ii = 0; (rc == SQLITE_OK) && (ii < int32((*jt_file)(unsafe.Pointer(pMain)).FnPage)); ii++ { 64656 var iOff i64 = ((i64((*jt_file)(unsafe.Pointer(pMain)).FnPagesize)) * i64(ii)) 64657 if iOff == i64(sqlite3.Xsqlite3PendingByte) { 64658 continue 64659 } 64660 rc = sqlite3.Xsqlite3OsRead(tls, (*jt_file)(unsafe.Pointer(pMain)).FpReal, aData, int32((*jt_file)(unsafe.Pointer(pMain)).FnPagesize), iOff) 64661 *(*u322)(unsafe.Pointer((*jt_file)(unsafe.Pointer(pMain)).FaCksum + uintptr(ii)*4)) = genCksum(tls, aData, int32((*jt_file)(unsafe.Pointer(pMain)).FnPagesize)) 64662 if ((ii + 1) == int32((*jt_file)(unsafe.Pointer(pMain)).FnPage)) && (rc == (SQLITE_IOERR | (int32(2) << 8))) { 64663 rc = SQLITE_OK 64664 } 64665 } 64666 } 64667 64668 start_ioerr_simulation(tls, *(*int32)(unsafe.Pointer(bp /* iSave */)), *(*int32)(unsafe.Pointer(bp + 4 /* iSave2 */))) 64669 } 64670 64671 sqlite3.Xsqlite3_free(tls, aData) 64672 return rc 64673 } 64674 64675 // The first argument to this function is a handle open on a journal file. 64676 // This function reads the journal file and adds the page number for each 64677 // page in the journal to the Bitvec object passed as the second argument. 64678 func readJournalFile(tls *libc.TLS, p uintptr, pMain uintptr) int32 { /* test_journal.c:433:12: */ 64679 bp := tls.Alloc(52) 64680 defer tls.Free(52) 64681 64682 var rc int32 64683 // var zBuf [28]uint8 at bp+8, 28 64684 64685 var pReal uintptr 64686 var iOff sqlite3_int64 64687 var iSize sqlite3_int64 64688 var aPage uintptr 64689 // var iSave int32 at bp, 4 64690 64691 // var iSave2 int32 at bp+4, 4 64692 64693 var cksum u322 64694 _ = cksum 64695 var pgno u322 64696 // var nRec u322 at bp+36, 4 64697 64698 // var nPage u322 at bp+40, 4 64699 64700 // var nSector u322 at bp+44, 4 64701 64702 // var nPagesize u322 at bp+48, 4 64703 64704 var ii u322 64705 rc = SQLITE_OK 64706 pReal = (*jt_file)(unsafe.Pointer(p)).FpReal 64707 iOff = int64(0) 64708 iSize = (*jt_file)(unsafe.Pointer(p)).FiMaxOff 64709 64710 aPage = sqlite3.Xsqlite3_malloc(tls, int32((*jt_file)(unsafe.Pointer(pMain)).FnPagesize)) 64711 if !(!(aPage != 0)) { 64712 goto __1 64713 } 64714 return (SQLITE_IOERR | (int32(12) << 8)) 64715 __1: 64716 ; 64717 64718 stop_ioerr_simulation(tls, bp /* &iSave */, bp+4 /* &iSave2 */) 64719 64720 __2: 64721 if !((rc == SQLITE_OK) && (iOff < iSize)) { 64722 goto __3 64723 } 64724 64725 // Read and decode the next journal-header from the journal file. 64726 rc = sqlite3.Xsqlite3OsRead(tls, pReal, bp+8 /* &zBuf[0] */, 28, iOff) 64727 if !((rc != SQLITE_OK) || 64728 (decodeJournalHdr(tls, bp+8 /* &zBuf[0] */, bp+36 /* &nRec */, bp+40 /* &nPage */, bp+44 /* &nSector */, bp+48 /* &nPagesize */) != 0)) { 64729 goto __4 64730 } 64731 goto finish_rjf 64732 __4: 64733 ; 64734 iOff = iOff + (sqlite3_int64(*(*u322)(unsafe.Pointer(bp + 44 /* nSector */)))) 64735 64736 if !(*(*u322)(unsafe.Pointer(bp + 36 /* nRec */)) == u322(0)) { 64737 goto __5 64738 } 64739 // A trick. There might be another journal-header immediately 64740 // following this one. In this case, 0 records means 0 records, 64741 // not "read until the end of the file". See also ticket #2565. 64742 if !(iSize >= (iOff + sqlite3_int64(*(*u322)(unsafe.Pointer(bp + 44 /* nSector */))))) { 64743 goto __6 64744 } 64745 rc = sqlite3.Xsqlite3OsRead(tls, pReal, bp+8 /* &zBuf[0] */, 28, iOff) 64746 if !((rc != SQLITE_OK) || (0 == decodeJournalHdr(tls, bp+8 /* &zBuf[0] */, uintptr(0), uintptr(0), uintptr(0), uintptr(0)))) { 64747 goto __7 64748 } 64749 goto __2 64750 __7: 64751 ; 64752 __6: 64753 ; 64754 *(*u322)(unsafe.Pointer(bp + 36 /* nRec */)) = (u322((iSize - iOff) / (sqlite3_int64((*jt_file)(unsafe.Pointer(pMain)).FnPagesize + u322(8))))) 64755 __5: 64756 ; 64757 64758 // Read all the records that follow the journal-header just read. 64759 ii = u322(0) 64760 __8: 64761 if !(((rc == SQLITE_OK) && (ii < *(*u322)(unsafe.Pointer(bp + 36 /* nRec */)))) && (iOff < iSize)) { 64762 goto __10 64763 } 64764 rc = sqlite3.Xsqlite3OsRead(tls, pReal, bp+8 /* &zBuf[0] */, 4, iOff) 64765 if !(rc == SQLITE_OK) { 64766 goto __11 64767 } 64768 pgno = decodeUint32(tls, bp+8 /* &zBuf[0] */) 64769 if !((pgno > u322(0)) && (pgno <= (*jt_file)(unsafe.Pointer(pMain)).FnPage)) { 64770 goto __12 64771 } 64772 if !(0 == sqlite3.Xsqlite3BitvecTest(tls, (*jt_file)(unsafe.Pointer(pMain)).FpWritable, pgno)) { 64773 goto __13 64774 } 64775 rc = sqlite3.Xsqlite3OsRead(tls, pReal, aPage, int32((*jt_file)(unsafe.Pointer(pMain)).FnPagesize), (iOff + int64(4))) 64776 if !(rc == SQLITE_OK) { 64777 goto __14 64778 } 64779 cksum = genCksum(tls, aPage, int32((*jt_file)(unsafe.Pointer(pMain)).FnPagesize)) 64780 64781 __14: 64782 ; 64783 __13: 64784 ; 64785 sqlite3.Xsqlite3BitvecSet(tls, (*jt_file)(unsafe.Pointer(pMain)).FpWritable, pgno) 64786 __12: 64787 ; 64788 iOff = iOff + (sqlite3_int64(u322(8) + (*jt_file)(unsafe.Pointer(pMain)).FnPagesize)) 64789 __11: 64790 ; 64791 goto __9 64792 __9: 64793 ii++ 64794 goto __8 64795 goto __10 64796 __10: 64797 ; 64798 64799 iOff = (((iOff + (sqlite3_int64(*(*u322)(unsafe.Pointer(bp + 44 /* nSector */)) - u322(1)))) / sqlite3_int64(*(*u322)(unsafe.Pointer(bp + 44 /* nSector */)))) * sqlite3_int64(*(*u322)(unsafe.Pointer(bp + 44 /* nSector */)))) 64800 goto __2 64801 __3: 64802 ; 64803 64804 finish_rjf: 64805 start_ioerr_simulation(tls, *(*int32)(unsafe.Pointer(bp /* iSave */)), *(*int32)(unsafe.Pointer(bp + 4 /* iSave2 */))) 64806 sqlite3.Xsqlite3_free(tls, aPage) 64807 if !(rc == (SQLITE_IOERR | (int32(2) << 8))) { 64808 goto __15 64809 } 64810 rc = SQLITE_OK 64811 __15: 64812 ; 64813 return rc 64814 } 64815 64816 // Write data to an jt-file. 64817 func jtWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test_journal.c:512:12: */ 64818 var rc int32 64819 var p uintptr = pFile 64820 if ((*jt_file)(unsafe.Pointer(p)).Fflags & SQLITE_OPEN_MAIN_JOURNAL) != 0 { 64821 if iOfst == int64(0) { 64822 var pMain uintptr = locateDatabaseHandle(tls, (*jt_file)(unsafe.Pointer(p)).FzName, 0) 64823 64824 if iAmt == 28 { 64825 // Zeroing the first journal-file header. This is the end of a 64826 // transaction. 64827 closeTransaction(tls, pMain) 64828 } else if iAmt != 12 { 64829 // Writing the first journal header to a journal file. This happens 64830 // when a transaction is first started. 64831 var z uintptr = zBuf 64832 (*jt_file)(unsafe.Pointer(pMain)).FnPage = decodeUint32(tls, (z + 16)) 64833 (*jt_file)(unsafe.Pointer(pMain)).FnPagesize = decodeUint32(tls, (z + 24)) 64834 if SQLITE_OK != (libc.AssignInt32(&rc, openTransaction(tls, pMain, p))) { 64835 return rc 64836 } 64837 } 64838 } 64839 if (*jt_file)(unsafe.Pointer(p)).FiMaxOff < (iOfst + sqlite_int64(iAmt)) { 64840 (*jt_file)(unsafe.Pointer(p)).FiMaxOff = (iOfst + sqlite_int64(iAmt)) 64841 } 64842 } 64843 64844 if (((*jt_file)(unsafe.Pointer(p)).Fflags & SQLITE_OPEN_MAIN_DB) != 0) && ((*jt_file)(unsafe.Pointer(p)).FpWritable != 0) { 64845 if (((iAmt < int32((*jt_file)(unsafe.Pointer(p)).FnPagesize)) && 64846 (((*jt_file)(unsafe.Pointer(p)).FnPagesize % u322(iAmt)) == u322(0))) && 64847 (iOfst >= (sqlite_int64(sqlite3.Xsqlite3PendingByte + 512)))) && 64848 ((iOfst + sqlite_int64(iAmt)) <= (sqlite_int64(u322(sqlite3.Xsqlite3PendingByte) + (*jt_file)(unsafe.Pointer(p)).FnPagesize))) { 64849 // No-op. This special case is hit when the backup code is copying a 64850 // to a database with a larger page-size than the source database and 64851 // it needs to fill in the non-locking-region part of the original 64852 // pending-byte page. 64853 } else { 64854 var pgno u322 = (u322((iOfst / sqlite_int64((*jt_file)(unsafe.Pointer(p)).FnPagesize)) + int64(1))) 64855 _ = pgno 64856 64857 // The following assert() statements may fail if this layer is used 64858 // with a connection in "PRAGMA synchronous=off" mode. If they 64859 // fail with sync=normal or sync=full, this may indicate problem. 64860 64861 } 64862 } 64863 64864 rc = sqlite3.Xsqlite3OsWrite(tls, (*jt_file)(unsafe.Pointer(p)).FpReal, zBuf, iAmt, iOfst) 64865 if (((*jt_file)(unsafe.Pointer(p)).Fflags & SQLITE_OPEN_MAIN_JOURNAL) != 0) && (iAmt == 12) { 64866 var pMain uintptr = locateDatabaseHandle(tls, (*jt_file)(unsafe.Pointer(p)).FzName, 0) 64867 var rc2 int32 = readJournalFile(tls, p, pMain) 64868 if rc == SQLITE_OK { 64869 rc = rc2 64870 } 64871 } 64872 return rc 64873 } 64874 64875 // Truncate an jt-file. 64876 func jtTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { /* test_journal.c:580:12: */ 64877 var p uintptr = pFile 64878 if (((*jt_file)(unsafe.Pointer(p)).Fflags & SQLITE_OPEN_MAIN_JOURNAL) != 0) && (size == int64(0)) { 64879 // Truncating a journal file. This is the end of a transaction. 64880 var pMain uintptr = locateDatabaseHandle(tls, (*jt_file)(unsafe.Pointer(p)).FzName, 0) 64881 closeTransaction(tls, pMain) 64882 } 64883 if (((*jt_file)(unsafe.Pointer(p)).Fflags & SQLITE_OPEN_MAIN_DB) != 0) && ((*jt_file)(unsafe.Pointer(p)).FpWritable != 0) { 64884 var pgno u322 64885 var locking_page u322 = ((u322(sqlite3.Xsqlite3PendingByte) / (*jt_file)(unsafe.Pointer(p)).FnPagesize) + u322(1)) 64886 _ = locking_page 64887 for pgno = (u322((size / sqlite_int64((*jt_file)(unsafe.Pointer(p)).FnPagesize)) + int64(1))); pgno <= (*jt_file)(unsafe.Pointer(p)).FnPage; pgno++ { 64888 64889 } 64890 } 64891 return sqlite3.Xsqlite3OsTruncate(tls, (*jt_file)(unsafe.Pointer(p)).FpReal, size) 64892 } 64893 64894 // Sync an jt-file. 64895 func jtSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* test_journal.c:600:12: */ 64896 var p uintptr = pFile 64897 64898 if ((*jt_file)(unsafe.Pointer(p)).Fflags & SQLITE_OPEN_MAIN_JOURNAL) != 0 { 64899 var rc int32 64900 var pMain uintptr // The associated database file 64901 64902 // The journal file is being synced. At this point, we inspect the 64903 // contents of the file up to this point and set each bit in the 64904 // jt_file.pWritable bitvec of the main database file associated with 64905 // this journal file. 64906 pMain = locateDatabaseHandle(tls, (*jt_file)(unsafe.Pointer(p)).FzName, 0) 64907 64908 // Set the bitvec values 64909 if (pMain != 0) && ((*jt_file)(unsafe.Pointer(pMain)).FpWritable != 0) { 64910 (*jt_file)(unsafe.Pointer(pMain)).FnSync++ 64911 rc = readJournalFile(tls, p, pMain) 64912 if rc != SQLITE_OK { 64913 return rc 64914 } 64915 } 64916 } 64917 64918 return sqlite3.Xsqlite3OsSync(tls, (*jt_file)(unsafe.Pointer(p)).FpReal, flags) 64919 } 64920 64921 // Return the current file-size of an jt-file. 64922 func jtFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { /* test_journal.c:630:12: */ 64923 var p uintptr = pFile 64924 return sqlite3.Xsqlite3OsFileSize(tls, (*jt_file)(unsafe.Pointer(p)).FpReal, pSize) 64925 } 64926 64927 // Lock an jt-file. 64928 func jtLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_journal.c:638:12: */ 64929 var rc int32 64930 var p uintptr = pFile 64931 rc = sqlite3.Xsqlite3OsLock(tls, (*jt_file)(unsafe.Pointer(p)).FpReal, eLock) 64932 if (rc == SQLITE_OK) && (eLock > (*jt_file)(unsafe.Pointer(p)).FeLock) { 64933 (*jt_file)(unsafe.Pointer(p)).FeLock = eLock 64934 } 64935 return rc 64936 } 64937 64938 // Unlock an jt-file. 64939 func jtUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_journal.c:651:12: */ 64940 var rc int32 64941 var p uintptr = pFile 64942 rc = sqlite3.Xsqlite3OsUnlock(tls, (*jt_file)(unsafe.Pointer(p)).FpReal, eLock) 64943 if (rc == SQLITE_OK) && (eLock < (*jt_file)(unsafe.Pointer(p)).FeLock) { 64944 (*jt_file)(unsafe.Pointer(p)).FeLock = eLock 64945 } 64946 return rc 64947 } 64948 64949 // Check if another file-handle holds a RESERVED lock on an jt-file. 64950 func jtCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int32 { /* test_journal.c:664:12: */ 64951 var p uintptr = pFile 64952 return sqlite3.Xsqlite3OsCheckReservedLock(tls, (*jt_file)(unsafe.Pointer(p)).FpReal, pResOut) 64953 } 64954 64955 // File control method. For custom operations on an jt-file. 64956 func jtFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 { /* test_journal.c:672:12: */ 64957 var p uintptr = pFile 64958 return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*jt_file)(unsafe.Pointer(p)).FpReal)).FpMethods + 80 /* &.xFileControl */))))(tls, (*jt_file)(unsafe.Pointer(p)).FpReal, op, pArg) 64959 } 64960 64961 // Return the sector-size in bytes for an jt-file. 64962 func jtSectorSize(tls *libc.TLS, pFile uintptr) int32 { /* test_journal.c:680:12: */ 64963 var p uintptr = pFile 64964 return sqlite3.Xsqlite3OsSectorSize(tls, (*jt_file)(unsafe.Pointer(p)).FpReal) 64965 } 64966 64967 // Return the device characteristic flags supported by an jt-file. 64968 func jtDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { /* test_journal.c:688:12: */ 64969 var p uintptr = pFile 64970 return sqlite3.Xsqlite3OsDeviceCharacteristics(tls, (*jt_file)(unsafe.Pointer(p)).FpReal) 64971 } 64972 64973 // Open an jt file handle. 64974 func jtOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags int32, pOutFlags uintptr) int32 { /* test_journal.c:696:12: */ 64975 var rc int32 64976 var p uintptr = pFile 64977 (*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(0) 64978 (*jt_file)(unsafe.Pointer(p)).FpReal = (p + 1*80) 64979 (*sqlite3_file)(unsafe.Pointer((*jt_file)(unsafe.Pointer(p)).FpReal)).FpMethods = uintptr(0) 64980 rc = sqlite3.Xsqlite3OsOpen(tls, g2.FpVfs, zName, (*jt_file)(unsafe.Pointer(p)).FpReal, flags, pOutFlags) 64981 64982 if rc == SQLITE_OK { 64983 (*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&jt_io_methods)) 64984 (*jt_file)(unsafe.Pointer(p)).FeLock = 0 64985 (*jt_file)(unsafe.Pointer(p)).FzName = zName 64986 (*jt_file)(unsafe.Pointer(p)).Fflags = flags 64987 (*jt_file)(unsafe.Pointer(p)).FpNext = uintptr(0) 64988 (*jt_file)(unsafe.Pointer(p)).FpWritable = uintptr(0) 64989 (*jt_file)(unsafe.Pointer(p)).FaCksum = uintptr(0) 64990 enterJtMutex(tls) 64991 if zName != 0 { 64992 (*jt_file)(unsafe.Pointer(p)).FpNext = g2.FpList 64993 g2.FpList = p 64994 } 64995 leaveJtMutex(tls) 64996 } 64997 return rc 64998 } 64999 65000 // Delete the file located at zPath. If the dirSync argument is true, 65001 // ensure the file-system modifications are synced to disk before 65002 // returning. 65003 func jtDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) int32 { /* test_journal.c:733:12: */ 65004 var nPath int32 = int32(libc.Xstrlen(tls, zPath)) 65005 if (nPath > 8) && (0 == libc.Xstrcmp(tls, ts+32144 /* "-journal" */, (zPath+uintptr((nPath-8))))) { 65006 // Deleting a journal file. The end of a transaction. 65007 var pMain uintptr = locateDatabaseHandle(tls, zPath, 0) 65008 if pMain != 0 { 65009 closeTransaction(tls, pMain) 65010 } 65011 } 65012 65013 return sqlite3.Xsqlite3OsDelete(tls, g2.FpVfs, zPath, dirSync) 65014 } 65015 65016 // Test for access permissions. Return true if the requested permission 65017 // is available, or false otherwise. 65018 func jtAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut uintptr) int32 { /* test_journal.c:750:12: */ 65019 return sqlite3.Xsqlite3OsAccess(tls, g2.FpVfs, zPath, flags, pResOut) 65020 } 65021 65022 // Populate buffer zOut with the full canonical pathname corresponding 65023 // to the pathname in zPath. zOut is guaranteed to point to a buffer 65024 // of at least (JT_MAX_PATHNAME+1) bytes. 65025 func jtFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zOut uintptr) int32 { /* test_journal.c:764:12: */ 65026 return sqlite3.Xsqlite3OsFullPathname(tls, g2.FpVfs, zPath, nOut, zOut) 65027 } 65028 65029 // Open the dynamic library located at zPath and return a handle. 65030 func jtDlOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr) uintptr { /* test_journal.c:776:13: */ 65031 return (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer((g2.FpVfs + 72 /* &.xDlOpen */))))(tls, g2.FpVfs, zPath) 65032 } 65033 65034 // Populate the buffer zErrMsg (size nByte bytes) with a human readable 65035 // utf-8 string describing the most recent error encountered associated 65036 // with dynamic libraries. 65037 func jtDlError(tls *libc.TLS, pVfs uintptr, nByte int32, zErrMsg uintptr) { /* test_journal.c:785:13: */ 65038 (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer((g2.FpVfs + 80 /* &.xDlError */))))(tls, g2.FpVfs, nByte, zErrMsg) 65039 } 65040 65041 // Return a pointer to the symbol zSymbol in the dynamic library pHandle. 65042 func jtDlSym(tls *libc.TLS, pVfs uintptr, p uintptr, zSym uintptr) uintptr { /* test_journal.c:792:13: */ 65043 return (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer((g2.FpVfs + 88 /* &.xDlSym */))))(tls, g2.FpVfs, p, zSym) 65044 } 65045 65046 // Close the dynamic library handle pHandle. 65047 func jtDlClose(tls *libc.TLS, pVfs uintptr, pHandle uintptr) { /* test_journal.c:799:13: */ 65048 (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer((g2.FpVfs + 96 /* &.xDlClose */))))(tls, g2.FpVfs, pHandle) 65049 } 65050 65051 // Populate the buffer pointed to by zBufOut with nByte bytes of 65052 // random data. 65053 func jtRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uintptr) int32 { /* test_journal.c:807:12: */ 65054 return sqlite3.Xsqlite3OsRandomness(tls, g2.FpVfs, nByte, zBufOut) 65055 } 65056 65057 // Sleep for nMicro microseconds. Return the number of microseconds 65058 // actually slept. 65059 func jtSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) int32 { /* test_journal.c:815:12: */ 65060 return sqlite3.Xsqlite3OsSleep(tls, g2.FpVfs, nMicro) 65061 } 65062 65063 // Return the current time as a Julian Day number in *pTimeOut. 65064 func jtCurrentTime(tls *libc.TLS, pVfs uintptr, pTimeOut uintptr) int32 { /* test_journal.c:822:12: */ 65065 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((g2.FpVfs + 120 /* &.xCurrentTime */))))(tls, g2.FpVfs, pTimeOut) 65066 } 65067 65068 // Return the current time as a Julian Day number in *pTimeOut. 65069 func jtCurrentTimeInt64(tls *libc.TLS, pVfs uintptr, pTimeOut uintptr) int32 { /* test_journal.c:828:12: */ 65070 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((g2.FpVfs + 136 /* &.xCurrentTimeInt64 */))))(tls, g2.FpVfs, pTimeOut) 65071 } 65072 65073 func jtGetLastError(tls *libc.TLS, pVfs uintptr, n int32, z uintptr) int32 { /* test_journal.c:832:12: */ 65074 return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((g2.FpVfs + 128 /* &.xGetLastError */))))(tls, g2.FpVfs, n, z) 65075 } 65076 65077 // ************************************************************************* 65078 // 65079 // Start of public API. 65080 65081 // Configure the jt VFS as a wrapper around the VFS named by parameter 65082 // zWrap. If the isDefault parameter is true, then the jt VFS is installed 65083 // as the new default VFS for SQLite connections. If isDefault is not 65084 // true, then the jt VFS is installed as non-default. In this case it 65085 // is available via its name, "jt". 65086 func jt_register(tls *libc.TLS, zWrap uintptr, isDefault int32) int32 { /* test_journal.c:847:5: */ 65087 g2.FpVfs = sqlite3.Xsqlite3_vfs_find(tls, zWrap) 65088 if g2.FpVfs == uintptr(0) { 65089 return SQLITE_ERROR 65090 } 65091 jt_vfs.FszOsFile = (int32(uint64(unsafe.Sizeof(jt_file{})) + uint64((*sqlite3_vfs)(unsafe.Pointer(g2.FpVfs)).FszOsFile))) 65092 if (*sqlite3_vfs)(unsafe.Pointer(g2.FpVfs)).FiVersion == 1 { 65093 jt_vfs.FiVersion = 1 65094 } else if (*sqlite3_vfs)(unsafe.Pointer(g2.FpVfs)).FxCurrentTimeInt64 == uintptr(0) { 65095 jt_vfs.FxCurrentTimeInt64 = uintptr(0) 65096 } 65097 sqlite3.Xsqlite3_vfs_register(tls, uintptr(unsafe.Pointer(&jt_vfs)), isDefault) 65098 return SQLITE_OK 65099 } 65100 65101 // Uninstall the jt VFS, if it is installed. 65102 func jt_unregister(tls *libc.TLS) { /* test_journal.c:865:6: */ 65103 sqlite3.Xsqlite3_vfs_unregister(tls, uintptr(unsafe.Pointer(&jt_vfs))) 65104 } 65105 65106 // end block for C++ 65107 65108 // Local Variables: 65109 // mode: c 65110 // c-basic-offset: 4 65111 // fill-column: 78 65112 // End: 65113 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 65114 // This file is part of the GNU C Library. 65115 // 65116 // The GNU C Library is free software; you can redistribute it and/or 65117 // modify it under the terms of the GNU Lesser General Public 65118 // License as published by the Free Software Foundation; either 65119 // version 2.1 of the License, or (at your option) any later version. 65120 // 65121 // The GNU C Library is distributed in the hope that it will be useful, 65122 // but WITHOUT ANY WARRANTY; without even the implied warranty of 65123 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 65124 // Lesser General Public License for more details. 65125 // 65126 // You should have received a copy of the GNU Lesser General Public 65127 // License along with the GNU C Library; if not, see 65128 // <http://www.gnu.org/licenses/>. 65129 65130 // ISO C99 Standard: 7.20 General utilities <stdlib.h> 65131 65132 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 65133 // This file is part of the GNU C Library. 65134 // 65135 // The GNU C Library is free software; you can redistribute it and/or 65136 // modify it under the terms of the GNU Lesser General Public 65137 // License as published by the Free Software Foundation; either 65138 // version 2.1 of the License, or (at your option) any later version. 65139 // 65140 // The GNU C Library is distributed in the hope that it will be useful, 65141 // but WITHOUT ANY WARRANTY; without even the implied warranty of 65142 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 65143 // Lesser General Public License for more details. 65144 // 65145 // You should have received a copy of the GNU Lesser General Public 65146 // License along with the GNU C Library; if not, see 65147 // <http://www.gnu.org/licenses/>. 65148 65149 // ISO C99 Standard: 7.21 String handling <string.h> 65150 65151 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 65152 // This file is part of the GNU C Library. 65153 // 65154 // The GNU C Library is free software; you can redistribute it and/or 65155 // modify it under the terms of the GNU Lesser General Public 65156 // License as published by the Free Software Foundation; either 65157 // version 2.1 of the License, or (at your option) any later version. 65158 // 65159 // The GNU C Library is distributed in the hope that it will be useful, 65160 // but WITHOUT ANY WARRANTY; without even the implied warranty of 65161 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 65162 // Lesser General Public License for more details. 65163 // 65164 // You should have received a copy of the GNU Lesser General Public 65165 // License along with the GNU C Library; if not, see 65166 // <http://www.gnu.org/licenses/>. 65167 65168 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 65169 65170 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 65171 // This file is part of the GNU C Library. 65172 // 65173 // The GNU C Library is free software; you can redistribute it and/or 65174 // modify it under the terms of the GNU Lesser General Public 65175 // License as published by the Free Software Foundation; either 65176 // version 2.1 of the License, or (at your option) any later version. 65177 // 65178 // The GNU C Library is distributed in the hope that it will be useful, 65179 // but WITHOUT ANY WARRANTY; without even the implied warranty of 65180 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 65181 // Lesser General Public License for more details. 65182 // 65183 // You should have received a copy of the GNU Lesser General Public 65184 // License along with the GNU C Library; if not, see 65185 // <http://www.gnu.org/licenses/>. 65186 65187 // void assert (int expression); 65188 // 65189 // If NDEBUG is defined, do nothing. 65190 // If not, and EXPRESSION is zero, print an error message and abort. 65191 65192 // void assert_perror (int errnum); 65193 // 65194 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 65195 // error message with the error text for ERRNUM and abort. 65196 // (This is a GNU extension.) 65197 65198 // This structure is used to encapsulate the global state variables used 65199 // by malloc() fault simulation. 65200 type MemFault = struct { 65201 FiCountdown int32 65202 FnRepeat int32 65203 FnBenign int32 65204 FnFail int32 65205 FnOkBefore int32 65206 FnOkAfter int32 65207 Fenable u8 65208 _ [3]byte 65209 FisInstalled int32 65210 FisBenignMode int32 65211 _ [4]byte 65212 Fm sqlite3_mem_methods 65213 } /* test_malloc.c:30:8 */ 65214 65215 // end block for C++ 65216 65217 // Local Variables: 65218 // mode: c 65219 // c-basic-offset: 4 65220 // fill-column: 78 65221 // End: 65222 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 65223 // This file is part of the GNU C Library. 65224 // 65225 // The GNU C Library is free software; you can redistribute it and/or 65226 // modify it under the terms of the GNU Lesser General Public 65227 // License as published by the Free Software Foundation; either 65228 // version 2.1 of the License, or (at your option) any later version. 65229 // 65230 // The GNU C Library is distributed in the hope that it will be useful, 65231 // but WITHOUT ANY WARRANTY; without even the implied warranty of 65232 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 65233 // Lesser General Public License for more details. 65234 // 65235 // You should have received a copy of the GNU Lesser General Public 65236 // License along with the GNU C Library; if not, see 65237 // <http://www.gnu.org/licenses/>. 65238 65239 // ISO C99 Standard: 7.20 General utilities <stdlib.h> 65240 65241 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 65242 // This file is part of the GNU C Library. 65243 // 65244 // The GNU C Library is free software; you can redistribute it and/or 65245 // modify it under the terms of the GNU Lesser General Public 65246 // License as published by the Free Software Foundation; either 65247 // version 2.1 of the License, or (at your option) any later version. 65248 // 65249 // The GNU C Library is distributed in the hope that it will be useful, 65250 // but WITHOUT ANY WARRANTY; without even the implied warranty of 65251 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 65252 // Lesser General Public License for more details. 65253 // 65254 // You should have received a copy of the GNU Lesser General Public 65255 // License along with the GNU C Library; if not, see 65256 // <http://www.gnu.org/licenses/>. 65257 65258 // ISO C99 Standard: 7.21 String handling <string.h> 65259 65260 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 65261 // This file is part of the GNU C Library. 65262 // 65263 // The GNU C Library is free software; you can redistribute it and/or 65264 // modify it under the terms of the GNU Lesser General Public 65265 // License as published by the Free Software Foundation; either 65266 // version 2.1 of the License, or (at your option) any later version. 65267 // 65268 // The GNU C Library is distributed in the hope that it will be useful, 65269 // but WITHOUT ANY WARRANTY; without even the implied warranty of 65270 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 65271 // Lesser General Public License for more details. 65272 // 65273 // You should have received a copy of the GNU Lesser General Public 65274 // License along with the GNU C Library; if not, see 65275 // <http://www.gnu.org/licenses/>. 65276 65277 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 65278 65279 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 65280 // This file is part of the GNU C Library. 65281 // 65282 // The GNU C Library is free software; you can redistribute it and/or 65283 // modify it under the terms of the GNU Lesser General Public 65284 // License as published by the Free Software Foundation; either 65285 // version 2.1 of the License, or (at your option) any later version. 65286 // 65287 // The GNU C Library is distributed in the hope that it will be useful, 65288 // but WITHOUT ANY WARRANTY; without even the implied warranty of 65289 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 65290 // Lesser General Public License for more details. 65291 // 65292 // You should have received a copy of the GNU Lesser General Public 65293 // License along with the GNU C Library; if not, see 65294 // <http://www.gnu.org/licenses/>. 65295 65296 // void assert (int expression); 65297 // 65298 // If NDEBUG is defined, do nothing. 65299 // If not, and EXPRESSION is zero, print an error message and abort. 65300 65301 // void assert_perror (int errnum); 65302 // 65303 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 65304 // error message with the error text for ERRNUM and abort. 65305 // (This is a GNU extension.) 65306 65307 // This structure is used to encapsulate the global state variables used 65308 // by malloc() fault simulation. 65309 var memfault MemFault /* test_malloc.c:41:3: */ 65310 65311 // This routine exists as a place to set a breakpoint that will 65312 // fire on any simulated malloc() failure. 65313 func sqlite3Fault(tls *libc.TLS) { /* test_malloc.c:47:13: */ 65314 cnt1++ 65315 } 65316 65317 var cnt1 int32 = 0 /* test_malloc.c:48:14 */ 65318 65319 // This routine exists as a place to set a breakpoint that will 65320 // fire the first time any malloc() fails on a single test case. 65321 // The sqlite3Fault() routine above runs on every malloc() failure. 65322 // This routine only runs on the first such failure. 65323 func sqlite3FirstFault(tls *libc.TLS) { /* test_malloc.c:58:13: */ 65324 cnt2++ 65325 } 65326 65327 var cnt2 int32 = 0 /* test_malloc.c:59:14 */ 65328 65329 // Check to see if a fault should be simulated. Return true to simulate 65330 // the fault. Return false if the fault should not be simulated. 65331 func faultsimStep(tls *libc.TLS) int32 { /* test_malloc.c:67:12: */ 65332 if !(int32(memfault.Fenable) != 0) { 65333 memfault.FnOkAfter++ 65334 return 0 65335 } 65336 if memfault.FiCountdown > 0 { 65337 memfault.FiCountdown-- 65338 memfault.FnOkBefore++ 65339 return 0 65340 } 65341 if memfault.FnFail == 0 { 65342 sqlite3FirstFault(tls) 65343 } 65344 sqlite3Fault(tls) 65345 memfault.FnFail++ 65346 if memfault.FisBenignMode > 0 { 65347 memfault.FnBenign++ 65348 } 65349 memfault.FnRepeat-- 65350 if memfault.FnRepeat <= 0 { 65351 memfault.Fenable = u8(0) 65352 } 65353 return 1 65354 } 65355 65356 // A version of sqlite3_mem_methods.xMalloc() that includes fault simulation 65357 // logic. 65358 func faultsimMalloc(tls *libc.TLS, n int32) uintptr { /* test_malloc.c:94:13: */ 65359 var p uintptr = uintptr(0) 65360 if !(faultsimStep(tls) != 0) { 65361 p = (*(*func(*libc.TLS, int32) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&memfault)) + 40 /* &.m */ /* &.xMalloc */))))(tls, n) 65362 } 65363 return p 65364 } 65365 65366 // A version of sqlite3_mem_methods.xRealloc() that includes fault simulation 65367 // logic. 65368 func faultsimRealloc(tls *libc.TLS, pOld uintptr, n int32) uintptr { /* test_malloc.c:107:13: */ 65369 var p uintptr = uintptr(0) 65370 if !(faultsimStep(tls) != 0) { 65371 p = (*(*func(*libc.TLS, uintptr, int32) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&memfault)) + 40 /* &.m */ + 16 /* &.xRealloc */))))(tls, pOld, n) 65372 } 65373 return p 65374 } 65375 65376 // This routine configures the malloc failure simulation. After 65377 // calling this routine, the next nDelay mallocs will succeed, followed 65378 // by a block of nRepeat failures, after which malloc() calls will begin 65379 // to succeed again. 65380 func faultsimConfig(tls *libc.TLS, nDelay int32, nRepeat int32) { /* test_malloc.c:121:13: */ 65381 memfault.FiCountdown = nDelay 65382 memfault.FnRepeat = nRepeat 65383 memfault.FnBenign = 0 65384 memfault.FnFail = 0 65385 memfault.FnOkBefore = 0 65386 memfault.FnOkAfter = 0 65387 memfault.Fenable = (u8(libc.Bool32(nDelay >= 0))) 65388 65389 // Sometimes, when running multi-threaded tests, the isBenignMode 65390 // variable is not properly incremented/decremented so that it is 65391 // 0 when not inside a benign malloc block. This doesn't affect 65392 // the multi-threaded tests, as they do not use this system. But 65393 // it does affect OOM tests run later in the same process. So 65394 // zero the variable here, just to be sure. 65395 memfault.FisBenignMode = 0 65396 } 65397 65398 // Return the number of faults (both hard and benign faults) that have 65399 // occurred since the injector was last configured. 65400 func faultsimFailures(tls *libc.TLS) int32 { /* test_malloc.c:144:12: */ 65401 return memfault.FnFail 65402 } 65403 65404 // Return the number of benign faults that have occurred since the 65405 // injector was last configured. 65406 func faultsimBenignFailures(tls *libc.TLS) int32 { /* test_malloc.c:152:12: */ 65407 return memfault.FnBenign 65408 } 65409 65410 // Return the number of successes that will occur before the next failure. 65411 // If no failures are scheduled, return -1. 65412 func faultsimPending(tls *libc.TLS) int32 { /* test_malloc.c:160:12: */ 65413 if memfault.Fenable != 0 { 65414 return memfault.FiCountdown 65415 } else { 65416 return -1 65417 } 65418 return int32(0) 65419 } 65420 65421 func faultsimBeginBenign(tls *libc.TLS) { /* test_malloc.c:169:13: */ 65422 memfault.FisBenignMode++ 65423 } 65424 65425 func faultsimEndBenign(tls *libc.TLS) { /* test_malloc.c:172:13: */ 65426 memfault.FisBenignMode-- 65427 } 65428 65429 // Add or remove the fault-simulation layer using sqlite3_config(). If 65430 // the argument is non-zero, the 65431 func faultsimInstall(tls *libc.TLS, install int32) int32 { /* test_malloc.c:180:12: */ 65432 bp := tls.Alloc(200) 65433 defer tls.Free(200) 65434 65435 var rc int32 65436 65437 install = func() int32 { 65438 if install != 0 { 65439 return 1 65440 } 65441 return 0 65442 }() 65443 65444 if install == memfault.FisInstalled { 65445 return SQLITE_ERROR 65446 } 65447 65448 if install != 0 { 65449 rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_GETMALLOC, libc.VaList(bp, (uintptr(unsafe.Pointer(&memfault))+40 /* &.m */))) 65450 65451 if rc == SQLITE_OK { 65452 *(*sqlite3_mem_methods)(unsafe.Pointer(bp + 72 /* m */)) = memfault.Fm 65453 (*sqlite3_mem_methods)(unsafe.Pointer(bp + 72 /* &m */)).FxMalloc = *(*uintptr)(unsafe.Pointer(&struct { 65454 f func(*libc.TLS, int32) uintptr 65455 }{faultsimMalloc})) 65456 (*sqlite3_mem_methods)(unsafe.Pointer(bp + 72 /* &m */)).FxRealloc = *(*uintptr)(unsafe.Pointer(&struct { 65457 f func(*libc.TLS, uintptr, int32) uintptr 65458 }{faultsimRealloc})) 65459 rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MALLOC, libc.VaList(bp+8, bp+72 /* &m */)) 65460 } 65461 sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, 65462 libc.VaList(bp+16, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS) }{faultsimBeginBenign})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS) }{faultsimEndBenign})))) 65463 } else { 65464 // var m2 sqlite3_mem_methods at bp+136, 64 65465 65466 // One should be able to reset the default memory allocator by storing 65467 // a zeroed allocator then calling GETMALLOC. 65468 libc.Xmemset(tls, bp+136 /* &m2 */, 0, uint64(unsafe.Sizeof(sqlite3_mem_methods{}))) 65469 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MALLOC, libc.VaList(bp+32, bp+136 /* &m2 */)) 65470 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_GETMALLOC, libc.VaList(bp+40, bp+136 /* &m2 */)) 65471 65472 rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MALLOC, libc.VaList(bp+48, (uintptr(unsafe.Pointer(&memfault))+40 /* &.m */))) 65473 sqlite3.Xsqlite3_test_control(tls, SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, 65474 libc.VaList(bp+56, uintptr(0), uintptr(0))) 65475 } 65476 65477 if rc == SQLITE_OK { 65478 memfault.FisInstalled = 1 65479 } 65480 return rc 65481 } 65482 65483 // Transform pointers to text and back again 65484 func pointerToText(tls *libc.TLS, p uintptr, z uintptr) { /* test_malloc.c:239:13: */ 65485 bp := tls.Alloc(20) 65486 defer tls.Free(20) 65487 *(*uintptr)(unsafe.Pointer(bp + 8)) = p 65488 65489 var i int32 65490 var k int32 65491 // var u uint32 at bp+16, 4 65492 65493 // var n sqlite3_uint64 at bp, 8 65494 65495 if *(*uintptr)(unsafe.Pointer(bp + 8 /* p */)) == uintptr(0) { 65496 libc.Xstrcpy(tls, z, ts+13875 /* "0" */) 65497 return 65498 } 65499 if uint64(unsafe.Sizeof(sqlite3_uint64(0))) == uint64(unsafe.Sizeof(uintptr(0))) { 65500 libc.Xmemcpy(tls, bp /* &n */, bp+8 /* &p */, uint64(unsafe.Sizeof(uintptr(0)))) 65501 } else if uint64(unsafe.Sizeof(uint32(0))) == uint64(unsafe.Sizeof(uintptr(0))) { 65502 libc.Xmemcpy(tls, bp+16 /* &u */, bp+8 /* &p */, uint64(unsafe.Sizeof(uint32(0)))) 65503 *(*sqlite3_uint64)(unsafe.Pointer(bp /* n */)) = sqlite3_uint64(*(*uint32)(unsafe.Pointer(bp + 16 /* u */))) 65504 } else { 65505 65506 } 65507 i = 0 65508 k = (int32((uint64(unsafe.Sizeof(uintptr(0))) * uint64(2)) - uint64(1))) 65509 __1: 65510 if !(uint64(i) < (uint64(unsafe.Sizeof(uintptr(0))) * uint64(2))) { 65511 goto __3 65512 } 65513 { 65514 *(*int8)(unsafe.Pointer(z + uintptr(k))) = zHex[(*(*sqlite3_uint64)(unsafe.Pointer(bp /* n */)) & uint64(0xf))] 65515 *(*sqlite3_uint64)(unsafe.Pointer(bp /* n */)) >>= 4 65516 65517 } 65518 goto __2 65519 __2: 65520 i++ 65521 k-- 65522 goto __1 65523 goto __3 65524 __3: 65525 ; 65526 *(*int8)(unsafe.Pointer(z + 16)) = int8(0) 65527 } 65528 65529 var zHex = *(*[17]int8)(unsafe.Pointer(ts + 30527 /* "0123456789abcdef" */)) /* test_malloc.c:240:21 */ 65530 65531 func hexToInt(tls *libc.TLS, h int32) int32 { /* test_malloc.c:262:12: */ 65532 if (h >= '0') && (h <= '9') { 65533 return (h - '0') 65534 } else if (h >= 'a') && (h <= 'f') { 65535 return ((h - 'a') + 10) 65536 } else { 65537 return -1 65538 } 65539 return int32(0) 65540 } 65541 65542 func textToPointer(tls *libc.TLS, z uintptr, pp uintptr) int32 { /* test_malloc.c:271:12: */ 65543 bp := tls.Alloc(12) 65544 defer tls.Free(12) 65545 65546 *(*sqlite3_uint64)(unsafe.Pointer(bp /* n */)) = uint64(0) 65547 var i int32 65548 // var u uint32 at bp+8, 4 65549 65550 for i = 0; (uint64(i) < (uint64(unsafe.Sizeof(uintptr(0))) * uint64(2))) && (*(*int8)(unsafe.Pointer(z)) != 0); i++ { 65551 var v int32 65552 v = hexToInt(tls, int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))))) 65553 if v < 0 { 65554 return TCL_ERROR 65555 } 65556 *(*sqlite3_uint64)(unsafe.Pointer(bp /* n */)) = ((*(*sqlite3_uint64)(unsafe.Pointer(bp /* n */)) * uint64(16)) + sqlite3_uint64(v)) 65557 } 65558 if int32(*(*int8)(unsafe.Pointer(z))) != 0 { 65559 return TCL_ERROR 65560 } 65561 if uint64(unsafe.Sizeof(sqlite3_uint64(0))) == uint64(unsafe.Sizeof(uintptr(0))) { 65562 libc.Xmemcpy(tls, pp, bp /* &n */, uint64(unsafe.Sizeof(sqlite3_uint64(0)))) 65563 } else if uint64(unsafe.Sizeof(uint32(0))) == uint64(unsafe.Sizeof(uintptr(0))) { 65564 *(*uint32)(unsafe.Pointer(bp + 8 /* u */)) = uint32(*(*sqlite3_uint64)(unsafe.Pointer(bp /* n */))) 65565 libc.Xmemcpy(tls, pp, bp+8 /* &u */, uint64(unsafe.Sizeof(uint32(0)))) 65566 } else { 65567 65568 } 65569 return TCL_OK 65570 } 65571 65572 // Usage: sqlite3_malloc NBYTES 65573 // 65574 // Raw test interface for sqlite3_malloc(). 65575 func test_malloc(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:298:26: */ 65576 bp := tls.Alloc(120) 65577 defer tls.Free(120) 65578 65579 // var nByte int32 at bp+16, 4 65580 65581 var p uintptr 65582 // var zOut [100]int8 at bp+20, 100 65583 65584 if objc != 2 { 65585 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32153 /* "NBYTES" */) 65586 return TCL_ERROR 65587 } 65588 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+16 /* &nByte */) != 0 { 65589 return TCL_ERROR 65590 } 65591 p = sqlite3.Xsqlite3_malloc(tls, int32(uint32(*(*int32)(unsafe.Pointer(bp + 16 /* nByte */))))) 65592 pointerToText(tls, p, bp+20 /* &zOut[0] */) 65593 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, bp+20 /* &zOut[0] */, uintptr(0))) 65594 return TCL_OK 65595 } 65596 65597 // Usage: sqlite3_realloc PRIOR NBYTES 65598 // 65599 // Raw test interface for sqlite3_realloc(). 65600 func test_realloc(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:323:26: */ 65601 bp := tls.Alloc(156) 65602 defer tls.Free(156) 65603 65604 // var nByte int32 at bp+40, 4 65605 65606 // var pPrior uintptr at bp+48, 8 65607 65608 var p uintptr 65609 // var zOut [100]int8 at bp+56, 100 65610 65611 if objc != 3 { 65612 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32160 /* "PRIOR NBYTES" */) 65613 return TCL_ERROR 65614 } 65615 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+40 /* &nByte */) != 0 { 65616 return TCL_ERROR 65617 } 65618 if textToPointer(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+48 /* &pPrior */) != 0 { 65619 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+32173 /* "bad pointer: " */, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), uintptr(0))) 65620 return TCL_ERROR 65621 } 65622 p = sqlite3.Xsqlite3_realloc(tls, *(*uintptr)(unsafe.Pointer(bp + 48 /* pPrior */)), int32(uint32(*(*int32)(unsafe.Pointer(bp + 40 /* nByte */))))) 65623 pointerToText(tls, p, bp+56 /* &zOut[0] */) 65624 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, bp+56 /* &zOut[0] */, uintptr(0))) 65625 return TCL_OK 65626 } 65627 65628 // Usage: sqlite3_free PRIOR 65629 // 65630 // Raw test interface for sqlite3_free(). 65631 func test_free(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:352:26: */ 65632 bp := tls.Alloc(32) 65633 defer tls.Free(32) 65634 65635 // var pPrior uintptr at bp+24, 8 65636 65637 if objc != 2 { 65638 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32187 /* "PRIOR" */) 65639 return TCL_ERROR 65640 } 65641 if textToPointer(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+24 /* &pPrior */) != 0 { 65642 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+32173 /* "bad pointer: " */, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), uintptr(0))) 65643 return TCL_ERROR 65644 } 65645 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* pPrior */))) 65646 return TCL_OK 65647 } 65648 65649 // Usage: memset ADDRESS SIZE HEX 65650 // 65651 // Set a chunk of memory (obtained from malloc, probably) to a 65652 // specified hex pattern. 65653 func test_memset(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:383:26: */ 65654 bp := tls.Alloc(172) 65655 defer tls.Free(172) 65656 65657 // var p uintptr at bp+56, 8 65658 65659 // var size int32 at bp+64, 4 65660 65661 // var n int32 at bp+68, 4 65662 65663 var i int32 65664 var zHex uintptr 65665 var zOut uintptr 65666 // var zBin [100]int8 at bp+72, 100 65667 65668 if objc != 4 { 65669 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32193 /* "ADDRESS SIZE HEX" */) 65670 return TCL_ERROR 65671 } 65672 if textToPointer(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+56 /* &p */) != 0 { 65673 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+32173 /* "bad pointer: " */, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), uintptr(0))) 65674 return TCL_ERROR 65675 } 65676 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+64 /* &size */) != 0 { 65677 return TCL_ERROR 65678 } 65679 if *(*int32)(unsafe.Pointer(bp + 64 /* size */)) <= 0 { 65680 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, ts+32210 /* "size must be pos..." */, uintptr(0))) 65681 return TCL_ERROR 65682 } 65683 zHex = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+68 /* &n */) 65684 if uint64(*(*int32)(unsafe.Pointer(bp + 68 /* n */))) > (uint64(unsafe.Sizeof([100]int8{})) * uint64(2)) { 65685 *(*int32)(unsafe.Pointer(bp + 68 /* n */)) = (int32(uint64(unsafe.Sizeof([100]int8{})) * uint64(2))) 65686 } 65687 *(*int32)(unsafe.Pointer(bp + 68 /* n */)) = sqlite3TestHexToBin(tls, zHex, *(*int32)(unsafe.Pointer(bp + 68 /* n */)), bp+72 /* &zBin[0] */) 65688 if *(*int32)(unsafe.Pointer(bp + 68 /* n */)) == 0 { 65689 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, ts+32232 /* "no data" */, uintptr(0))) 65690 return TCL_ERROR 65691 } 65692 zOut = *(*uintptr)(unsafe.Pointer(bp + 56 /* p */)) 65693 for i = 0; i < *(*int32)(unsafe.Pointer(bp + 64 /* size */)); i++ { 65694 *(*int8)(unsafe.Pointer(zOut + uintptr(i))) = *(*int8)(unsafe.Pointer(bp + 72 /* &zBin[0] */ + uintptr((i % *(*int32)(unsafe.Pointer(bp + 68 /* n */)))))) 65695 } 65696 return TCL_OK 65697 } 65698 65699 // Usage: memget ADDRESS SIZE 65700 // 65701 // Return memory as hexadecimal text. 65702 func test_memget(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:429:26: */ 65703 bp := tls.Alloc(168) 65704 defer tls.Free(168) 65705 65706 // var p uintptr at bp+56, 8 65707 65708 // var size int32 at bp+64, 4 65709 65710 var n int32 65711 var zBin uintptr 65712 // var zHex [100]int8 at bp+68, 100 65713 65714 if objc != 3 { 65715 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32240 /* "ADDRESS SIZE" */) 65716 return TCL_ERROR 65717 } 65718 if textToPointer(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+56 /* &p */) != 0 { 65719 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+32173 /* "bad pointer: " */, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), uintptr(0))) 65720 return TCL_ERROR 65721 } 65722 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+64 /* &size */) != 0 { 65723 return TCL_ERROR 65724 } 65725 if *(*int32)(unsafe.Pointer(bp + 64 /* size */)) <= 0 { 65726 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, ts+32210 /* "size must be pos..." */, uintptr(0))) 65727 return TCL_ERROR 65728 } 65729 zBin = *(*uintptr)(unsafe.Pointer(bp + 56 /* p */)) 65730 for *(*int32)(unsafe.Pointer(bp + 64 /* size */)) > 0 { 65731 if uint64(*(*int32)(unsafe.Pointer(bp + 64 /* size */))) > ((uint64(unsafe.Sizeof([100]int8{})) - uint64(1)) / uint64(2)) { 65732 n = (int32((uint64(unsafe.Sizeof([100]int8{})) - uint64(1)) / uint64(2))) 65733 } else { 65734 n = *(*int32)(unsafe.Pointer(bp + 64 /* size */)) 65735 } 65736 libc.Xmemcpy(tls, bp+68 /* &zHex[0] */, zBin, uint64(n)) 65737 zBin += uintptr(n) 65738 *(*int32)(unsafe.Pointer(bp + 64 /* size */)) -= n 65739 sqlite3TestBinToHex(tls, bp+68 /* &zHex[0] */, n) 65740 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+68 /* &zHex[0] */, uintptr(0))) 65741 } 65742 return TCL_OK 65743 } 65744 65745 // Usage: sqlite3_memory_used 65746 // 65747 // Raw test interface for sqlite3_memory_used(). 65748 func test_memory_used(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:476:26: */ 65749 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, sqlite3.Xsqlite3_memory_used(tls))) 65750 return TCL_OK 65751 } 65752 65753 // Usage: sqlite3_memory_highwater ?RESETFLAG? 65754 // 65755 // Raw test interface for sqlite3_memory_highwater(). 65756 func test_memory_highwater(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:491:26: */ 65757 bp := tls.Alloc(4) 65758 defer tls.Free(4) 65759 65760 *(*int32)(unsafe.Pointer(bp /* resetFlag */)) = 0 65761 if (objc != 1) && (objc != 2) { 65762 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32253 /* "?RESET?" */) 65763 return TCL_ERROR 65764 } 65765 if objc == 2 { 65766 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &resetFlag */) != 0 { 65767 return TCL_ERROR 65768 } 65769 } 65770 tcl.XTcl_SetObjResult(tls, interp, 65771 tcl.XTcl_NewWideIntObj(tls, sqlite3.Xsqlite3_memory_highwater(tls, *(*int32)(unsafe.Pointer(bp /* resetFlag */))))) 65772 return TCL_OK 65773 } 65774 65775 // Usage: sqlite3_memdebug_backtrace DEPTH 65776 // 65777 // Set the depth of backtracing. If SQLITE_MEMDEBUG is not defined 65778 // then this routine is a no-op. 65779 func test_memdebug_backtrace(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:516:26: */ 65780 bp := tls.Alloc(4) 65781 defer tls.Free(4) 65782 65783 // var depth int32 at bp, 4 65784 65785 if objc != 2 { 65786 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32261 /* "DEPT" */) 65787 return TCL_ERROR 65788 } 65789 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &depth */) != 0 { 65790 return TCL_ERROR 65791 } 65792 return TCL_OK 65793 } 65794 65795 // Usage: sqlite3_memdebug_dump FILENAME 65796 // 65797 // Write a summary of unfreed memory to FILENAME. 65798 func test_memdebug_dump(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:542:26: */ 65799 if objc != 2 { 65800 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32266 /* "FILENAME" */) 65801 return TCL_ERROR 65802 } 65803 return TCL_OK 65804 } 65805 65806 // Usage: sqlite3_memdebug_malloc_count 65807 // 65808 // Return the total number of times malloc() has been called. 65809 func test_memdebug_malloc_count(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:567:26: */ 65810 var nMalloc int32 = -1 65811 if objc != 1 { 65812 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 65813 return TCL_ERROR 65814 } 65815 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, nMalloc)) 65816 return TCL_OK 65817 } 65818 65819 // Usage: sqlite3_memdebug_fail COUNTER ?OPTIONS? 65820 // 65821 // where options are: 65822 // 65823 // -repeat <count> 65824 // -benigncnt <varname> 65825 // 65826 // Arrange for a simulated malloc() failure after COUNTER successes. 65827 // If a repeat count is specified, the fault is repeated that many 65828 // times. 65829 // 65830 // Each call to this routine overrides the prior counter value. 65831 // This routine returns the number of simulated failures that have 65832 // happened since the previous call to this routine. 65833 // 65834 // To disable simulated failures, use a COUNTER of -1. 65835 func test_memdebug_fail(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:607:26: */ 65836 bp := tls.Alloc(36) 65837 defer tls.Free(36) 65838 65839 var ii int32 65840 // var iFail int32 at bp+24, 4 65841 65842 *(*int32)(unsafe.Pointer(bp + 32 /* nRepeat */)) = 1 65843 var pBenignCnt uintptr = uintptr(0) 65844 var nBenign int32 65845 var nFail int32 = 0 65846 65847 if objc < 2 { 65848 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32275 /* "COUNTER ?OPTIONS..." */) 65849 return TCL_ERROR 65850 } 65851 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+24 /* &iFail */) != 0 { 65852 return TCL_ERROR 65853 } 65854 65855 for ii = 2; ii < objc; ii = ii + (2) { 65856 // var nOption int32 at bp+28, 4 65857 65858 var zOption uintptr = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(ii)*8)), bp+28 /* &nOption */) 65859 var zErr uintptr = uintptr(0) 65860 65861 if (*(*int32)(unsafe.Pointer(bp + 28 /* nOption */)) > 1) && (libc.Xstrncmp(tls, zOption, ts+32293 /* "-repeat" */, uint64(*(*int32)(unsafe.Pointer(bp + 28 /* nOption */)))) == 0) { 65862 if ii == (objc - 1) { 65863 zErr = ts + 12329 /* "option requires ..." */ 65864 } else { 65865 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((ii+1))*8)), bp+32 /* &nRepeat */) != 0 { 65866 return TCL_ERROR 65867 } 65868 } 65869 } else if (*(*int32)(unsafe.Pointer(bp + 28 /* nOption */)) > 1) && (libc.Xstrncmp(tls, zOption, ts+32301 /* "-benigncnt" */, uint64(*(*int32)(unsafe.Pointer(bp + 28 /* nOption */)))) == 0) { 65870 if ii == (objc - 1) { 65871 zErr = ts + 12329 /* "option requires ..." */ 65872 } else { 65873 pBenignCnt = *(*uintptr)(unsafe.Pointer(objv + uintptr((ii+1))*8)) 65874 } 65875 } else { 65876 zErr = ts + 12135 /* "unknown option: " */ 65877 } 65878 65879 if zErr != 0 { 65880 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, zErr, zOption, 0)) 65881 return TCL_ERROR 65882 } 65883 } 65884 65885 nBenign = faultsimBenignFailures(tls) 65886 nFail = faultsimFailures(tls) 65887 faultsimConfig(tls, *(*int32)(unsafe.Pointer(bp + 24 /* iFail */)), *(*int32)(unsafe.Pointer(bp + 32 /* nRepeat */))) 65888 65889 if pBenignCnt != 0 { 65890 tcl.XTcl_ObjSetVar2(tls, interp, pBenignCnt, uintptr(0), tcl.XTcl_NewIntObj(tls, nBenign), 0) 65891 } 65892 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, nFail)) 65893 return TCL_OK 65894 } 65895 65896 // Usage: sqlite3_memdebug_pending 65897 // 65898 // Return the number of malloc() calls that will succeed before a 65899 // simulated failure occurs. A negative return value indicates that 65900 // no malloc() failure is scheduled. 65901 func test_memdebug_pending(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:673:26: */ 65902 var nPending int32 65903 if objc != 1 { 65904 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 65905 return TCL_ERROR 65906 } 65907 nPending = faultsimPending(tls) 65908 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, nPending)) 65909 return TCL_OK 65910 } 65911 65912 // The following global variable keeps track of the number of tests 65913 // that have run. This variable is only useful when running in the 65914 // debugger. 65915 var sqlite3_memdebug_title_count int32 = 0 /* test_malloc.c:694:12 */ 65916 65917 // Usage: sqlite3_memdebug_settitle TITLE 65918 // 65919 // Set a title string stored with each allocation. The TITLE is 65920 // typically the name of the test that was running when the 65921 // allocation occurred. The TITLE is stored with the allocation 65922 // and can be used to figure out which tests are leaking memory. 65923 // 65924 // Each title overwrite the previous. 65925 func test_memdebug_settitle(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:706:26: */ 65926 sqlite3_memdebug_title_count++ 65927 if objc != 2 { 65928 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32312 /* "TITLE" */) 65929 return TCL_ERROR 65930 } 65931 return TCL_OK 65932 } 65933 65934 var aMallocLog Tcl_HashTable /* test_malloc.c:732:22: */ 65935 var mallocLogEnabled int32 = 0 /* test_malloc.c:733:12 */ 65936 65937 type MallocLog1 = struct { 65938 FnCall int32 65939 FnByte int32 65940 } /* test_malloc.c:735:9 */ 65941 65942 type MallocLog = MallocLog1 /* test_malloc.c:735:26 */ 65943 65944 func test_memdebug_log_clear(tls *libc.TLS) { /* test_malloc.c:772:13: */ 65945 bp := tls.Alloc(24) 65946 defer tls.Free(24) 65947 65948 // var search Tcl_HashSearch at bp, 24 65949 65950 var pEntry uintptr 65951 for pEntry = tcl.XTcl_FirstHashEntry(tls, uintptr(unsafe.Pointer(&aMallocLog)), bp /* &search */); pEntry != 0; pEntry = tcl.XTcl_NextHashEntry(tls, bp /* &search */) { 65952 var pLog uintptr = (*Tcl_HashEntry)(unsafe.Pointer(pEntry)).FclientData 65953 tcl.XTcl_Free(tls, pLog) 65954 } 65955 tcl.XTcl_DeleteHashTable(tls, uintptr(unsafe.Pointer(&aMallocLog))) 65956 tcl.XTcl_InitHashTable(tls, uintptr(unsafe.Pointer(&aMallocLog)), (int32(uint64(10) * (func() uint64 { 65957 if uint64(unsafe.Sizeof(int32(0))) >= uint64(unsafe.Sizeof(uintptr(0))) { 65958 return uint64(1) 65959 } 65960 return (uint64(unsafe.Sizeof(uintptr(0))) / uint64(unsafe.Sizeof(int32(0)))) 65961 }())))) 65962 } 65963 65964 func test_memdebug_log(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:787:26: */ 65965 bp := tls.Alloc(128) 65966 defer tls.Free(128) 65967 65968 // var iSub int32 at bp, 4 65969 65970 if !(isInit != 0) { 65971 tcl.XTcl_InitHashTable(tls, uintptr(unsafe.Pointer(&aMallocLog)), (int32(uint64(10) * (func() uint64 { 65972 if uint64(unsafe.Sizeof(int32(0))) >= uint64(unsafe.Sizeof(uintptr(0))) { 65973 return uint64(1) 65974 } 65975 return (uint64(unsafe.Sizeof(uintptr(0))) / uint64(unsafe.Sizeof(int32(0)))) 65976 }())))) 65977 isInit = 1 65978 } 65979 65980 if objc < 2 { 65981 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32318 /* "SUB-COMMAND ..." */) 65982 } 65983 if tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&MB_strs)), int32(unsafe.Sizeof(uintptr(0))), ts+1875 /* "sub-command" */, 0, bp /* &iSub */) != 0 { 65984 return TCL_ERROR 65985 } 65986 65987 switch uint32(*(*int32)(unsafe.Pointer(bp /* iSub */))) { 65988 case uint32(0) /* MB_LOG_START */ : 65989 mallocLogEnabled = 1 65990 break 65991 case uint32(1) /* MB_LOG_STOP */ : 65992 mallocLogEnabled = 0 65993 break 65994 case uint32(2) /* MB_LOG_DUMP */ : 65995 { 65996 // var search Tcl_HashSearch at bp+8, 24 65997 65998 var pEntry uintptr 65999 var pRet uintptr = tcl.XTcl_NewObj(tls) 66000 66001 for pEntry = tcl.XTcl_FirstHashEntry(tls, uintptr(unsafe.Pointer(&aMallocLog)), bp+8 /* &search */); pEntry != 0; pEntry = tcl.XTcl_NextHashEntry(tls, bp+8 /* &search */) { 66002 // var apElem [12]uintptr at bp+32, 96 66003 66004 var pLog uintptr = (*Tcl_HashEntry)(unsafe.Pointer(pEntry)).FclientData 66005 var aKey uintptr = func() uintptr { 66006 if ((*Tcl_HashTable)(unsafe.Pointer((uintptr(unsafe.Pointer(&aMallocLog))))).FkeyType == (1)) || ((*Tcl_HashTable)(unsafe.Pointer((uintptr(unsafe.Pointer(&aMallocLog))))).FkeyType == (-1)) { 66007 return *(*uintptr)(unsafe.Pointer(pEntry + 32 /* &.key */)) 66008 } 66009 return pEntry + 32 /* &.key */ 66010 }() 66011 var ii int32 66012 66013 *(*uintptr)(unsafe.Pointer(bp + 32 /* &apElem[0] */)) = tcl.XTcl_NewIntObj(tls, (*MallocLog)(unsafe.Pointer(pLog)).FnCall) 66014 *(*uintptr)(unsafe.Pointer(bp + 32 /* &apElem[0] */ + 1*8)) = tcl.XTcl_NewIntObj(tls, (*MallocLog)(unsafe.Pointer(pLog)).FnByte) 66015 for ii = 0; ii < MALLOC_LOG_FRAMES; ii++ { 66016 *(*uintptr)(unsafe.Pointer(bp + 32 /* &apElem[0] */ + uintptr((ii+2))*8)) = tcl.XTcl_NewWideIntObj(tls, *(*Tcl_WideInt)(unsafe.Pointer(aKey + uintptr(ii)*8))) 66017 } 66018 66019 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, 66020 tcl.XTcl_NewListObj(tls, (MALLOC_LOG_FRAMES+2), bp+32 /* &apElem[0] */)) 66021 } 66022 66023 tcl.XTcl_SetObjResult(tls, interp, pRet) 66024 break 66025 66026 } 66027 case uint32(3) /* MB_LOG_CLEAR */ : 66028 { 66029 test_memdebug_log_clear(tls) 66030 break 66031 66032 } 66033 66034 case uint32(4) /* MB_LOG_SYNC */ : 66035 { 66036 break 66037 66038 } 66039 } 66040 66041 return TCL_OK 66042 } 66043 66044 var isInit int32 = 0 /* test_malloc.c:793:14 */ 66045 var MB_strs = [5]uintptr{ts + 32334 /* "start" */, ts + 32340 /* "stop" */, ts + 32345 /* "dump" */, ts + 32350 /* "clear" */, ts + 32356 /* "sync" */} /* test_malloc.c:796:21 */ 66046 66047 // Usage: sqlite3_config_pagecache SIZE N 66048 // 66049 // Set the page-cache memory buffer using SQLITE_CONFIG_PAGECACHE. 66050 // The buffer is static and is of limited size. N might be 66051 // adjusted downward as needed to accommodate the requested size. 66052 // The revised value of N is returned. 66053 // 66054 // A negative SIZE causes the buffer pointer to be NULL. 66055 func test_config_pagecache(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:885:26: */ 66056 bp := tls.Alloc(56) 66057 defer tls.Free(56) 66058 66059 // var sz int32 at bp+48, 4 66060 66061 // var N int32 at bp+52, 4 66062 66063 var pRes uintptr 66064 if objc != 3 { 66065 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32361 /* "SIZE N" */) 66066 return TCL_ERROR 66067 } 66068 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+48 /* &sz */) != 0 { 66069 return TCL_ERROR 66070 } 66071 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+52 /* &N */) != 0 { 66072 return TCL_ERROR 66073 } 66074 libc.Xfree(tls, buf1) 66075 buf1 = uintptr(0) 66076 66077 // Set the return value 66078 pRes = tcl.XTcl_NewObj(tls) 66079 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pRes, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3Config.FszPage)) 66080 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pRes, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3Config.FnPage)) 66081 tcl.XTcl_SetObjResult(tls, interp, pRes) 66082 66083 if *(*int32)(unsafe.Pointer(bp + 48 /* sz */)) < 0 { 66084 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_PAGECACHE, libc.VaList(bp, uintptr(0), 0, 0)) 66085 } else { 66086 buf1 = libc.Xmalloc(tls, (uint64(*(*int32)(unsafe.Pointer(bp + 48 /* sz */)) * *(*int32)(unsafe.Pointer(bp + 52 /* N */))))) 66087 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_PAGECACHE, libc.VaList(bp+24, buf1, *(*int32)(unsafe.Pointer(bp + 48 /* sz */)), *(*int32)(unsafe.Pointer(bp + 52 /* N */)))) 66088 } 66089 return TCL_OK 66090 } 66091 66092 var buf1 uintptr = uintptr(0) /* test_malloc.c:893:15 */ 66093 66094 // Usage: sqlite3_config_alt_pcache INSTALL_FLAG DISCARD_CHANCE PRNG_SEED 66095 // 66096 // Set up the alternative test page cache. Install if INSTALL_FLAG is 66097 // true and uninstall (reverting to the default page cache) if INSTALL_FLAG 66098 // is false. DISCARD_CHANGE is an integer between 0 and 100 inclusive 66099 // which determines the chance of discarding a page when unpinned. 100 66100 // is certainty. 0 is never. PRNG_SEED is the pseudo-random number generator 66101 // seed. 66102 func test_alt_pcache(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:928:26: */ 66103 bp := tls.Alloc(32) 66104 defer tls.Free(32) 66105 66106 // var installFlag int32 at bp+16, 4 66107 66108 *(*int32)(unsafe.Pointer(bp + 20 /* discardChance */)) = 0 66109 *(*int32)(unsafe.Pointer(bp + 24 /* prngSeed */)) = 0 66110 *(*int32)(unsafe.Pointer(bp + 28 /* highStress */)) = 0 66111 if (objc < 2) || (objc > 5) { 66112 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, 66113 ts+32368 /* "INSTALLFLAG DISC..." */) 66114 return TCL_ERROR 66115 } 66116 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+16 /* &installFlag */) != 0 { 66117 return TCL_ERROR 66118 } 66119 if (objc >= 3) && (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+20 /* &discardChance */) != 0) { 66120 return TCL_ERROR 66121 } 66122 if (objc >= 4) && (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+24 /* &prngSeed */) != 0) { 66123 return TCL_ERROR 66124 } 66125 if (objc >= 5) && (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+28 /* &highStress */) != 0) { 66126 return TCL_ERROR 66127 } 66128 if (*(*int32)(unsafe.Pointer(bp + 20 /* discardChance */)) < 0) || (*(*int32)(unsafe.Pointer(bp + 20 /* discardChance */)) > 100) { 66129 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+32415, /* "discard-chance s..." */ 66130 uintptr(0))) 66131 return TCL_ERROR 66132 } 66133 installTestPCache(tls, *(*int32)(unsafe.Pointer(bp + 16 /* installFlag */)), uint32(*(*int32)(unsafe.Pointer(bp + 20 /* discardChance */))), uint32(*(*int32)(unsafe.Pointer(bp + 24 /* prngSeed */))), 66134 uint32(*(*int32)(unsafe.Pointer(bp + 28 /* highStress */)))) 66135 return TCL_OK 66136 } 66137 66138 // Usage: sqlite3_config_memstatus BOOLEAN 66139 // 66140 // Enable or disable memory status reporting using SQLITE_CONFIG_MEMSTATUS. 66141 func test_config_memstatus(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:969:26: */ 66142 bp := tls.Alloc(12) 66143 defer tls.Free(12) 66144 66145 // var enable int32 at bp+8, 4 66146 66147 var rc int32 66148 if objc != 2 { 66149 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17888 /* "BOOLEAN" */) 66150 return TCL_ERROR 66151 } 66152 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+8 /* &enable */) != 0 { 66153 return TCL_ERROR 66154 } 66155 rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MEMSTATUS, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* enable */)))) 66156 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) 66157 return TCL_OK 66158 } 66159 66160 // Usage: sqlite3_config_lookaside SIZE COUNT 66161 // 66162 func test_config_lookaside(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:990:26: */ 66163 bp := tls.Alloc(24) 66164 defer tls.Free(24) 66165 66166 // var sz int32 at bp+16, 4 66167 66168 // var cnt int32 at bp+20, 4 66169 66170 var pRet uintptr 66171 if objc != 3 { 66172 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32458 /* "SIZE COUNT" */) 66173 return TCL_ERROR 66174 } 66175 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+16 /* &sz */) != 0 { 66176 return TCL_ERROR 66177 } 66178 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+20 /* &cnt */) != 0 { 66179 return TCL_ERROR 66180 } 66181 pRet = tcl.XTcl_NewObj(tls) 66182 tcl.XTcl_ListObjAppendElement(tls, 66183 interp, pRet, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3Config.FszLookaside)) 66184 tcl.XTcl_ListObjAppendElement(tls, 66185 interp, pRet, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3Config.FnLookaside)) 66186 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_LOOKASIDE, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 16 /* sz */)), *(*int32)(unsafe.Pointer(bp + 20 /* cnt */)))) 66187 tcl.XTcl_SetObjResult(tls, interp, pRet) 66188 return TCL_OK 66189 } 66190 66191 // Usage: sqlite3_db_config_lookaside CONNECTION BUFID SIZE COUNT 66192 // 66193 // There are two static buffers with BUFID 1 and 2. Each static buffer 66194 // is 10KB in size. A BUFID of 0 indicates that the buffer should be NULL 66195 // which will cause sqlite3_db_config() to allocate space on its own. 66196 func test_db_config_lookaside(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:1024:26: */ 66197 bp := tls.Alloc(84) 66198 defer tls.Free(84) 66199 66200 var rc int32 66201 // var sz int32 at bp+76, 4 66202 66203 // var cnt int32 at bp+80, 4 66204 66205 // var db uintptr at bp+64, 8 66206 66207 // var bufid int32 at bp+72, 4 66208 66209 if objc != 5 { 66210 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32469 /* "BUFID SIZE COUNT" */) 66211 return TCL_ERROR 66212 } 66213 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+64 /* &db */) != 0 { 66214 return TCL_ERROR 66215 } 66216 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+72 /* &bufid */) != 0 { 66217 return TCL_ERROR 66218 } 66219 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+76 /* &sz */) != 0 { 66220 return TCL_ERROR 66221 } 66222 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+80 /* &cnt */) != 0 { 66223 return TCL_ERROR 66224 } 66225 if *(*int32)(unsafe.Pointer(bp + 72 /* bufid */)) == 0 { 66226 rc = sqlite3.Xsqlite3_db_config(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* db */)), SQLITE_DBCONFIG_LOOKASIDE, libc.VaList(bp, uintptr(0), *(*int32)(unsafe.Pointer(bp + 76 /* sz */)), *(*int32)(unsafe.Pointer(bp + 80 /* cnt */)))) 66227 } else if ((*(*int32)(unsafe.Pointer(bp + 72 /* bufid */)) >= 1) && (*(*int32)(unsafe.Pointer(bp + 72 /* bufid */)) <= 2)) && ((uint64(*(*int32)(unsafe.Pointer(bp + 76 /* sz */)) * *(*int32)(unsafe.Pointer(bp + 80 /* cnt */)))) <= uint64(unsafe.Sizeof([10000]int8{}))) { 66228 rc = sqlite3.Xsqlite3_db_config(tls, *(*uintptr)(unsafe.Pointer(bp + 64 /* db */)), SQLITE_DBCONFIG_LOOKASIDE, libc.VaList(bp+24, (uintptr(unsafe.Pointer(&azBuf))+uintptr(*(*int32)(unsafe.Pointer(bp + 72 /* bufid */)))*10000), *(*int32)(unsafe.Pointer(bp + 76 /* sz */)), *(*int32)(unsafe.Pointer(bp + 80 /* cnt */)))) 66229 } else { 66230 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+32486 /* "illegal argument..." */, uintptr(0))) 66231 return TCL_ERROR 66232 } 66233 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) 66234 return TCL_OK 66235 } 66236 66237 var azBuf [2][10000]int8 /* test_malloc.c:1034:15: */ 66238 66239 // Usage: sqlite3_config_heap NBYTE NMINALLOC 66240 func test_config_heap(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:1059:26: */ 66241 bp := tls.Alloc(56) 66242 defer tls.Free(56) 66243 // Use this memory 66244 // var nByte int32 at bp+48, 4 66245 // Size of buffer to pass to sqlite3_config() 66246 // var nMinAlloc int32 at bp+52, 4 66247 // Size of minimum allocation 66248 var rc int32 // Return code of sqlite3_config() 66249 66250 var aArg uintptr = (objv + 1*8) 66251 var nArg int32 = (objc - 1) 66252 66253 if nArg != 2 { 66254 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32524 /* "NBYTE NMINALLOC" */) 66255 return TCL_ERROR 66256 } 66257 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(aArg)), bp+48 /* &nByte */) != 0 { 66258 return TCL_ERROR 66259 } 66260 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(aArg + 1*8)), bp+52 /* &nMinAlloc */) != 0 { 66261 return TCL_ERROR 66262 } 66263 66264 if *(*int32)(unsafe.Pointer(bp + 48 /* nByte */)) == 0 { 66265 libc.Xfree(tls, zBuf) 66266 zBuf = uintptr(0) 66267 rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_HEAP, libc.VaList(bp, uintptr(0), 0, 0)) 66268 } else { 66269 zBuf = libc.Xrealloc(tls, zBuf, uint64(*(*int32)(unsafe.Pointer(bp + 48 /* nByte */)))) 66270 rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_HEAP, libc.VaList(bp+24, zBuf, *(*int32)(unsafe.Pointer(bp + 48 /* nByte */)), *(*int32)(unsafe.Pointer(bp + 52 /* nMinAlloc */)))) 66271 } 66272 66273 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 66274 return TCL_OK 66275 } 66276 66277 var zBuf uintptr /* test_malloc.c:1065:15: */ 66278 66279 // Usage: sqlite3_config_heap_size NBYTE 66280 func test_config_heap_size(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:1096:26: */ 66281 bp := tls.Alloc(12) 66282 defer tls.Free(12) 66283 66284 // var nByte int32 at bp+8, 4 66285 // Size to pass to sqlite3_config() 66286 var rc int32 // Return code of sqlite3_config() 66287 66288 var aArg uintptr = (objv + 1*8) 66289 var nArg int32 = (objc - 1) 66290 66291 if nArg != 1 { 66292 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+15902 /* "NBYTE" */) 66293 return TCL_ERROR 66294 } 66295 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(aArg)), bp+8 /* &nByte */) != 0 { 66296 return TCL_ERROR 66297 } 66298 66299 rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_WIN32_HEAPSIZE, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* nByte */)))) 66300 66301 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 66302 return TCL_OK 66303 } 66304 66305 // Usage: sqlite3_config_error [DB] 66306 // 66307 // Invoke sqlite3_config() or sqlite3_db_config() with invalid 66308 // opcodes and verify that they return errors. 66309 func test_config_error(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:1126:26: */ 66310 bp := tls.Alloc(40) 66311 defer tls.Free(40) 66312 66313 // var db uintptr at bp+32, 8 66314 66315 if (objc != 2) && (objc != 1) { 66316 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32540 /* "[DB]" */) 66317 return TCL_ERROR 66318 } 66319 if objc == 2 { 66320 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+32 /* &db */) != 0 { 66321 return TCL_ERROR 66322 } 66323 if sqlite3.Xsqlite3_db_config(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* db */)), 99999, 0) != SQLITE_ERROR { 66324 tcl.XTcl_AppendResult(tls, interp, 66325 libc.VaList(bp, ts+32545, /* "sqlite3_db_confi..." */ 66326 uintptr(0))) 66327 return TCL_ERROR 66328 } 66329 } else { 66330 if sqlite3.Xsqlite3_config(tls, 99999, 0) != SQLITE_ERROR { 66331 tcl.XTcl_AppendResult(tls, interp, 66332 libc.VaList(bp+16, ts+32603, /* "sqlite3_config(9..." */ 66333 uintptr(0))) 66334 return TCL_ERROR 66335 } 66336 } 66337 return TCL_OK 66338 } 66339 66340 // Usage: sqlite3_config_uri BOOLEAN 66341 // 66342 // Enables or disables interpretation of URI parameters by default using 66343 // SQLITE_CONFIG_URI. 66344 func test_config_uri(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:1164:26: */ 66345 bp := tls.Alloc(12) 66346 defer tls.Free(12) 66347 66348 var rc int32 66349 // var bOpenUri int32 at bp+8, 4 66350 66351 if objc != 2 { 66352 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18611 /* "BOOL" */) 66353 return TCL_ERROR 66354 } 66355 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+8 /* &bOpenUri */) != 0 { 66356 return TCL_ERROR 66357 } 66358 66359 rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_URI, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* bOpenUri */)))) 66360 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 66361 66362 return TCL_OK 66363 } 66364 66365 // Usage: sqlite3_config_cis BOOLEAN 66366 // 66367 // Enables or disables the use of the covering-index scan optimization. 66368 // SQLITE_CONFIG_COVERING_INDEX_SCAN. 66369 func test_config_cis(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:1193:26: */ 66370 bp := tls.Alloc(12) 66371 defer tls.Free(12) 66372 66373 var rc int32 66374 // var bUseCis int32 at bp+8, 4 66375 66376 if objc != 2 { 66377 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18611 /* "BOOL" */) 66378 return TCL_ERROR 66379 } 66380 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+8 /* &bUseCis */) != 0 { 66381 return TCL_ERROR 66382 } 66383 66384 rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_COVERING_INDEX_SCAN, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* bUseCis */)))) 66385 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 66386 66387 return TCL_OK 66388 } 66389 66390 // Usage: sqlite3_config_pmasz INTEGER 66391 // 66392 // Set the minimum PMA size. 66393 func test_config_pmasz(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:1221:26: */ 66394 bp := tls.Alloc(12) 66395 defer tls.Free(12) 66396 66397 var rc int32 66398 // var iPmaSz int32 at bp+8, 4 66399 66400 if objc != 2 { 66401 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+18611 /* "BOOL" */) 66402 return TCL_ERROR 66403 } 66404 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+8 /* &iPmaSz */) != 0 { 66405 return TCL_ERROR 66406 } 66407 66408 rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_PMASZ, libc.VaList(bp, *(*int32)(unsafe.Pointer(bp + 8 /* iPmaSz */)))) 66409 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 66410 66411 return TCL_OK 66412 } 66413 66414 // Usage: sqlite3_dump_memsys3 FILENAME 66415 // sqlite3_dump_memsys5 FILENAME 66416 // 66417 // Write a summary of unfreed memsys3 allocations to FILENAME. 66418 func test_dump_memsys3(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:1251:26: */ 66419 if objc != 2 { 66420 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32266 /* "FILENAME" */) 66421 return TCL_ERROR 66422 } 66423 66424 switch int32(clientData) { 66425 case 3: 66426 { 66427 66428 } 66429 fallthrough 66430 case 5: 66431 { 66432 66433 } 66434 } 66435 return TCL_OK 66436 } 66437 66438 // Usage: sqlite3_status OPCODE RESETFLAG 66439 // 66440 // Return a list of three elements which are the sqlite3_status() return 66441 // code, the current value, and the high-water mark value. 66442 func test_status(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:1287:26: */ 66443 bp := tls.Alloc(16) 66444 defer tls.Free(16) 66445 66446 var rc int32 66447 // var iValue int32 at bp+8, 4 66448 66449 // var mxValue int32 at bp+12, 4 66450 66451 var i int32 66452 *(*int32)(unsafe.Pointer(bp /* op */)) = 0 66453 // var resetFlag int32 at bp+4, 4 66454 66455 var zOpName uintptr 66456 var pResult uintptr 66457 if objc != 3 { 66458 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32654 /* "PARAMETER RESETF..." */) 66459 return TCL_ERROR 66460 } 66461 zOpName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 66462 for i = 0; i < (int32(uint64(unsafe.Sizeof(aOp1)) / uint64(unsafe.Sizeof(struct { 66463 FzName uintptr 66464 Fop int32 66465 _ [4]byte 66466 }{})))); i++ { 66467 if libc.Xstrcmp(tls, aOp1[i].FzName, zOpName) == 0 { 66468 *(*int32)(unsafe.Pointer(bp /* op */)) = aOp1[i].Fop 66469 break 66470 } 66471 } 66472 if i >= (int32(uint64(unsafe.Sizeof(aOp1)) / uint64(unsafe.Sizeof(struct { 66473 FzName uintptr 66474 Fop int32 66475 _ [4]byte 66476 }{})))) { 66477 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &op */) != 0 { 66478 return TCL_ERROR 66479 } 66480 } 66481 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+4 /* &resetFlag */) != 0 { 66482 return TCL_ERROR 66483 } 66484 *(*int32)(unsafe.Pointer(bp + 8 /* iValue */)) = 0 66485 *(*int32)(unsafe.Pointer(bp + 12 /* mxValue */)) = 0 66486 rc = sqlite3.Xsqlite3_status(tls, *(*int32)(unsafe.Pointer(bp /* op */)), bp+8 /* &iValue */, bp+12 /* &mxValue */, *(*int32)(unsafe.Pointer(bp + 4 /* resetFlag */))) 66487 pResult = tcl.XTcl_NewObj(tls) 66488 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pResult, tcl.XTcl_NewIntObj(tls, rc)) 66489 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pResult, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 8 /* iValue */)))) 66490 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pResult, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 12 /* mxValue */)))) 66491 tcl.XTcl_SetObjResult(tls, interp, pResult) 66492 return TCL_OK 66493 } 66494 66495 var aOp1 = [10]struct { 66496 FzName uintptr 66497 Fop int32 66498 _ [4]byte 66499 }{ 66500 {FzName: ts + 32674 /* "SQLITE_STATUS_ME..." */}, 66501 {FzName: ts + 32700 /* "SQLITE_STATUS_MA..." */, Fop: SQLITE_STATUS_MALLOC_SIZE}, 66502 {FzName: ts + 32726 /* "SQLITE_STATUS_PA..." */, Fop: SQLITE_STATUS_PAGECACHE_USED}, 66503 {FzName: ts + 32755 /* "SQLITE_STATUS_PA..." */, Fop: SQLITE_STATUS_PAGECACHE_OVERFLOW}, 66504 {FzName: ts + 32788 /* "SQLITE_STATUS_PA..." */, Fop: SQLITE_STATUS_PAGECACHE_SIZE}, 66505 {FzName: ts + 32817 /* "SQLITE_STATUS_SC..." */, Fop: SQLITE_STATUS_SCRATCH_USED}, 66506 {FzName: ts + 32844 /* "SQLITE_STATUS_SC..." */, Fop: SQLITE_STATUS_SCRATCH_OVERFLOW}, 66507 {FzName: ts + 32875 /* "SQLITE_STATUS_SC..." */, Fop: SQLITE_STATUS_SCRATCH_SIZE}, 66508 {FzName: ts + 32902 /* "SQLITE_STATUS_PA..." */, Fop: SQLITE_STATUS_PARSER_STACK}, 66509 {FzName: ts + 32929 /* "SQLITE_STATUS_MA..." */, Fop: SQLITE_STATUS_MALLOC_COUNT}, 66510 } /* test_malloc.c:1299:5 */ 66511 66512 // Usage: sqlite3_db_status DATABASE OPCODE RESETFLAG 66513 // 66514 // Return a list of three elements which are the sqlite3_db_status() return 66515 // code, the current value, and the high-water mark value. 66516 func test_db_status(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:1344:26: */ 66517 bp := tls.Alloc(24) 66518 defer tls.Free(24) 66519 66520 var rc int32 66521 // var iValue int32 at bp+16, 4 66522 66523 // var mxValue int32 at bp+20, 4 66524 66525 var i int32 66526 *(*int32)(unsafe.Pointer(bp + 8 /* op */)) = 0 66527 // var resetFlag int32 at bp+12, 4 66528 66529 var zOpName uintptr 66530 // var db uintptr at bp, 8 66531 66532 var pResult uintptr 66533 if objc != 4 { 66534 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32956 /* "DB PARAMETER RES..." */) 66535 return TCL_ERROR 66536 } 66537 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 66538 return TCL_ERROR 66539 } 66540 zOpName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 66541 if libc.Xmemcmp(tls, zOpName, ts+32979 /* "SQLITE_" */, uint64(7)) == 0 { 66542 zOpName += uintptr(7) 66543 } 66544 if libc.Xmemcmp(tls, zOpName, ts+32987 /* "DBSTATUS_" */, uint64(9)) == 0 { 66545 zOpName += uintptr(9) 66546 } 66547 for i = 0; i < (int32(uint64(unsafe.Sizeof(aOp2)) / uint64(unsafe.Sizeof(struct { 66548 FzName uintptr 66549 Fop int32 66550 _ [4]byte 66551 }{})))); i++ { 66552 if libc.Xstrcmp(tls, aOp2[i].FzName, zOpName) == 0 { 66553 *(*int32)(unsafe.Pointer(bp + 8 /* op */)) = aOp2[i].Fop 66554 break 66555 } 66556 } 66557 if i >= (int32(uint64(unsafe.Sizeof(aOp2)) / uint64(unsafe.Sizeof(struct { 66558 FzName uintptr 66559 Fop int32 66560 _ [4]byte 66561 }{})))) { 66562 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+8 /* &op */) != 0 { 66563 return TCL_ERROR 66564 } 66565 } 66566 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+12 /* &resetFlag */) != 0 { 66567 return TCL_ERROR 66568 } 66569 *(*int32)(unsafe.Pointer(bp + 16 /* iValue */)) = 0 66570 *(*int32)(unsafe.Pointer(bp + 20 /* mxValue */)) = 0 66571 rc = sqlite3.Xsqlite3_db_status(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), *(*int32)(unsafe.Pointer(bp + 8 /* op */)), bp+16 /* &iValue */, bp+20 /* &mxValue */, *(*int32)(unsafe.Pointer(bp + 12 /* resetFlag */))) 66572 pResult = tcl.XTcl_NewObj(tls) 66573 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pResult, tcl.XTcl_NewIntObj(tls, rc)) 66574 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pResult, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 16 /* iValue */)))) 66575 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pResult, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer(bp + 20 /* mxValue */)))) 66576 tcl.XTcl_SetObjResult(tls, interp, pResult) 66577 return TCL_OK 66578 } 66579 66580 var aOp2 = [13]struct { 66581 FzName uintptr 66582 Fop int32 66583 _ [4]byte 66584 }{ 66585 {FzName: ts + 32997 /* "LOOKASIDE_USED" */}, 66586 {FzName: ts + 33012 /* "CACHE_USED" */, Fop: SQLITE_DBSTATUS_CACHE_USED}, 66587 {FzName: ts + 33023 /* "SCHEMA_USED" */, Fop: SQLITE_DBSTATUS_SCHEMA_USED}, 66588 {FzName: ts + 33035 /* "STMT_USED" */, Fop: SQLITE_DBSTATUS_STMT_USED}, 66589 {FzName: ts + 33045 /* "LOOKASIDE_HIT" */, Fop: SQLITE_DBSTATUS_LOOKASIDE_HIT}, 66590 {FzName: ts + 33059 /* "LOOKASIDE_MISS_S..." */, Fop: SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE}, 66591 {FzName: ts + 33079 /* "LOOKASIDE_MISS_F..." */, Fop: SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL}, 66592 {FzName: ts + 33099 /* "CACHE_HIT" */, Fop: SQLITE_DBSTATUS_CACHE_HIT}, 66593 {FzName: ts + 33109 /* "CACHE_MISS" */, Fop: SQLITE_DBSTATUS_CACHE_MISS}, 66594 {FzName: ts + 33120 /* "CACHE_WRITE" */, Fop: SQLITE_DBSTATUS_CACHE_WRITE}, 66595 {FzName: ts + 33132 /* "DEFERRED_FKS" */, Fop: SQLITE_DBSTATUS_DEFERRED_FKS}, 66596 {FzName: ts + 33145 /* "CACHE_USED_SHARE..." */, Fop: SQLITE_DBSTATUS_CACHE_USED_SHARED}, 66597 {FzName: ts + 33163 /* "CACHE_SPILL" */, Fop: SQLITE_DBSTATUS_CACHE_SPILL}, 66598 } /* test_malloc.c:1358:5 */ 66599 66600 // install_malloc_faultsim BOOLEAN 66601 func test_install_malloc_faultsim(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:1406:26: */ 66602 bp := tls.Alloc(4) 66603 defer tls.Free(4) 66604 66605 var rc int32 66606 // var isInstall int32 at bp, 4 66607 66608 if objc != 2 { 66609 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17888 /* "BOOLEAN" */) 66610 return TCL_ERROR 66611 } 66612 if TCL_OK != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &isInstall */) { 66613 return TCL_ERROR 66614 } 66615 rc = faultsimInstall(tls, *(*int32)(unsafe.Pointer(bp /* isInstall */))) 66616 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 66617 return TCL_OK 66618 } 66619 66620 // sqlite3_install_memsys3 66621 func test_install_memsys3(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:1430:26: */ 66622 var rc int32 = SQLITE_MISUSE 66623 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 66624 return TCL_OK 66625 } 66626 66627 func test_vfs_oom_test(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_malloc.c:1445:26: */ 66628 bp := tls.Alloc(4) 66629 defer tls.Free(4) 66630 66631 if objc > 2 { 66632 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+33175 /* "?INTEGER?" */) 66633 return TCL_ERROR 66634 } else if objc == 2 { 66635 // var iNew int32 at bp, 4 66636 66637 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &iNew */) != 0 { 66638 return TCL_ERROR 66639 } 66640 sqlite3.Xsqlite3_memdebug_vfs_oom_test = *(*int32)(unsafe.Pointer(bp /* iNew */)) 66641 } 66642 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, sqlite3.Xsqlite3_memdebug_vfs_oom_test)) 66643 return TCL_OK 66644 } 66645 66646 // Register commands with the TCL interpreter. 66647 func Sqlitetest_malloc_Init(tls *libc.TLS, interp uintptr) int32 { /* test_malloc.c:1467:5: */ 66648 var i int32 66649 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aObjCmd11)) / uint64(unsafe.Sizeof(struct { 66650 FzName uintptr 66651 FxProc uintptr 66652 FclientData int32 66653 _ [4]byte 66654 }{}))); i++ { 66655 var c ClientData = uintptr(intptr_t(aObjCmd11[i].FclientData)) 66656 tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd11[i].FzName, aObjCmd11[i].FxProc, c, uintptr(0)) 66657 } 66658 return TCL_OK 66659 } 66660 66661 var aObjCmd11 = [32]struct { 66662 FzName uintptr 66663 FxProc uintptr 66664 FclientData int32 66665 _ [4]byte 66666 }{ 66667 {FzName: ts + 27537 /* "sqlite3_malloc" */, FxProc: 0}, 66668 {FzName: ts + 27552 /* "sqlite3_realloc" */, FxProc: 0}, 66669 {FzName: ts + 33185 /* "sqlite3_free" */, FxProc: 0}, 66670 {FzName: ts + 33198 /* "memset" */, FxProc: 0}, 66671 {FzName: ts + 33205 /* "memget" */, FxProc: 0}, 66672 {FzName: ts + 33212 /* "sqlite3_memory_u..." */, FxProc: 0}, 66673 {FzName: ts + 33232 /* "sqlite3_memory_h..." */, FxProc: 0}, 66674 {FzName: ts + 33257 /* "sqlite3_memdebug..." */, FxProc: 0}, 66675 {FzName: ts + 33284 /* "sqlite3_memdebug..." */, FxProc: 0}, 66676 {FzName: ts + 33306 /* "sqlite3_memdebug..." */, FxProc: 0}, 66677 {FzName: ts + 33328 /* "sqlite3_memdebug..." */, FxProc: 0}, 66678 {FzName: ts + 33353 /* "sqlite3_memdebug..." */, FxProc: 0}, 66679 {FzName: ts + 33379 /* "sqlite3_memdebug..." */, FxProc: 0}, 66680 {FzName: ts + 33409 /* "sqlite3_memdebug..." */, FxProc: 0}, 66681 {FzName: ts + 33430 /* "sqlite3_config_p..." */, FxProc: 0}, 66682 {FzName: ts + 33455 /* "sqlite3_config_a..." */, FxProc: 0}, 66683 {FzName: ts + 33481 /* "sqlite3_status" */, FxProc: 0}, 66684 {FzName: ts + 33496 /* "sqlite3_db_statu..." */, FxProc: 0}, 66685 {FzName: ts + 33514 /* "install_malloc_f..." */, FxProc: 0}, 66686 {FzName: ts + 33538 /* "sqlite3_config_h..." */, FxProc: 0}, 66687 {FzName: ts + 33558 /* "sqlite3_config_h..." */, FxProc: 0}, 66688 {FzName: ts + 33583 /* "sqlite3_config_m..." */, FxProc: 0}, 66689 {FzName: ts + 33608 /* "sqlite3_config_l..." */, FxProc: 0}, 66690 {FzName: ts + 33633 /* "sqlite3_config_e..." */, FxProc: 0}, 66691 {FzName: ts + 33654 /* "sqlite3_config_u..." */, FxProc: 0}, 66692 {FzName: ts + 33673 /* "sqlite3_config_c..." */, FxProc: 0}, 66693 {FzName: ts + 33692 /* "sqlite3_config_p..." */, FxProc: 0}, 66694 {FzName: ts + 33713 /* "sqlite3_db_confi..." */, FxProc: 0}, 66695 {FzName: ts + 33741 /* "sqlite3_dump_mem..." */, FxProc: 0, FclientData: 3}, 66696 {FzName: ts + 33762 /* "sqlite3_dump_mem..." */, FxProc: 0, FclientData: 5}, 66697 {FzName: ts + 33783 /* "sqlite3_install_..." */, FxProc: 0}, 66698 {FzName: ts + 33807 /* "sqlite3_memdebug..." */, FxProc: 0}, 66699 } /* test_malloc.c:1472:5 */ 66700 66701 // Some versions of <linux/posix_types.h> define this macros. 66702 // It's easier to assume 8-bit bytes than to get CHAR_BIT. 66703 66704 // fd_set for select and pselect. 66705 type fd_set4 = struct{ F__fds_bits [16]int64 } /* select.h:70:5 */ 66706 66707 // end block for C++ 66708 66709 // Local Variables: 66710 // mode: c 66711 // c-basic-offset: 4 66712 // fill-column: 78 66713 // End: 66714 66715 // This code implements the MD5 message-digest algorithm. 66716 // The algorithm is due to Ron Rivest. This code was 66717 // written by Colin Plumb in 1993, no copyright is claimed. 66718 // This code is in the public domain; do with it what you wish. 66719 // 66720 // Equivalent code is available from RSA Data Security, Inc. 66721 // This code has been tested against that, and is equivalent, 66722 // except that you don't need to include two pages of legalese 66723 // with every copy. 66724 // 66725 // To compute the message digest of a chunk of bytes, declare an 66726 // MD5Context structure, pass it to MD5Init, call MD5Update as 66727 // needed on buffers full of bytes, and then call MD5Final, which 66728 // will fill a supplied 16-byte array with the digest. 66729 66730 // If compiled on a machine that doesn't have a 32-bit integer, 66731 // you just set "uint32" to the appropriate datatype for an 66732 // unsigned 32-bit integer. For example: 66733 // 66734 // cc -Duint32='unsigned long' md5.c 66735 // 66736 66737 type MD5Context1 = struct { 66738 FisInit int32 66739 Fbuf [4]uint32 66740 Fbits [2]uint32 66741 Fin [64]uint8 66742 } /* test_md5.c:57:1 */ 66743 66744 type MD5Context = MD5Context1 /* test_md5.c:63:27 */ 66745 66746 // Note: this code is harmless on little-endian machines. 66747 func byteReverse(tls *libc.TLS, buf uintptr, longs uint32) { /* test_md5.c:68:13: */ 66748 var t uint32 66749 for ok := true; ok; ok = libc.PreDecUint32(&longs, 1) != 0 { 66750 t = ((((uint32(*(*uint8)(unsafe.Pointer(buf + 3))) << 8) | uint32(*(*uint8)(unsafe.Pointer(buf + 2)))) << 16) | ((uint32(*(*uint8)(unsafe.Pointer(buf + 1))) << 8) | uint32(*(*uint8)(unsafe.Pointer(buf))))) 66751 *(*uint32)(unsafe.Pointer(buf)) = t 66752 buf += uintptr(4) 66753 } 66754 } 66755 66756 // The four core functions - F1 is optimized somewhat 66757 66758 // #define F1(x, y, z) (x & y | ~x & z) 66759 66760 // This is the central step in the MD5 algorithm. 66761 66762 // The core of the MD5 algorithm, this alters an existing MD5 hash to 66763 // reflect the addition of 16 longwords of new data. MD5Update blocks 66764 // the data and converts bytes into longwords for this routine. 66765 func MD5Transform(tls *libc.TLS, buf uintptr, in uintptr) { /* test_md5.c:94:13: */ 66766 var a uint32 66767 var b uint32 66768 var c uint32 66769 var d uint32 66770 66771 a = *(*uint32)(unsafe.Pointer(buf)) 66772 b = *(*uint32)(unsafe.Pointer(buf + 1*4)) 66773 c = *(*uint32)(unsafe.Pointer(buf + 2*4)) 66774 d = *(*uint32)(unsafe.Pointer(buf + 3*4)) 66775 66776 a = a + (((d ^ (b & (c ^ d))) + *(*uint32)(unsafe.Pointer(in))) + 0xd76aa478) 66777 a = ((a << 7) | (a >> (32 - 7))) 66778 a = a + (b) 66779 d = d + (((c ^ (a & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + 1*4))) + 0xe8c7b756) 66780 d = ((d << 12) | (d >> (32 - 12))) 66781 d = d + (a) 66782 c = c + (((b ^ (d & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + 2*4))) + uint32(0x242070db)) 66783 c = ((c << 17) | (c >> (32 - 17))) 66784 c = c + (d) 66785 b = b + (((a ^ (c & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + 3*4))) + 0xc1bdceee) 66786 b = ((b << 22) | (b >> (32 - 22))) 66787 b = b + (c) 66788 a = a + (((d ^ (b & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + 4*4))) + 0xf57c0faf) 66789 a = ((a << 7) | (a >> (32 - 7))) 66790 a = a + (b) 66791 d = d + (((c ^ (a & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + 5*4))) + uint32(0x4787c62a)) 66792 d = ((d << 12) | (d >> (32 - 12))) 66793 d = d + (a) 66794 c = c + (((b ^ (d & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + 6*4))) + 0xa8304613) 66795 c = ((c << 17) | (c >> (32 - 17))) 66796 c = c + (d) 66797 b = b + (((a ^ (c & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + 7*4))) + 0xfd469501) 66798 b = ((b << 22) | (b >> (32 - 22))) 66799 b = b + (c) 66800 a = a + (((d ^ (b & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + 8*4))) + uint32(0x698098d8)) 66801 a = ((a << 7) | (a >> (32 - 7))) 66802 a = a + (b) 66803 d = d + (((c ^ (a & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + 9*4))) + 0x8b44f7af) 66804 d = ((d << 12) | (d >> (32 - 12))) 66805 d = d + (a) 66806 c = c + (((b ^ (d & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + 10*4))) + 0xffff5bb1) 66807 c = ((c << 17) | (c >> (32 - 17))) 66808 c = c + (d) 66809 b = b + (((a ^ (c & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + 11*4))) + 0x895cd7be) 66810 b = ((b << 22) | (b >> (32 - 22))) 66811 b = b + (c) 66812 a = a + (((d ^ (b & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + 12*4))) + uint32(0x6b901122)) 66813 a = ((a << 7) | (a >> (32 - 7))) 66814 a = a + (b) 66815 d = d + (((c ^ (a & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + 13*4))) + 0xfd987193) 66816 d = ((d << 12) | (d >> (32 - 12))) 66817 d = d + (a) 66818 c = c + (((b ^ (d & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + 14*4))) + 0xa679438e) 66819 c = ((c << 17) | (c >> (32 - 17))) 66820 c = c + (d) 66821 b = b + (((a ^ (c & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + 15*4))) + uint32(0x49b40821)) 66822 b = ((b << 22) | (b >> (32 - 22))) 66823 b = b + (c) 66824 66825 a = a + (((c ^ (d & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + 1*4))) + 0xf61e2562) 66826 a = ((a << 5) | (a >> (32 - 5))) 66827 a = a + (b) 66828 d = d + (((b ^ (c & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + 6*4))) + 0xc040b340) 66829 d = ((d << 9) | (d >> (32 - 9))) 66830 d = d + (a) 66831 c = c + (((a ^ (b & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + 11*4))) + uint32(0x265e5a51)) 66832 c = ((c << 14) | (c >> (32 - 14))) 66833 c = c + (d) 66834 b = b + (((d ^ (a & (c ^ d))) + *(*uint32)(unsafe.Pointer(in))) + 0xe9b6c7aa) 66835 b = ((b << 20) | (b >> (32 - 20))) 66836 b = b + (c) 66837 a = a + (((c ^ (d & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + 5*4))) + 0xd62f105d) 66838 a = ((a << 5) | (a >> (32 - 5))) 66839 a = a + (b) 66840 d = d + (((b ^ (c & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + 10*4))) + uint32(0x02441453)) 66841 d = ((d << 9) | (d >> (32 - 9))) 66842 d = d + (a) 66843 c = c + (((a ^ (b & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + 15*4))) + 0xd8a1e681) 66844 c = ((c << 14) | (c >> (32 - 14))) 66845 c = c + (d) 66846 b = b + (((d ^ (a & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + 4*4))) + 0xe7d3fbc8) 66847 b = ((b << 20) | (b >> (32 - 20))) 66848 b = b + (c) 66849 a = a + (((c ^ (d & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + 9*4))) + uint32(0x21e1cde6)) 66850 a = ((a << 5) | (a >> (32 - 5))) 66851 a = a + (b) 66852 d = d + (((b ^ (c & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + 14*4))) + 0xc33707d6) 66853 d = ((d << 9) | (d >> (32 - 9))) 66854 d = d + (a) 66855 c = c + (((a ^ (b & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + 3*4))) + 0xf4d50d87) 66856 c = ((c << 14) | (c >> (32 - 14))) 66857 c = c + (d) 66858 b = b + (((d ^ (a & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + 8*4))) + uint32(0x455a14ed)) 66859 b = ((b << 20) | (b >> (32 - 20))) 66860 b = b + (c) 66861 a = a + (((c ^ (d & (b ^ c))) + *(*uint32)(unsafe.Pointer(in + 13*4))) + 0xa9e3e905) 66862 a = ((a << 5) | (a >> (32 - 5))) 66863 a = a + (b) 66864 d = d + (((b ^ (c & (a ^ b))) + *(*uint32)(unsafe.Pointer(in + 2*4))) + 0xfcefa3f8) 66865 d = ((d << 9) | (d >> (32 - 9))) 66866 d = d + (a) 66867 c = c + (((a ^ (b & (d ^ a))) + *(*uint32)(unsafe.Pointer(in + 7*4))) + uint32(0x676f02d9)) 66868 c = ((c << 14) | (c >> (32 - 14))) 66869 c = c + (d) 66870 b = b + (((d ^ (a & (c ^ d))) + *(*uint32)(unsafe.Pointer(in + 12*4))) + 0x8d2a4c8a) 66871 b = ((b << 20) | (b >> (32 - 20))) 66872 b = b + (c) 66873 66874 a = a + ((((b ^ c) ^ d) + *(*uint32)(unsafe.Pointer(in + 5*4))) + 0xfffa3942) 66875 a = ((a << 4) | (a >> (32 - 4))) 66876 a = a + (b) 66877 d = d + ((((a ^ b) ^ c) + *(*uint32)(unsafe.Pointer(in + 8*4))) + 0x8771f681) 66878 d = ((d << 11) | (d >> (32 - 11))) 66879 d = d + (a) 66880 c = c + ((((d ^ a) ^ b) + *(*uint32)(unsafe.Pointer(in + 11*4))) + uint32(0x6d9d6122)) 66881 c = ((c << 16) | (c >> (32 - 16))) 66882 c = c + (d) 66883 b = b + ((((c ^ d) ^ a) + *(*uint32)(unsafe.Pointer(in + 14*4))) + 0xfde5380c) 66884 b = ((b << 23) | (b >> (32 - 23))) 66885 b = b + (c) 66886 a = a + ((((b ^ c) ^ d) + *(*uint32)(unsafe.Pointer(in + 1*4))) + 0xa4beea44) 66887 a = ((a << 4) | (a >> (32 - 4))) 66888 a = a + (b) 66889 d = d + ((((a ^ b) ^ c) + *(*uint32)(unsafe.Pointer(in + 4*4))) + uint32(0x4bdecfa9)) 66890 d = ((d << 11) | (d >> (32 - 11))) 66891 d = d + (a) 66892 c = c + ((((d ^ a) ^ b) + *(*uint32)(unsafe.Pointer(in + 7*4))) + 0xf6bb4b60) 66893 c = ((c << 16) | (c >> (32 - 16))) 66894 c = c + (d) 66895 b = b + ((((c ^ d) ^ a) + *(*uint32)(unsafe.Pointer(in + 10*4))) + 0xbebfbc70) 66896 b = ((b << 23) | (b >> (32 - 23))) 66897 b = b + (c) 66898 a = a + ((((b ^ c) ^ d) + *(*uint32)(unsafe.Pointer(in + 13*4))) + uint32(0x289b7ec6)) 66899 a = ((a << 4) | (a >> (32 - 4))) 66900 a = a + (b) 66901 d = d + ((((a ^ b) ^ c) + *(*uint32)(unsafe.Pointer(in))) + 0xeaa127fa) 66902 d = ((d << 11) | (d >> (32 - 11))) 66903 d = d + (a) 66904 c = c + ((((d ^ a) ^ b) + *(*uint32)(unsafe.Pointer(in + 3*4))) + 0xd4ef3085) 66905 c = ((c << 16) | (c >> (32 - 16))) 66906 c = c + (d) 66907 b = b + ((((c ^ d) ^ a) + *(*uint32)(unsafe.Pointer(in + 6*4))) + uint32(0x04881d05)) 66908 b = ((b << 23) | (b >> (32 - 23))) 66909 b = b + (c) 66910 a = a + ((((b ^ c) ^ d) + *(*uint32)(unsafe.Pointer(in + 9*4))) + 0xd9d4d039) 66911 a = ((a << 4) | (a >> (32 - 4))) 66912 a = a + (b) 66913 d = d + ((((a ^ b) ^ c) + *(*uint32)(unsafe.Pointer(in + 12*4))) + 0xe6db99e5) 66914 d = ((d << 11) | (d >> (32 - 11))) 66915 d = d + (a) 66916 c = c + ((((d ^ a) ^ b) + *(*uint32)(unsafe.Pointer(in + 15*4))) + uint32(0x1fa27cf8)) 66917 c = ((c << 16) | (c >> (32 - 16))) 66918 c = c + (d) 66919 b = b + ((((c ^ d) ^ a) + *(*uint32)(unsafe.Pointer(in + 2*4))) + 0xc4ac5665) 66920 b = ((b << 23) | (b >> (32 - 23))) 66921 b = b + (c) 66922 66923 a = a + (((c ^ (b | ^d)) + *(*uint32)(unsafe.Pointer(in))) + 0xf4292244) 66924 a = ((a << 6) | (a >> (32 - 6))) 66925 a = a + (b) 66926 d = d + (((b ^ (a | ^c)) + *(*uint32)(unsafe.Pointer(in + 7*4))) + uint32(0x432aff97)) 66927 d = ((d << 10) | (d >> (32 - 10))) 66928 d = d + (a) 66929 c = c + (((a ^ (d | ^b)) + *(*uint32)(unsafe.Pointer(in + 14*4))) + 0xab9423a7) 66930 c = ((c << 15) | (c >> (32 - 15))) 66931 c = c + (d) 66932 b = b + (((d ^ (c | ^a)) + *(*uint32)(unsafe.Pointer(in + 5*4))) + 0xfc93a039) 66933 b = ((b << 21) | (b >> (32 - 21))) 66934 b = b + (c) 66935 a = a + (((c ^ (b | ^d)) + *(*uint32)(unsafe.Pointer(in + 12*4))) + uint32(0x655b59c3)) 66936 a = ((a << 6) | (a >> (32 - 6))) 66937 a = a + (b) 66938 d = d + (((b ^ (a | ^c)) + *(*uint32)(unsafe.Pointer(in + 3*4))) + 0x8f0ccc92) 66939 d = ((d << 10) | (d >> (32 - 10))) 66940 d = d + (a) 66941 c = c + (((a ^ (d | ^b)) + *(*uint32)(unsafe.Pointer(in + 10*4))) + 0xffeff47d) 66942 c = ((c << 15) | (c >> (32 - 15))) 66943 c = c + (d) 66944 b = b + (((d ^ (c | ^a)) + *(*uint32)(unsafe.Pointer(in + 1*4))) + 0x85845dd1) 66945 b = ((b << 21) | (b >> (32 - 21))) 66946 b = b + (c) 66947 a = a + (((c ^ (b | ^d)) + *(*uint32)(unsafe.Pointer(in + 8*4))) + uint32(0x6fa87e4f)) 66948 a = ((a << 6) | (a >> (32 - 6))) 66949 a = a + (b) 66950 d = d + (((b ^ (a | ^c)) + *(*uint32)(unsafe.Pointer(in + 15*4))) + 0xfe2ce6e0) 66951 d = ((d << 10) | (d >> (32 - 10))) 66952 d = d + (a) 66953 c = c + (((a ^ (d | ^b)) + *(*uint32)(unsafe.Pointer(in + 6*4))) + 0xa3014314) 66954 c = ((c << 15) | (c >> (32 - 15))) 66955 c = c + (d) 66956 b = b + (((d ^ (c | ^a)) + *(*uint32)(unsafe.Pointer(in + 13*4))) + uint32(0x4e0811a1)) 66957 b = ((b << 21) | (b >> (32 - 21))) 66958 b = b + (c) 66959 a = a + (((c ^ (b | ^d)) + *(*uint32)(unsafe.Pointer(in + 4*4))) + 0xf7537e82) 66960 a = ((a << 6) | (a >> (32 - 6))) 66961 a = a + (b) 66962 d = d + (((b ^ (a | ^c)) + *(*uint32)(unsafe.Pointer(in + 11*4))) + 0xbd3af235) 66963 d = ((d << 10) | (d >> (32 - 10))) 66964 d = d + (a) 66965 c = c + (((a ^ (d | ^b)) + *(*uint32)(unsafe.Pointer(in + 2*4))) + uint32(0x2ad7d2bb)) 66966 c = ((c << 15) | (c >> (32 - 15))) 66967 c = c + (d) 66968 b = b + (((d ^ (c | ^a)) + *(*uint32)(unsafe.Pointer(in + 9*4))) + 0xeb86d391) 66969 b = ((b << 21) | (b >> (32 - 21))) 66970 b = b + (c) 66971 66972 *(*uint32)(unsafe.Pointer(buf)) += (a) 66973 *(*uint32)(unsafe.Pointer(buf + 1*4)) += (b) 66974 *(*uint32)(unsafe.Pointer(buf + 2*4)) += (c) 66975 *(*uint32)(unsafe.Pointer(buf + 3*4)) += (d) 66976 } 66977 66978 // Start MD5 accumulation. Set bit count to 0 and buffer to mysterious 66979 // initialization constants. 66980 func MD5Init(tls *libc.TLS, ctx uintptr) { /* test_md5.c:180:13: */ 66981 (*MD5Context)(unsafe.Pointer(ctx)).FisInit = 1 66982 *(*uint32)(unsafe.Pointer((ctx + 4 /* &.buf */))) = uint32(0x67452301) 66983 *(*uint32)(unsafe.Pointer((ctx + 4 /* &.buf */) + 1*4)) = 0xefcdab89 66984 *(*uint32)(unsafe.Pointer((ctx + 4 /* &.buf */) + 2*4)) = 0x98badcfe 66985 *(*uint32)(unsafe.Pointer((ctx + 4 /* &.buf */) + 3*4)) = uint32(0x10325476) 66986 *(*uint32)(unsafe.Pointer((ctx + 20 /* &.bits */))) = uint32(0) 66987 *(*uint32)(unsafe.Pointer((ctx + 20 /* &.bits */) + 1*4)) = uint32(0) 66988 } 66989 66990 // Update context to reflect the concatenation of another buffer full 66991 // of bytes. 66992 func MD5Update(tls *libc.TLS, ctx uintptr, buf uintptr, len uint32) { /* test_md5.c:195:6: */ 66993 var t uint32 66994 66995 // Update bitcount 66996 66997 t = *(*uint32)(unsafe.Pointer((ctx + 20 /* &.bits */))) 66998 if (libc.AssignPtrUint32((ctx + 20 /* &.bits */), (t + (len << 3)))) < t { 66999 *(*uint32)(unsafe.Pointer((ctx + 20 /* &.bits */) + 1*4))++ 67000 } // Carry from low to high 67001 *(*uint32)(unsafe.Pointer((ctx + 20 /* &.bits */) + 1*4)) += (len >> 29) 67002 67003 t = ((t >> 3) & uint32(0x3f)) // Bytes already in shsInfo->data 67004 67005 // Handle any leading odd-sized chunks 67006 67007 if t != 0 { 67008 var p uintptr = (ctx + 28 /* &.in */ + uintptr(t)) 67009 67010 t = (uint32(64) - t) 67011 if len < t { 67012 libc.Xmemcpy(tls, p, buf, uint64(len)) 67013 return 67014 } 67015 libc.Xmemcpy(tls, p, buf, uint64(t)) 67016 byteReverse(tls, ctx+28 /* &.in */, uint32(16)) 67017 MD5Transform(tls, ctx+4 /* &.buf */, ctx+28 /* &.in */) 67018 buf += uintptr(t) 67019 len = len - (t) 67020 } 67021 67022 // Process data in 64-byte chunks 67023 67024 for len >= uint32(64) { 67025 libc.Xmemcpy(tls, ctx+28 /* &.in */, buf, uint64(64)) 67026 byteReverse(tls, ctx+28 /* &.in */, uint32(16)) 67027 MD5Transform(tls, ctx+4 /* &.buf */, ctx+28 /* &.in */) 67028 buf += uintptr(64) 67029 len = len - (uint32(64)) 67030 } 67031 67032 // Handle any remaining bytes of data. 67033 67034 libc.Xmemcpy(tls, ctx+28 /* &.in */, buf, uint64(len)) 67035 } 67036 67037 // Final wrapup - pad to 64-byte boundary with the bit pattern 67038 // 1 0* (64-bit count of bits processed, MSB-first) 67039 func MD5Final(tls *libc.TLS, digest uintptr, ctx uintptr) { /* test_md5.c:243:13: */ 67040 var count uint32 67041 var p uintptr 67042 67043 // Compute number of bytes mod 64 67044 count = ((*(*uint32)(unsafe.Pointer((ctx + 20 /* &.bits */))) >> 3) & uint32(0x3F)) 67045 67046 // Set the first char of padding to 0x80. This is safe since there is 67047 // always at least one byte free 67048 p = ((ctx + 28 /* &.in */) + uintptr(count)) 67049 *(*uint8)(unsafe.Pointer(libc.PostIncUintptr(&p, 1))) = uint8(0x80) 67050 67051 // Bytes of padding needed to make 64 bytes 67052 count = ((uint32(64 - 1)) - count) 67053 67054 // Pad out to 56 mod 64 67055 if count < uint32(8) { 67056 // Two lots of padding: Pad the first block to 64 bytes 67057 libc.Xmemset(tls, p, 0, uint64(count)) 67058 byteReverse(tls, ctx+28 /* &.in */, uint32(16)) 67059 MD5Transform(tls, ctx+4 /* &.buf */, ctx+28 /* &.in */) 67060 67061 // Now fill the next block with 56 bytes 67062 libc.Xmemset(tls, ctx+28 /* &.in */, 0, uint64(56)) 67063 } else { 67064 // Pad block to 56 bytes 67065 libc.Xmemset(tls, p, 0, (uint64(count - uint32(8)))) 67066 } 67067 byteReverse(tls, ctx+28 /* &.in */, uint32(14)) 67068 67069 // Append length in bits and transform 67070 libc.Xmemcpy(tls, ((ctx + 28 /* &.in */) + uintptr((14 * 4))), ctx+20 /* &.bits */, uint64(8)) 67071 67072 MD5Transform(tls, ctx+4 /* &.buf */, ctx+28 /* &.in */) 67073 byteReverse(tls, ctx+4 /* &.buf */, uint32(4)) 67074 libc.Xmemcpy(tls, digest, ctx+4 /* &.buf */, uint64(16)) 67075 } 67076 67077 // Convert a 128-bit MD5 digest into a 32-digit base-16 number. 67078 func MD5DigestToBase16(tls *libc.TLS, digest uintptr, zBuf uintptr) { /* test_md5.c:284:13: */ 67079 var i int32 67080 var j int32 67081 67082 for j = libc.AssignInt32(&i, 0); i < 16; i++ { 67083 var a int32 = int32(*(*uint8)(unsafe.Pointer(digest + uintptr(i)))) 67084 *(*int8)(unsafe.Pointer(zBuf + uintptr(libc.PostIncInt32(&j, 1)))) = zEncode[((a >> 4) & 0xf)] 67085 *(*int8)(unsafe.Pointer(zBuf + uintptr(libc.PostIncInt32(&j, 1)))) = zEncode[(a & 0xf)] 67086 } 67087 *(*int8)(unsafe.Pointer(zBuf + uintptr(j))) = int8(0) 67088 } 67089 67090 var zEncode = *(*[17]int8)(unsafe.Pointer(ts + 30527 /* "0123456789abcdef" */)) /* test_md5.c:285:21 */ 67091 67092 // Convert a 128-bit MD5 digest into sequency of eight 5-digit integers 67093 // each representing 16 bits of the digest and separated from each 67094 // other by a "-" character. 67095 func MD5DigestToBase10x8(tls *libc.TLS, digest uintptr, zDigest uintptr) { /* test_md5.c:302:13: */ 67096 bp := tls.Alloc(8) 67097 defer tls.Free(8) 67098 67099 var i int32 67100 var j int32 67101 var x uint32 67102 for i = libc.AssignInt32(&j, 0); i < 16; i = i + (2) { 67103 x = (uint32((int32(*(*uint8)(unsafe.Pointer(digest + uintptr(i)))) * 256) + int32(*(*uint8)(unsafe.Pointer(digest + uintptr((i + 1))))))) 67104 if i > 0 { 67105 *(*int8)(unsafe.Pointer(zDigest + uintptr(libc.PostIncInt32(&j, 1)))) = int8('-') 67106 } 67107 sqlite3.Xsqlite3_snprintf(tls, (50 - j), (zDigest + uintptr(j)), ts+33837 /* "%05u" */, libc.VaList(bp, x)) 67108 j = j + (5) 67109 } 67110 *(*int8)(unsafe.Pointer(zDigest + uintptr(j))) = int8(0) 67111 } 67112 67113 // A TCL command for md5. The argument is the text to be hashed. The 67114 // Result is the hash in base64. 67115 func md5_cmd(tls *libc.TLS, cd uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test_md5.c:318:26: */ 67116 bp := tls.Alloc(206) 67117 defer tls.Free(206) 67118 67119 // var ctx MD5Context at bp+48, 92 67120 67121 // var digest [16]uint8 at bp+140, 16 67122 67123 // var zBuf [50]int8 at bp+156, 50 67124 67125 var converter uintptr 67126 67127 if argc != 2 { 67128 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 67129 ts+14994 /* " TEXT\"" */, uintptr(0))) 67130 return TCL_ERROR 67131 } 67132 MD5Init(tls, bp+48 /* &ctx */) 67133 MD5Update(tls, bp+48 /* &ctx */, *(*uintptr)(unsafe.Pointer(argv + 1*8)), uint32(libc.Xstrlen(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))))) 67134 MD5Final(tls, bp+140 /* &digest[0] */, bp+48 /* &ctx */) 67135 converter = cd 67136 (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&converter)))(tls, bp+140 /* &digest[0] */, bp+156 /* &zBuf[0] */) 67137 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, bp+156 /* &zBuf[0] */, uintptr(0))) 67138 return TCL_OK 67139 } 67140 67141 // A TCL command to take the md5 hash of a file. The argument is the 67142 // name of the file. 67143 func md5file_cmd(tls *libc.TLS, cd uintptr, interp uintptr, argc int32, argv uintptr) int32 { /* test_md5.c:347:26: */ 67144 bp := tls.Alloc(10428) 67145 defer tls.Free(10428) 67146 67147 var in uintptr 67148 var ofst int32 67149 var amt int32 67150 // var ctx MD5Context at bp+80, 92 67151 67152 var converter uintptr 67153 // var digest [16]uint8 at bp+10412, 16 67154 67155 // var zBuf [10240]int8 at bp+172, 10240 67156 67157 if (argc != 2) && (argc != 4) { 67158 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631 /* "wrong # args: sh..." */, *(*uintptr)(unsafe.Pointer(argv)), 67159 ts+33842 /* " FILENAME [OFFSE..." */, uintptr(0))) 67160 return TCL_ERROR 67161 } 67162 if argc == 4 { 67163 ofst = libc.Xatoi(tls, *(*uintptr)(unsafe.Pointer(argv + 2*8))) 67164 amt = libc.Xatoi(tls, *(*uintptr)(unsafe.Pointer(argv + 3*8))) 67165 } else { 67166 ofst = 0 67167 amt = 2147483647 67168 } 67169 in = libc.Xfopen(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+4273 /* "rb" */) 67170 if in == uintptr(0) { 67171 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+33866 /* "unable to open f..." */, *(*uintptr)(unsafe.Pointer(argv + 1*8)), 67172 ts+33888 /* "\" for reading" */, uintptr(0))) 67173 return TCL_ERROR 67174 } 67175 libc.Xfseek(tls, in, int64(ofst), SEEK_SET) 67176 MD5Init(tls, bp+80 /* &ctx */) 67177 for amt > 0 { 67178 var n int32 67179 n = int32(libc.Xfread(tls, bp+172 /* &zBuf[0] */, uint64(1), func() uint64 { 67180 if uint64(unsafe.Sizeof([10240]int8{})) <= uint64(amt) { 67181 return uint64(unsafe.Sizeof([10240]int8{})) 67182 } 67183 return uint64(amt) 67184 }(), in)) 67185 if n <= 0 { 67186 break 67187 } 67188 MD5Update(tls, bp+80 /* &ctx */, bp+172 /* zBuf */, uint32(n)) 67189 amt = amt - (n) 67190 } 67191 libc.Xfclose(tls, in) 67192 MD5Final(tls, bp+10412 /* &digest[0] */, bp+80 /* &ctx */) 67193 converter = cd 67194 (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(&converter)))(tls, bp+10412 /* &digest[0] */, bp+172 /* &zBuf[0] */) 67195 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, bp+172 /* &zBuf[0] */, uintptr(0))) 67196 return TCL_OK 67197 } 67198 67199 // Register the four new TCL commands for generating MD5 checksums 67200 // with the TCL interpreter. 67201 func Md5_Init(tls *libc.TLS, interp uintptr) int32 { /* test_md5.c:400:5: */ 67202 tcl.XTcl_CreateCommand(tls, interp, ts+33902 /* "md5" */, *(*uintptr)(unsafe.Pointer(&struct { 67203 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 67204 }{md5_cmd})), 67205 *(*uintptr)(unsafe.Pointer(&struct { 67206 f func(*libc.TLS, uintptr, uintptr) 67207 }{MD5DigestToBase16})), uintptr(0)) 67208 tcl.XTcl_CreateCommand(tls, interp, ts+33906 /* "md5-10x8" */, *(*uintptr)(unsafe.Pointer(&struct { 67209 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 67210 }{md5_cmd})), 67211 *(*uintptr)(unsafe.Pointer(&struct { 67212 f func(*libc.TLS, uintptr, uintptr) 67213 }{MD5DigestToBase10x8})), uintptr(0)) 67214 tcl.XTcl_CreateCommand(tls, interp, ts+33915 /* "md5file" */, *(*uintptr)(unsafe.Pointer(&struct { 67215 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 67216 }{md5file_cmd})), 67217 *(*uintptr)(unsafe.Pointer(&struct { 67218 f func(*libc.TLS, uintptr, uintptr) 67219 }{MD5DigestToBase16})), uintptr(0)) 67220 tcl.XTcl_CreateCommand(tls, interp, ts+33923 /* "md5file-10x8" */, *(*uintptr)(unsafe.Pointer(&struct { 67221 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 67222 }{md5file_cmd})), 67223 *(*uintptr)(unsafe.Pointer(&struct { 67224 f func(*libc.TLS, uintptr, uintptr) 67225 }{MD5DigestToBase10x8})), uintptr(0)) 67226 return TCL_OK 67227 } 67228 67229 // During testing, the special md5sum() aggregate function is available. 67230 // inside SQLite. The following routines implement that function. 67231 func md5step(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test_md5.c:416:13: */ 67232 var p uintptr 67233 var i int32 67234 if argc < 1 { 67235 return 67236 } 67237 p = sqlite3.Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(MD5Context{}))) 67238 if p == uintptr(0) { 67239 return 67240 } 67241 if !((*MD5Context)(unsafe.Pointer(p)).FisInit != 0) { 67242 MD5Init(tls, p) 67243 } 67244 for i = 0; i < argc; i++ { 67245 var zData uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) 67246 if zData != 0 { 67247 MD5Update(tls, p, zData, uint32(int32(libc.Xstrlen(tls, zData)))) 67248 } 67249 } 67250 } 67251 67252 func md5finalize(tls *libc.TLS, context uintptr) { /* test_md5.c:432:13: */ 67253 bp := tls.Alloc(49) 67254 defer tls.Free(49) 67255 67256 var p uintptr 67257 // var digest [16]uint8 at bp, 16 67258 67259 // var zBuf [33]int8 at bp+16, 33 67260 67261 p = sqlite3.Xsqlite3_aggregate_context(tls, context, int32(unsafe.Sizeof(MD5Context{}))) 67262 MD5Final(tls, bp /* &digest[0] */, p) 67263 MD5DigestToBase16(tls, bp /* &digest[0] */, bp+16 /* &zBuf[0] */) 67264 sqlite3.Xsqlite3_result_text(tls, context, bp+16 /* &zBuf[0] */, -1, libc.UintptrFromInt32(-1)) 67265 } 67266 67267 func Md5_Register(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pThunk uintptr) int32 { /* test_md5.c:441:5: */ 67268 var rc int32 = sqlite3.Xsqlite3_create_function(tls, db, ts+33936 /* "md5sum" */, -1, SQLITE_UTF8, uintptr(0), uintptr(0), 67269 *(*uintptr)(unsafe.Pointer(&struct { 67270 f func(*libc.TLS, uintptr, int32, uintptr) 67271 }{md5step})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{md5finalize}))) 67272 sqlite3.Xsqlite3_overload_function(tls, db, ts+33936 /* "md5sum" */, -1) // To exercise this API 67273 return rc 67274 } 67275 67276 // The following macros redefine the API routines so that they are 67277 // redirected through the global sqlite3_api structure. 67278 // 67279 // This header file is also used by the loadext.c source file 67280 // (part of the main SQLite library - not an extension) so that 67281 // it can get access to the sqlite3_api_routines structure 67282 // definition. But the main library does not want to redefine 67283 // the API. So the redefinition macros are only valid if the 67284 // SQLITE_CORE macros is undefined. 67285 67286 // This case when the file is being statically linked into the 67287 // application 67288 67289 // These should be defined to be the same as the values in 67290 // sqliteInt.h. They are defined separately here so that 67291 // the multiplex VFS shim can be built as a loadable 67292 // module. 67293 67294 // Maximum chunk number 67295 67296 // First chunk for rollback journal files 67297 67298 //*********************** Shim Definitions ***************************** 67299 67300 // This is the limit on the chunk size. It may be changed by calling 67301 // the xFileControl() interface. It will be rounded up to a 67302 // multiple of MAX_PAGE_SIZE. We default it here to 2GiB less 64KiB. 67303 67304 // This used to be the default limit on number of chunks, but 67305 // it is no longer enforced. There is currently no limit to the 67306 // number of chunks. 67307 // 67308 // May be changed by calling the xFileControl() interface. 67309 67310 //*********************** Object Definitions ***************************** 67311 67312 // Forward declaration of all object types 67313 type multiplexGroup1 = struct { 67314 FaReal uintptr 67315 FnReal int32 67316 _ [4]byte 67317 FzName uintptr 67318 FnName int32 67319 Fflags int32 67320 FszChunk uint32 67321 FbEnabled uint8 67322 FbTruncate uint8 67323 _ [2]byte 67324 } /* test_multiplex.c:106:9 */ 67325 67326 // The following macros redefine the API routines so that they are 67327 // redirected through the global sqlite3_api structure. 67328 // 67329 // This header file is also used by the loadext.c source file 67330 // (part of the main SQLite library - not an extension) so that 67331 // it can get access to the sqlite3_api_routines structure 67332 // definition. But the main library does not want to redefine 67333 // the API. So the redefinition macros are only valid if the 67334 // SQLITE_CORE macros is undefined. 67335 67336 // This case when the file is being statically linked into the 67337 // application 67338 67339 // These should be defined to be the same as the values in 67340 // sqliteInt.h. They are defined separately here so that 67341 // the multiplex VFS shim can be built as a loadable 67342 // module. 67343 67344 // Maximum chunk number 67345 67346 // First chunk for rollback journal files 67347 67348 //*********************** Shim Definitions ***************************** 67349 67350 // This is the limit on the chunk size. It may be changed by calling 67351 // the xFileControl() interface. It will be rounded up to a 67352 // multiple of MAX_PAGE_SIZE. We default it here to 2GiB less 64KiB. 67353 67354 // This used to be the default limit on number of chunks, but 67355 // it is no longer enforced. There is currently no limit to the 67356 // number of chunks. 67357 // 67358 // May be changed by calling the xFileControl() interface. 67359 67360 //*********************** Object Definitions ***************************** 67361 67362 // Forward declaration of all object types 67363 type multiplexGroup = multiplexGroup1 /* test_multiplex.c:106:31 */ 67364 type multiplexConn1 = struct { 67365 Fbase sqlite3_file 67366 FpGroup uintptr 67367 } /* test_multiplex.c:107:9 */ 67368 67369 type multiplexConn = multiplexConn1 /* test_multiplex.c:107:30 */ 67370 67371 // A "multiplex group" is a collection of files that collectively 67372 // makeup a single SQLite DB file. This allows the size of the DB 67373 // to exceed the limits imposed by the file system. 67374 // 67375 // There is an instance of the following object for each defined multiplex 67376 // group. 67377 type multiplexReal = struct { 67378 Fp uintptr 67379 Fz uintptr 67380 } /* test_multiplex.c:106:9 */ 67381 67382 //************************ Global Variables ********************************* 67383 // All global variables used by this file are containing within the following 67384 // gMultiplex structure. 67385 var gMultiplex struct { 67386 FpOrigVfs uintptr 67387 FsThisVfs sqlite3_vfs 67388 FsIoMethodsV1 sqlite3_io_methods 67389 FsIoMethodsV2 sqlite3_io_methods 67390 FisInitialized int32 67391 _ [4]byte 67392 } /* test_multiplex.c:176:3: */ 67393 67394 //************************ Utility Routines ******************************** 67395 // Compute a string length that is limited to what can be stored in 67396 // lower 30 bits of a 32-bit signed integer. 67397 // 67398 // The value returned will never be negative. Nor will it ever be greater 67399 // than the actual length of the string. For very long strings (greater 67400 // than 1GiB) the value returned might be less than the true string length. 67401 func multiplexStrlen30(tls *libc.TLS, z uintptr) int32 { /* test_multiplex.c:187:12: */ 67402 var z2 uintptr = z 67403 if z == uintptr(0) { 67404 return 0 67405 } 67406 for *(*int8)(unsafe.Pointer(z2)) != 0 { 67407 z2++ 67408 } 67409 return (0x3fffffff & (int32((int64(z2) - int64(z)) / 1))) 67410 } 67411 67412 // Generate the file-name for chunk iChunk of the group with base name 67413 // zBase. The file-name is written to buffer zOut before returning. Buffer 67414 // zOut must be allocated by the caller so that it is at least (nBase+5) 67415 // bytes in size, where nBase is the length of zBase, not including the 67416 // nul-terminator. 67417 // 67418 // If iChunk is 0 (or 400 - the number for the first journal file chunk), 67419 // the output is a copy of the input string. Otherwise, if 67420 // SQLITE_ENABLE_8_3_NAMES is not defined or the input buffer does not contain 67421 // a "." character, then the output is a copy of the input string with the 67422 // three-digit zero-padded decimal representation if iChunk appended to it. 67423 // For example: 67424 // 67425 // zBase="test.db", iChunk=4 -> zOut="test.db004" 67426 // 67427 // Or, if SQLITE_ENABLE_8_3_NAMES is defined and the input buffer contains 67428 // a "." character, then everything after the "." is replaced by the 67429 // three-digit representation of iChunk. 67430 // 67431 // zBase="test.db", iChunk=4 -> zOut="test.004" 67432 // 67433 // The output buffer string is terminated by 2 0x00 bytes. This makes it safe 67434 // to pass to sqlite3_uri_parameter() and similar. 67435 func multiplexFilename(tls *libc.TLS, zBase uintptr, nBase int32, flags int32, iChunk int32, zOut uintptr) { /* test_multiplex.c:219:13: */ 67436 bp := tls.Alloc(8) 67437 defer tls.Free(8) 67438 67439 var n int32 = nBase 67440 libc.Xmemcpy(tls, zOut, zBase, (uint64(n + 1))) 67441 if (iChunk != 0) && (iChunk <= MX_CHUNK_NUMBER) { 67442 sqlite3.Xsqlite3_snprintf(tls, 4, (zOut + uintptr(n)), ts+33943 /* "%03d" */, libc.VaList(bp, iChunk)) 67443 n = n + (3) 67444 } 67445 67446 *(*int8)(unsafe.Pointer(zOut + uintptr((n + 1)))) = int8(0) 67447 } 67448 67449 // Compute the filename for the iChunk-th chunk 67450 func multiplexSubFilename(tls *libc.TLS, pGroup uintptr, iChunk int32) int32 { /* test_multiplex.c:256:12: */ 67451 if iChunk >= (*multiplexGroup)(unsafe.Pointer(pGroup)).FnReal { 67452 var p uintptr 67453 p = sqlite3.Xsqlite3_realloc64(tls, (*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal, (uint64((uint64(iChunk + 1)) * uint64(unsafe.Sizeof(multiplexReal{}))))) 67454 if p == uintptr(0) { 67455 return SQLITE_NOMEM 67456 } 67457 libc.Xmemset(tls, (p + uintptr((*multiplexGroup)(unsafe.Pointer(pGroup)).FnReal)*16), 0, (uint64(unsafe.Sizeof(multiplexReal{})) * (uint64((iChunk + 1) - (*multiplexGroup)(unsafe.Pointer(pGroup)).FnReal)))) 67458 (*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal = p 67459 (*multiplexGroup)(unsafe.Pointer(pGroup)).FnReal = (iChunk + 1) 67460 } 67461 if ((*multiplexGroup)(unsafe.Pointer(pGroup)).FzName != 0) && ((*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fz == uintptr(0)) { 67462 var z uintptr 67463 var n int32 = (*multiplexGroup)(unsafe.Pointer(pGroup)).FnName 67464 z = sqlite3.Xsqlite3_malloc64(tls, (uint64(n + 5))) 67465 if z == uintptr(0) { 67466 return SQLITE_NOMEM 67467 } 67468 multiplexFilename(tls, (*multiplexGroup)(unsafe.Pointer(pGroup)).FzName, (*multiplexGroup)(unsafe.Pointer(pGroup)).FnName, (*multiplexGroup)(unsafe.Pointer(pGroup)).Fflags, iChunk, z) 67469 (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal + uintptr(iChunk)*16)).Fz = sqlite3.Xsqlite3_create_filename(tls, z, ts+489 /* "" */, ts+489 /* "" */, 0, uintptr(0)) 67470 sqlite3.Xsqlite3_free(tls, z) 67471 if (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fz == uintptr(0) { 67472 return SQLITE_NOMEM 67473 } 67474 } 67475 return SQLITE_OK 67476 } 67477 67478 // Translate an sqlite3_file* that is really a multiplexGroup* into 67479 // the sqlite3_file* for the underlying original VFS. 67480 // 67481 // For chunk 0, the pGroup->flags determines whether or not a new file 67482 // is created if it does not already exist. For chunks 1 and higher, the 67483 // file is created only if createFlag is 1. 67484 func multiplexSubOpen(tls *libc.TLS, pGroup uintptr, iChunk int32, rc uintptr, pOutFlags uintptr, createFlag int32) uintptr { /* test_multiplex.c:289:21: */ 67485 bp := tls.Alloc(20) 67486 defer tls.Free(20) 67487 67488 var pSubOpen uintptr = uintptr(0) 67489 var pOrigVfs uintptr = gMultiplex.FpOrigVfs // Real VFS 67490 67491 *(*int32)(unsafe.Pointer(rc)) = multiplexSubFilename(tls, pGroup, iChunk) 67492 if ((*(*int32)(unsafe.Pointer(rc))) == SQLITE_OK) && ((libc.AssignUintptr(&pSubOpen, (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fp)) == uintptr(0)) { 67493 var flags int32 67494 // var bExists int32 at bp+16, 4 67495 67496 flags = (*multiplexGroup)(unsafe.Pointer(pGroup)).Fflags 67497 if createFlag != 0 { 67498 flags = flags | (SQLITE_OPEN_CREATE) 67499 } else if iChunk == 0 { 67500 // Fall through 67501 } else if (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fz == uintptr(0) { 67502 return uintptr(0) 67503 } else { 67504 *(*int32)(unsafe.Pointer(rc)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pOrigVfs + 56 /* &.xAccess */))))(tls, pOrigVfs, (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fz, 67505 SQLITE_ACCESS_EXISTS, bp+16 /* &bExists */) 67506 if (*(*int32)(unsafe.Pointer(rc)) != 0) || !(*(*int32)(unsafe.Pointer(bp + 16 /* bExists */)) != 0) { 67507 if *(*int32)(unsafe.Pointer(rc)) != 0 { 67508 sqlite3.Xsqlite3_log(tls, *(*int32)(unsafe.Pointer(rc)), ts+33948, /* "multiplexor.xAcc..." */ 67509 libc.VaList(bp, (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fz)) 67510 } 67511 return uintptr(0) 67512 } 67513 flags = flags & (libc.CplInt32(SQLITE_OPEN_CREATE)) 67514 } 67515 pSubOpen = sqlite3.Xsqlite3_malloc64(tls, uint64((*sqlite3_vfs)(unsafe.Pointer(pOrigVfs)).FszOsFile)) 67516 if pSubOpen == uintptr(0) { 67517 *(*int32)(unsafe.Pointer(rc)) = (SQLITE_IOERR | (int32(12) << 8)) 67518 return uintptr(0) 67519 } 67520 (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal + uintptr(iChunk)*16)).Fp = pSubOpen 67521 *(*int32)(unsafe.Pointer(rc)) = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pOrigVfs + 40 /* &.xOpen */))))(tls, pOrigVfs, (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fz, pSubOpen, 67522 flags, pOutFlags) 67523 if (*(*int32)(unsafe.Pointer(rc))) != SQLITE_OK { 67524 sqlite3.Xsqlite3_log(tls, *(*int32)(unsafe.Pointer(rc)), ts+33982, /* "multiplexor.xOpe..." */ 67525 libc.VaList(bp+8, (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fz)) 67526 sqlite3.Xsqlite3_free(tls, pSubOpen) 67527 (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal + uintptr(iChunk)*16)).Fp = uintptr(0) 67528 return uintptr(0) 67529 } 67530 } 67531 return pSubOpen 67532 } 67533 67534 // Return the size, in bytes, of chunk number iChunk. If that chunk 67535 // does not exist, then return 0. This function does not distingish between 67536 // non-existant files and zero-length files. 67537 func multiplexSubSize(tls *libc.TLS, pGroup uintptr, iChunk int32, rc uintptr) sqlite3_int64 { /* test_multiplex.c:357:22: */ 67538 bp := tls.Alloc(8) 67539 defer tls.Free(8) 67540 67541 var pSub uintptr 67542 *(*sqlite3_int64)(unsafe.Pointer(bp /* sz */)) = int64(0) 67543 67544 if *(*int32)(unsafe.Pointer(rc)) != 0 { 67545 return int64(0) 67546 } 67547 pSub = multiplexSubOpen(tls, pGroup, iChunk, rc, uintptr(0), 0) 67548 if pSub == uintptr(0) { 67549 return int64(0) 67550 } 67551 *(*int32)(unsafe.Pointer(rc)) = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSub)).FpMethods + 48 /* &.xFileSize */))))(tls, pSub, bp /* &sz */) 67552 return *(*sqlite3_int64)(unsafe.Pointer(bp /* sz */)) 67553 } 67554 67555 // This is the implementation of the multiplex_control() SQL function. 67556 func multiplexControlFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) { /* test_multiplex.c:375:13: */ 67557 bp := tls.Alloc(4) 67558 defer tls.Free(4) 67559 67560 var rc int32 = SQLITE_OK 67561 var db uintptr = sqlite3.Xsqlite3_context_db_handle(tls, context) 67562 var op int32 = 0 67563 // var iVal int32 at bp, 4 67564 67565 if !(db != 0) || (argc != 2) { 67566 rc = SQLITE_ERROR 67567 } else { 67568 // extract params 67569 op = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv))) 67570 *(*int32)(unsafe.Pointer(bp /* iVal */)) = sqlite3.Xsqlite3_value_int(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 67571 // map function op to file_control op 67572 switch op { 67573 case 1: 67574 op = MULTIPLEX_CTRL_ENABLE 67575 break 67576 fallthrough 67577 case 2: 67578 op = MULTIPLEX_CTRL_SET_CHUNK_SIZE 67579 break 67580 fallthrough 67581 case 3: 67582 op = MULTIPLEX_CTRL_SET_MAX_CHUNKS 67583 break 67584 fallthrough 67585 default: 67586 rc = SQLITE_NOTFOUND 67587 break 67588 } 67589 } 67590 if rc == SQLITE_OK { 67591 rc = sqlite3.Xsqlite3_file_control(tls, db, uintptr(0), op, bp /* &iVal */) 67592 } 67593 sqlite3.Xsqlite3_result_error_code(tls, context, rc) 67594 } 67595 67596 // This is the entry point to register the auto-extension for the 67597 // multiplex_control() function. 67598 func multiplexFuncInit(tls *libc.TLS, db uintptr, pzErrMsg uintptr, pApi uintptr) int32 { /* test_multiplex.c:417:12: */ 67599 var rc int32 67600 rc = sqlite3.Xsqlite3_create_function(tls, db, ts+34014 /* "multiplex_contro..." */, 2, SQLITE_ANY, 67601 uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 67602 f func(*libc.TLS, uintptr, int32, uintptr) 67603 }{multiplexControlFunc})), uintptr(0), uintptr(0)) 67604 return rc 67605 } 67606 67607 // Close a single sub-file in the connection group. 67608 func multiplexSubClose(tls *libc.TLS, pGroup uintptr, iChunk int32, pOrigVfs uintptr) { /* test_multiplex.c:431:13: */ 67609 var pSubOpen uintptr = (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal + uintptr(iChunk)*16)).Fp 67610 if pSubOpen != 0 { 67611 (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 8 /* &.xClose */))))(tls, pSubOpen) 67612 if (pOrigVfs != 0) && ((*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fz != 0) { 67613 (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer((pOrigVfs + 48 /* &.xDelete */))))(tls, pOrigVfs, (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fz, 0) 67614 } 67615 sqlite3.Xsqlite3_free(tls, (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fp) 67616 } 67617 sqlite3.Xsqlite3_free_filename(tls, (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fz) 67618 libc.Xmemset(tls, ((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal + uintptr(iChunk)*16), 0, uint64(unsafe.Sizeof(multiplexReal{}))) 67619 } 67620 67621 // Deallocate memory held by a multiplexGroup 67622 func multiplexFreeComponents(tls *libc.TLS, pGroup uintptr) { /* test_multiplex.c:451:13: */ 67623 var i int32 67624 for i = 0; i < (*multiplexGroup)(unsafe.Pointer(pGroup)).FnReal; i++ { 67625 multiplexSubClose(tls, pGroup, i, uintptr(0)) 67626 } 67627 sqlite3.Xsqlite3_free(tls, (*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal) 67628 (*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal = uintptr(0) 67629 (*multiplexGroup)(unsafe.Pointer(pGroup)).FnReal = 0 67630 } 67631 67632 //************************ VFS Method Wrappers **************************** 67633 67634 // This is the xOpen method used for the "multiplex" VFS. 67635 // 67636 // Most of the work is done by the underlying original VFS. This method 67637 // simply links the new file into the appropriate multiplex group if it is a 67638 // file that needs to be tracked. 67639 func multiplexOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pConn uintptr, flags int32, pOutFlags uintptr) int32 { /* test_multiplex.c:469:12: */ 67640 bp := tls.Alloc(20) 67641 defer tls.Free(20) 67642 67643 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK // Result code 67644 var pMultiplexOpen uintptr // The new multiplex file descriptor 67645 var pGroup uintptr = uintptr(0) // Corresponding multiplexGroup object 67646 var pSubOpen uintptr = uintptr(0) // Real file descriptor 67647 var pOrigVfs uintptr = gMultiplex.FpOrigVfs // Real VFS 67648 var nName int32 = 0 67649 var sz int32 = 0 67650 var zToFree uintptr = uintptr(0) 67651 67652 _ = pVfs 67653 libc.Xmemset(tls, pConn, 0, uint64((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile)) 67654 67655 // We need to create a group structure and manage 67656 // access to this group of files. 67657 pMultiplexOpen = pConn 67658 67659 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 67660 // allocate space for group 67661 if zName != 0 { 67662 nName = multiplexStrlen30(tls, zName) 67663 } else { 67664 nName = 0 67665 } 67666 sz = (int32((uint64(unsafe.Sizeof(multiplexGroup{})) + // multiplexGroup 67667 uint64(nName)) + uint64(1))) // zName 67668 pGroup = sqlite3.Xsqlite3_malloc64(tls, uint64(sz)) 67669 if pGroup == uintptr(0) { 67670 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_NOMEM 67671 } 67672 } 67673 67674 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 67675 var zUri uintptr 67676 if (flags & SQLITE_OPEN_URI) != 0 { 67677 zUri = zName 67678 } else { 67679 zUri = uintptr(0) 67680 } 67681 // assign pointers to extra space allocated 67682 libc.Xmemset(tls, pGroup, 0, uint64(sz)) 67683 (*multiplexConn)(unsafe.Pointer(pMultiplexOpen)).FpGroup = pGroup 67684 (*multiplexGroup)(unsafe.Pointer(pGroup)).FbEnabled = libc.Uint8(libc.Uint8FromInt32(-1)) 67685 (*multiplexGroup)(unsafe.Pointer(pGroup)).FbTruncate = uint8(sqlite3.Xsqlite3_uri_boolean(tls, zUri, ts+17954, /* "truncate" */ 67686 (libc.Bool32((flags & SQLITE_OPEN_MAIN_DB) == 0)))) 67687 (*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk = uint32(int32(sqlite3.Xsqlite3_uri_int64(tls, zUri, ts+34032, /* "chunksize" */ 67688 int64(SQLITE_MULTIPLEX_CHUNK_SIZE)))) 67689 (*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk = (((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk + uint32(0xffff)) & libc.Uint32FromInt32(libc.CplInt32(0xffff))) 67690 if zName != 0 { 67691 var p uintptr = (pGroup + 1*40) 67692 (*multiplexGroup)(unsafe.Pointer(pGroup)).FzName = p 67693 libc.Xmemcpy(tls, (*multiplexGroup)(unsafe.Pointer(pGroup)).FzName, zName, (uint64(nName + 1))) 67694 (*multiplexGroup)(unsafe.Pointer(pGroup)).FnName = nName 67695 } 67696 if (*multiplexGroup)(unsafe.Pointer(pGroup)).FbEnabled != 0 { 67697 for (uint32(sqlite3.Xsqlite3PendingByte) % (*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk) >= ((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk - uint32(65536)) { 67698 *(*uint32)(unsafe.Pointer(pGroup + 32 /* &.szChunk */)) += (uint32(65536)) 67699 } 67700 } 67701 (*multiplexGroup)(unsafe.Pointer(pGroup)).Fflags = (flags & libc.CplInt32(SQLITE_OPEN_URI)) 67702 *(*int32)(unsafe.Pointer(bp /* rc */)) = multiplexSubFilename(tls, pGroup, 1) 67703 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 67704 pSubOpen = multiplexSubOpen(tls, pGroup, 0, bp /* &rc */, pOutFlags, 0) 67705 if (pSubOpen == uintptr(0)) && (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) { 67706 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_CANTOPEN 67707 } 67708 } 67709 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 67710 // var sz64 sqlite3_int64 at bp+8, 8 67711 67712 *(*int32)(unsafe.Pointer(bp /* rc */)) = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 48 /* &.xFileSize */))))(tls, pSubOpen, bp+8 /* &sz64 */) 67713 if (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (zName != 0) { 67714 // var bExists int32 at bp+16, 4 67715 67716 if (flags & SQLITE_OPEN_SUPER_JOURNAL) != 0 { 67717 (*multiplexGroup)(unsafe.Pointer(pGroup)).FbEnabled = uint8(0) 67718 } else if *(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* sz64 */)) == int64(0) { 67719 if (flags & SQLITE_OPEN_MAIN_JOURNAL) != 0 { 67720 // If opening a main journal file and the first chunk is zero 67721 // bytes in size, delete any subsequent chunks from the 67722 // file-system. 67723 var iChunk int32 = 1 67724 for ok := true; ok; ok = ((*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 16 /* bExists */)) != 0)) { 67725 *(*int32)(unsafe.Pointer(bp /* rc */)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pOrigVfs + 56 /* &.xAccess */))))(tls, pOrigVfs, 67726 (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fz, SQLITE_ACCESS_EXISTS, bp+16 /* &bExists */) 67727 if (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 16 /* bExists */)) != 0) { 67728 *(*int32)(unsafe.Pointer(bp /* rc */)) = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer((pOrigVfs + 48 /* &.xDelete */))))(tls, pOrigVfs, (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+uintptr(iChunk)*16)).Fz, 0) 67729 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 67730 *(*int32)(unsafe.Pointer(bp /* rc */)) = multiplexSubFilename(tls, pGroup, libc.PreIncInt32(&iChunk, 1)) 67731 } 67732 } 67733 } 67734 } 67735 } else { 67736 // If the first overflow file exists and if the size of the main file 67737 // is different from the chunk size, that means the chunk size is set 67738 // set incorrectly. So fix it. 67739 // 67740 // Or, if the first overflow file does not exist and the main file is 67741 // larger than the chunk size, that means the chunk size is too small. 67742 // But we have no way of determining the intended chunk size, so 67743 // just disable the multiplexor all togethre. 67744 *(*int32)(unsafe.Pointer(bp /* rc */)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pOrigVfs + 56 /* &.xAccess */))))(tls, pOrigVfs, (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal+1*16)).Fz, 67745 SQLITE_ACCESS_EXISTS, bp+16 /* &bExists */) 67746 *(*int32)(unsafe.Pointer(bp + 16 /* bExists */)) = (libc.Bool32(multiplexSubSize(tls, pGroup, 1, bp /* &rc */) > int64(0))) 67747 if ((((*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp + 16 /* bExists */)) != 0)) && (*(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* sz64 */)) == (*(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* sz64 */)) & int64(0xffff0000)))) && (*(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* sz64 */)) > int64(0))) && 67748 (*(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* sz64 */)) != sqlite3_int64((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk)) { 67749 (*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk = uint32(int32(*(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* sz64 */)))) 67750 } else if ((*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && !(*(*int32)(unsafe.Pointer(bp + 16 /* bExists */)) != 0)) && (*(*sqlite3_int64)(unsafe.Pointer(bp + 8 /* sz64 */)) > sqlite3_int64((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk)) { 67751 (*multiplexGroup)(unsafe.Pointer(pGroup)).FbEnabled = uint8(0) 67752 } 67753 } 67754 } 67755 } 67756 67757 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 67758 if (*sqlite3_io_methods1)(unsafe.Pointer((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods)).FiVersion == 1 { 67759 (*sqlite3_file)(unsafe.Pointer(pConn)).FpMethods = (uintptr(unsafe.Pointer(&gMultiplex)) + 176 /* &.sIoMethodsV1 */) 67760 } else { 67761 (*sqlite3_file)(unsafe.Pointer(pConn)).FpMethods = (uintptr(unsafe.Pointer(&gMultiplex)) + 328 /* &.sIoMethodsV2 */) 67762 } 67763 } else { 67764 multiplexFreeComponents(tls, pGroup) 67765 sqlite3.Xsqlite3_free(tls, pGroup) 67766 } 67767 } 67768 sqlite3.Xsqlite3_free(tls, zToFree) 67769 return *(*int32)(unsafe.Pointer(bp /* rc */)) 67770 } 67771 67772 // This is the xDelete method used for the "multiplex" VFS. 67773 // It attempts to delete the filename specified. 67774 func multiplexDelete(tls *libc.TLS, pVfs uintptr, zName uintptr, syncDir int32) int32 { /* test_multiplex.c:611:12: */ 67775 bp := tls.Alloc(4) 67776 defer tls.Free(4) 67777 67778 var rc int32 67779 var pOrigVfs uintptr = gMultiplex.FpOrigVfs // Real VFS 67780 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer((pOrigVfs + 48 /* &.xDelete */))))(tls, pOrigVfs, zName, syncDir) 67781 if rc == SQLITE_OK { 67782 // If the main chunk was deleted successfully, also delete any subsequent 67783 // chunks - starting with the last (highest numbered). 67784 var nName int32 = int32(libc.Xstrlen(tls, zName)) 67785 var z uintptr 67786 z = sqlite3.Xsqlite3_malloc64(tls, (uint64(nName + 5))) 67787 if z == uintptr(0) { 67788 rc = (SQLITE_IOERR | (int32(12) << 8)) 67789 } else { 67790 var iChunk int32 = 0 67791 // var bExists int32 at bp, 4 67792 67793 for ok := true; ok; ok = ((rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp /* bExists */)) != 0)) { 67794 multiplexFilename(tls, zName, nName, SQLITE_OPEN_MAIN_JOURNAL, libc.PreIncInt32(&iChunk, 1), z) 67795 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pOrigVfs + 56 /* &.xAccess */))))(tls, pOrigVfs, z, SQLITE_ACCESS_EXISTS, bp /* &bExists */) 67796 } 67797 for (rc == SQLITE_OK) && (iChunk > 1) { 67798 multiplexFilename(tls, zName, nName, SQLITE_OPEN_MAIN_JOURNAL, libc.PreDecInt32(&iChunk, 1), z) 67799 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer((pOrigVfs + 48 /* &.xDelete */))))(tls, pOrigVfs, z, syncDir) 67800 } 67801 if rc == SQLITE_OK { 67802 iChunk = 0 67803 for ok1 := true; ok1; ok1 = ((rc == SQLITE_OK) && (*(*int32)(unsafe.Pointer(bp /* bExists */)) != 0)) { 67804 multiplexFilename(tls, zName, nName, SQLITE_OPEN_WAL, libc.PreIncInt32(&iChunk, 1), z) 67805 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pOrigVfs + 56 /* &.xAccess */))))(tls, pOrigVfs, z, SQLITE_ACCESS_EXISTS, bp /* &bExists */) 67806 } 67807 for (rc == SQLITE_OK) && (iChunk > 1) { 67808 multiplexFilename(tls, zName, nName, SQLITE_OPEN_WAL, libc.PreDecInt32(&iChunk, 1), z) 67809 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer((pOrigVfs + 48 /* &.xDelete */))))(tls, pOrigVfs, z, syncDir) 67810 } 67811 } 67812 } 67813 sqlite3.Xsqlite3_free(tls, z) 67814 } 67815 return rc 67816 } 67817 67818 func multiplexAccess(tls *libc.TLS, a uintptr, b uintptr, c int32, d uintptr) int32 { /* test_multiplex.c:656:12: */ 67819 return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((gMultiplex.FpOrigVfs + 56 /* &.xAccess */))))(tls, gMultiplex.FpOrigVfs, b, c, d) 67820 } 67821 67822 func multiplexFullPathname(tls *libc.TLS, a uintptr, b uintptr, c int32, d uintptr) int32 { /* test_multiplex.c:659:12: */ 67823 return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((gMultiplex.FpOrigVfs + 64 /* &.xFullPathname */))))(tls, gMultiplex.FpOrigVfs, b, c, d) 67824 } 67825 67826 func multiplexDlOpen(tls *libc.TLS, a uintptr, b uintptr) uintptr { /* test_multiplex.c:662:13: */ 67827 return (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer((gMultiplex.FpOrigVfs + 72 /* &.xDlOpen */))))(tls, gMultiplex.FpOrigVfs, b) 67828 } 67829 67830 func multiplexDlError(tls *libc.TLS, a uintptr, b int32, c uintptr) { /* test_multiplex.c:665:13: */ 67831 (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer((gMultiplex.FpOrigVfs + 80 /* &.xDlError */))))(tls, gMultiplex.FpOrigVfs, b, c) 67832 } 67833 67834 func multiplexDlSym(tls *libc.TLS, a uintptr, b uintptr, c uintptr) uintptr { /* test_multiplex.c:668:13: */ 67835 return (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer((gMultiplex.FpOrigVfs + 88 /* &.xDlSym */))))(tls, gMultiplex.FpOrigVfs, b, c) 67836 } 67837 67838 func multiplexDlClose(tls *libc.TLS, a uintptr, b uintptr) { /* test_multiplex.c:671:13: */ 67839 (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer((gMultiplex.FpOrigVfs + 96 /* &.xDlClose */))))(tls, gMultiplex.FpOrigVfs, b) 67840 } 67841 67842 func multiplexRandomness(tls *libc.TLS, a uintptr, b int32, c uintptr) int32 { /* test_multiplex.c:674:12: */ 67843 return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((gMultiplex.FpOrigVfs + 104 /* &.xRandomness */))))(tls, gMultiplex.FpOrigVfs, b, c) 67844 } 67845 67846 func multiplexSleep(tls *libc.TLS, a uintptr, b int32) int32 { /* test_multiplex.c:677:12: */ 67847 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((gMultiplex.FpOrigVfs + 112 /* &.xSleep */))))(tls, gMultiplex.FpOrigVfs, b) 67848 } 67849 67850 func multiplexCurrentTime(tls *libc.TLS, a uintptr, b uintptr) int32 { /* test_multiplex.c:680:12: */ 67851 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((gMultiplex.FpOrigVfs + 120 /* &.xCurrentTime */))))(tls, gMultiplex.FpOrigVfs, b) 67852 } 67853 67854 func multiplexGetLastError(tls *libc.TLS, a uintptr, b int32, c uintptr) int32 { /* test_multiplex.c:683:12: */ 67855 if (*sqlite3_vfs)(unsafe.Pointer(gMultiplex.FpOrigVfs)).FxGetLastError != 0 { 67856 return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((gMultiplex.FpOrigVfs + 128 /* &.xGetLastError */))))(tls, gMultiplex.FpOrigVfs, b, c) 67857 } else { 67858 return 0 67859 } 67860 return int32(0) 67861 } 67862 67863 func multiplexCurrentTimeInt64(tls *libc.TLS, a uintptr, b uintptr) int32 { /* test_multiplex.c:690:12: */ 67864 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((gMultiplex.FpOrigVfs + 136 /* &.xCurrentTimeInt64 */))))(tls, gMultiplex.FpOrigVfs, b) 67865 } 67866 67867 //*********************** I/O Method Wrappers ****************************** 67868 67869 // xClose requests get passed through to the original VFS. 67870 // We loop over all open chunk handles and close them. 67871 // The group structure for this file is unlinked from 67872 // our list of groups and freed. 67873 func multiplexClose(tls *libc.TLS, pConn uintptr) int32 { /* test_multiplex.c:701:12: */ 67874 var p uintptr = pConn 67875 var pGroup uintptr = (*multiplexConn)(unsafe.Pointer(p)).FpGroup 67876 var rc int32 = SQLITE_OK 67877 multiplexFreeComponents(tls, pGroup) 67878 sqlite3.Xsqlite3_free(tls, pGroup) 67879 return rc 67880 } 67881 67882 // Pass xRead requests thru to the original VFS after 67883 // determining the correct chunk to operate on. 67884 // Break up reads across chunk boundaries. 67885 func multiplexRead(tls *libc.TLS, pConn uintptr, pBuf uintptr, iAmt int32, iOfst sqlite3_int64) int32 { /* test_multiplex.c:714:12: */ 67886 bp := tls.Alloc(4) 67887 defer tls.Free(4) 67888 67889 var p uintptr = pConn 67890 var pGroup uintptr = (*multiplexConn)(unsafe.Pointer(p)).FpGroup 67891 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK 67892 if !(int32((*multiplexGroup)(unsafe.Pointer(pGroup)).FbEnabled) != 0) { 67893 var pSubOpen uintptr = multiplexSubOpen(tls, pGroup, 0, bp /* &rc */, uintptr(0), 0) 67894 if pSubOpen == uintptr(0) { 67895 *(*int32)(unsafe.Pointer(bp /* rc */)) = (SQLITE_IOERR | (int32(1) << 8)) 67896 } else { 67897 *(*int32)(unsafe.Pointer(bp /* rc */)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 16 /* &.xRead */))))(tls, pSubOpen, pBuf, iAmt, iOfst) 67898 } 67899 } else { 67900 for iAmt > 0 { 67901 var i int32 = (int32(iOfst / sqlite3_int64((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk))) 67902 var pSubOpen uintptr 67903 pSubOpen = multiplexSubOpen(tls, pGroup, i, bp /* &rc */, uintptr(0), 1) 67904 if pSubOpen != 0 { 67905 var extra int32 = (int32((uint32((int32(iOfst % sqlite3_int64((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk))) + iAmt)) - (*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk)) 67906 if extra < 0 { 67907 extra = 0 67908 } 67909 iAmt = iAmt - (extra) 67910 *(*int32)(unsafe.Pointer(bp /* rc */)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 16 /* &.xRead */))))(tls, pSubOpen, pBuf, iAmt, 67911 (iOfst % sqlite3_int64((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk))) 67912 if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { 67913 break 67914 } 67915 pBuf = (pBuf + uintptr(iAmt)) 67916 iOfst = iOfst + (sqlite3_int64(iAmt)) 67917 iAmt = extra 67918 } else { 67919 *(*int32)(unsafe.Pointer(bp /* rc */)) = (SQLITE_IOERR | (int32(1) << 8)) 67920 break 67921 } 67922 } 67923 } 67924 67925 return *(*int32)(unsafe.Pointer(bp /* rc */)) 67926 } 67927 67928 // Pass xWrite requests thru to the original VFS after 67929 // determining the correct chunk to operate on. 67930 // Break up writes across chunk boundaries. 67931 func multiplexWrite(tls *libc.TLS, pConn uintptr, pBuf uintptr, iAmt int32, iOfst sqlite3_int64) int32 { /* test_multiplex.c:759:12: */ 67932 bp := tls.Alloc(4) 67933 defer tls.Free(4) 67934 67935 var p uintptr = pConn 67936 var pGroup uintptr = (*multiplexConn)(unsafe.Pointer(p)).FpGroup 67937 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK 67938 if !(int32((*multiplexGroup)(unsafe.Pointer(pGroup)).FbEnabled) != 0) { 67939 var pSubOpen uintptr = multiplexSubOpen(tls, pGroup, 0, bp /* &rc */, uintptr(0), 0) 67940 if pSubOpen == uintptr(0) { 67941 *(*int32)(unsafe.Pointer(bp /* rc */)) = (SQLITE_IOERR | (int32(3) << 8)) 67942 } else { 67943 *(*int32)(unsafe.Pointer(bp /* rc */)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 24 /* &.xWrite */))))(tls, pSubOpen, pBuf, iAmt, iOfst) 67944 } 67945 } else { 67946 for (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (iAmt > 0) { 67947 var i int32 = (int32(iOfst / sqlite3_int64((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk))) 67948 var pSubOpen uintptr = multiplexSubOpen(tls, pGroup, i, bp /* &rc */, uintptr(0), 1) 67949 if pSubOpen != 0 { 67950 var extra int32 = (int32((uint32((int32(iOfst % sqlite3_int64((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk))) + iAmt)) - (*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk)) 67951 if extra < 0 { 67952 extra = 0 67953 } 67954 iAmt = iAmt - (extra) 67955 *(*int32)(unsafe.Pointer(bp /* rc */)) = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 24 /* &.xWrite */))))(tls, pSubOpen, pBuf, iAmt, 67956 (iOfst % sqlite3_int64((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk))) 67957 pBuf = (pBuf + uintptr(iAmt)) 67958 iOfst = iOfst + (sqlite3_int64(iAmt)) 67959 iAmt = extra 67960 } 67961 } 67962 } 67963 return *(*int32)(unsafe.Pointer(bp /* rc */)) 67964 } 67965 67966 // Pass xTruncate requests thru to the original VFS after 67967 // determining the correct chunk to operate on. Delete any 67968 // chunks above the truncate mark. 67969 func multiplexTruncate(tls *libc.TLS, pConn uintptr, size sqlite3_int64) int32 { /* test_multiplex.c:799:12: */ 67970 bp := tls.Alloc(4) 67971 defer tls.Free(4) 67972 67973 var p uintptr = pConn 67974 var pGroup uintptr = (*multiplexConn)(unsafe.Pointer(p)).FpGroup 67975 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK 67976 if !(int32((*multiplexGroup)(unsafe.Pointer(pGroup)).FbEnabled) != 0) { 67977 var pSubOpen uintptr = multiplexSubOpen(tls, pGroup, 0, bp /* &rc */, uintptr(0), 0) 67978 if pSubOpen == uintptr(0) { 67979 *(*int32)(unsafe.Pointer(bp /* rc */)) = (SQLITE_IOERR | (int32(6) << 8)) 67980 } else { 67981 *(*int32)(unsafe.Pointer(bp /* rc */)) = (*(*func(*libc.TLS, uintptr, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 32 /* &.xTruncate */))))(tls, pSubOpen, size) 67982 } 67983 } else { 67984 var i int32 67985 var iBaseGroup int32 = (int32(size / sqlite3_int64((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk))) 67986 var pSubOpen uintptr 67987 var pOrigVfs uintptr = gMultiplex.FpOrigVfs // Real VFS 67988 // delete the chunks above the truncate limit 67989 for i = ((*multiplexGroup)(unsafe.Pointer(pGroup)).FnReal - 1); (i > iBaseGroup) && (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK); i-- { 67990 if (*multiplexGroup)(unsafe.Pointer(pGroup)).FbTruncate != 0 { 67991 multiplexSubClose(tls, pGroup, i, pOrigVfs) 67992 } else { 67993 pSubOpen = multiplexSubOpen(tls, pGroup, i, bp /* &rc */, uintptr(0), 0) 67994 if pSubOpen != 0 { 67995 *(*int32)(unsafe.Pointer(bp /* rc */)) = (*(*func(*libc.TLS, uintptr, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 32 /* &.xTruncate */))))(tls, pSubOpen, int64(0)) 67996 } 67997 } 67998 } 67999 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 68000 pSubOpen = multiplexSubOpen(tls, pGroup, iBaseGroup, bp /* &rc */, uintptr(0), 0) 68001 if pSubOpen != 0 { 68002 *(*int32)(unsafe.Pointer(bp /* rc */)) = (*(*func(*libc.TLS, uintptr, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 32 /* &.xTruncate */))))(tls, pSubOpen, (size % sqlite3_int64((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk))) 68003 } 68004 } 68005 if *(*int32)(unsafe.Pointer(bp /* rc */)) != 0 { 68006 *(*int32)(unsafe.Pointer(bp /* rc */)) = (SQLITE_IOERR | (int32(6) << 8)) 68007 } 68008 } 68009 return *(*int32)(unsafe.Pointer(bp /* rc */)) 68010 } 68011 68012 // Pass xSync requests through to the original VFS without change 68013 func multiplexSync(tls *libc.TLS, pConn uintptr, flags int32) int32 { /* test_multiplex.c:839:12: */ 68014 var p uintptr = pConn 68015 var pGroup uintptr = (*multiplexConn)(unsafe.Pointer(p)).FpGroup 68016 var rc int32 = SQLITE_OK 68017 var i int32 68018 for i = 0; i < (*multiplexGroup)(unsafe.Pointer(pGroup)).FnReal; i++ { 68019 var pSubOpen uintptr = (*multiplexReal)(unsafe.Pointer((*multiplexGroup)(unsafe.Pointer(pGroup)).FaReal + uintptr(i)*16)).Fp 68020 if pSubOpen != 0 { 68021 var rc2 int32 = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 40 /* &.xSync */))))(tls, pSubOpen, flags) 68022 if rc2 != SQLITE_OK { 68023 rc = rc2 68024 } 68025 } 68026 } 68027 return rc 68028 } 68029 68030 // Pass xFileSize requests through to the original VFS. 68031 // Aggregate the size of all the chunks before returning. 68032 func multiplexFileSize(tls *libc.TLS, pConn uintptr, pSize uintptr) int32 { /* test_multiplex.c:857:12: */ 68033 bp := tls.Alloc(4) 68034 defer tls.Free(4) 68035 68036 var p uintptr = pConn 68037 var pGroup uintptr = (*multiplexConn)(unsafe.Pointer(p)).FpGroup 68038 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK 68039 var i int32 68040 if !(int32((*multiplexGroup)(unsafe.Pointer(pGroup)).FbEnabled) != 0) { 68041 var pSubOpen uintptr = multiplexSubOpen(tls, pGroup, 0, bp /* &rc */, uintptr(0), 0) 68042 if pSubOpen == uintptr(0) { 68043 *(*int32)(unsafe.Pointer(bp /* rc */)) = (SQLITE_IOERR | (int32(7) << 8)) 68044 } else { 68045 *(*int32)(unsafe.Pointer(bp /* rc */)) = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 48 /* &.xFileSize */))))(tls, pSubOpen, pSize) 68046 } 68047 } else { 68048 *(*sqlite3_int64)(unsafe.Pointer(pSize)) = int64(0) 68049 for i = 0; *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK; i++ { 68050 var sz sqlite3_int64 = multiplexSubSize(tls, pGroup, i, bp /* &rc */) 68051 if sz == int64(0) { 68052 break 68053 } 68054 *(*sqlite3_int64)(unsafe.Pointer(pSize)) = ((sqlite3_int64(i) * sqlite3_int64((*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk)) + sz) 68055 } 68056 } 68057 return *(*int32)(unsafe.Pointer(bp /* rc */)) 68058 } 68059 68060 // Pass xLock requests through to the original VFS unchanged. 68061 func multiplexLock(tls *libc.TLS, pConn uintptr, lock int32) int32 { /* test_multiplex.c:882:12: */ 68062 bp := tls.Alloc(4) 68063 defer tls.Free(4) 68064 68065 var p uintptr = pConn 68066 // var rc int32 at bp, 4 68067 68068 var pSubOpen uintptr = multiplexSubOpen(tls, (*multiplexConn)(unsafe.Pointer(p)).FpGroup, 0, bp /* &rc */, uintptr(0), 0) 68069 if pSubOpen != 0 { 68070 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 56 /* &.xLock */))))(tls, pSubOpen, lock) 68071 } 68072 return SQLITE_BUSY 68073 } 68074 68075 // Pass xUnlock requests through to the original VFS unchanged. 68076 func multiplexUnlock(tls *libc.TLS, pConn uintptr, lock int32) int32 { /* test_multiplex.c:894:12: */ 68077 bp := tls.Alloc(4) 68078 defer tls.Free(4) 68079 68080 var p uintptr = pConn 68081 // var rc int32 at bp, 4 68082 68083 var pSubOpen uintptr = multiplexSubOpen(tls, (*multiplexConn)(unsafe.Pointer(p)).FpGroup, 0, bp /* &rc */, uintptr(0), 0) 68084 if pSubOpen != 0 { 68085 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 64 /* &.xUnlock */))))(tls, pSubOpen, lock) 68086 } 68087 return (SQLITE_IOERR | (int32(8) << 8)) 68088 } 68089 68090 // Pass xCheckReservedLock requests through to the original VFS unchanged. 68091 func multiplexCheckReservedLock(tls *libc.TLS, pConn uintptr, pResOut uintptr) int32 { /* test_multiplex.c:906:12: */ 68092 bp := tls.Alloc(4) 68093 defer tls.Free(4) 68094 68095 var p uintptr = pConn 68096 // var rc int32 at bp, 4 68097 68098 var pSubOpen uintptr = multiplexSubOpen(tls, (*multiplexConn)(unsafe.Pointer(p)).FpGroup, 0, bp /* &rc */, uintptr(0), 0) 68099 if pSubOpen != 0 { 68100 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 72 /* &.xCheckReservedLock */))))(tls, pSubOpen, pResOut) 68101 } 68102 return (SQLITE_IOERR | (int32(14) << 8)) 68103 } 68104 68105 // Pass xFileControl requests through to the original VFS unchanged, 68106 // except for any MULTIPLEX_CTRL_* requests here. 68107 func multiplexFileControl(tls *libc.TLS, pConn uintptr, op int32, pArg uintptr) int32 { /* test_multiplex.c:919:12: */ 68108 bp := tls.Alloc(12) 68109 defer tls.Free(12) 68110 68111 var p uintptr = pConn 68112 var pGroup uintptr = (*multiplexConn)(unsafe.Pointer(p)).FpGroup 68113 *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_ERROR 68114 var pSubOpen uintptr 68115 68116 if !(gMultiplex.FisInitialized != 0) { 68117 return SQLITE_MISUSE 68118 } 68119 switch op { 68120 case MULTIPLEX_CTRL_ENABLE: 68121 if pArg != 0 { 68122 var bEnabled int32 = *(*int32)(unsafe.Pointer(pArg)) 68123 (*multiplexGroup)(unsafe.Pointer(pGroup)).FbEnabled = uint8(bEnabled) 68124 *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK 68125 } 68126 break 68127 case MULTIPLEX_CTRL_SET_CHUNK_SIZE: 68128 if pArg != 0 { 68129 var szChunk uint32 = *(*uint32)(unsafe.Pointer(pArg)) 68130 if szChunk < uint32(1) { 68131 *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_MISUSE 68132 } else { 68133 // Round up to nearest multiple of MAX_PAGE_SIZE. 68134 szChunk = (szChunk + (uint32(MAX_PAGE_SIZE - 1))) 68135 szChunk = szChunk & (libc.Uint32FromInt32(libc.CplInt32((MAX_PAGE_SIZE - 1)))) 68136 (*multiplexGroup)(unsafe.Pointer(pGroup)).FszChunk = szChunk 68137 *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK 68138 } 68139 } 68140 break 68141 case MULTIPLEX_CTRL_SET_MAX_CHUNKS: 68142 *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK 68143 break 68144 case SQLITE_FCNTL_SIZE_HINT: 68145 fallthrough 68146 case SQLITE_FCNTL_CHUNK_SIZE: 68147 // no-op these 68148 *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK 68149 break 68150 case SQLITE_FCNTL_PRAGMA: 68151 { 68152 var aFcntl uintptr = pArg 68153 // EVIDENCE-OF: R-29875-31678 The argument to the SQLITE_FCNTL_PRAGMA 68154 // file control is an array of pointers to strings (char**) in which the 68155 // second element of the array is the name of the pragma and the third 68156 // element is the argument to the pragma or NULL if the pragma has no 68157 // argument. 68158 if (*(*uintptr)(unsafe.Pointer(aFcntl + 1*8)) != 0) && (sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(aFcntl + 1*8)), ts+34042 /* "multiplex_trunca..." */) == 0) { 68159 if (*(*uintptr)(unsafe.Pointer(aFcntl + 2*8)) != 0) && (*(*int8)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(aFcntl + 2*8)))) != 0) { 68160 if (sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(aFcntl + 2*8)), ts+4049 /* "on" */) == 0) || 68161 (sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(aFcntl + 2*8)), ts+28250 /* "1" */) == 0) { 68162 (*multiplexGroup)(unsafe.Pointer(pGroup)).FbTruncate = uint8(1) 68163 } else if (sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(aFcntl + 2*8)), ts+4413 /* "off" */) == 0) || 68164 (sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(aFcntl + 2*8)), ts+13875 /* "0" */) == 0) { 68165 (*multiplexGroup)(unsafe.Pointer(pGroup)).FbTruncate = uint8(0) 68166 } 68167 } 68168 // EVIDENCE-OF: R-27806-26076 The handler for an SQLITE_FCNTL_PRAGMA 68169 // file control can optionally make the first element of the char** 68170 // argument point to a string obtained from sqlite3_mprintf() or the 68171 // equivalent and that string will become the result of the pragma 68172 // or the error message if the pragma fails. 68173 *(*uintptr)(unsafe.Pointer(aFcntl)) = sqlite3.Xsqlite3_mprintf(tls, func() uintptr { 68174 if (*multiplexGroup)(unsafe.Pointer(pGroup)).FbTruncate != 0 { 68175 return ts + 4049 /* "on" */ 68176 } 68177 return ts + 4413 /* "off" */ 68178 }(), 0) 68179 *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = SQLITE_OK 68180 break 68181 } 68182 // If the multiplexor does not handle the pragma, pass it through 68183 // into the default case. 68184 68185 } 68186 fallthrough 68187 default: 68188 pSubOpen = multiplexSubOpen(tls, pGroup, 0, bp+8 /* &rc */, uintptr(0), 0) 68189 if pSubOpen != 0 { 68190 *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 80 /* &.xFileControl */))))(tls, pSubOpen, op, pArg) 68191 if (op == SQLITE_FCNTL_VFSNAME) && (*(*int32)(unsafe.Pointer(bp + 8 /* rc */)) == SQLITE_OK) { 68192 *(*uintptr)(unsafe.Pointer(pArg)) = sqlite3.Xsqlite3_mprintf(tls, ts+34061 /* "multiplex/%z" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(pArg)))) 68193 } 68194 } 68195 break 68196 } 68197 return *(*int32)(unsafe.Pointer(bp + 8 /* rc */)) 68198 } 68199 68200 // Pass xSectorSize requests through to the original VFS unchanged. 68201 func multiplexSectorSize(tls *libc.TLS, pConn uintptr) int32 { /* test_multiplex.c:1004:12: */ 68202 bp := tls.Alloc(4) 68203 defer tls.Free(4) 68204 68205 var p uintptr = pConn 68206 // var rc int32 at bp, 4 68207 68208 var pSubOpen uintptr = multiplexSubOpen(tls, (*multiplexConn)(unsafe.Pointer(p)).FpGroup, 0, bp /* &rc */, uintptr(0), 0) 68209 if (pSubOpen != 0) && ((*sqlite3_io_methods1)(unsafe.Pointer((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods)).FxSectorSize != 0) { 68210 return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 88 /* &.xSectorSize */))))(tls, pSubOpen) 68211 } 68212 return DEFAULT_SECTOR_SIZE 68213 } 68214 68215 // Pass xDeviceCharacteristics requests through to the original VFS unchanged. 68216 func multiplexDeviceCharacteristics(tls *libc.TLS, pConn uintptr) int32 { /* test_multiplex.c:1016:12: */ 68217 bp := tls.Alloc(4) 68218 defer tls.Free(4) 68219 68220 var p uintptr = pConn 68221 // var rc int32 at bp, 4 68222 68223 var pSubOpen uintptr = multiplexSubOpen(tls, (*multiplexConn)(unsafe.Pointer(p)).FpGroup, 0, bp /* &rc */, uintptr(0), 0) 68224 if pSubOpen != 0 { 68225 return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 96 /* &.xDeviceCharacteristics */))))(tls, pSubOpen) 68226 } 68227 return 0 68228 } 68229 68230 // Pass xShmMap requests through to the original VFS unchanged. 68231 func multiplexShmMap(tls *libc.TLS, pConn uintptr, iRegion int32, szRegion int32, bExtend int32, pp uintptr) int32 { /* test_multiplex.c:1028:12: */ 68232 bp := tls.Alloc(4) 68233 defer tls.Free(4) 68234 68235 var p uintptr = pConn 68236 // var rc int32 at bp, 4 68237 68238 var pSubOpen uintptr = multiplexSubOpen(tls, (*multiplexConn)(unsafe.Pointer(p)).FpGroup, 0, bp /* &rc */, uintptr(0), 0) 68239 if pSubOpen != 0 { 68240 return (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 104 /* &.xShmMap */))))(tls, pSubOpen, iRegion, szRegion, bExtend, libc.AtomicLoadUintptr(&pp)) 68241 } 68242 return SQLITE_IOERR 68243 } 68244 68245 // Pass xShmLock requests through to the original VFS unchanged. 68246 func multiplexShmLock(tls *libc.TLS, pConn uintptr, ofst int32, n int32, flags int32) int32 { /* test_multiplex.c:1046:12: */ 68247 bp := tls.Alloc(4) 68248 defer tls.Free(4) 68249 68250 var p uintptr = pConn 68251 // var rc int32 at bp, 4 68252 68253 var pSubOpen uintptr = multiplexSubOpen(tls, (*multiplexConn)(unsafe.Pointer(p)).FpGroup, 0, bp /* &rc */, uintptr(0), 0) 68254 if pSubOpen != 0 { 68255 return (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 112 /* &.xShmLock */))))(tls, pSubOpen, ofst, n, flags) 68256 } 68257 return SQLITE_BUSY 68258 } 68259 68260 // Pass xShmBarrier requests through to the original VFS unchanged. 68261 func multiplexShmBarrier(tls *libc.TLS, pConn uintptr) { /* test_multiplex.c:1063:13: */ 68262 bp := tls.Alloc(4) 68263 defer tls.Free(4) 68264 68265 var p uintptr = pConn 68266 // var rc int32 at bp, 4 68267 68268 var pSubOpen uintptr = multiplexSubOpen(tls, (*multiplexConn)(unsafe.Pointer(p)).FpGroup, 0, bp /* &rc */, uintptr(0), 0) 68269 if pSubOpen != 0 { 68270 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 120 /* &.xShmBarrier */))))(tls, pSubOpen) 68271 } 68272 } 68273 68274 // Pass xShmUnmap requests through to the original VFS unchanged. 68275 func multiplexShmUnmap(tls *libc.TLS, pConn uintptr, deleteFlag int32) int32 { /* test_multiplex.c:1074:12: */ 68276 bp := tls.Alloc(4) 68277 defer tls.Free(4) 68278 68279 var p uintptr = pConn 68280 // var rc int32 at bp, 4 68281 68282 var pSubOpen uintptr = multiplexSubOpen(tls, (*multiplexConn)(unsafe.Pointer(p)).FpGroup, 0, bp /* &rc */, uintptr(0), 0) 68283 if pSubOpen != 0 { 68284 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 128 /* &.xShmUnmap */))))(tls, pSubOpen, deleteFlag) 68285 } 68286 return SQLITE_OK 68287 } 68288 68289 //************************* Public Interfaces **************************** 68290 // CAPI: Initialize the multiplex VFS shim - sqlite3_multiplex_initialize() 68291 // 68292 // Use the VFS named zOrigVfsName as the VFS that does the actual work. 68293 // Use the default if zOrigVfsName==NULL. 68294 // 68295 // The multiplex VFS shim is named "multiplex". It will become the default 68296 // VFS if makeDefault is non-zero. 68297 // 68298 // THIS ROUTINE IS NOT THREADSAFE. Call this routine exactly once 68299 // during start-up. 68300 func sqlite3_multiplex_initialize(tls *libc.TLS, zOrigVfsName uintptr, makeDefault int32) int32 { /* test_multiplex.c:1097:5: */ 68301 var pOrigVfs uintptr 68302 if gMultiplex.FisInitialized != 0 { 68303 return SQLITE_MISUSE 68304 } 68305 pOrigVfs = sqlite3.Xsqlite3_vfs_find(tls, zOrigVfsName) 68306 if pOrigVfs == uintptr(0) { 68307 return SQLITE_ERROR 68308 } 68309 68310 gMultiplex.FisInitialized = 1 68311 gMultiplex.FpOrigVfs = pOrigVfs 68312 gMultiplex.FsThisVfs = *(*sqlite3_vfs)(unsafe.Pointer(pOrigVfs)) 68313 *(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&gMultiplex)) + 8 /* &.sThisVfs */ + 4 /* &.szOsFile */)) += int32((uint64(unsafe.Sizeof(multiplexConn{})))) 68314 gMultiplex.FsThisVfs.FzName = ts + 34074 /* "multiplex" */ 68315 gMultiplex.FsThisVfs.FxOpen = *(*uintptr)(unsafe.Pointer(&struct { 68316 f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32 68317 }{multiplexOpen})) 68318 gMultiplex.FsThisVfs.FxDelete = *(*uintptr)(unsafe.Pointer(&struct { 68319 f func(*libc.TLS, uintptr, uintptr, int32) int32 68320 }{multiplexDelete})) 68321 gMultiplex.FsThisVfs.FxAccess = *(*uintptr)(unsafe.Pointer(&struct { 68322 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 68323 }{multiplexAccess})) 68324 gMultiplex.FsThisVfs.FxFullPathname = *(*uintptr)(unsafe.Pointer(&struct { 68325 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 68326 }{multiplexFullPathname})) 68327 gMultiplex.FsThisVfs.FxDlOpen = *(*uintptr)(unsafe.Pointer(&struct { 68328 f func(*libc.TLS, uintptr, uintptr) uintptr 68329 }{multiplexDlOpen})) 68330 gMultiplex.FsThisVfs.FxDlError = *(*uintptr)(unsafe.Pointer(&struct { 68331 f func(*libc.TLS, uintptr, int32, uintptr) 68332 }{multiplexDlError})) 68333 gMultiplex.FsThisVfs.FxDlSym = *(*uintptr)(unsafe.Pointer(&struct { 68334 f func(*libc.TLS, uintptr, uintptr, uintptr) uintptr 68335 }{multiplexDlSym})) 68336 gMultiplex.FsThisVfs.FxDlClose = *(*uintptr)(unsafe.Pointer(&struct { 68337 f func(*libc.TLS, uintptr, uintptr) 68338 }{multiplexDlClose})) 68339 gMultiplex.FsThisVfs.FxRandomness = *(*uintptr)(unsafe.Pointer(&struct { 68340 f func(*libc.TLS, uintptr, int32, uintptr) int32 68341 }{multiplexRandomness})) 68342 gMultiplex.FsThisVfs.FxSleep = *(*uintptr)(unsafe.Pointer(&struct { 68343 f func(*libc.TLS, uintptr, int32) int32 68344 }{multiplexSleep})) 68345 gMultiplex.FsThisVfs.FxCurrentTime = *(*uintptr)(unsafe.Pointer(&struct { 68346 f func(*libc.TLS, uintptr, uintptr) int32 68347 }{multiplexCurrentTime})) 68348 gMultiplex.FsThisVfs.FxGetLastError = *(*uintptr)(unsafe.Pointer(&struct { 68349 f func(*libc.TLS, uintptr, int32, uintptr) int32 68350 }{multiplexGetLastError})) 68351 gMultiplex.FsThisVfs.FxCurrentTimeInt64 = *(*uintptr)(unsafe.Pointer(&struct { 68352 f func(*libc.TLS, uintptr, uintptr) int32 68353 }{multiplexCurrentTimeInt64})) 68354 68355 gMultiplex.FsIoMethodsV1.FiVersion = 1 68356 gMultiplex.FsIoMethodsV1.FxClose = *(*uintptr)(unsafe.Pointer(&struct { 68357 f func(*libc.TLS, uintptr) int32 68358 }{multiplexClose})) 68359 gMultiplex.FsIoMethodsV1.FxRead = *(*uintptr)(unsafe.Pointer(&struct { 68360 f func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32 68361 }{multiplexRead})) 68362 gMultiplex.FsIoMethodsV1.FxWrite = *(*uintptr)(unsafe.Pointer(&struct { 68363 f func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32 68364 }{multiplexWrite})) 68365 gMultiplex.FsIoMethodsV1.FxTruncate = *(*uintptr)(unsafe.Pointer(&struct { 68366 f func(*libc.TLS, uintptr, sqlite3_int64) int32 68367 }{multiplexTruncate})) 68368 gMultiplex.FsIoMethodsV1.FxSync = *(*uintptr)(unsafe.Pointer(&struct { 68369 f func(*libc.TLS, uintptr, int32) int32 68370 }{multiplexSync})) 68371 gMultiplex.FsIoMethodsV1.FxFileSize = *(*uintptr)(unsafe.Pointer(&struct { 68372 f func(*libc.TLS, uintptr, uintptr) int32 68373 }{multiplexFileSize})) 68374 gMultiplex.FsIoMethodsV1.FxLock = *(*uintptr)(unsafe.Pointer(&struct { 68375 f func(*libc.TLS, uintptr, int32) int32 68376 }{multiplexLock})) 68377 gMultiplex.FsIoMethodsV1.FxUnlock = *(*uintptr)(unsafe.Pointer(&struct { 68378 f func(*libc.TLS, uintptr, int32) int32 68379 }{multiplexUnlock})) 68380 gMultiplex.FsIoMethodsV1.FxCheckReservedLock = *(*uintptr)(unsafe.Pointer(&struct { 68381 f func(*libc.TLS, uintptr, uintptr) int32 68382 }{multiplexCheckReservedLock})) 68383 gMultiplex.FsIoMethodsV1.FxFileControl = *(*uintptr)(unsafe.Pointer(&struct { 68384 f func(*libc.TLS, uintptr, int32, uintptr) int32 68385 }{multiplexFileControl})) 68386 gMultiplex.FsIoMethodsV1.FxSectorSize = *(*uintptr)(unsafe.Pointer(&struct { 68387 f func(*libc.TLS, uintptr) int32 68388 }{multiplexSectorSize})) 68389 gMultiplex.FsIoMethodsV1.FxDeviceCharacteristics = *(*uintptr)(unsafe.Pointer(&struct { 68390 f func(*libc.TLS, uintptr) int32 68391 }{multiplexDeviceCharacteristics})) 68392 gMultiplex.FsIoMethodsV2 = gMultiplex.FsIoMethodsV1 68393 gMultiplex.FsIoMethodsV2.FiVersion = 2 68394 gMultiplex.FsIoMethodsV2.FxShmMap = *(*uintptr)(unsafe.Pointer(&struct { 68395 f func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32 68396 }{multiplexShmMap})) 68397 gMultiplex.FsIoMethodsV2.FxShmLock = *(*uintptr)(unsafe.Pointer(&struct { 68398 f func(*libc.TLS, uintptr, int32, int32, int32) int32 68399 }{multiplexShmLock})) 68400 gMultiplex.FsIoMethodsV2.FxShmBarrier = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{multiplexShmBarrier})) 68401 gMultiplex.FsIoMethodsV2.FxShmUnmap = *(*uintptr)(unsafe.Pointer(&struct { 68402 f func(*libc.TLS, uintptr, int32) int32 68403 }{multiplexShmUnmap})) 68404 sqlite3.Xsqlite3_vfs_register(tls, (uintptr(unsafe.Pointer(&gMultiplex)) + 8 /* &.sThisVfs */), makeDefault) 68405 68406 sqlite3.Xsqlite3_auto_extension(tls, *(*uintptr)(unsafe.Pointer(&struct { 68407 f func(*libc.TLS, uintptr, uintptr, uintptr) int32 68408 }{multiplexFuncInit}))) 68409 68410 return SQLITE_OK 68411 } 68412 68413 // CAPI: Shutdown the multiplex system - sqlite3_multiplex_shutdown() 68414 // 68415 // All SQLite database connections must be closed before calling this 68416 // routine. 68417 // 68418 // THIS ROUTINE IS NOT THREADSAFE. Call this routine exactly once while 68419 // shutting down in order to free all remaining multiplex groups. 68420 func sqlite3_multiplex_shutdown(tls *libc.TLS, eForce int32) int32 { /* test_multiplex.c:1158:5: */ 68421 var rc int32 = SQLITE_OK 68422 if gMultiplex.FisInitialized == 0 { 68423 return SQLITE_MISUSE 68424 } 68425 gMultiplex.FisInitialized = 0 68426 sqlite3.Xsqlite3_vfs_unregister(tls, (uintptr(unsafe.Pointer(&gMultiplex)) + 8 /* &.sThisVfs */)) 68427 libc.Xmemset(tls, uintptr(unsafe.Pointer(&gMultiplex)), 0, uint64(unsafe.Sizeof(gMultiplex))) 68428 return rc 68429 } 68430 68431 // tclcmd: sqlite3_multiplex_initialize NAME MAKEDEFAULT 68432 func test_multiplex_initialize(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_multiplex.c:1183:26: */ 68433 bp := tls.Alloc(4) 68434 defer tls.Free(4) 68435 68436 var zName uintptr // Name of new multiplex VFS 68437 // var makeDefault int32 at bp, 4 68438 // True to make the new VFS the default 68439 var rc int32 // Value returned by multiplex_initialize() 68440 68441 _ = clientData 68442 68443 // Process arguments 68444 if objc != 3 { 68445 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+34084 /* "NAME MAKEDEFAULT" */) 68446 return TCL_ERROR 68447 } 68448 zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 68449 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &makeDefault */) != 0 { 68450 return TCL_ERROR 68451 } 68452 if int32(*(*int8)(unsafe.Pointer(zName))) == 0 { 68453 zName = uintptr(0) 68454 } 68455 68456 // Call sqlite3_multiplex_initialize() 68457 rc = sqlite3_multiplex_initialize(tls, zName, *(*int32)(unsafe.Pointer(bp /* makeDefault */))) 68458 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 68459 68460 return TCL_OK 68461 } 68462 68463 // tclcmd: sqlite3_multiplex_shutdown 68464 func test_multiplex_shutdown(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_multiplex.c:1214:26: */ 68465 var rc int32 // Value returned by multiplex_shutdown() 68466 68467 _ = clientData 68468 68469 if (objc == 2) && (libc.Xstrcmp(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), ts+34101 /* "-force" */) != 0) { 68470 objc = 3 68471 } 68472 if (objc != 1) && (objc != 2) { 68473 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+34108 /* "?-force?" */) 68474 return TCL_ERROR 68475 } 68476 68477 // Call sqlite3_multiplex_shutdown() 68478 rc = sqlite3_multiplex_shutdown(tls, (libc.Bool32(objc == 2))) 68479 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 68480 68481 return TCL_OK 68482 } 68483 68484 // Tclcmd: test_multiplex_control HANDLE DBNAME SUB-COMMAND ?INT-VALUE? 68485 func test_multiplex_control(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_multiplex.c:1242:26: */ 68486 bp := tls.Alloc(176) 68487 defer tls.Free(176) 68488 68489 var rc int32 // Return code from file_control() 68490 // var idx int32 at bp+168, 4 68491 // Index in aSub[] 68492 // var cmdInfo Tcl_CmdInfo at bp+40, 64 68493 // Command info structure for HANDLE 68494 var db uintptr // Underlying db handle for HANDLE 68495 *(*int32)(unsafe.Pointer(bp + 172 /* iValue */)) = 0 68496 var pArg uintptr = uintptr(0) 68497 68498 *(*[4]struct { 68499 FzName uintptr 68500 Fop int32 68501 Fargtype int32 68502 })(unsafe.Pointer(bp + 104 /* aSub */)) = [4]struct { 68503 FzName uintptr 68504 Fop int32 68505 Fargtype int32 68506 }{ 68507 {FzName: ts + 34117 /* "enable" */, Fop: MULTIPLEX_CTRL_ENABLE, Fargtype: 1}, 68508 {FzName: ts + 34124 /* "chunk_size" */, Fop: MULTIPLEX_CTRL_SET_CHUNK_SIZE, Fargtype: 1}, 68509 {FzName: ts + 34135 /* "max_chunks" */, Fop: MULTIPLEX_CTRL_SET_MAX_CHUNKS, Fargtype: 1}, 68510 {}, 68511 } 68512 68513 if objc != 5 { 68514 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+34146 /* "HANDLE DBNAME SU..." */) 68515 return TCL_ERROR 68516 } 68517 68518 if 0 == tcl.XTcl_GetCommandInfo(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+40 /* &cmdInfo */) { 68519 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+34182 /* "expected databas..." */, 0)) 68520 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), ts+11636 /* "\"" */, 0)) 68521 return TCL_ERROR 68522 } else { 68523 db = *(*uintptr)(unsafe.Pointer((*Tcl_CmdInfo)(unsafe.Pointer(bp + 40 /* &cmdInfo */)).FobjClientData)) 68524 } 68525 68526 rc = tcl.XTcl_GetIndexFromObjStruct(tls, 68527 interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+104 /* &aSub[0] */, int32(unsafe.Sizeof(struct { 68528 FzName uintptr 68529 Fop int32 68530 Fargtype int32 68531 }{})), ts+1875 /* "sub-command" */, 0, bp+168 /* &idx */) 68532 if rc != TCL_OK { 68533 return rc 68534 } 68535 68536 switch (*struct { 68537 FzName uintptr 68538 Fop int32 68539 Fargtype int32 68540 })(unsafe.Pointer(bp + 104 /* &aSub */ + uintptr(*(*int32)(unsafe.Pointer(bp + 168 /* idx */)))*16)).Fargtype { 68541 case 1: 68542 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+172 /* &iValue */) != 0 { 68543 return TCL_ERROR 68544 } 68545 pArg = bp + 172 /* &iValue */ 68546 break 68547 default: 68548 tcl.XTcl_WrongNumArgs(tls, interp, 4, objv, ts+2384 /* "SUB-COMMAND" */) 68549 return TCL_ERROR 68550 } 68551 68552 rc = sqlite3.Xsqlite3_file_control(tls, db, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), (*struct { 68553 FzName uintptr 68554 Fop int32 68555 Fargtype int32 68556 })(unsafe.Pointer(bp+104 /* &aSub */ +uintptr(*(*int32)(unsafe.Pointer(bp + 168 /* idx */)))*16)).Fop, pArg) 68557 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 68558 if rc == SQLITE_OK { 68559 return TCL_OK 68560 } 68561 return TCL_ERROR 68562 } 68563 68564 // This routine registers the custom TCL commands defined in this 68565 // module. This should be the only procedure visible from outside 68566 // of this module. 68567 func Sqlitemultiplex_Init(tls *libc.TLS, interp uintptr) int32 { /* test_multiplex.c:1306:5: */ 68568 var i int32 68569 68570 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aCmd7)) / uint64(unsafe.Sizeof(struct { 68571 FzName uintptr 68572 FxProc uintptr 68573 }{}))); i++ { 68574 tcl.XTcl_CreateObjCommand(tls, interp, aCmd7[i].FzName, aCmd7[i].FxProc, uintptr(0), uintptr(0)) 68575 } 68576 68577 return TCL_OK 68578 } 68579 68580 var aCmd7 = [3]struct { 68581 FzName uintptr 68582 FxProc uintptr 68583 }{ 68584 {FzName: ts + 34214 /* "sqlite3_multiple..." */, FxProc: 0}, 68585 {FzName: ts + 34243 /* "sqlite3_multiple..." */, FxProc: 0}, 68586 {FzName: ts + 34270 /* "sqlite3_multiple..." */, FxProc: 0}, 68587 } /* test_multiplex.c:1310:5 */ 68588 68589 // CAPI3REF: Standard File Control Opcodes 68590 // KEYWORDS: {file control opcodes} {file control opcode} 68591 // 68592 // These integer constants are opcodes for the xFileControl method 68593 // of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] 68594 // interface. 68595 // 68596 // <ul> 68597 // <li>[[SQLITE_FCNTL_LOCKSTATE]] 68598 // The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This 68599 // opcode causes the xFileControl method to write the current state of 68600 // the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED], 68601 // [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE]) 68602 // into an integer that the pArg argument points to. This capability 68603 // is used during testing and is only available when the SQLITE_TEST 68604 // compile-time option is used. 68605 // 68606 // <li>[[SQLITE_FCNTL_SIZE_HINT]] 68607 // The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS 68608 // layer a hint of how large the database file will grow to be during the 68609 // current transaction. This hint is not guaranteed to be accurate but it 68610 // is often close. The underlying VFS might choose to preallocate database 68611 // file space based on this hint in order to help writes to the database 68612 // file run faster. 68613 // 68614 // <li>[[SQLITE_FCNTL_SIZE_LIMIT]] 68615 // The [SQLITE_FCNTL_SIZE_LIMIT] opcode is used by in-memory VFS that 68616 // implements [sqlite3_deserialize()] to set an upper bound on the size 68617 // of the in-memory database. The argument is a pointer to a [sqlite3_int64]. 68618 // If the integer pointed to is negative, then it is filled in with the 68619 // current limit. Otherwise the limit is set to the larger of the value 68620 // of the integer pointed to and the current database size. The integer 68621 // pointed to is set to the new limit. 68622 // 68623 // <li>[[SQLITE_FCNTL_CHUNK_SIZE]] 68624 // The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS 68625 // extends and truncates the database file in chunks of a size specified 68626 // by the user. The fourth argument to [sqlite3_file_control()] should 68627 // point to an integer (type int) containing the new chunk-size to use 68628 // for the nominated database. Allocating database file space in large 68629 // chunks (say 1MB at a time), may reduce file-system fragmentation and 68630 // improve performance on some systems. 68631 // 68632 // <li>[[SQLITE_FCNTL_FILE_POINTER]] 68633 // The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer 68634 // to the [sqlite3_file] object associated with a particular database 68635 // connection. See also [SQLITE_FCNTL_JOURNAL_POINTER]. 68636 // 68637 // <li>[[SQLITE_FCNTL_JOURNAL_POINTER]] 68638 // The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer 68639 // to the [sqlite3_file] object associated with the journal file (either 68640 // the [rollback journal] or the [write-ahead log]) for a particular database 68641 // connection. See also [SQLITE_FCNTL_FILE_POINTER]. 68642 // 68643 // <li>[[SQLITE_FCNTL_SYNC_OMITTED]] 68644 // No longer in use. 68645 // 68646 // <li>[[SQLITE_FCNTL_SYNC]] 68647 // The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and 68648 // sent to the VFS immediately before the xSync method is invoked on a 68649 // database file descriptor. Or, if the xSync method is not invoked 68650 // because the user has configured SQLite with 68651 // [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place 68652 // of the xSync method. In most cases, the pointer argument passed with 68653 // this file-control is NULL. However, if the database file is being synced 68654 // as part of a multi-database commit, the argument points to a nul-terminated 68655 // string containing the transactions super-journal file name. VFSes that 68656 // do not need this signal should silently ignore this opcode. Applications 68657 // should not call [sqlite3_file_control()] with this opcode as doing so may 68658 // disrupt the operation of the specialized VFSes that do require it. 68659 // 68660 // <li>[[SQLITE_FCNTL_COMMIT_PHASETWO]] 68661 // The [SQLITE_FCNTL_COMMIT_PHASETWO] opcode is generated internally by SQLite 68662 // and sent to the VFS after a transaction has been committed immediately 68663 // but before the database is unlocked. VFSes that do not need this signal 68664 // should silently ignore this opcode. Applications should not call 68665 // [sqlite3_file_control()] with this opcode as doing so may disrupt the 68666 // operation of the specialized VFSes that do require it. 68667 // 68668 // <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]] 68669 // ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic 68670 // retry counts and intervals for certain disk I/O operations for the 68671 // windows [VFS] in order to provide robustness in the presence of 68672 // anti-virus programs. By default, the windows VFS will retry file read, 68673 // file write, and file delete operations up to 10 times, with a delay 68674 // of 25 milliseconds before the first retry and with the delay increasing 68675 // by an additional 25 milliseconds with each subsequent retry. This 68676 // opcode allows these two values (10 retries and 25 milliseconds of delay) 68677 // to be adjusted. The values are changed for all database connections 68678 // within the same process. The argument is a pointer to an array of two 68679 // integers where the first integer is the new retry count and the second 68680 // integer is the delay. If either integer is negative, then the setting 68681 // is not changed but instead the prior value of that setting is written 68682 // into the array entry, allowing the current retry settings to be 68683 // interrogated. The zDbName parameter is ignored. 68684 // 68685 // <li>[[SQLITE_FCNTL_PERSIST_WAL]] 68686 // ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the 68687 // persistent [WAL | Write Ahead Log] setting. By default, the auxiliary 68688 // write ahead log ([WAL file]) and shared memory 68689 // files used for transaction control 68690 // are automatically deleted when the latest connection to the database 68691 // closes. Setting persistent WAL mode causes those files to persist after 68692 // close. Persisting the files is useful when other processes that do not 68693 // have write permission on the directory containing the database file want 68694 // to read the database file, as the WAL and shared memory files must exist 68695 // in order for the database to be readable. The fourth parameter to 68696 // [sqlite3_file_control()] for this opcode should be a pointer to an integer. 68697 // That integer is 0 to disable persistent WAL mode or 1 to enable persistent 68698 // WAL mode. If the integer is -1, then it is overwritten with the current 68699 // WAL persistence setting. 68700 // 68701 // <li>[[SQLITE_FCNTL_POWERSAFE_OVERWRITE]] 68702 // ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the 68703 // persistent "powersafe-overwrite" or "PSOW" setting. The PSOW setting 68704 // determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the 68705 // xDeviceCharacteristics methods. The fourth parameter to 68706 // [sqlite3_file_control()] for this opcode should be a pointer to an integer. 68707 // That integer is 0 to disable zero-damage mode or 1 to enable zero-damage 68708 // mode. If the integer is -1, then it is overwritten with the current 68709 // zero-damage mode setting. 68710 // 68711 // <li>[[SQLITE_FCNTL_OVERWRITE]] 68712 // ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening 68713 // a write transaction to indicate that, unless it is rolled back for some 68714 // reason, the entire database file will be overwritten by the current 68715 // transaction. This is used by VACUUM operations. 68716 // 68717 // <li>[[SQLITE_FCNTL_VFSNAME]] 68718 // ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of 68719 // all [VFSes] in the VFS stack. The names are of all VFS shims and the 68720 // final bottom-level VFS are written into memory obtained from 68721 // [sqlite3_malloc()] and the result is stored in the char* variable 68722 // that the fourth parameter of [sqlite3_file_control()] points to. 68723 // The caller is responsible for freeing the memory when done. As with 68724 // all file-control actions, there is no guarantee that this will actually 68725 // do anything. Callers should initialize the char* variable to a NULL 68726 // pointer in case this file-control is not implemented. This file-control 68727 // is intended for diagnostic use only. 68728 // 68729 // <li>[[SQLITE_FCNTL_VFS_POINTER]] 68730 // ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level 68731 // [VFSes] currently in use. ^(The argument X in 68732 // sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be 68733 // of type "[sqlite3_vfs] **". This opcodes will set *X 68734 // to a pointer to the top-level VFS.)^ 68735 // ^When there are multiple VFS shims in the stack, this opcode finds the 68736 // upper-most shim only. 68737 // 68738 // <li>[[SQLITE_FCNTL_PRAGMA]] 68739 // ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA] 68740 // file control is sent to the open [sqlite3_file] object corresponding 68741 // to the database file to which the pragma statement refers. ^The argument 68742 // to the [SQLITE_FCNTL_PRAGMA] file control is an array of 68743 // pointers to strings (char**) in which the second element of the array 68744 // is the name of the pragma and the third element is the argument to the 68745 // pragma or NULL if the pragma has no argument. ^The handler for an 68746 // [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element 68747 // of the char** argument point to a string obtained from [sqlite3_mprintf()] 68748 // or the equivalent and that string will become the result of the pragma or 68749 // the error message if the pragma fails. ^If the 68750 // [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal 68751 // [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA] 68752 // file control returns [SQLITE_OK], then the parser assumes that the 68753 // VFS has handled the PRAGMA itself and the parser generates a no-op 68754 // prepared statement if result string is NULL, or that returns a copy 68755 // of the result string if the string is non-NULL. 68756 // ^If the [SQLITE_FCNTL_PRAGMA] file control returns 68757 // any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means 68758 // that the VFS encountered an error while handling the [PRAGMA] and the 68759 // compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA] 68760 // file control occurs at the beginning of pragma statement analysis and so 68761 // it is able to override built-in [PRAGMA] statements. 68762 // 68763 // <li>[[SQLITE_FCNTL_BUSYHANDLER]] 68764 // ^The [SQLITE_FCNTL_BUSYHANDLER] 68765 // file-control may be invoked by SQLite on the database file handle 68766 // shortly after it is opened in order to provide a custom VFS with access 68767 // to the connection's busy-handler callback. The argument is of type (void**) 68768 // - an array of two (void *) values. The first (void *) actually points 68769 // to a function of type (int (*)(void *)). In order to invoke the connection's 68770 // busy-handler, this function should be invoked with the second (void *) in 68771 // the array as the only argument. If it returns non-zero, then the operation 68772 // should be retried. If it returns zero, the custom VFS should abandon the 68773 // current operation. 68774 // 68775 // <li>[[SQLITE_FCNTL_TEMPFILENAME]] 68776 // ^Applications can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control 68777 // to have SQLite generate a 68778 // temporary filename using the same algorithm that is followed to generate 68779 // temporary filenames for TEMP tables and other internal uses. The 68780 // argument should be a char** which will be filled with the filename 68781 // written into memory obtained from [sqlite3_malloc()]. The caller should 68782 // invoke [sqlite3_free()] on the result to avoid a memory leak. 68783 // 68784 // <li>[[SQLITE_FCNTL_MMAP_SIZE]] 68785 // The [SQLITE_FCNTL_MMAP_SIZE] file control is used to query or set the 68786 // maximum number of bytes that will be used for memory-mapped I/O. 68787 // The argument is a pointer to a value of type sqlite3_int64 that 68788 // is an advisory maximum number of bytes in the file to memory map. The 68789 // pointer is overwritten with the old value. The limit is not changed if 68790 // the value originally pointed to is negative, and so the current limit 68791 // can be queried by passing in a pointer to a negative number. This 68792 // file-control is used internally to implement [PRAGMA mmap_size]. 68793 // 68794 // <li>[[SQLITE_FCNTL_TRACE]] 68795 // The [SQLITE_FCNTL_TRACE] file control provides advisory information 68796 // to the VFS about what the higher layers of the SQLite stack are doing. 68797 // This file control is used by some VFS activity tracing [shims]. 68798 // The argument is a zero-terminated string. Higher layers in the 68799 // SQLite stack may generate instances of this file control if 68800 // the [SQLITE_USE_FCNTL_TRACE] compile-time option is enabled. 68801 // 68802 // <li>[[SQLITE_FCNTL_HAS_MOVED]] 68803 // The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a 68804 // pointer to an integer and it writes a boolean into that integer depending 68805 // on whether or not the file has been renamed, moved, or deleted since it 68806 // was first opened. 68807 // 68808 // <li>[[SQLITE_FCNTL_WIN32_GET_HANDLE]] 68809 // The [SQLITE_FCNTL_WIN32_GET_HANDLE] opcode can be used to obtain the 68810 // underlying native file handle associated with a file handle. This file 68811 // control interprets its argument as a pointer to a native file handle and 68812 // writes the resulting value there. 68813 // 68814 // <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]] 68815 // The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This 68816 // opcode causes the xFileControl method to swap the file handle with the one 68817 // pointed to by the pArg argument. This capability is used during testing 68818 // and only needs to be supported when SQLITE_TEST is defined. 68819 // 68820 // <li>[[SQLITE_FCNTL_WAL_BLOCK]] 68821 // The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might 68822 // be advantageous to block on the next WAL lock if the lock is not immediately 68823 // available. The WAL subsystem issues this signal during rare 68824 // circumstances in order to fix a problem with priority inversion. 68825 // Applications should <em>not</em> use this file-control. 68826 // 68827 // <li>[[SQLITE_FCNTL_ZIPVFS]] 68828 // The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other 68829 // VFS should return SQLITE_NOTFOUND for this opcode. 68830 // 68831 // <li>[[SQLITE_FCNTL_RBU]] 68832 // The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by 68833 // the RBU extension only. All other VFS should return SQLITE_NOTFOUND for 68834 // this opcode. 68835 // 68836 // <li>[[SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]] 68837 // If the [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] opcode returns SQLITE_OK, then 68838 // the file descriptor is placed in "batch write mode", which 68839 // means all subsequent write operations will be deferred and done 68840 // atomically at the next [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. Systems 68841 // that do not support batch atomic writes will return SQLITE_NOTFOUND. 68842 // ^Following a successful SQLITE_FCNTL_BEGIN_ATOMIC_WRITE and prior to 68843 // the closing [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] or 68844 // [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE], SQLite will make 68845 // no VFS interface calls on the same [sqlite3_file] file descriptor 68846 // except for calls to the xWrite method and the xFileControl method 68847 // with [SQLITE_FCNTL_SIZE_HINT]. 68848 // 68849 // <li>[[SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]] 68850 // The [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] opcode causes all write 68851 // operations since the previous successful call to 68852 // [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be performed atomically. 68853 // This file control returns [SQLITE_OK] if and only if the writes were 68854 // all performed successfully and have been committed to persistent storage. 68855 // ^Regardless of whether or not it is successful, this file control takes 68856 // the file descriptor out of batch write mode so that all subsequent 68857 // write operations are independent. 68858 // ^SQLite will never invoke SQLITE_FCNTL_COMMIT_ATOMIC_WRITE without 68859 // a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]. 68860 // 68861 // <li>[[SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE]] 68862 // The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write 68863 // operations since the previous successful call to 68864 // [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back. 68865 // ^This file control takes the file descriptor out of batch write mode 68866 // so that all subsequent write operations are independent. 68867 // ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without 68868 // a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]. 68869 // 68870 // <li>[[SQLITE_FCNTL_LOCK_TIMEOUT]] 68871 // The [SQLITE_FCNTL_LOCK_TIMEOUT] opcode is used to configure a VFS 68872 // to block for up to M milliseconds before failing when attempting to 68873 // obtain a file lock using the xLock or xShmLock methods of the VFS. 68874 // The parameter is a pointer to a 32-bit signed integer that contains 68875 // the value that M is to be set to. Before returning, the 32-bit signed 68876 // integer is overwritten with the previous value of M. 68877 // 68878 // <li>[[SQLITE_FCNTL_DATA_VERSION]] 68879 // The [SQLITE_FCNTL_DATA_VERSION] opcode is used to detect changes to 68880 // a database file. The argument is a pointer to a 32-bit unsigned integer. 68881 // The "data version" for the pager is written into the pointer. The 68882 // "data version" changes whenever any change occurs to the corresponding 68883 // database file, either through SQL statements on the same database 68884 // connection or through transactions committed by separate database 68885 // connections possibly in other processes. The [sqlite3_total_changes()] 68886 // interface can be used to find if any database on the connection has changed, 68887 // but that interface responds to changes on TEMP as well as MAIN and does 68888 // not provide a mechanism to detect changes to MAIN only. Also, the 68889 // [sqlite3_total_changes()] interface responds to internal changes only and 68890 // omits changes made by other database connections. The 68891 // [PRAGMA data_version] command provides a mechanism to detect changes to 68892 // a single attached database that occur due to other database connections, 68893 // but omits changes implemented by the database connection on which it is 68894 // called. This file control is the only mechanism to detect changes that 68895 // happen either internally or externally and that are associated with 68896 // a particular attached database. 68897 // 68898 // <li>[[SQLITE_FCNTL_CKPT_START]] 68899 // The [SQLITE_FCNTL_CKPT_START] opcode is invoked from within a checkpoint 68900 // in wal mode before the client starts to copy pages from the wal 68901 // file to the database file. 68902 // 68903 // <li>[[SQLITE_FCNTL_CKPT_DONE]] 68904 // The [SQLITE_FCNTL_CKPT_DONE] opcode is invoked from within a checkpoint 68905 // in wal mode after the client has finished copying pages from the wal 68906 // file to the database file, but before the *-shm file is updated to 68907 // record the fact that the pages have been checkpointed. 68908 // </ul> 68909 68910 // deprecated names 68911 68912 // CAPI3REF: Mutex Handle 68913 // 68914 // The mutex module within SQLite defines [sqlite3_mutex] to be an 68915 // abstract type for a mutex object. The SQLite core never looks 68916 // at the internal representation of an [sqlite3_mutex]. It only 68917 // deals with pointers to the [sqlite3_mutex] object. 68918 // 68919 // Mutexes are created using [sqlite3_mutex_alloc()]. 68920 type sqlite3_mutex = sqlite3_mutex1 /* sqlite3.h:1187:30 */ 68921 68922 var aName = [15]uintptr{ 68923 ts + 34296 /* "fast" */, ts + 34301 /* "recursive" */, ts + 34311 /* "static_main" */, ts + 34323, /* "static_mem" */ 68924 ts + 34334 /* "static_open" */, ts + 34346 /* "static_prng" */, ts + 34358 /* "static_lru" */, ts + 34369, /* "static_pmem" */ 68925 ts + 34381 /* "static_app1" */, ts + 34393 /* "static_app2" */, ts + 34405 /* "static_app3" */, ts + 34417, /* "static_vfs1" */ 68926 ts + 34429 /* "static_vfs2" */, ts + 34441 /* "static_vfs3" */, uintptr(0), 68927 } /* test_mutex.c:32:19 */ 68928 68929 // State variables 68930 type test_mutex_globals = struct { 68931 FisInstalled int32 68932 FdisableInit int32 68933 FdisableTry int32 68934 FisInit int32 68935 Fm sqlite3_mutex_methods 68936 FaCounter [14]int32 68937 FaStatic [12]sqlite3_mutex 68938 } /* test_mutex.c:46:8 */ 68939 68940 // State variables 68941 var g3 = test_mutex_globals{} /* test_mutex.c:54:3 */ 68942 68943 // Return true if the countable mutex is currently held 68944 func counterMutexHeld(tls *libc.TLS, p uintptr) int32 { /* test_mutex.c:57:12: */ 68945 return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&g3)) + 16 /* &.m */ + 56 /* &.xMutexHeld */))))(tls, (*sqlite3_mutex)(unsafe.Pointer(p)).FpReal) 68946 } 68947 68948 // Return true if the countable mutex is not currently held 68949 func counterMutexNotheld(tls *libc.TLS, p uintptr) int32 { /* test_mutex.c:62:12: */ 68950 return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&g3)) + 16 /* &.m */ + 64 /* &.xMutexNotheld */))))(tls, (*sqlite3_mutex)(unsafe.Pointer(p)).FpReal) 68951 } 68952 68953 // Initialize the countable mutex interface 68954 // Or, if g.disableInit is non-zero, then do not initialize but instead 68955 // return the value of g.disableInit as the result code. This can be used 68956 // to simulate an initialization failure. 68957 func counterMutexInit(tls *libc.TLS) int32 { /* test_mutex.c:71:12: */ 68958 var rc int32 68959 if g3.FdisableInit != 0 { 68960 return g3.FdisableInit 68961 } 68962 rc = (*(*func(*libc.TLS) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&g3)) + 16 /* &.m */ /* &.xMutexInit */))))(tls) 68963 g3.FisInit = 1 68964 return rc 68965 } 68966 68967 // Uninitialize the mutex subsystem 68968 func counterMutexEnd(tls *libc.TLS) int32 { /* test_mutex.c:82:12: */ 68969 g3.FisInit = 0 68970 return (*(*func(*libc.TLS) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&g3)) + 16 /* &.m */ + 8 /* &.xMutexEnd */))))(tls) 68971 } 68972 68973 // Allocate a countable mutex 68974 func counterMutexAlloc(tls *libc.TLS, eType int32) uintptr { /* test_mutex.c:90:22: */ 68975 var pReal uintptr 68976 var pRet uintptr = uintptr(0) 68977 68978 pReal = (*(*func(*libc.TLS, int32) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&g3)) + 16 /* &.m */ + 16 /* &.xMutexAlloc */))))(tls, eType) 68979 if !(pReal != 0) { 68980 return uintptr(0) 68981 } 68982 68983 if (eType == SQLITE_MUTEX_FAST) || (eType == SQLITE_MUTEX_RECURSIVE) { 68984 pRet = libc.Xmalloc(tls, uint64(unsafe.Sizeof(sqlite3_mutex{}))) 68985 } else { 68986 var eStaticType int32 = (eType - ((SQLITE_MUTEX_STATIC_VFS3 + 1) - ((SQLITE_MUTEX_STATIC_VFS3 + 1) - (SQLITE_MUTEX_RECURSIVE + 1)))) 68987 68988 pRet = ((uintptr(unsafe.Pointer(&g3)) + 144 /* &.aStatic */) + uintptr(eStaticType)*16) 68989 } 68990 68991 (*sqlite3_mutex)(unsafe.Pointer(pRet)).FeType = eType 68992 (*sqlite3_mutex)(unsafe.Pointer(pRet)).FpReal = pReal 68993 return pRet 68994 } 68995 68996 // Free a countable mutex 68997 func counterMutexFree(tls *libc.TLS, p uintptr) { /* test_mutex.c:118:13: */ 68998 68999 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((uintptr(unsafe.Pointer(&g3)) + 16 /* &.m */ + 24 /* &.xMutexFree */))))(tls, (*sqlite3_mutex)(unsafe.Pointer(p)).FpReal) 69000 if ((*sqlite3_mutex)(unsafe.Pointer(p)).FeType == SQLITE_MUTEX_FAST) || ((*sqlite3_mutex)(unsafe.Pointer(p)).FeType == SQLITE_MUTEX_RECURSIVE) { 69001 libc.Xfree(tls, p) 69002 } 69003 } 69004 69005 // Enter a countable mutex. Block until entry is safe. 69006 func counterMutexEnter(tls *libc.TLS, p uintptr) { /* test_mutex.c:129:13: */ 69007 69008 *(*int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&g3)) + 88 /* &.aCounter */) + uintptr((*sqlite3_mutex)(unsafe.Pointer(p)).FeType)*4))++ 69009 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((uintptr(unsafe.Pointer(&g3)) + 16 /* &.m */ + 32 /* &.xMutexEnter */))))(tls, (*sqlite3_mutex)(unsafe.Pointer(p)).FpReal) 69010 } 69011 69012 // Try to enter a mutex. Return true on success. 69013 func counterMutexTry(tls *libc.TLS, p uintptr) int32 { /* test_mutex.c:140:12: */ 69014 69015 *(*int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&g3)) + 88 /* &.aCounter */) + uintptr((*sqlite3_mutex)(unsafe.Pointer(p)).FeType)*4))++ 69016 if g3.FdisableTry != 0 { 69017 return SQLITE_BUSY 69018 } 69019 return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&g3)) + 16 /* &.m */ + 40 /* &.xMutexTry */))))(tls, (*sqlite3_mutex)(unsafe.Pointer(p)).FpReal) 69020 } 69021 69022 // Leave a mutex 69023 func counterMutexLeave(tls *libc.TLS, p uintptr) { /* test_mutex.c:151:13: */ 69024 69025 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((uintptr(unsafe.Pointer(&g3)) + 16 /* &.m */ + 48 /* &.xMutexLeave */))))(tls, (*sqlite3_mutex)(unsafe.Pointer(p)).FpReal) 69026 } 69027 69028 // sqlite3_shutdown 69029 func test_shutdown(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_mutex.c:159:26: */ 69030 var rc int32 69031 69032 if objc != 1 { 69033 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 69034 return TCL_ERROR 69035 } 69036 69037 rc = sqlite3.Xsqlite3_shutdown(tls) 69038 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 69039 return TCL_OK 69040 } 69041 69042 // sqlite3_initialize 69043 func test_initialize(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_mutex.c:180:26: */ 69044 var rc int32 69045 69046 if objc != 1 { 69047 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 69048 return TCL_ERROR 69049 } 69050 69051 rc = sqlite3.Xsqlite3_initialize(tls) 69052 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 69053 return TCL_OK 69054 } 69055 69056 // install_mutex_counters BOOLEAN 69057 func test_install_mutex_counters(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_mutex.c:201:26: */ 69058 bp := tls.Alloc(136) 69059 defer tls.Free(136) 69060 69061 var rc int32 = SQLITE_OK 69062 // var isInstall int32 at bp+56, 4 69063 69064 *(*sqlite3_mutex_methods)(unsafe.Pointer(bp + 64 /* counter_methods */)) = sqlite3_mutex_methods{ 69065 FxMutexInit: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS) int32 }{counterMutexInit})), 69066 FxMutexEnd: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS) int32 }{counterMutexEnd})), 69067 FxMutexAlloc: *(*uintptr)(unsafe.Pointer(&struct { 69068 f func(*libc.TLS, int32) uintptr 69069 }{counterMutexAlloc})), 69070 FxMutexFree: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{counterMutexFree})), 69071 FxMutexEnter: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{counterMutexEnter})), 69072 FxMutexTry: *(*uintptr)(unsafe.Pointer(&struct { 69073 f func(*libc.TLS, uintptr) int32 69074 }{counterMutexTry})), 69075 FxMutexLeave: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{counterMutexLeave})), 69076 FxMutexHeld: *(*uintptr)(unsafe.Pointer(&struct { 69077 f func(*libc.TLS, uintptr) int32 69078 }{counterMutexHeld})), 69079 FxMutexNotheld: *(*uintptr)(unsafe.Pointer(&struct { 69080 f func(*libc.TLS, uintptr) int32 69081 }{counterMutexNotheld})), 69082 } 69083 69084 if objc != 2 { 69085 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+17888 /* "BOOLEAN" */) 69086 return TCL_ERROR 69087 } 69088 if TCL_OK != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+56 /* &isInstall */) { 69089 return TCL_ERROR 69090 } 69091 69092 if *(*int32)(unsafe.Pointer(bp + 56 /* isInstall */)) == g3.FisInstalled { 69093 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+34453 /* "mutex counters a..." */, 0)) 69094 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, func() uintptr { 69095 if *(*int32)(unsafe.Pointer(bp + 56 /* isInstall */)) != 0 { 69096 return ts + 34473 /* "already installe..." */ 69097 } 69098 return ts + 34491 /* "not installed" */ 69099 }(), 0)) 69100 return TCL_ERROR 69101 } 69102 69103 if *(*int32)(unsafe.Pointer(bp + 56 /* isInstall */)) != 0 { 69104 69105 rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_GETMUTEX, libc.VaList(bp+32, (uintptr(unsafe.Pointer(&g3))+16 /* &.m */))) 69106 if rc == SQLITE_OK { 69107 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MUTEX, libc.VaList(bp+40, bp+64 /* &counter_methods */)) 69108 } 69109 g3.FdisableTry = 0 69110 } else { 69111 69112 rc = sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_MUTEX, libc.VaList(bp+48, (uintptr(unsafe.Pointer(&g3))+16 /* &.m */))) 69113 libc.Xmemset(tls, (uintptr(unsafe.Pointer(&g3)) + 16 /* &.m */), 0, uint64(unsafe.Sizeof(sqlite3_mutex_methods{}))) 69114 } 69115 69116 if rc == SQLITE_OK { 69117 g3.FisInstalled = *(*int32)(unsafe.Pointer(bp + 56 /* isInstall */)) 69118 } 69119 69120 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 69121 return TCL_OK 69122 } 69123 69124 // read_mutex_counters 69125 func test_read_mutex_counters(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_mutex.c:262:26: */ 69126 var pRet uintptr 69127 var ii int32 69128 69129 if objc != 1 { 69130 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 69131 return TCL_ERROR 69132 } 69133 69134 pRet = tcl.XTcl_NewObj(tls) 69135 (*Tcl_Obj)(unsafe.Pointer(pRet)).FrefCount++ 69136 for ii = 0; ii < (SQLITE_MUTEX_STATIC_VFS3 + 1); ii++ { 69137 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewStringObj(tls, aName[ii], -1)) 69138 tcl.XTcl_ListObjAppendElement(tls, interp, pRet, tcl.XTcl_NewIntObj(tls, *(*int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&g3)) + 88 /* &.aCounter */) + uintptr(ii)*4)))) 69139 } 69140 tcl.XTcl_SetObjResult(tls, interp, pRet) 69141 for ok := true; ok; ok = 0 != 0 { 69142 var _objPtr uintptr = pRet 69143 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 69144 tcl.XTclFreeObj(tls, _objPtr) 69145 } 69146 } 69147 69148 return TCL_OK 69149 } 69150 69151 // clear_mutex_counters 69152 func test_clear_mutex_counters(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_mutex.c:291:26: */ 69153 var ii int32 69154 69155 if objc != 1 { 69156 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 69157 return TCL_ERROR 69158 } 69159 69160 for ii = 0; ii < (SQLITE_MUTEX_STATIC_VFS3 + 1); ii++ { 69161 *(*int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&g3)) + 88 /* &.aCounter */) + uintptr(ii)*4)) = 0 69162 } 69163 return TCL_OK 69164 } 69165 69166 // Create and free a mutex. Return the mutex pointer. The pointer 69167 // will be invalid since the mutex has already been freed. The 69168 // return pointer just checks to see if the mutex really was allocated. 69169 func test_alloc_mutex(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_mutex.c:315:26: */ 69170 bp := tls.Alloc(124) 69171 defer tls.Free(124) 69172 69173 var p uintptr = sqlite3.Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_FAST) 69174 // var zBuf [100]int8 at bp+24, 100 69175 69176 sqlite3.Xsqlite3_mutex_free(tls, p) 69177 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([100]int8{})), bp+24 /* &zBuf[0] */, ts+13023 /* "%p" */, libc.VaList(bp, p)) 69178 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+8, bp+24 /* &zBuf[0] */, uintptr(0))) 69179 return TCL_OK 69180 } 69181 69182 // sqlite3_config OPTION 69183 // 69184 // OPTION can be either one of the keywords: 69185 // 69186 // SQLITE_CONFIG_SINGLETHREAD 69187 // SQLITE_CONFIG_MULTITHREAD 69188 // SQLITE_CONFIG_SERIALIZED 69189 // 69190 // Or OPTION can be an raw integer. 69191 func test_config(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_mutex.c:342:26: */ 69192 bp := tls.Alloc(68) 69193 defer tls.Free(68) 69194 69195 *(*[4]ConfigOption)(unsafe.Pointer(bp /* aOpt */)) = [4]ConfigOption{ 69196 {FzName: ts + 34505 /* "singlethread" */, FiValue: SQLITE_CONFIG_SINGLETHREAD}, 69197 {FzName: ts + 34518 /* "multithread" */, FiValue: SQLITE_CONFIG_MULTITHREAD}, 69198 {FzName: ts + 34530 /* "serialized" */, FiValue: SQLITE_CONFIG_SERIALIZED}, 69199 {}, 69200 } 69201 var s int32 = int32(unsafe.Sizeof(ConfigOption{})) 69202 // var i int32 at bp+64, 4 69203 69204 var rc int32 69205 69206 if objc != 2 { 69207 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 69208 return TCL_ERROR 69209 } 69210 69211 if tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &aOpt[0] */, s, ts+17196 /* "flag" */, 0, bp+64 /* &i */) != 0 { 69212 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+64 /* &i */) != 0 { 69213 return TCL_ERROR 69214 } 69215 } else { 69216 *(*int32)(unsafe.Pointer(bp + 64 /* i */)) = (*ConfigOption)(unsafe.Pointer(bp /* &aOpt */ + uintptr(*(*int32)(unsafe.Pointer(bp + 64 /* i */)))*16)).FiValue 69217 } 69218 69219 rc = sqlite3.Xsqlite3_config(tls, *(*int32)(unsafe.Pointer(bp + 64 /* i */)), 0) 69220 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(1)) 69221 return TCL_OK 69222 } 69223 69224 type ConfigOption = struct { 69225 FzName uintptr 69226 FiValue int32 69227 _ [4]byte 69228 } /* test_mutex.c:348:3 */ 69229 69230 func getDbPointer1(tls *libc.TLS, pInterp uintptr, pObj uintptr) uintptr { /* test_mutex.c:379:16: */ 69231 bp := tls.Alloc(64) 69232 defer tls.Free(64) 69233 69234 var db uintptr 69235 // var info Tcl_CmdInfo at bp, 64 69236 69237 var zCmd uintptr = tcl.XTcl_GetString(tls, pObj) 69238 if tcl.XTcl_GetCommandInfo(tls, pInterp, zCmd, bp /* &info */) != 0 { 69239 db = *(*uintptr)(unsafe.Pointer((*Tcl_CmdInfo)(unsafe.Pointer(bp /* &info */)).FobjClientData)) 69240 } else { 69241 db = sqlite3TestTextToPtr(tls, zCmd) 69242 } 69243 69244 return db 69245 } 69246 69247 func getStaticMutexPointer(tls *libc.TLS, pInterp uintptr, pObj uintptr) uintptr { /* test_mutex.c:392:22: */ 69248 bp := tls.Alloc(4) 69249 defer tls.Free(4) 69250 69251 // var iMutex int32 at bp, 4 69252 69253 if tcl.XTcl_GetIndexFromObjStruct(tls, pInterp, pObj, uintptr(unsafe.Pointer(&aName)), int32(unsafe.Sizeof(uintptr(0))), ts+34541 /* "mutex name" */, 0, bp /* &iMutex */) != 0 { 69254 return uintptr(0) 69255 } 69256 69257 return counterMutexAlloc(tls, *(*int32)(unsafe.Pointer(bp /* iMutex */))) 69258 } 69259 69260 func test_enter_static_mutex(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_mutex.c:404:26: */ 69261 var pMutex uintptr 69262 if objc != 2 { 69263 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+10399 /* "NAME" */) 69264 return TCL_ERROR 69265 } 69266 pMutex = getStaticMutexPointer(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 69267 if !(pMutex != 0) { 69268 return TCL_ERROR 69269 } 69270 sqlite3.Xsqlite3_mutex_enter(tls, pMutex) 69271 return TCL_OK 69272 } 69273 69274 func test_leave_static_mutex(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_mutex.c:423:26: */ 69275 var pMutex uintptr 69276 if objc != 2 { 69277 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+10399 /* "NAME" */) 69278 return TCL_ERROR 69279 } 69280 pMutex = getStaticMutexPointer(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 69281 if !(pMutex != 0) { 69282 return TCL_ERROR 69283 } 69284 sqlite3.Xsqlite3_mutex_leave(tls, pMutex) 69285 return TCL_OK 69286 } 69287 69288 func test_enter_db_mutex(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_mutex.c:442:26: */ 69289 var db uintptr 69290 if objc != 2 { 69291 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 69292 return TCL_ERROR 69293 } 69294 db = getDbPointer1(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 69295 if !(db != 0) { 69296 return TCL_ERROR 69297 } 69298 sqlite3.Xsqlite3_mutex_enter(tls, sqlite3.Xsqlite3_db_mutex(tls, db)) 69299 return TCL_OK 69300 } 69301 69302 func test_leave_db_mutex(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_mutex.c:461:26: */ 69303 var db uintptr 69304 if objc != 2 { 69305 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 69306 return TCL_ERROR 69307 } 69308 db = getDbPointer1(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 69309 if !(db != 0) { 69310 return TCL_ERROR 69311 } 69312 sqlite3.Xsqlite3_mutex_leave(tls, sqlite3.Xsqlite3_db_mutex(tls, db)) 69313 return TCL_OK 69314 } 69315 69316 func Sqlitetest_mutex_Init(tls *libc.TLS, interp uintptr) int32 { /* test_mutex.c:480:5: */ 69317 var i int32 69318 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aCmd8)) / uint64(unsafe.Sizeof(struct { 69319 FzName uintptr 69320 FxProc uintptr 69321 }{}))); i++ { 69322 tcl.XTcl_CreateObjCommand(tls, interp, aCmd8[i].FzName, aCmd8[i].FxProc, uintptr(0), uintptr(0)) 69323 } 69324 69325 tcl.XTcl_LinkVar(tls, interp, ts+34552, /* "disable_mutex_in..." */ 69326 (uintptr(unsafe.Pointer(&g3)) + 4 /* &.disableInit */), TCL_LINK_INT) 69327 tcl.XTcl_LinkVar(tls, interp, ts+34571, /* "disable_mutex_tr..." */ 69328 (uintptr(unsafe.Pointer(&g3)) + 8 /* &.disableTry */), TCL_LINK_INT) 69329 return SQLITE_OK 69330 } 69331 69332 var aCmd8 = [11]struct { 69333 FzName uintptr 69334 FxProc uintptr 69335 }{ 69336 {FzName: ts + 34589 /* "sqlite3_shutdown" */, FxProc: 0}, 69337 {FzName: ts + 34606 /* "sqlite3_initiali..." */, FxProc: 0}, 69338 {FzName: ts + 34625 /* "sqlite3_config" */, FxProc: 0}, 69339 69340 {FzName: ts + 34640 /* "enter_static_mut..." */, FxProc: 0}, 69341 {FzName: ts + 34659 /* "leave_static_mut..." */, FxProc: 0}, 69342 69343 {FzName: ts + 34678 /* "enter_db_mutex" */, FxProc: 0}, 69344 {FzName: ts + 34693 /* "leave_db_mutex" */, FxProc: 0}, 69345 69346 {FzName: ts + 34708 /* "alloc_dealloc_mu..." */, FxProc: 0}, 69347 {FzName: ts + 34728 /* "install_mutex_co..." */, FxProc: 0}, 69348 {FzName: ts + 34751 /* "read_mutex_count..." */, FxProc: 0}, 69349 {FzName: ts + 34771 /* "clear_mutex_coun..." */, FxProc: 0}, 69350 } /* test_mutex.c:484:5 */ 69351 69352 // Maximum pathname length supported by the fs backend. 69353 69354 // Name used to identify this VFS. 69355 69356 type fs_real_file1 = struct { 69357 FpFile uintptr 69358 FzName uintptr 69359 FnDatabase int32 69360 FnJournal int32 69361 FnBlob int32 69362 FnRef int32 69363 FpNext uintptr 69364 FppThis uintptr 69365 } /* test_onefile.c:97:9 */ 69366 69367 // Maximum pathname length supported by the fs backend. 69368 69369 // Name used to identify this VFS. 69370 69371 type fs_real_file = fs_real_file1 /* test_onefile.c:97:29 */ 69372 69373 type fs_file1 = struct { 69374 Fbase sqlite3_file 69375 FeType int32 69376 _ [4]byte 69377 FpReal uintptr 69378 } /* test_onefile.c:109:9 */ 69379 69380 type fs_file = fs_file1 /* test_onefile.c:109:24 */ 69381 69382 type tmp_file1 = struct { 69383 Fbase sqlite3_file 69384 FnSize int32 69385 FnAlloc int32 69386 FzAlloc uintptr 69387 } /* test_onefile.c:116:9 */ 69388 69389 type tmp_file = tmp_file1 /* test_onefile.c:116:25 */ 69390 69391 type fs_vfs_t1 = struct { 69392 Fbase sqlite3_vfs 69393 FpFileList uintptr 69394 FpParent uintptr 69395 } /* test_onefile.c:176:9 */ 69396 69397 type fs_vfs_t = fs_vfs_t1 /* test_onefile.c:176:25 */ 69398 69399 var fs_vfs = fs_vfs_t{ 69400 Fbase: sqlite3_vfs{ 69401 FiVersion: 1, // pNext 69402 FzName: ts + 30388, /* "fs" */ // pAppData 69403 FxOpen: 0, // xOpen 69404 FxDelete: 0, // xDelete 69405 FxAccess: 0, // xAccess 69406 FxFullPathname: 0, // xFullPathname 69407 FxDlOpen: 0, // xDlOpen 69408 FxDlError: 0, // xDlError 69409 FxDlSym: 0, // xDlSym 69410 FxDlClose: 0, // xDlClose 69411 FxRandomness: 0, // xRandomness 69412 FxSleep: 0, // xSleep 69413 FxCurrentTime: 0, // xCurrentTimeInt64 69414 }, // pParent 69415 } /* test_onefile.c:183:17 */ 69416 69417 var fs_io_methods = sqlite3_io_methods{ 69418 FiVersion: 1, // iVersion 69419 FxClose: 0, // xClose 69420 FxRead: 0, // xRead 69421 FxWrite: 0, // xWrite 69422 FxTruncate: 0, // xTruncate 69423 FxSync: 0, // xSync 69424 FxFileSize: 0, // xFileSize 69425 FxLock: 0, // xLock 69426 FxUnlock: 0, // xUnlock 69427 FxCheckReservedLock: 0, // xCheckReservedLock 69428 FxFileControl: 0, // xFileControl 69429 FxSectorSize: 0, // xSectorSize 69430 FxDeviceCharacteristics: 0, // xShmUnmap 69431 } /* test_onefile.c:208:27 */ 69432 69433 var tmp_io_methods = sqlite3_io_methods{ 69434 FiVersion: 1, // iVersion 69435 FxClose: 0, // xClose 69436 FxRead: 0, // xRead 69437 FxWrite: 0, // xWrite 69438 FxTruncate: 0, // xTruncate 69439 FxSync: 0, // xSync 69440 FxFileSize: 0, // xFileSize 69441 FxLock: 0, // xLock 69442 FxUnlock: 0, // xUnlock 69443 FxCheckReservedLock: 0, // xCheckReservedLock 69444 FxFileControl: 0, // xFileControl 69445 FxSectorSize: 0, // xSectorSize 69446 FxDeviceCharacteristics: 0, // xShmUnmap 69447 } /* test_onefile.c:229:27 */ 69448 69449 // Useful macros used in several places 69450 69451 // Close a tmp-file. 69452 func tmpClose(tls *libc.TLS, pFile uintptr) int32 { /* test_onefile.c:257:12: */ 69453 var pTmp uintptr = pFile 69454 sqlite3.Xsqlite3_free(tls, (*tmp_file)(unsafe.Pointer(pTmp)).FzAlloc) 69455 return SQLITE_OK 69456 } 69457 69458 // Read data from a tmp-file. 69459 func tmpRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test_onefile.c:266:12: */ 69460 var pTmp uintptr = pFile 69461 if (sqlite_int64(iAmt) + iOfst) > sqlite_int64((*tmp_file)(unsafe.Pointer(pTmp)).FnSize) { 69462 return (SQLITE_IOERR | (int32(2) << 8)) 69463 } 69464 libc.Xmemcpy(tls, zBuf, ((*tmp_file)(unsafe.Pointer(pTmp)).FzAlloc + uintptr(iOfst)), uint64(iAmt)) 69465 return SQLITE_OK 69466 } 69467 69468 // Write data to a tmp-file. 69469 func tmpWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test_onefile.c:283:12: */ 69470 var pTmp uintptr = pFile 69471 if (sqlite_int64(iAmt) + iOfst) > sqlite_int64((*tmp_file)(unsafe.Pointer(pTmp)).FnAlloc) { 69472 var nNew int32 = (int32(int64(2) * ((sqlite_int64(iAmt) + iOfst) + sqlite_int64((*tmp_file)(unsafe.Pointer(pTmp)).FnAlloc)))) 69473 var zNew uintptr = sqlite3.Xsqlite3_realloc(tls, (*tmp_file)(unsafe.Pointer(pTmp)).FzAlloc, nNew) 69474 if !(zNew != 0) { 69475 return SQLITE_NOMEM 69476 } 69477 (*tmp_file)(unsafe.Pointer(pTmp)).FzAlloc = zNew 69478 (*tmp_file)(unsafe.Pointer(pTmp)).FnAlloc = nNew 69479 } 69480 libc.Xmemcpy(tls, ((*tmp_file)(unsafe.Pointer(pTmp)).FzAlloc + uintptr(iOfst)), zBuf, uint64(iAmt)) 69481 (*tmp_file)(unsafe.Pointer(pTmp)).FnSize = func() int32 { 69482 if (sqlite_int64((*tmp_file)(unsafe.Pointer(pTmp)).FnSize)) > (iOfst + sqlite_int64(iAmt)) { 69483 return (*tmp_file)(unsafe.Pointer(pTmp)).FnSize 69484 } 69485 return (int32(iOfst + sqlite_int64(iAmt))) 69486 }() 69487 return SQLITE_OK 69488 } 69489 69490 // Truncate a tmp-file. 69491 func tmpTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { /* test_onefile.c:307:12: */ 69492 var pTmp uintptr = pFile 69493 (*tmp_file)(unsafe.Pointer(pTmp)).FnSize = func() int32 { 69494 if (sqlite_int64((*tmp_file)(unsafe.Pointer(pTmp)).FnSize)) < (size) { 69495 return (*tmp_file)(unsafe.Pointer(pTmp)).FnSize 69496 } 69497 return int32(size) 69498 }() 69499 return SQLITE_OK 69500 } 69501 69502 // Sync a tmp-file. 69503 func tmpSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* test_onefile.c:316:12: */ 69504 return SQLITE_OK 69505 } 69506 69507 // Return the current file-size of a tmp-file. 69508 func tmpFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { /* test_onefile.c:323:12: */ 69509 var pTmp uintptr = pFile 69510 *(*sqlite_int64)(unsafe.Pointer(pSize)) = sqlite_int64((*tmp_file)(unsafe.Pointer(pTmp)).FnSize) 69511 return SQLITE_OK 69512 } 69513 69514 // Lock a tmp-file. 69515 func tmpLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_onefile.c:332:12: */ 69516 return SQLITE_OK 69517 } 69518 69519 // Unlock a tmp-file. 69520 func tmpUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_onefile.c:339:12: */ 69521 return SQLITE_OK 69522 } 69523 69524 // Check if another file-handle holds a RESERVED lock on a tmp-file. 69525 func tmpCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int32 { /* test_onefile.c:346:12: */ 69526 *(*int32)(unsafe.Pointer(pResOut)) = 0 69527 return SQLITE_OK 69528 } 69529 69530 // File control method. For custom operations on a tmp-file. 69531 func tmpFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 { /* test_onefile.c:354:12: */ 69532 return SQLITE_OK 69533 } 69534 69535 // Return the sector-size in bytes for a tmp-file. 69536 func tmpSectorSize(tls *libc.TLS, pFile uintptr) int32 { /* test_onefile.c:361:12: */ 69537 return 0 69538 } 69539 69540 // Return the device characteristic flags supported by a tmp-file. 69541 func tmpDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { /* test_onefile.c:368:12: */ 69542 return 0 69543 } 69544 69545 // Close an fs-file. 69546 func fsClose1(tls *libc.TLS, pFile uintptr) int32 { /* test_onefile.c:375:12: */ 69547 var rc int32 = SQLITE_OK 69548 var p uintptr = pFile 69549 var pReal uintptr = (*fs_file)(unsafe.Pointer(p)).FpReal 69550 69551 // Decrement the real_file ref-count. 69552 (*fs_real_file)(unsafe.Pointer(pReal)).FnRef-- 69553 69554 // When the ref-count reaches 0, destroy the structure 69555 if (*fs_real_file)(unsafe.Pointer(pReal)).FnRef == 0 { 69556 *(*uintptr)(unsafe.Pointer((*fs_real_file)(unsafe.Pointer(pReal)).FppThis)) = (*fs_real_file)(unsafe.Pointer(pReal)).FpNext 69557 if (*fs_real_file)(unsafe.Pointer(pReal)).FpNext != 0 { 69558 (*fs_real_file)(unsafe.Pointer((*fs_real_file)(unsafe.Pointer(pReal)).FpNext)).FppThis = (*fs_real_file)(unsafe.Pointer(pReal)).FppThis 69559 } 69560 rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*fs_real_file)(unsafe.Pointer(pReal)).FpFile)).FpMethods + 8 /* &.xClose */))))(tls, (*fs_real_file)(unsafe.Pointer(pReal)).FpFile) 69561 sqlite3.Xsqlite3_free(tls, pReal) 69562 } 69563 69564 return rc 69565 } 69566 69567 // Read data from an fs-file. 69568 func fsRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test_onefile.c:400:12: */ 69569 var rc int32 = SQLITE_OK 69570 var p uintptr = pFile 69571 var pReal uintptr = (*fs_file)(unsafe.Pointer(p)).FpReal 69572 var pF uintptr = (*fs_real_file)(unsafe.Pointer(pReal)).FpFile 69573 69574 if (((*fs_file)(unsafe.Pointer(p)).FeType == DATABASE_FILE) && ((sqlite_int64(iAmt) + iOfst) > sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase))) || 69575 (((*fs_file)(unsafe.Pointer(p)).FeType == JOURNAL_FILE) && ((sqlite_int64(iAmt) + iOfst) > sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnJournal))) { 69576 rc = (SQLITE_IOERR | (int32(2) << 8)) 69577 } else if (*fs_file)(unsafe.Pointer(p)).FeType == DATABASE_FILE { 69578 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pF)).FpMethods + 16 /* &.xRead */))))(tls, pF, zBuf, iAmt, (iOfst + int64(BLOCKSIZE))) 69579 } else { 69580 // Journal file. 69581 var iRem int32 = iAmt 69582 var iBuf int32 = 0 69583 var ii int32 = int32(iOfst) 69584 for (iRem > 0) && (rc == SQLITE_OK) { 69585 var iRealOff int32 = (((*fs_real_file)(unsafe.Pointer(pReal)).FnBlob - (BLOCKSIZE * ((ii / BLOCKSIZE) + 1))) + (ii % BLOCKSIZE)) 69586 var iRealAmt int32 = func() int32 { 69587 if (iRem) < (BLOCKSIZE - (iRealOff % BLOCKSIZE)) { 69588 return iRem 69589 } 69590 return (BLOCKSIZE - (iRealOff % BLOCKSIZE)) 69591 }() 69592 69593 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pF)).FpMethods + 16 /* &.xRead */))))(tls, pF, ((zBuf) + uintptr(iBuf)), iRealAmt, int64(iRealOff)) 69594 ii = ii + (iRealAmt) 69595 iBuf = iBuf + (iRealAmt) 69596 iRem = iRem - (iRealAmt) 69597 } 69598 } 69599 69600 return rc 69601 } 69602 69603 // Write data to an fs-file. 69604 func fsWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test_onefile.c:439:12: */ 69605 var rc int32 = SQLITE_OK 69606 var p uintptr = pFile 69607 var pReal uintptr = (*fs_file)(unsafe.Pointer(p)).FpReal 69608 var pF uintptr = (*fs_real_file)(unsafe.Pointer(pReal)).FpFile 69609 69610 if (*fs_file)(unsafe.Pointer(p)).FeType == DATABASE_FILE { 69611 if ((sqlite_int64(iAmt) + iOfst) + int64(BLOCKSIZE)) > (sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnBlob - (*fs_real_file)(unsafe.Pointer(pReal)).FnJournal)) { 69612 rc = SQLITE_FULL 69613 } else { 69614 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pF)).FpMethods + 24 /* &.xWrite */))))(tls, pF, zBuf, iAmt, (iOfst + int64(BLOCKSIZE))) 69615 if rc == SQLITE_OK { 69616 (*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase = func() int32 { 69617 if (sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase)) > (sqlite_int64(iAmt) + iOfst) { 69618 return (*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase 69619 } 69620 return (int32(sqlite_int64(iAmt) + iOfst)) 69621 }() 69622 } 69623 } 69624 } else { 69625 // Journal file. 69626 var iRem int32 = iAmt 69627 var iBuf int32 = 0 69628 var ii int32 = int32(iOfst) 69629 for (iRem > 0) && (rc == SQLITE_OK) { 69630 var iRealOff int32 = (((*fs_real_file)(unsafe.Pointer(pReal)).FnBlob - (BLOCKSIZE * ((ii / BLOCKSIZE) + 1))) + (ii % BLOCKSIZE)) 69631 var iRealAmt int32 = func() int32 { 69632 if (iRem) < (BLOCKSIZE - (iRealOff % BLOCKSIZE)) { 69633 return iRem 69634 } 69635 return (BLOCKSIZE - (iRealOff % BLOCKSIZE)) 69636 }() 69637 69638 if iRealOff < ((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase + BLOCKSIZE) { 69639 rc = SQLITE_FULL 69640 } else { 69641 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pF)).FpMethods + 24 /* &.xWrite */))))(tls, pF, ((zBuf) + uintptr(iBuf)), iRealAmt, int64(iRealOff)) 69642 ii = ii + (iRealAmt) 69643 iBuf = iBuf + (iRealAmt) 69644 iRem = iRem - (iRealAmt) 69645 } 69646 } 69647 if rc == SQLITE_OK { 69648 (*fs_real_file)(unsafe.Pointer(pReal)).FnJournal = func() int32 { 69649 if (sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnJournal)) > (sqlite_int64(iAmt) + iOfst) { 69650 return (*fs_real_file)(unsafe.Pointer(pReal)).FnJournal 69651 } 69652 return (int32(sqlite_int64(iAmt) + iOfst)) 69653 }() 69654 } 69655 } 69656 69657 return rc 69658 } 69659 69660 // Truncate an fs-file. 69661 func fsTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { /* test_onefile.c:488:12: */ 69662 var p uintptr = pFile 69663 var pReal uintptr = (*fs_file)(unsafe.Pointer(p)).FpReal 69664 if (*fs_file)(unsafe.Pointer(p)).FeType == DATABASE_FILE { 69665 (*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase = func() int32 { 69666 if (sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase)) < (size) { 69667 return (*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase 69668 } 69669 return int32(size) 69670 }() 69671 } else { 69672 (*fs_real_file)(unsafe.Pointer(pReal)).FnJournal = func() int32 { 69673 if (sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnJournal)) < (size) { 69674 return (*fs_real_file)(unsafe.Pointer(pReal)).FnJournal 69675 } 69676 return int32(size) 69677 }() 69678 } 69679 return SQLITE_OK 69680 } 69681 69682 // Sync an fs-file. 69683 func fsSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* test_onefile.c:502:12: */ 69684 bp := tls.Alloc(4) 69685 defer tls.Free(4) 69686 69687 var p uintptr = pFile 69688 var pReal uintptr = (*fs_file)(unsafe.Pointer(p)).FpReal 69689 var pRealFile uintptr = (*fs_real_file)(unsafe.Pointer(pReal)).FpFile 69690 var rc int32 = SQLITE_OK 69691 69692 if (*fs_file)(unsafe.Pointer(p)).FeType == DATABASE_FILE { 69693 // var zSize [4]uint8 at bp, 4 69694 69695 *(*uint8)(unsafe.Pointer(bp /* &zSize[0] */)) = (uint8((uint32((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase) & 0xFF000000) >> 24)) 69696 *(*uint8)(unsafe.Pointer(bp /* &zSize[0] */ + 1)) = (uint8(((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase & 0x00FF0000) >> 16)) 69697 *(*uint8)(unsafe.Pointer(bp /* &zSize[0] */ + 2)) = (uint8(((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase & 0x0000FF00) >> 8)) 69698 *(*uint8)(unsafe.Pointer(bp /* &zSize[0] */ + 3)) = (uint8((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase & 0x000000FF)) 69699 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pRealFile)).FpMethods + 24 /* &.xWrite */))))(tls, pRealFile, bp /* &zSize[0] */, 4, int64(0)) 69700 } 69701 if rc == SQLITE_OK { 69702 rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pRealFile)).FpMethods + 40 /* &.xSync */))))(tls, pRealFile, (flags & (libc.CplInt32(SQLITE_SYNC_DATAONLY)))) 69703 } 69704 69705 return rc 69706 } 69707 69708 // Return the current file-size of an fs-file. 69709 func fsFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { /* test_onefile.c:526:12: */ 69710 var p uintptr = pFile 69711 var pReal uintptr = (*fs_file)(unsafe.Pointer(p)).FpReal 69712 if (*fs_file)(unsafe.Pointer(p)).FeType == DATABASE_FILE { 69713 *(*sqlite_int64)(unsafe.Pointer(pSize)) = sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase) 69714 } else { 69715 *(*sqlite_int64)(unsafe.Pointer(pSize)) = sqlite_int64((*fs_real_file)(unsafe.Pointer(pReal)).FnJournal) 69716 } 69717 return SQLITE_OK 69718 } 69719 69720 // Lock an fs-file. 69721 func fsLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_onefile.c:540:12: */ 69722 return SQLITE_OK 69723 } 69724 69725 // Unlock an fs-file. 69726 func fsUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_onefile.c:547:12: */ 69727 return SQLITE_OK 69728 } 69729 69730 // Check if another file-handle holds a RESERVED lock on an fs-file. 69731 func fsCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int32 { /* test_onefile.c:554:12: */ 69732 *(*int32)(unsafe.Pointer(pResOut)) = 0 69733 return SQLITE_OK 69734 } 69735 69736 // File control method. For custom operations on an fs-file. 69737 func fsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 { /* test_onefile.c:562:12: */ 69738 if op == SQLITE_FCNTL_PRAGMA { 69739 return SQLITE_NOTFOUND 69740 } 69741 return SQLITE_OK 69742 } 69743 69744 // Return the sector-size in bytes for an fs-file. 69745 func fsSectorSize(tls *libc.TLS, pFile uintptr) int32 { /* test_onefile.c:570:12: */ 69746 return BLOCKSIZE 69747 } 69748 69749 // Return the device characteristic flags supported by an fs-file. 69750 func fsDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { /* test_onefile.c:577:12: */ 69751 return 0 69752 } 69753 69754 // Open an fs file handle. 69755 func fsOpen1(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags int32, pOutFlags uintptr) int32 { /* test_onefile.c:584:12: */ 69756 bp := tls.Alloc(12) 69757 defer tls.Free(12) 69758 69759 var pFsVfs uintptr 69760 var p uintptr 69761 var pReal uintptr 69762 var eType int32 69763 var nName int32 69764 var rc int32 69765 var p2 uintptr 69766 // var zS [4]uint8 at bp+8, 4 69767 69768 var real_flags int32 69769 // var size sqlite3_int64 at bp, 8 69770 69771 var pRealFile uintptr 69772 var pParent uintptr 69773 pFsVfs = pVfs 69774 p = pFile 69775 pReal = uintptr(0) 69776 rc = SQLITE_OK 69777 69778 if !(0 == (flags & (SQLITE_OPEN_MAIN_DB | SQLITE_OPEN_MAIN_JOURNAL))) { 69779 goto __1 69780 } 69781 p2 = pFile 69782 libc.Xmemset(tls, p2, 0, uint64(unsafe.Sizeof(tmp_file{}))) 69783 (*tmp_file)(unsafe.Pointer(p2)).Fbase.FpMethods = uintptr(unsafe.Pointer(&tmp_io_methods)) 69784 return SQLITE_OK 69785 __1: 69786 ; 69787 69788 eType = func() int32 { 69789 if (flags & (SQLITE_OPEN_MAIN_DB)) != 0 { 69790 return DATABASE_FILE 69791 } 69792 return JOURNAL_FILE 69793 }() 69794 (*fs_file)(unsafe.Pointer(p)).Fbase.FpMethods = uintptr(unsafe.Pointer(&fs_io_methods)) 69795 (*fs_file)(unsafe.Pointer(p)).FeType = eType 69796 69797 nName = (int32(libc.Xstrlen(tls, zName)) - (func() int32 { 69798 if eType == JOURNAL_FILE { 69799 return 8 69800 } 69801 return 0 69802 }())) 69803 pReal = (*fs_vfs_t)(unsafe.Pointer(pFsVfs)).FpFileList 69804 __2: 69805 if !((pReal != 0) && (libc.Xstrncmp(tls, (*fs_real_file)(unsafe.Pointer(pReal)).FzName, zName, uint64(nName)) != 0)) { 69806 goto __4 69807 } 69808 goto __3 69809 __3: 69810 pReal = (*fs_real_file)(unsafe.Pointer(pReal)).FpNext 69811 goto __2 69812 goto __4 69813 __4: 69814 ; 69815 69816 if !(!(pReal != 0)) { 69817 goto __5 69818 } 69819 real_flags = ((flags & libc.CplInt32(SQLITE_OPEN_MAIN_DB)) | SQLITE_OPEN_TEMP_DB) 69820 pParent = (*fs_vfs_t)(unsafe.Pointer(pFsVfs)).FpParent 69821 69822 pReal = sqlite3.Xsqlite3_malloc(tls, (int32(uint64(unsafe.Sizeof(fs_real_file{})) + uint64((*sqlite3_vfs)(unsafe.Pointer(pParent)).FszOsFile)))) 69823 if !(!(pReal != 0)) { 69824 goto __6 69825 } 69826 rc = SQLITE_NOMEM 69827 goto open_out 69828 __6: 69829 ; 69830 libc.Xmemset(tls, pReal, 0, (uint64(unsafe.Sizeof(fs_real_file{})) + uint64((*sqlite3_vfs)(unsafe.Pointer(pParent)).FszOsFile))) 69831 (*fs_real_file)(unsafe.Pointer(pReal)).FzName = zName 69832 (*fs_real_file)(unsafe.Pointer(pReal)).FpFile = (pReal + 1*48) 69833 69834 rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pParent + 40 /* &.xOpen */))))(tls, pParent, zName, (*fs_real_file)(unsafe.Pointer(pReal)).FpFile, real_flags, pOutFlags) 69835 if !(rc != SQLITE_OK) { 69836 goto __7 69837 } 69838 goto open_out 69839 __7: 69840 ; 69841 pRealFile = (*fs_real_file)(unsafe.Pointer(pReal)).FpFile 69842 69843 rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pRealFile)).FpMethods + 48 /* &.xFileSize */))))(tls, pRealFile, bp /* &size */) 69844 if !(rc != SQLITE_OK) { 69845 goto __8 69846 } 69847 goto open_out 69848 __8: 69849 ; 69850 if !(*(*sqlite3_int64)(unsafe.Pointer(bp /* size */)) == int64(0)) { 69851 goto __9 69852 } 69853 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pRealFile)).FpMethods + 24 /* &.xWrite */))))(tls, pRealFile, ts+34792 /* "\x00" */, 1, (int64(BLOBSIZE - 1))) 69854 (*fs_real_file)(unsafe.Pointer(pReal)).FnBlob = BLOBSIZE 69855 goto __10 69856 __9: 69857 (*fs_real_file)(unsafe.Pointer(pReal)).FnBlob = int32(*(*sqlite3_int64)(unsafe.Pointer(bp /* size */))) 69858 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pRealFile)).FpMethods + 16 /* &.xRead */))))(tls, pRealFile, bp+8 /* &zS[0] */, 4, int64(0)) 69859 (*fs_real_file)(unsafe.Pointer(pReal)).FnDatabase = ((((int32(*(*uint8)(unsafe.Pointer(bp + 8 /* &zS[0] */))) << 24) + (int32(*(*uint8)(unsafe.Pointer(bp + 8 /* &zS[0] */ + 1))) << 16)) + (int32(*(*uint8)(unsafe.Pointer(bp + 8 /* &zS[0] */ + 2))) << 8)) + int32(*(*uint8)(unsafe.Pointer(bp + 8 /* &zS[0] */ + 3)))) 69860 if !(rc == SQLITE_OK) { 69861 goto __11 69862 } 69863 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pRealFile)).FpMethods + 16 /* &.xRead */))))(tls, pRealFile, bp+8 /* &zS[0] */, 4, (int64((*fs_real_file)(unsafe.Pointer(pReal)).FnBlob - 4))) 69864 if !((((*(*uint8)(unsafe.Pointer(bp + 8 /* &zS[0] */)) != 0) || (*(*uint8)(unsafe.Pointer(bp + 8 /* &zS[0] */ + 1)) != 0)) || (*(*uint8)(unsafe.Pointer(bp + 8 /* &zS[0] */ + 2)) != 0)) || (*(*uint8)(unsafe.Pointer(bp + 8 /* &zS[0] */ + 3)) != 0)) { 69865 goto __12 69866 } 69867 (*fs_real_file)(unsafe.Pointer(pReal)).FnJournal = (*fs_real_file)(unsafe.Pointer(pReal)).FnBlob 69868 __12: 69869 ; 69870 __11: 69871 ; 69872 __10: 69873 ; 69874 69875 if !(rc == SQLITE_OK) { 69876 goto __13 69877 } 69878 (*fs_real_file)(unsafe.Pointer(pReal)).FpNext = (*fs_vfs_t)(unsafe.Pointer(pFsVfs)).FpFileList 69879 if !((*fs_real_file)(unsafe.Pointer(pReal)).FpNext != 0) { 69880 goto __14 69881 } 69882 (*fs_real_file)(unsafe.Pointer((*fs_real_file)(unsafe.Pointer(pReal)).FpNext)).FppThis = (pReal + 32 /* &.pNext */) 69883 __14: 69884 ; 69885 (*fs_real_file)(unsafe.Pointer(pReal)).FppThis = (pFsVfs + 168 /* &.pFileList */) 69886 (*fs_vfs_t)(unsafe.Pointer(pFsVfs)).FpFileList = pReal 69887 __13: 69888 ; 69889 __5: 69890 ; 69891 69892 open_out: 69893 if !(pReal != 0) { 69894 goto __15 69895 } 69896 if !(rc == SQLITE_OK) { 69897 goto __16 69898 } 69899 (*fs_file)(unsafe.Pointer(p)).FpReal = pReal 69900 (*fs_real_file)(unsafe.Pointer(pReal)).FnRef++ 69901 goto __17 69902 __16: 69903 if !((*sqlite3_file)(unsafe.Pointer((*fs_real_file)(unsafe.Pointer(pReal)).FpFile)).FpMethods != 0) { 69904 goto __18 69905 } 69906 (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*fs_real_file)(unsafe.Pointer(pReal)).FpFile)).FpMethods + 8 /* &.xClose */))))(tls, (*fs_real_file)(unsafe.Pointer(pReal)).FpFile) 69907 __18: 69908 ; 69909 sqlite3.Xsqlite3_free(tls, pReal) 69910 __17: 69911 ; 69912 __15: 69913 ; 69914 return rc 69915 } 69916 69917 // Delete the file located at zPath. If the dirSync argument is true, 69918 // ensure the file-system modifications are synced to disk before 69919 // returning. 69920 func fsDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) int32 { /* test_onefile.c:686:12: */ 69921 var rc int32 = SQLITE_OK 69922 var pFsVfs uintptr = pVfs 69923 var pReal uintptr 69924 var pF uintptr 69925 var nName int32 = (int32(libc.Xstrlen(tls, zPath)) - 8) 69926 69927 pReal = (*fs_vfs_t)(unsafe.Pointer(pFsVfs)).FpFileList 69928 for ; (pReal != 0) && (libc.Xstrncmp(tls, (*fs_real_file)(unsafe.Pointer(pReal)).FzName, zPath, uint64(nName)) != 0); pReal = (*fs_real_file)(unsafe.Pointer(pReal)).FpNext { 69929 } 69930 if pReal != 0 { 69931 pF = (*fs_real_file)(unsafe.Pointer(pReal)).FpFile 69932 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pF)).FpMethods + 24 /* &.xWrite */))))(tls, pF, ts+34794 /* "\x00\x00\x00\x00" */, 4, (int64((*fs_real_file)(unsafe.Pointer(pReal)).FnBlob - BLOCKSIZE))) 69933 if rc == SQLITE_OK { 69934 (*fs_real_file)(unsafe.Pointer(pReal)).FnJournal = 0 69935 } 69936 } 69937 return rc 69938 } 69939 69940 // Test for access permissions. Return true if the requested permission 69941 // is available, or false otherwise. 69942 func fsAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut uintptr) int32 { /* test_onefile.c:712:12: */ 69943 var pFsVfs uintptr = pVfs 69944 var pReal uintptr 69945 var isJournal int32 = 0 69946 var nName int32 = int32(libc.Xstrlen(tls, zPath)) 69947 69948 if flags != SQLITE_ACCESS_EXISTS { 69949 var pParent uintptr = (*fs_vfs_t)(unsafe.Pointer(pVfs)).FpParent 69950 return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pParent + 56 /* &.xAccess */))))(tls, pParent, zPath, flags, pResOut) 69951 } 69952 69953 if (nName > 8) && (libc.Xstrcmp(tls, ts+32144 /* "-journal" */, (zPath+uintptr((nName-8)))) == 0) { 69954 nName = nName - (8) 69955 isJournal = 1 69956 } 69957 69958 pReal = (*fs_vfs_t)(unsafe.Pointer(pFsVfs)).FpFileList 69959 for ; (pReal != 0) && (libc.Xstrncmp(tls, (*fs_real_file)(unsafe.Pointer(pReal)).FzName, zPath, uint64(nName)) != 0); pReal = (*fs_real_file)(unsafe.Pointer(pReal)).FpNext { 69960 } 69961 69962 *(*int32)(unsafe.Pointer(pResOut)) = (libc.Bool32((pReal != 0) && (!(isJournal != 0) || ((*fs_real_file)(unsafe.Pointer(pReal)).FnJournal > 0)))) 69963 return SQLITE_OK 69964 } 69965 69966 // Populate buffer zOut with the full canonical pathname corresponding 69967 // to the pathname in zPath. zOut is guaranteed to point to a buffer 69968 // of at least (FS_MAX_PATHNAME+1) bytes. 69969 func fsFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zOut uintptr) int32 { /* test_onefile.c:746:12: */ 69970 var pParent uintptr = (*fs_vfs_t)(unsafe.Pointer(pVfs)).FpParent 69971 return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pParent + 64 /* &.xFullPathname */))))(tls, pParent, zPath, nOut, zOut) 69972 } 69973 69974 // Open the dynamic library located at zPath and return a handle. 69975 func fsDlOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr) uintptr { /* test_onefile.c:759:13: */ 69976 var pParent uintptr = (*fs_vfs_t)(unsafe.Pointer(pVfs)).FpParent 69977 return (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer((pParent + 72 /* &.xDlOpen */))))(tls, pParent, zPath) 69978 } 69979 69980 // Populate the buffer zErrMsg (size nByte bytes) with a human readable 69981 // utf-8 string describing the most recent error encountered associated 69982 // with dynamic libraries. 69983 func fsDlError(tls *libc.TLS, pVfs uintptr, nByte int32, zErrMsg uintptr) { /* test_onefile.c:769:13: */ 69984 var pParent uintptr = (*fs_vfs_t)(unsafe.Pointer(pVfs)).FpParent 69985 (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer((pParent + 80 /* &.xDlError */))))(tls, pParent, nByte, zErrMsg) 69986 } 69987 69988 // Return a pointer to the symbol zSymbol in the dynamic library pHandle. 69989 func fsDlSym(tls *libc.TLS, pVfs uintptr, pH uintptr, zSym uintptr) uintptr { /* test_onefile.c:777:13: */ 69990 var pParent uintptr = (*fs_vfs_t)(unsafe.Pointer(pVfs)).FpParent 69991 return (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer((pParent + 88 /* &.xDlSym */))))(tls, pParent, pH, zSym) 69992 } 69993 69994 // Close the dynamic library handle pHandle. 69995 func fsDlClose(tls *libc.TLS, pVfs uintptr, pHandle uintptr) { /* test_onefile.c:785:13: */ 69996 var pParent uintptr = (*fs_vfs_t)(unsafe.Pointer(pVfs)).FpParent 69997 (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer((pParent + 96 /* &.xDlClose */))))(tls, pParent, pHandle) 69998 } 69999 70000 // Populate the buffer pointed to by zBufOut with nByte bytes of 70001 // random data. 70002 func fsRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uintptr) int32 { /* test_onefile.c:794:12: */ 70003 var pParent uintptr = (*fs_vfs_t)(unsafe.Pointer(pVfs)).FpParent 70004 return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer((pParent + 104 /* &.xRandomness */))))(tls, pParent, nByte, zBufOut) 70005 } 70006 70007 // Sleep for nMicro microseconds. Return the number of microseconds 70008 // actually slept. 70009 func fsSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) int32 { /* test_onefile.c:803:12: */ 70010 var pParent uintptr = (*fs_vfs_t)(unsafe.Pointer(pVfs)).FpParent 70011 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((pParent + 112 /* &.xSleep */))))(tls, pParent, nMicro) 70012 } 70013 70014 // Return the current time as a Julian Day number in *pTimeOut. 70015 func fsCurrentTime(tls *libc.TLS, pVfs uintptr, pTimeOut uintptr) int32 { /* test_onefile.c:811:12: */ 70016 var pParent uintptr = (*fs_vfs_t)(unsafe.Pointer(pVfs)).FpParent 70017 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((pParent + 120 /* &.xCurrentTime */))))(tls, pParent, pTimeOut) 70018 } 70019 70020 // This procedure registers the fs vfs with SQLite. If the argument is 70021 // true, the fs vfs becomes the new default vfs. It is the only publicly 70022 // available function in this file. 70023 func fs_register(tls *libc.TLS) int32 { /* test_onefile.c:821:5: */ 70024 if fs_vfs.FpParent != 0 { 70025 return SQLITE_OK 70026 } 70027 fs_vfs.FpParent = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 70028 fs_vfs.Fbase.FmxPathname = (*sqlite3_vfs)(unsafe.Pointer(fs_vfs.FpParent)).FmxPathname 70029 fs_vfs.Fbase.FszOsFile = func() int32 { 70030 if (uint64(unsafe.Sizeof(tmp_file{}))) > (uint64(unsafe.Sizeof(fs_file{}))) { 70031 return int32(unsafe.Sizeof(tmp_file{})) 70032 } 70033 return int32(unsafe.Sizeof(fs_file{})) 70034 }() 70035 return sqlite3.Xsqlite3_vfs_register(tls, (uintptr(unsafe.Pointer(&fs_vfs)) /* &.base */), 0) 70036 } 70037 70038 func SqlitetestOnefile_Init(tls *libc.TLS) int32 { /* test_onefile.c:830:7: */ 70039 return fs_register(tls) 70040 } 70041 70042 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 70043 // This file is part of the GNU C Library. 70044 // 70045 // The GNU C Library is free software; you can redistribute it and/or 70046 // modify it under the terms of the GNU Lesser General Public 70047 // License as published by the Free Software Foundation; either 70048 // version 2.1 of the License, or (at your option) any later version. 70049 // 70050 // The GNU C Library is distributed in the hope that it will be useful, 70051 // but WITHOUT ANY WARRANTY; without even the implied warranty of 70052 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 70053 // Lesser General Public License for more details. 70054 // 70055 // You should have received a copy of the GNU Lesser General Public 70056 // License along with the GNU C Library; if not, see 70057 // <http://www.gnu.org/licenses/>. 70058 70059 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 70060 70061 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 70062 // This file is part of the GNU C Library. 70063 // 70064 // The GNU C Library is free software; you can redistribute it and/or 70065 // modify it under the terms of the GNU Lesser General Public 70066 // License as published by the Free Software Foundation; either 70067 // version 2.1 of the License, or (at your option) any later version. 70068 // 70069 // The GNU C Library is distributed in the hope that it will be useful, 70070 // but WITHOUT ANY WARRANTY; without even the implied warranty of 70071 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 70072 // Lesser General Public License for more details. 70073 // 70074 // You should have received a copy of the GNU Lesser General Public 70075 // License along with the GNU C Library; if not, see 70076 // <http://www.gnu.org/licenses/>. 70077 70078 // void assert (int expression); 70079 // 70080 // If NDEBUG is defined, do nothing. 70081 // If not, and EXPRESSION is zero, print an error message and abort. 70082 70083 // void assert_perror (int errnum); 70084 // 70085 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 70086 // error message with the error text for ERRNUM and abort. 70087 // (This is a GNU extension.) 70088 70089 // Maximum pathname length supported by the vfslog backend. 70090 70091 type VfslogVfs1 = struct { 70092 Fbase sqlite3_vfs 70093 FpVfs uintptr 70094 FiNextFileId int32 70095 _ [4]byte 70096 FpLog uintptr 70097 FiOffset sqlite3_int64 70098 FnBuf int32 70099 FaBuf [8192]int8 70100 _ [4]byte 70101 } /* test_osinst.c:117:9 */ 70102 70103 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 70104 // This file is part of the GNU C Library. 70105 // 70106 // The GNU C Library is free software; you can redistribute it and/or 70107 // modify it under the terms of the GNU Lesser General Public 70108 // License as published by the Free Software Foundation; either 70109 // version 2.1 of the License, or (at your option) any later version. 70110 // 70111 // The GNU C Library is distributed in the hope that it will be useful, 70112 // but WITHOUT ANY WARRANTY; without even the implied warranty of 70113 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 70114 // Lesser General Public License for more details. 70115 // 70116 // You should have received a copy of the GNU Lesser General Public 70117 // License along with the GNU C Library; if not, see 70118 // <http://www.gnu.org/licenses/>. 70119 70120 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 70121 70122 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 70123 // This file is part of the GNU C Library. 70124 // 70125 // The GNU C Library is free software; you can redistribute it and/or 70126 // modify it under the terms of the GNU Lesser General Public 70127 // License as published by the Free Software Foundation; either 70128 // version 2.1 of the License, or (at your option) any later version. 70129 // 70130 // The GNU C Library is distributed in the hope that it will be useful, 70131 // but WITHOUT ANY WARRANTY; without even the implied warranty of 70132 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 70133 // Lesser General Public License for more details. 70134 // 70135 // You should have received a copy of the GNU Lesser General Public 70136 // License along with the GNU C Library; if not, see 70137 // <http://www.gnu.org/licenses/>. 70138 70139 // void assert (int expression); 70140 // 70141 // If NDEBUG is defined, do nothing. 70142 // If not, and EXPRESSION is zero, print an error message and abort. 70143 70144 // void assert_perror (int errnum); 70145 // 70146 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 70147 // error message with the error text for ERRNUM and abort. 70148 // (This is a GNU extension.) 70149 70150 // Maximum pathname length supported by the vfslog backend. 70151 70152 type VfslogVfs = VfslogVfs1 /* test_osinst.c:117:26 */ 70153 type VfslogFile1 = struct { 70154 Fbase sqlite3_file 70155 FpReal uintptr 70156 FpVfslog uintptr 70157 FiFileId int32 70158 _ [4]byte 70159 } /* test_osinst.c:118:9 */ 70160 70161 type VfslogFile = VfslogFile1 /* test_osinst.c:118:27 */ 70162 70163 var vfslog_vfs = sqlite3_vfs{ 70164 FiVersion: 1, // iVersion 70165 FszOsFile: int32(unsafe.Sizeof(VfslogFile{})), // szOsFile 70166 FmxPathname: INST_MAX_PATHNAME, // pAppData 70167 FxOpen: 0, // xOpen 70168 FxDelete: 0, // xDelete 70169 FxAccess: 0, // xAccess 70170 FxFullPathname: 0, // xFullPathname 70171 FxDlOpen: 0, // xDlOpen 70172 FxDlError: 0, // xDlError 70173 FxDlSym: 0, // xDlSym 70174 FxDlClose: 0, // xDlClose 70175 FxRandomness: 0, // xRandomness 70176 FxSleep: 0, // xSleep 70177 FxCurrentTime: 0, // xCurrentTime 70178 FxGetLastError: 0, // xGetLastError 70179 FxCurrentTimeInt64: 0, // xCurrentTime 70180 } /* test_osinst.c:180:20 */ 70181 70182 var vfslog_io_methods = sqlite3_io_methods{ 70183 FiVersion: 2, // iVersion 70184 FxClose: 0, // xClose 70185 FxRead: 0, // xRead 70186 FxWrite: 0, // xWrite 70187 FxTruncate: 0, // xTruncate 70188 FxSync: 0, // xSync 70189 FxFileSize: 0, // xFileSize 70190 FxLock: 0, // xLock 70191 FxUnlock: 0, // xUnlock 70192 FxCheckReservedLock: 0, // xCheckReservedLock 70193 FxFileControl: 0, // xFileControl 70194 FxSectorSize: 0, // xSectorSize 70195 FxDeviceCharacteristics: 0, // xDeviceCharacteristics 70196 FxShmMap: 0, // xShmMap 70197 FxShmLock: 0, // xShmLock 70198 FxShmBarrier: 0, // xShmBarrier 70199 FxShmUnmap: 0, // xShmUnmap 70200 } /* test_osinst.c:202:27 */ 70201 70202 // Convenience macros for operations on timevals. 70203 // NOTE: `timercmp' does not work for >= or <=. 70204 70205 func vfslog_time(tls *libc.TLS) sqlite3_uint64 { /* test_osinst.c:224:23: */ 70206 bp := tls.Alloc(16) 70207 defer tls.Free(16) 70208 70209 // var sTime timeval at bp, 16 70210 70211 libc.Xgettimeofday(tls, bp /* &sTime */, uintptr(0)) 70212 return (sqlite3_uint64((*timeval)(unsafe.Pointer(bp /* &sTime */)).Ftv_usec) + (sqlite3_uint64((*timeval)(unsafe.Pointer(bp /* &sTime */)).Ftv_sec) * uint64(1000000))) 70213 } 70214 70215 // Close an vfslog-file. 70216 func vfslogClose(tls *libc.TLS, pFile uintptr) int32 { /* test_osinst.c:256:12: */ 70217 var t sqlite3_uint64 70218 var rc int32 = SQLITE_OK 70219 var p uintptr = pFile 70220 70221 t = vfslog_time(tls) 70222 if (*sqlite3_file)(unsafe.Pointer((*VfslogFile)(unsafe.Pointer(p)).FpReal)).FpMethods != 0 { 70223 rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogFile)(unsafe.Pointer(p)).FpReal)).FpMethods + 8 /* &.xClose */))))(tls, (*VfslogFile)(unsafe.Pointer(p)).FpReal) 70224 } 70225 t = (vfslog_time(tls) - t) 70226 vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_CLOSE, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) 70227 return rc 70228 } 70229 70230 // Read data from an vfslog-file. 70231 func vfslogRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test_osinst.c:273:12: */ 70232 var rc int32 70233 var t sqlite3_uint64 70234 var p uintptr = pFile 70235 t = vfslog_time(tls) 70236 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogFile)(unsafe.Pointer(p)).FpReal)).FpMethods + 16 /* &.xRead */))))(tls, (*VfslogFile)(unsafe.Pointer(p)).FpReal, zBuf, iAmt, iOfst) 70237 t = (vfslog_time(tls) - t) 70238 vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_READ, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, iAmt, int32(iOfst)) 70239 return rc 70240 } 70241 70242 // Write data to an vfslog-file. 70243 func vfslogWrite(tls *libc.TLS, pFile uintptr, z uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test_osinst.c:292:12: */ 70244 var rc int32 70245 var t sqlite3_uint64 70246 var p uintptr = pFile 70247 t = vfslog_time(tls) 70248 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogFile)(unsafe.Pointer(p)).FpReal)).FpMethods + 24 /* &.xWrite */))))(tls, (*VfslogFile)(unsafe.Pointer(p)).FpReal, z, iAmt, iOfst) 70249 t = (vfslog_time(tls) - t) 70250 vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_WRITE, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, iAmt, int32(iOfst)) 70251 return rc 70252 } 70253 70254 // Truncate an vfslog-file. 70255 func vfslogTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { /* test_osinst.c:311:12: */ 70256 var rc int32 70257 var t sqlite3_uint64 70258 var p uintptr = pFile 70259 t = vfslog_time(tls) 70260 rc = (*(*func(*libc.TLS, uintptr, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogFile)(unsafe.Pointer(p)).FpReal)).FpMethods + 32 /* &.xTruncate */))))(tls, (*VfslogFile)(unsafe.Pointer(p)).FpReal, size) 70261 t = (vfslog_time(tls) - t) 70262 vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_TRUNCATE, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, int32(size)) 70263 return rc 70264 } 70265 70266 // Sync an vfslog-file. 70267 func vfslogSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* test_osinst.c:325:12: */ 70268 var rc int32 70269 var t sqlite3_uint64 70270 var p uintptr = pFile 70271 t = vfslog_time(tls) 70272 rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogFile)(unsafe.Pointer(p)).FpReal)).FpMethods + 40 /* &.xSync */))))(tls, (*VfslogFile)(unsafe.Pointer(p)).FpReal, flags) 70273 t = (vfslog_time(tls) - t) 70274 vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_SYNC, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, flags, 0) 70275 return rc 70276 } 70277 70278 // Return the current file-size of an vfslog-file. 70279 func vfslogFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { /* test_osinst.c:339:12: */ 70280 var rc int32 70281 var t sqlite3_uint64 70282 var p uintptr = pFile 70283 t = vfslog_time(tls) 70284 rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogFile)(unsafe.Pointer(p)).FpReal)).FpMethods + 48 /* &.xFileSize */))))(tls, (*VfslogFile)(unsafe.Pointer(p)).FpReal, pSize) 70285 t = (vfslog_time(tls) - t) 70286 vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_FILESIZE, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, int32(*(*sqlite_int64)(unsafe.Pointer(pSize)))) 70287 return rc 70288 } 70289 70290 // Lock an vfslog-file. 70291 func vfslogLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_osinst.c:353:12: */ 70292 var rc int32 70293 var t sqlite3_uint64 70294 var p uintptr = pFile 70295 t = vfslog_time(tls) 70296 rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogFile)(unsafe.Pointer(p)).FpReal)).FpMethods + 56 /* &.xLock */))))(tls, (*VfslogFile)(unsafe.Pointer(p)).FpReal, eLock) 70297 t = (vfslog_time(tls) - t) 70298 vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_LOCK, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, eLock, 0) 70299 return rc 70300 } 70301 70302 // Unlock an vfslog-file. 70303 func vfslogUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_osinst.c:367:12: */ 70304 var rc int32 70305 var t sqlite3_uint64 70306 var p uintptr = pFile 70307 t = vfslog_time(tls) 70308 rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogFile)(unsafe.Pointer(p)).FpReal)).FpMethods + 64 /* &.xUnlock */))))(tls, (*VfslogFile)(unsafe.Pointer(p)).FpReal, eLock) 70309 t = (vfslog_time(tls) - t) 70310 vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_UNLOCK, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, eLock, 0) 70311 return rc 70312 } 70313 70314 // Check if another file-handle holds a RESERVED lock on an vfslog-file. 70315 func vfslogCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int32 { /* test_osinst.c:381:12: */ 70316 var rc int32 70317 var t sqlite3_uint64 70318 var p uintptr = pFile 70319 t = vfslog_time(tls) 70320 rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogFile)(unsafe.Pointer(p)).FpReal)).FpMethods + 72 /* &.xCheckReservedLock */))))(tls, (*VfslogFile)(unsafe.Pointer(p)).FpReal, pResOut) 70321 t = (vfslog_time(tls) - t) 70322 vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_CHECKRESERVEDLOCK, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, *(*int32)(unsafe.Pointer(pResOut)), 0) 70323 return rc 70324 } 70325 70326 // File control method. For custom operations on an vfslog-file. 70327 func vfslogFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 { /* test_osinst.c:395:12: */ 70328 bp := tls.Alloc(8) 70329 defer tls.Free(8) 70330 70331 var p uintptr = pFile 70332 var rc int32 = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogFile)(unsafe.Pointer(p)).FpReal)).FpMethods + 80 /* &.xFileControl */))))(tls, (*VfslogFile)(unsafe.Pointer(p)).FpReal, op, pArg) 70333 if (op == SQLITE_FCNTL_VFSNAME) && (rc == SQLITE_OK) { 70334 *(*uintptr)(unsafe.Pointer(pArg)) = sqlite3.Xsqlite3_mprintf(tls, ts+34799 /* "vfslog/%z" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(pArg)))) 70335 } 70336 return rc 70337 } 70338 70339 // Return the sector-size in bytes for an vfslog-file. 70340 func vfslogSectorSize(tls *libc.TLS, pFile uintptr) int32 { /* test_osinst.c:407:12: */ 70341 var rc int32 70342 var t sqlite3_uint64 70343 var p uintptr = pFile 70344 t = vfslog_time(tls) 70345 rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogFile)(unsafe.Pointer(p)).FpReal)).FpMethods + 88 /* &.xSectorSize */))))(tls, (*VfslogFile)(unsafe.Pointer(p)).FpReal) 70346 t = (vfslog_time(tls) - t) 70347 vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_SECTORSIZE, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) 70348 return rc 70349 } 70350 70351 // Return the device characteristic flags supported by an vfslog-file. 70352 func vfslogDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { /* test_osinst.c:421:12: */ 70353 var rc int32 70354 var t sqlite3_uint64 70355 var p uintptr = pFile 70356 t = vfslog_time(tls) 70357 rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogFile)(unsafe.Pointer(p)).FpReal)).FpMethods + 96 /* &.xDeviceCharacteristics */))))(tls, (*VfslogFile)(unsafe.Pointer(p)).FpReal) 70358 t = (vfslog_time(tls) - t) 70359 vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_DEVCHAR, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) 70360 return rc 70361 } 70362 70363 func vfslogShmLock(tls *libc.TLS, pFile uintptr, ofst int32, n int32, flags int32) int32 { /* test_osinst.c:432:12: */ 70364 var rc int32 70365 var t sqlite3_uint64 70366 var p uintptr = pFile 70367 t = vfslog_time(tls) 70368 rc = (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogFile)(unsafe.Pointer(p)).FpReal)).FpMethods + 112 /* &.xShmLock */))))(tls, (*VfslogFile)(unsafe.Pointer(p)).FpReal, ofst, n, flags) 70369 t = (vfslog_time(tls) - t) 70370 vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_SHMLOCK, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) 70371 return rc 70372 } 70373 70374 func vfslogShmMap(tls *libc.TLS, pFile uintptr, iRegion int32, szRegion int32, isWrite int32, pp uintptr) int32 { /* test_osinst.c:442:12: */ 70375 var rc int32 70376 var t sqlite3_uint64 70377 var p uintptr = pFile 70378 t = vfslog_time(tls) 70379 rc = (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogFile)(unsafe.Pointer(p)).FpReal)).FpMethods + 104 /* &.xShmMap */))))(tls, (*VfslogFile)(unsafe.Pointer(p)).FpReal, iRegion, szRegion, isWrite, libc.AtomicLoadUintptr(&pp)) 70380 t = (vfslog_time(tls) - t) 70381 vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_SHMMAP, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) 70382 return rc 70383 } 70384 70385 func vfslogShmBarrier(tls *libc.TLS, pFile uintptr) { /* test_osinst.c:458:13: */ 70386 var t sqlite3_uint64 70387 var p uintptr = pFile 70388 t = vfslog_time(tls) 70389 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogFile)(unsafe.Pointer(p)).FpReal)).FpMethods + 120 /* &.xShmBarrier */))))(tls, (*VfslogFile)(unsafe.Pointer(p)).FpReal) 70390 t = (vfslog_time(tls) - t) 70391 vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_SHMBARRIER, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), SQLITE_OK, 0, 0) 70392 } 70393 70394 func vfslogShmUnmap(tls *libc.TLS, pFile uintptr, deleteFlag int32) int32 { /* test_osinst.c:466:12: */ 70395 var rc int32 70396 var t sqlite3_uint64 70397 var p uintptr = pFile 70398 t = vfslog_time(tls) 70399 rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogFile)(unsafe.Pointer(p)).FpReal)).FpMethods + 128 /* &.xShmUnmap */))))(tls, (*VfslogFile)(unsafe.Pointer(p)).FpReal, deleteFlag) 70400 t = (vfslog_time(tls) - t) 70401 vfslog_call(tls, (*VfslogFile)(unsafe.Pointer(p)).FpVfslog, OS_SHMUNMAP, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) 70402 return rc 70403 } 70404 70405 // Open an vfslog file handle. 70406 func vfslogOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags int32, pOutFlags uintptr) int32 { /* test_osinst.c:481:12: */ 70407 var rc int32 70408 var t sqlite3_uint64 70409 var p uintptr = pFile 70410 var pLog uintptr = pVfs 70411 70412 (*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = uintptr(unsafe.Pointer(&vfslog_io_methods)) 70413 (*VfslogFile)(unsafe.Pointer(p)).FpReal = (p + 1*32) 70414 (*VfslogFile)(unsafe.Pointer(p)).FpVfslog = pVfs 70415 (*VfslogFile)(unsafe.Pointer(p)).FiFileId = libc.PreIncInt32(&(*VfslogVfs)(unsafe.Pointer(pLog)).FiNextFileId, 1) 70416 70417 t = vfslog_time(tls) 70418 rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs + 40 /* &.xOpen */))))(tls, (*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs, zName, (*VfslogFile)(unsafe.Pointer(p)).FpReal, flags, pOutFlags) 70419 t = (vfslog_time(tls) - t) 70420 70421 vfslog_call(tls, pVfs, OS_OPEN, (*VfslogFile)(unsafe.Pointer(p)).FiFileId, int64(t), rc, 0, 0) 70422 vfslog_string(tls, pVfs, zName) 70423 return rc 70424 } 70425 70426 // Delete the file located at zPath. If the dirSync argument is true, 70427 // ensure the file-system modifications are synced to disk before 70428 // returning. 70429 func vfslogDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) int32 { /* test_osinst.c:512:12: */ 70430 var rc int32 70431 var t sqlite3_uint64 70432 t = vfslog_time(tls) 70433 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(((*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs + 48 /* &.xDelete */))))(tls, (*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs, zPath, dirSync) 70434 t = (vfslog_time(tls) - t) 70435 vfslog_call(tls, pVfs, OS_DELETE, 0, int64(t), rc, dirSync, 0) 70436 vfslog_string(tls, pVfs, zPath) 70437 return rc 70438 } 70439 70440 // Test for access permissions. Return true if the requested permission 70441 // is available, or false otherwise. 70442 func vfslogAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut uintptr) int32 { /* test_osinst.c:527:12: */ 70443 var rc int32 70444 var t sqlite3_uint64 70445 t = vfslog_time(tls) 70446 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs + 56 /* &.xAccess */))))(tls, (*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs, zPath, flags, pResOut) 70447 t = (vfslog_time(tls) - t) 70448 vfslog_call(tls, pVfs, OS_ACCESS, 0, int64(t), rc, flags, *(*int32)(unsafe.Pointer(pResOut))) 70449 vfslog_string(tls, pVfs, zPath) 70450 return rc 70451 } 70452 70453 // Populate buffer zOut with the full canonical pathname corresponding 70454 // to the pathname in zPath. zOut is guaranteed to point to a buffer 70455 // of at least (INST_MAX_PATHNAME+1) bytes. 70456 func vfslogFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zOut uintptr) int32 { /* test_osinst.c:548:12: */ 70457 return (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs + 64 /* &.xFullPathname */))))(tls, (*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs, zPath, nOut, zOut) 70458 } 70459 70460 // Open the dynamic library located at zPath and return a handle. 70461 func vfslogDlOpen(tls *libc.TLS, pVfs uintptr, zPath uintptr) uintptr { /* test_osinst.c:560:13: */ 70462 return (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(((*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs + 72 /* &.xDlOpen */))))(tls, (*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs, zPath) 70463 } 70464 70465 // Populate the buffer zErrMsg (size nByte bytes) with a human readable 70466 // utf-8 string describing the most recent error encountered associated 70467 // with dynamic libraries. 70468 func vfslogDlError(tls *libc.TLS, pVfs uintptr, nByte int32, zErrMsg uintptr) { /* test_osinst.c:569:13: */ 70469 (*(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(((*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs + 80 /* &.xDlError */))))(tls, (*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs, nByte, zErrMsg) 70470 } 70471 70472 // Return a pointer to the symbol zSymbol in the dynamic library pHandle. 70473 func vfslogDlSym(tls *libc.TLS, pVfs uintptr, p uintptr, zSym uintptr) uintptr { /* test_osinst.c:576:13: */ 70474 return (*(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(((*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs + 88 /* &.xDlSym */))))(tls, (*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs, p, zSym) 70475 } 70476 70477 // Close the dynamic library handle pHandle. 70478 func vfslogDlClose(tls *libc.TLS, pVfs uintptr, pHandle uintptr) { /* test_osinst.c:583:13: */ 70479 (*(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(((*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs + 96 /* &.xDlClose */))))(tls, (*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs, pHandle) 70480 } 70481 70482 // Populate the buffer pointed to by zBufOut with nByte bytes of 70483 // random data. 70484 func vfslogRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uintptr) int32 { /* test_osinst.c:591:12: */ 70485 return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs + 104 /* &.xRandomness */))))(tls, (*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs, nByte, zBufOut) 70486 } 70487 70488 // Sleep for nMicro microseconds. Return the number of microseconds 70489 // actually slept. 70490 func vfslogSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) int32 { /* test_osinst.c:599:12: */ 70491 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs + 112 /* &.xSleep */))))(tls, (*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs, nMicro) 70492 } 70493 70494 // Return the current time as a Julian Day number in *pTimeOut. 70495 func vfslogCurrentTime(tls *libc.TLS, pVfs uintptr, pTimeOut uintptr) int32 { /* test_osinst.c:606:12: */ 70496 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs + 120 /* &.xCurrentTime */))))(tls, (*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs, pTimeOut) 70497 } 70498 70499 func vfslogGetLastError(tls *libc.TLS, pVfs uintptr, a int32, b uintptr) int32 { /* test_osinst.c:610:12: */ 70500 return (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs + 128 /* &.xGetLastError */))))(tls, (*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs, a, b) 70501 } 70502 70503 func vfslogCurrentTimeInt64(tls *libc.TLS, pVfs uintptr, p uintptr) int32 { /* test_osinst.c:613:12: */ 70504 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs + 136 /* &.xCurrentTimeInt64 */))))(tls, (*VfslogVfs)(unsafe.Pointer(pVfs)).FpVfs, p) 70505 } 70506 70507 func vfslog_flush(tls *libc.TLS, p uintptr) { /* test_osinst.c:617:13: */ 70508 70509 var pending int32 = libc.AtomicLoadInt32(&sqlite3.Xsqlite3_io_error_pending) 70510 var persist int32 = sqlite3.Xsqlite3_io_error_persist 70511 var diskfull int32 = sqlite3.Xsqlite3_diskfull_pending 70512 70513 libc.AtomicStoreInt32(&sqlite3.Xsqlite3_io_error_pending, int32(0)) 70514 sqlite3.Xsqlite3_io_error_persist = 0 70515 sqlite3.Xsqlite3_diskfull_pending = 0 70516 70517 if (*VfslogVfs)(unsafe.Pointer(p)).FnBuf != 0 { 70518 (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogVfs)(unsafe.Pointer(p)).FpLog)).FpMethods + 24 /* &.xWrite */))))(tls, (*VfslogVfs)(unsafe.Pointer(p)).FpLog, p+204 /* &.aBuf */, (*VfslogVfs)(unsafe.Pointer(p)).FnBuf, (*VfslogVfs)(unsafe.Pointer(p)).FiOffset) 70519 *(*sqlite3_int64)(unsafe.Pointer(p + 192 /* &.iOffset */)) += (sqlite3_int64((*VfslogVfs)(unsafe.Pointer(p)).FnBuf)) 70520 (*VfslogVfs)(unsafe.Pointer(p)).FnBuf = 0 70521 } 70522 70523 libc.AtomicStoreInt32(&sqlite3.Xsqlite3_io_error_pending, int32(pending)) 70524 sqlite3.Xsqlite3_io_error_persist = persist 70525 sqlite3.Xsqlite3_diskfull_pending = diskfull 70526 } 70527 70528 func put32bits(tls *libc.TLS, p uintptr, v uint32) { /* test_osinst.c:645:13: */ 70529 *(*uint8)(unsafe.Pointer(p)) = (uint8(v >> 24)) 70530 *(*uint8)(unsafe.Pointer(p + 1)) = (uint8(v >> 16)) 70531 *(*uint8)(unsafe.Pointer(p + 2)) = (uint8(v >> 8)) 70532 *(*uint8)(unsafe.Pointer(p + 3)) = uint8(v) 70533 } 70534 70535 func vfslog_call(tls *libc.TLS, pVfs uintptr, eEvent int32, iFileid int32, nClick sqlite3_int64, return_code int32, size int32, offset int32) { /* test_osinst.c:652:13: */ 70536 var p uintptr = pVfs 70537 var zRec uintptr 70538 if (uint64(24 + (*VfslogVfs)(unsafe.Pointer(p)).FnBuf)) > uint64(unsafe.Sizeof([8192]int8{})) { 70539 vfslog_flush(tls, p) 70540 } 70541 zRec = ((p + 204 /* &.aBuf */) + uintptr((*VfslogVfs)(unsafe.Pointer(p)).FnBuf)) 70542 put32bits(tls, (zRec), uint32(eEvent)) 70543 put32bits(tls, (zRec + 4), uint32(iFileid)) 70544 put32bits(tls, (zRec + 8), (uint32(nClick & int64(0xffff)))) 70545 put32bits(tls, (zRec + 12), uint32(return_code)) 70546 put32bits(tls, (zRec + 16), uint32(size)) 70547 put32bits(tls, (zRec + 20), uint32(offset)) 70548 *(*int32)(unsafe.Pointer(p + 200 /* &.nBuf */)) += (24) 70549 } 70550 70551 func vfslog_string(tls *libc.TLS, pVfs uintptr, zStr uintptr) { /* test_osinst.c:676:13: */ 70552 var p uintptr = pVfs 70553 var zRec uintptr 70554 var nStr int32 70555 if zStr != 0 { 70556 nStr = int32(libc.Xstrlen(tls, zStr)) 70557 } else { 70558 nStr = 0 70559 } 70560 if (uint64((4 + nStr) + (*VfslogVfs)(unsafe.Pointer(p)).FnBuf)) > uint64(unsafe.Sizeof([8192]int8{})) { 70561 vfslog_flush(tls, p) 70562 } 70563 zRec = ((p + 204 /* &.aBuf */) + uintptr((*VfslogVfs)(unsafe.Pointer(p)).FnBuf)) 70564 put32bits(tls, (zRec), uint32(nStr)) 70565 if zStr != 0 { 70566 libc.Xmemcpy(tls, (zRec + 4), zStr, uint64(nStr)) 70567 } 70568 *(*int32)(unsafe.Pointer(p + 200 /* &.nBuf */)) += (4 + nStr) 70569 } 70570 70571 func vfslog_finalize(tls *libc.TLS, p uintptr) { /* test_osinst.c:691:13: */ 70572 if (*sqlite3_file)(unsafe.Pointer((*VfslogVfs)(unsafe.Pointer(p)).FpLog)).FpMethods != 0 { 70573 vfslog_flush(tls, p) 70574 (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogVfs)(unsafe.Pointer(p)).FpLog)).FpMethods + 8 /* &.xClose */))))(tls, (*VfslogVfs)(unsafe.Pointer(p)).FpLog) 70575 } 70576 sqlite3.Xsqlite3_free(tls, p) 70577 } 70578 70579 func sqlite3_vfslog_finalize(tls *libc.TLS, zVfs uintptr) int32 { /* test_osinst.c:699:5: */ 70580 var pVfs uintptr 70581 pVfs = sqlite3.Xsqlite3_vfs_find(tls, zVfs) 70582 if !(pVfs != 0) || ((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FxOpen != *(*uintptr)(unsafe.Pointer(&struct { 70583 f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32 70584 }{vfslogOpen}))) { 70585 return SQLITE_ERROR 70586 } 70587 sqlite3.Xsqlite3_vfs_unregister(tls, pVfs) 70588 vfslog_finalize(tls, pVfs) 70589 return SQLITE_OK 70590 } 70591 70592 func sqlite3_vfslog_new(tls *libc.TLS, zVfs uintptr, zParentVfs uintptr, zLog uintptr) int32 { /* test_osinst.c:710:5: */ 70593 bp := tls.Alloc(4) 70594 defer tls.Free(4) 70595 70596 var p uintptr 70597 var pParent uintptr 70598 var nByte int32 70599 // var flags int32 at bp, 4 70600 70601 var rc int32 70602 var zFile uintptr 70603 var nVfs int32 70604 70605 pParent = sqlite3.Xsqlite3_vfs_find(tls, zParentVfs) 70606 if !(pParent != 0) { 70607 return SQLITE_ERROR 70608 } 70609 70610 nVfs = int32(libc.Xstrlen(tls, zVfs)) 70611 nByte = (int32(((((uint64(unsafe.Sizeof(VfslogVfs{})) + uint64((*sqlite3_vfs)(unsafe.Pointer(pParent)).FszOsFile)) + uint64(nVfs)) + uint64(1)) + uint64((*sqlite3_vfs)(unsafe.Pointer(pParent)).FmxPathname)) + uint64(1))) 70612 p = sqlite3.Xsqlite3_malloc(tls, nByte) 70613 libc.Xmemset(tls, p, 0, uint64(nByte)) 70614 70615 (*VfslogVfs)(unsafe.Pointer(p)).FpVfs = pParent 70616 (*VfslogVfs)(unsafe.Pointer(p)).FpLog = (p + 1*8400) 70617 libc.Xmemcpy(tls, (p /* &.base */), uintptr(unsafe.Pointer(&vfslog_vfs)), uint64(unsafe.Sizeof(sqlite3_vfs{}))) 70618 (*VfslogVfs)(unsafe.Pointer(p)).Fbase.FzName = (((*VfslogVfs)(unsafe.Pointer(p)).FpLog) + uintptr((*sqlite3_vfs)(unsafe.Pointer(pParent)).FszOsFile)) 70619 *(*int32)(unsafe.Pointer(p /* &.base */ + 4 /* &.szOsFile */)) += ((*sqlite3_vfs)(unsafe.Pointer(pParent)).FszOsFile) 70620 libc.Xmemcpy(tls, (*VfslogVfs)(unsafe.Pointer(p)).Fbase.FzName, zVfs, uint64(nVfs)) 70621 70622 zFile = ((*VfslogVfs)(unsafe.Pointer(p)).Fbase.FzName + uintptr((nVfs + 1))) 70623 (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pParent + 64 /* &.xFullPathname */))))(tls, pParent, zLog, (*sqlite3_vfs)(unsafe.Pointer(pParent)).FmxPathname, zFile) 70624 70625 *(*int32)(unsafe.Pointer(bp /* flags */)) = ((SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE) | SQLITE_OPEN_SUPER_JOURNAL) 70626 (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer((pParent + 48 /* &.xDelete */))))(tls, pParent, zFile, 0) 70627 rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pParent + 40 /* &.xOpen */))))(tls, pParent, zFile, (*VfslogVfs)(unsafe.Pointer(p)).FpLog, *(*int32)(unsafe.Pointer(bp /* flags */)), bp /* &flags */) 70628 if rc == SQLITE_OK { 70629 libc.Xmemcpy(tls, p+204 /* &.aBuf */, ts+34809 /* "sqlite_ostrace1...." */, uint64(20)) 70630 (*VfslogVfs)(unsafe.Pointer(p)).FiOffset = int64(0) 70631 (*VfslogVfs)(unsafe.Pointer(p)).FnBuf = 20 70632 rc = sqlite3.Xsqlite3_vfs_register(tls, p, 1) 70633 } 70634 if rc != 0 { 70635 vfslog_finalize(tls, p) 70636 } 70637 return rc 70638 } 70639 70640 func sqlite3_vfslog_annotate(tls *libc.TLS, zVfs uintptr, zMsg uintptr) int32 { /* test_osinst.c:758:5: */ 70641 var pVfs uintptr 70642 pVfs = sqlite3.Xsqlite3_vfs_find(tls, zVfs) 70643 if !(pVfs != 0) || ((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FxOpen != *(*uintptr)(unsafe.Pointer(&struct { 70644 f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32 70645 }{vfslogOpen}))) { 70646 return SQLITE_ERROR 70647 } 70648 vfslog_call(tls, pVfs, OS_ANNOTATE, 0, int64(0), 0, 0, 0) 70649 vfslog_string(tls, pVfs, zMsg) 70650 return SQLITE_OK 70651 } 70652 70653 func vfslog_eventname(tls *libc.TLS, eEvent int32) uintptr { /* test_osinst.c:769:19: */ 70654 var zEvent uintptr = uintptr(0) 70655 70656 switch eEvent { 70657 case OS_CLOSE: 70658 zEvent = ts + 34830 /* "xClose" */ 70659 break 70660 case OS_READ: 70661 zEvent = ts + 34837 /* "xRead" */ 70662 break 70663 case OS_WRITE: 70664 zEvent = ts + 34843 /* "xWrite" */ 70665 break 70666 case OS_TRUNCATE: 70667 zEvent = ts + 34850 /* "xTruncate" */ 70668 break 70669 case OS_SYNC: 70670 zEvent = ts + 27316 /* "xSync" */ 70671 break 70672 case OS_FILESIZE: 70673 zEvent = ts + 34860 /* "xFilesize" */ 70674 break 70675 case OS_LOCK: 70676 zEvent = ts + 34870 /* "xLock" */ 70677 break 70678 case OS_UNLOCK: 70679 zEvent = ts + 34876 /* "xUnlock" */ 70680 break 70681 case OS_CHECKRESERVEDLOCK: 70682 zEvent = ts + 34884 /* "xCheckResLock" */ 70683 break 70684 case OS_FILECONTROL: 70685 zEvent = ts + 34898 /* "xFileControl" */ 70686 break 70687 case OS_SECTORSIZE: 70688 zEvent = ts + 34911 /* "xSectorSize" */ 70689 break 70690 case OS_DEVCHAR: 70691 zEvent = ts + 34923 /* "xDeviceChar" */ 70692 break 70693 case OS_OPEN: 70694 zEvent = ts + 26888 /* "xOpen" */ 70695 break 70696 case OS_DELETE: 70697 zEvent = ts + 34935 /* "xDelete" */ 70698 break 70699 case OS_ACCESS: 70700 zEvent = ts + 34943 /* "xAccess" */ 70701 break 70702 case OS_FULLPATHNAME: 70703 zEvent = ts + 34951 /* "xFullPathname" */ 70704 break 70705 case OS_RANDOMNESS: 70706 zEvent = ts + 34965 /* "xRandomness" */ 70707 break 70708 case OS_SLEEP: 70709 zEvent = ts + 34977 /* "xSleep" */ 70710 break 70711 case OS_CURRENTTIME: 70712 zEvent = ts + 34984 /* "xCurrentTime" */ 70713 break 70714 70715 case OS_SHMUNMAP: 70716 zEvent = ts + 34997 /* "xShmUnmap" */ 70717 break 70718 case OS_SHMLOCK: 70719 zEvent = ts + 35007 /* "xShmLock" */ 70720 break 70721 case OS_SHMBARRIER: 70722 zEvent = ts + 35016 /* "xShmBarrier" */ 70723 break 70724 case OS_SHMMAP: 70725 zEvent = ts + 35028 /* "xShmMap" */ 70726 break 70727 70728 case OS_ANNOTATE: 70729 zEvent = ts + 35036 /* "annotation" */ 70730 break 70731 } 70732 70733 return zEvent 70734 } 70735 70736 type VfslogVtab1 = struct { 70737 Fbase sqlite3_vtab 70738 FpFd uintptr 70739 FnByte sqlite3_int64 70740 FzFile uintptr 70741 } /* test_osinst.c:804:9 */ 70742 70743 type VfslogVtab = VfslogVtab1 /* test_osinst.c:804:27 */ 70744 type VfslogCsr1 = struct { 70745 Fbase sqlite3_vtab_cursor 70746 FiRowid sqlite3_int64 70747 FiOffset sqlite3_int64 70748 FzTransient uintptr 70749 FnFile int32 70750 _ [4]byte 70751 FazFile uintptr 70752 FaBuf [1024]uint8 70753 } /* test_osinst.c:805:9 */ 70754 70755 type VfslogCsr = VfslogCsr1 /* test_osinst.c:805:26 */ 70756 70757 func get32bits(tls *libc.TLS, p uintptr) uint32 { /* test_osinst.c:830:21: */ 70758 return (uint32((((int32(*(*uint8)(unsafe.Pointer(p))) << 24) + (int32(*(*uint8)(unsafe.Pointer(p + 1))) << 16)) + (int32(*(*uint8)(unsafe.Pointer(p + 2))) << 8)) + int32(*(*uint8)(unsafe.Pointer(p + 3))))) 70759 } 70760 70761 // The argument must point to a buffer containing a nul-terminated string. 70762 // If the string begins with an SQL quote character it is overwritten by 70763 // the dequoted version. Otherwise the buffer is left unmodified. 70764 func dequote(tls *libc.TLS, z uintptr) { /* test_osinst.c:839:13: */ 70765 var quote int8 // Quote character (if any ) 70766 quote = *(*int8)(unsafe.Pointer(z)) 70767 if (((int32(quote) == '[') || (int32(quote) == '\'')) || (int32(quote) == '"')) || (int32(quote) == '`') { 70768 var iIn int32 = 1 // Index of next byte to read from input 70769 var iOut int32 = 0 // Index of next byte to write to output 70770 if int32(quote) == '[' { 70771 quote = int8(']') 70772 } 70773 for *(*int8)(unsafe.Pointer(z + uintptr(iIn))) != 0 { 70774 if int32(*(*int8)(unsafe.Pointer(z + uintptr(iIn)))) == int32(quote) { 70775 if int32(*(*int8)(unsafe.Pointer(z + uintptr((iIn + 1))))) != int32(quote) { 70776 break 70777 } 70778 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&iOut, 1)))) = quote 70779 iIn = iIn + (2) 70780 } else { 70781 *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&iOut, 1)))) = *(*int8)(unsafe.Pointer(z + uintptr(libc.PostIncInt32(&iIn, 1)))) 70782 } 70783 } 70784 *(*int8)(unsafe.Pointer(z + uintptr(iOut))) = int8(0) 70785 } 70786 } 70787 70788 // Connect to or create a vfslog virtual table. 70789 func vlogConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* test_osinst.c:863:12: */ 70790 bp := tls.Alloc(12) 70791 defer tls.Free(12) 70792 70793 var pVfs uintptr // VFS used to read log file 70794 // var flags int32 at bp+8, 4 70795 // flags passed to pVfs->xOpen() 70796 var p uintptr 70797 var rc int32 70798 var nByte int32 70799 var zFile uintptr 70800 70801 *(*uintptr)(unsafe.Pointer(ppVtab)) = uintptr(0) 70802 pVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 70803 nByte = (int32((uint64(unsafe.Sizeof(VfslogVtab{})) + uint64((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile)) + uint64((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname))) 70804 p = sqlite3.Xsqlite3_malloc(tls, nByte) 70805 if p == uintptr(0) { 70806 return SQLITE_NOMEM 70807 } 70808 libc.Xmemset(tls, p, 0, uint64(nByte)) 70809 70810 (*VfslogVtab)(unsafe.Pointer(p)).FpFd = (p + 1*48) 70811 (*VfslogVtab)(unsafe.Pointer(p)).FzFile = (((*VfslogVtab)(unsafe.Pointer(p)).FpFd) + uintptr((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile)) 70812 70813 zFile = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(argv + 3*8)))) 70814 if !(zFile != 0) { 70815 sqlite3.Xsqlite3_free(tls, p) 70816 return SQLITE_NOMEM 70817 } 70818 dequote(tls, zFile) 70819 (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pVfs + 64 /* &.xFullPathname */))))(tls, pVfs, zFile, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname, (*VfslogVtab)(unsafe.Pointer(p)).FzFile) 70820 sqlite3.Xsqlite3_free(tls, zFile) 70821 70822 *(*int32)(unsafe.Pointer(bp + 8 /* flags */)) = (SQLITE_OPEN_READWRITE | SQLITE_OPEN_SUPER_JOURNAL) 70823 rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pVfs + 40 /* &.xOpen */))))(tls, pVfs, (*VfslogVtab)(unsafe.Pointer(p)).FzFile, (*VfslogVtab)(unsafe.Pointer(p)).FpFd, *(*int32)(unsafe.Pointer(bp + 8 /* flags */)), bp+8 /* &flags */) 70824 70825 if rc == SQLITE_OK { 70826 (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogVtab)(unsafe.Pointer(p)).FpFd)).FpMethods + 48 /* &.xFileSize */))))(tls, (*VfslogVtab)(unsafe.Pointer(p)).FpFd, (p + 32 /* &.nByte */)) 70827 sqlite3.Xsqlite3_declare_vtab(tls, db, 70828 ts+35047 /* "CREATE TABLE xxx..." */) 70829 *(*uintptr)(unsafe.Pointer(ppVtab)) = (p /* &.base */) 70830 } else { 70831 sqlite3.Xsqlite3_free(tls, p) 70832 } 70833 70834 return rc 70835 } 70836 70837 // There is no "best-index". This virtual table always does a linear 70838 // scan of the binary VFS log file. 70839 func vlogBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_osinst.c:916:12: */ 70840 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = 10.0 70841 return SQLITE_OK 70842 } 70843 70844 // Disconnect from or destroy a vfslog virtual table. 70845 func vlogDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* test_osinst.c:924:12: */ 70846 var p uintptr = pVtab 70847 if (*sqlite3_file)(unsafe.Pointer((*VfslogVtab)(unsafe.Pointer(p)).FpFd)).FpMethods != 0 { 70848 (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogVtab)(unsafe.Pointer(p)).FpFd)).FpMethods + 8 /* &.xClose */))))(tls, (*VfslogVtab)(unsafe.Pointer(p)).FpFd) 70849 (*sqlite3_file)(unsafe.Pointer((*VfslogVtab)(unsafe.Pointer(p)).FpFd)).FpMethods = uintptr(0) 70850 } 70851 sqlite3.Xsqlite3_free(tls, p) 70852 return SQLITE_OK 70853 } 70854 70855 // Open a new vfslog cursor. 70856 func vlogOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* test_osinst.c:937:12: */ 70857 var pCsr uintptr // Newly allocated cursor object 70858 70859 pCsr = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(VfslogCsr{}))) 70860 if !(pCsr != 0) { 70861 return SQLITE_NOMEM 70862 } 70863 libc.Xmemset(tls, pCsr, 0, uint64(unsafe.Sizeof(VfslogCsr{}))) 70864 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCsr /* &.base */) 70865 return SQLITE_OK 70866 } 70867 70868 // Close a vfslog cursor. 70869 func vlogClose(tls *libc.TLS, pCursor uintptr) int32 { /* test_osinst.c:950:12: */ 70870 var p uintptr = pCursor 70871 var i int32 70872 for i = 0; i < (*VfslogCsr)(unsafe.Pointer(p)).FnFile; i++ { 70873 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer((*VfslogCsr)(unsafe.Pointer(p)).FazFile + uintptr(i)*8))) 70874 } 70875 sqlite3.Xsqlite3_free(tls, (*VfslogCsr)(unsafe.Pointer(p)).FazFile) 70876 sqlite3.Xsqlite3_free(tls, (*VfslogCsr)(unsafe.Pointer(p)).FzTransient) 70877 sqlite3.Xsqlite3_free(tls, p) 70878 return SQLITE_OK 70879 } 70880 70881 // Move a vfslog cursor to the next entry in the file. 70882 func vlogNext(tls *libc.TLS, pCursor uintptr) int32 { /* test_osinst.c:965:12: */ 70883 bp := tls.Alloc(4) 70884 defer tls.Free(4) 70885 70886 var pCsr uintptr = pCursor 70887 var p uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab 70888 var rc int32 = SQLITE_OK 70889 var nRead int32 70890 70891 sqlite3.Xsqlite3_free(tls, (*VfslogCsr)(unsafe.Pointer(pCsr)).FzTransient) 70892 (*VfslogCsr)(unsafe.Pointer(pCsr)).FzTransient = uintptr(0) 70893 70894 nRead = 24 70895 if ((*VfslogCsr)(unsafe.Pointer(pCsr)).FiOffset + sqlite3_int64(nRead)) <= (*VfslogVtab)(unsafe.Pointer(p)).FnByte { 70896 var eEvent int32 70897 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogVtab)(unsafe.Pointer(p)).FpFd)).FpMethods + 16 /* &.xRead */))))(tls, (*VfslogVtab)(unsafe.Pointer(p)).FpFd, pCsr+48 /* &.aBuf */, nRead, (*VfslogCsr)(unsafe.Pointer(pCsr)).FiOffset) 70898 70899 eEvent = int32(get32bits(tls, pCsr+48 /* &.aBuf */)) 70900 if (rc == SQLITE_OK) && 70901 (((eEvent == OS_OPEN) || (eEvent == OS_DELETE)) || (eEvent == OS_ACCESS)) { 70902 // var buf [4]int8 at bp, 4 70903 70904 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogVtab)(unsafe.Pointer(p)).FpFd)).FpMethods + 16 /* &.xRead */))))(tls, (*VfslogVtab)(unsafe.Pointer(p)).FpFd, bp /* &buf[0] */, 4, ((*VfslogCsr)(unsafe.Pointer(pCsr)).FiOffset + sqlite3_int64(nRead))) 70905 nRead = nRead + (4) 70906 if rc == SQLITE_OK { 70907 var nStr int32 = int32(get32bits(tls, bp /* buf */)) 70908 var zStr uintptr = sqlite3.Xsqlite3_malloc(tls, (nStr + 1)) 70909 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer((*VfslogVtab)(unsafe.Pointer(p)).FpFd)).FpMethods + 16 /* &.xRead */))))(tls, (*VfslogVtab)(unsafe.Pointer(p)).FpFd, zStr, nStr, ((*VfslogCsr)(unsafe.Pointer(pCsr)).FiOffset + sqlite3_int64(nRead))) 70910 *(*int8)(unsafe.Pointer(zStr + uintptr(nStr))) = int8(0) 70911 nRead = nRead + (nStr) 70912 70913 if eEvent == OS_OPEN { 70914 var iFileid int32 = int32(get32bits(tls, ((pCsr + 48 /* &.aBuf */) + 4))) 70915 if iFileid >= (*VfslogCsr)(unsafe.Pointer(pCsr)).FnFile { 70916 var nNew int32 = (int32(uint64(unsafe.Sizeof(uintptr(0))) * (uint64(iFileid + 1)))) 70917 (*VfslogCsr)(unsafe.Pointer(pCsr)).FazFile = sqlite3.Xsqlite3_realloc(tls, (*VfslogCsr)(unsafe.Pointer(pCsr)).FazFile, nNew) 70918 nNew = int32(uint64(nNew) - (uint64(unsafe.Sizeof(uintptr(0))) * uint64((*VfslogCsr)(unsafe.Pointer(pCsr)).FnFile))) 70919 libc.Xmemset(tls, ((*VfslogCsr)(unsafe.Pointer(pCsr)).FazFile + uintptr((*VfslogCsr)(unsafe.Pointer(pCsr)).FnFile)*8), 0, uint64(nNew)) 70920 (*VfslogCsr)(unsafe.Pointer(pCsr)).FnFile = (iFileid + 1) 70921 } 70922 sqlite3.Xsqlite3_free(tls, *(*uintptr)(unsafe.Pointer((*VfslogCsr)(unsafe.Pointer(pCsr)).FazFile + uintptr(iFileid)*8))) 70923 *(*uintptr)(unsafe.Pointer((*VfslogCsr)(unsafe.Pointer(pCsr)).FazFile + uintptr(iFileid)*8)) = zStr 70924 } else { 70925 (*VfslogCsr)(unsafe.Pointer(pCsr)).FzTransient = zStr 70926 } 70927 } 70928 } 70929 } 70930 70931 *(*sqlite3_int64)(unsafe.Pointer(pCsr + 8 /* &.iRowid */)) += (int64(1)) 70932 *(*sqlite3_int64)(unsafe.Pointer(pCsr + 16 /* &.iOffset */)) += (sqlite3_int64(nRead)) 70933 return rc 70934 } 70935 70936 func vlogEof(tls *libc.TLS, pCursor uintptr) int32 { /* test_osinst.c:1016:12: */ 70937 var pCsr uintptr = pCursor 70938 var p uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(pCursor)).FpVtab 70939 return (libc.Bool32((*VfslogCsr)(unsafe.Pointer(pCsr)).FiOffset >= (*VfslogVtab)(unsafe.Pointer(p)).FnByte)) 70940 } 70941 70942 func vlogFilter(tls *libc.TLS, pCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* test_osinst.c:1022:12: */ 70943 var pCsr uintptr = pCursor 70944 (*VfslogCsr)(unsafe.Pointer(pCsr)).FiRowid = int64(0) 70945 (*VfslogCsr)(unsafe.Pointer(pCsr)).FiOffset = int64(20) 70946 return vlogNext(tls, pCursor) 70947 } 70948 70949 func vlogColumn(tls *libc.TLS, pCursor uintptr, ctx uintptr, i int32) int32 { /* test_osinst.c:1033:12: */ 70950 var val uint32 70951 var pCsr uintptr = pCursor 70952 70953 val = get32bits(tls, ((pCsr + 48 /* &.aBuf */) + uintptr((4 * i)))) 70954 70955 switch i { 70956 case 0: 70957 { 70958 sqlite3.Xsqlite3_result_text(tls, ctx, vfslog_eventname(tls, int32(val)), -1, uintptr(0)) 70959 break 70960 70961 } 70962 case 1: 70963 { 70964 var zStr uintptr = (*VfslogCsr)(unsafe.Pointer(pCsr)).FzTransient 70965 if (val != uint32(0)) && (val < uint32((*VfslogCsr)(unsafe.Pointer(pCsr)).FnFile)) { 70966 zStr = *(*uintptr)(unsafe.Pointer((*VfslogCsr)(unsafe.Pointer(pCsr)).FazFile + uintptr(val)*8)) 70967 } 70968 sqlite3.Xsqlite3_result_text(tls, ctx, zStr, -1, libc.UintptrFromInt32(-1)) 70969 break 70970 70971 } 70972 default: 70973 sqlite3.Xsqlite3_result_int(tls, ctx, int32(val)) 70974 break 70975 } 70976 70977 return SQLITE_OK 70978 } 70979 70980 func vlogRowid(tls *libc.TLS, pCursor uintptr, pRowid uintptr) int32 { /* test_osinst.c:1065:12: */ 70981 var pCsr uintptr = pCursor 70982 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = (*VfslogCsr)(unsafe.Pointer(pCsr)).FiRowid 70983 return SQLITE_OK 70984 } 70985 70986 func sqlite3_vfslog_register(tls *libc.TLS, db uintptr) int32 { /* test_osinst.c:1071:5: */ 70987 70988 sqlite3.Xsqlite3_create_module(tls, db, ts+35102 /* "vfslog" */, uintptr(unsafe.Pointer(&vfslog_module)), uintptr(0)) 70989 return SQLITE_OK 70990 } 70991 70992 var vfslog_module = sqlite3_module{ // iVersion 70993 FxCreate: 0, // xCreate 70994 FxConnect: 0, // xConnect 70995 FxBestIndex: 0, // xBestIndex 70996 FxDisconnect: 0, // xDisconnect 70997 FxDestroy: 0, // xDestroy 70998 FxOpen: 0, // xOpen - open a cursor 70999 FxClose: 0, // xClose - close a cursor 71000 FxFilter: 0, // xFilter - configure scan constraints 71001 FxNext: 0, // xNext - advance a cursor 71002 FxEof: 0, // xEof - check for end of scan 71003 FxColumn: 0, // xColumn - read data 71004 FxRowid: 0, // xRename 71005 } /* test_osinst.c:1072:25 */ 71006 71007 // end block for C++ 71008 71009 // Local Variables: 71010 // mode: c 71011 // c-basic-offset: 4 71012 // fill-column: 78 71013 // End: 71014 71015 func test_vfslog(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_osinst.c:1116:26: */ 71016 bp := tls.Alloc(144) 71017 defer tls.Free(144) 71018 71019 var db uintptr 71020 // var cmdInfo Tcl_CmdInfo at bp+80, 64 71021 71022 var rc int32 = SQLITE_ERROR 71023 // var iSub int32 at bp+72, 4 71024 71025 if objc < 2 { 71026 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32318 /* "SUB-COMMAND ..." */) 71027 return TCL_ERROR 71028 } 71029 if tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), uintptr(unsafe.Pointer(&strs)), int32(unsafe.Sizeof(uintptr(0))), ts+1875 /* "sub-command" */, 0, bp+72 /* &iSub */) != 0 { 71030 return TCL_ERROR 71031 } 71032 71033 switch uint32(*(*int32)(unsafe.Pointer(bp + 72 /* iSub */))) { 71034 case uint32(0) /* VL_ANNOTATE */ : 71035 { 71036 var zVfs uintptr 71037 var zMsg uintptr 71038 if objc != 4 { 71039 tcl.XTcl_WrongNumArgs(tls, interp, 3, objv, ts+35109 /* "VFS" */) 71040 return TCL_ERROR 71041 } 71042 zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 71043 zMsg = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 71044 rc = sqlite3_vfslog_annotate(tls, zVfs, zMsg) 71045 if rc != SQLITE_OK { 71046 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+35113 /* "failed" */, 0)) 71047 return TCL_ERROR 71048 } 71049 break 71050 71051 } 71052 case uint32(1) /* VL_FINALIZE */ : 71053 { 71054 var zVfs uintptr 71055 if objc != 3 { 71056 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+35109 /* "VFS" */) 71057 return TCL_ERROR 71058 } 71059 zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 71060 rc = sqlite3_vfslog_finalize(tls, zVfs) 71061 if rc != SQLITE_OK { 71062 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+16, ts+35113 /* "failed" */, 0)) 71063 return TCL_ERROR 71064 } 71065 break 71066 71067 } 71068 71069 case uint32(2) /* VL_NEW */ : 71070 { 71071 var zVfs uintptr 71072 var zParent uintptr 71073 var zLog uintptr 71074 if objc != 5 { 71075 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+35120 /* "VFS PARENT LOGFI..." */) 71076 return TCL_ERROR 71077 } 71078 zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 71079 zParent = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 71080 zLog = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8))) 71081 if int32(*(*int8)(unsafe.Pointer(zParent))) == 0 { 71082 zParent = uintptr(0) 71083 } 71084 rc = sqlite3_vfslog_new(tls, zVfs, zParent, zLog) 71085 if rc != SQLITE_OK { 71086 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+32, ts+35113 /* "failed" */, 0)) 71087 return TCL_ERROR 71088 } 71089 break 71090 71091 } 71092 71093 case uint32(3) /* VL_REGISTER */ : 71094 { 71095 var zDb uintptr 71096 if objc != 3 { 71097 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+1911 /* "DB" */) 71098 return TCL_ERROR 71099 } 71100 zDb = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 71101 if tcl.XTcl_GetCommandInfo(tls, interp, zDb, bp+80 /* &cmdInfo */) != 0 { 71102 db = (*struct{ Fdb uintptr })(unsafe.Pointer((*Tcl_CmdInfo)(unsafe.Pointer(bp + 80 /* &cmdInfo */)).FobjClientData)).Fdb 71103 rc = sqlite3_vfslog_register(tls, db) 71104 } 71105 if rc != SQLITE_OK { 71106 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+35139 /* "bad sqlite3 hand..." */, zDb, uintptr(0))) 71107 return TCL_ERROR 71108 } 71109 break 71110 71111 } 71112 } 71113 71114 return TCL_OK 71115 } 71116 71117 var strs = [5]uintptr{ts + 35160 /* "annotate" */, ts + 35169 /* "finalize" */, ts + 13691 /* "new" */, ts + 35178 /* "register" */, uintptr(0)} /* test_osinst.c:1127:21 */ 71118 71119 func SqlitetestOsinst_Init(tls *libc.TLS, interp uintptr) int32 { /* test_osinst.c:1219:5: */ 71120 tcl.XTcl_CreateObjCommand(tls, interp, ts+35102 /* "vfslog" */, *(*uintptr)(unsafe.Pointer(&struct { 71121 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 71122 }{test_vfslog})), uintptr(0), uintptr(0)) 71123 return TCL_OK 71124 } 71125 71126 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 71127 // This file is part of the GNU C Library. 71128 // 71129 // The GNU C Library is free software; you can redistribute it and/or 71130 // modify it under the terms of the GNU Lesser General Public 71131 // License as published by the Free Software Foundation; either 71132 // version 2.1 of the License, or (at your option) any later version. 71133 // 71134 // The GNU C Library is distributed in the hope that it will be useful, 71135 // but WITHOUT ANY WARRANTY; without even the implied warranty of 71136 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 71137 // Lesser General Public License for more details. 71138 // 71139 // You should have received a copy of the GNU Lesser General Public 71140 // License along with the GNU C Library; if not, see 71141 // <http://www.gnu.org/licenses/>. 71142 71143 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 71144 71145 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 71146 // This file is part of the GNU C Library. 71147 // 71148 // The GNU C Library is free software; you can redistribute it and/or 71149 // modify it under the terms of the GNU Lesser General Public 71150 // License as published by the Free Software Foundation; either 71151 // version 2.1 of the License, or (at your option) any later version. 71152 // 71153 // The GNU C Library is distributed in the hope that it will be useful, 71154 // but WITHOUT ANY WARRANTY; without even the implied warranty of 71155 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 71156 // Lesser General Public License for more details. 71157 // 71158 // You should have received a copy of the GNU Lesser General Public 71159 // License along with the GNU C Library; if not, see 71160 // <http://www.gnu.org/licenses/>. 71161 71162 // void assert (int expression); 71163 // 71164 // If NDEBUG is defined, do nothing. 71165 // If not, and EXPRESSION is zero, print an error message and abort. 71166 71167 // void assert_perror (int errnum); 71168 // 71169 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 71170 // error message with the error text for ERRNUM and abort. 71171 // (This is a GNU extension.) 71172 71173 // Global data used by this test implementation. There is no 71174 // mutexing, which means this page cache will not work in a 71175 // multi-threaded test. 71176 type testpcacheGlobalType1 = struct { 71177 FpDummy uintptr 71178 FnInstance int32 71179 FdiscardChance uint32 71180 FprngSeed uint32 71181 FhighStress uint32 71182 } /* test_pcache.c:33:9 */ 71183 71184 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 71185 // This file is part of the GNU C Library. 71186 // 71187 // The GNU C Library is free software; you can redistribute it and/or 71188 // modify it under the terms of the GNU Lesser General Public 71189 // License as published by the Free Software Foundation; either 71190 // version 2.1 of the License, or (at your option) any later version. 71191 // 71192 // The GNU C Library is distributed in the hope that it will be useful, 71193 // but WITHOUT ANY WARRANTY; without even the implied warranty of 71194 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 71195 // Lesser General Public License for more details. 71196 // 71197 // You should have received a copy of the GNU Lesser General Public 71198 // License along with the GNU C Library; if not, see 71199 // <http://www.gnu.org/licenses/>. 71200 71201 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 71202 71203 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 71204 // This file is part of the GNU C Library. 71205 // 71206 // The GNU C Library is free software; you can redistribute it and/or 71207 // modify it under the terms of the GNU Lesser General Public 71208 // License as published by the Free Software Foundation; either 71209 // version 2.1 of the License, or (at your option) any later version. 71210 // 71211 // The GNU C Library is distributed in the hope that it will be useful, 71212 // but WITHOUT ANY WARRANTY; without even the implied warranty of 71213 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 71214 // Lesser General Public License for more details. 71215 // 71216 // You should have received a copy of the GNU Lesser General Public 71217 // License along with the GNU C Library; if not, see 71218 // <http://www.gnu.org/licenses/>. 71219 71220 // void assert (int expression); 71221 // 71222 // If NDEBUG is defined, do nothing. 71223 // If not, and EXPRESSION is zero, print an error message and abort. 71224 71225 // void assert_perror (int errnum); 71226 // 71227 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 71228 // error message with the error text for ERRNUM and abort. 71229 // (This is a GNU extension.) 71230 71231 // Global data used by this test implementation. There is no 71232 // mutexing, which means this page cache will not work in a 71233 // multi-threaded test. 71234 type testpcacheGlobalType = testpcacheGlobalType1 /* test_pcache.c:33:37 */ 71235 var testpcacheGlobal testpcacheGlobalType /* test_pcache.c:41:29: */ 71236 71237 // Initializer. 71238 // 71239 // Verify that the initializer is only called when the system is 71240 // uninitialized. Allocate some memory and report SQLITE_NOMEM if 71241 // the allocation fails. This provides a means to test the recovery 71242 // from a failed initialization attempt. It also verifies that the 71243 // the destructor always gets call - otherwise there would be a 71244 // memory leak. 71245 func testpcacheInit(tls *libc.TLS, pArg uintptr) int32 { /* test_pcache.c:53:12: */ 71246 71247 testpcacheGlobal.FpDummy = sqlite3.Xsqlite3_malloc(tls, 10) 71248 if testpcacheGlobal.FpDummy == uintptr(0) { 71249 return SQLITE_NOMEM 71250 } 71251 return SQLITE_OK 71252 } 71253 71254 // Destructor 71255 // 71256 // Verify that this is only called after initialization. 71257 // Free the memory allocated by the initializer. 71258 func testpcacheShutdown(tls *libc.TLS, pArg uintptr) { /* test_pcache.c:67:13: */ 71259 71260 sqlite3.Xsqlite3_free(tls, testpcacheGlobal.FpDummy) 71261 testpcacheGlobal.FpDummy = uintptr(0) 71262 } 71263 71264 // Number of pages in a cache. 71265 // 71266 // The number of pages is a hard upper bound in this test module. 71267 // If more pages are requested, sqlite3PcacheFetch() returns NULL. 71268 // 71269 // If testing with in-memory temp tables, provide a larger pcache. 71270 // Some of the test cases need this. 71271 71272 // Magic numbers used to determine validity of the page cache. 71273 71274 // Private implementation of a page cache. 71275 type testpcache1 = struct { 71276 FszPage int32 71277 FszExtra int32 71278 FbPurgeable int32 71279 FnFree int32 71280 FnPinned int32 71281 FiRand uint32 71282 FiMagic uint32 71283 _ [4]byte 71284 Fa [217]struct { 71285 Fpage sqlite3_pcache_page 71286 Fkey uint32 71287 FisPinned int32 71288 } 71289 } /* test_pcache.c:100:9 */ 71290 71291 // Number of pages in a cache. 71292 // 71293 // The number of pages is a hard upper bound in this test module. 71294 // If more pages are requested, sqlite3PcacheFetch() returns NULL. 71295 // 71296 // If testing with in-memory temp tables, provide a larger pcache. 71297 // Some of the test cases need this. 71298 71299 // Magic numbers used to determine validity of the page cache. 71300 71301 // Private implementation of a page cache. 71302 type testpcache = testpcache1 /* test_pcache.c:100:27 */ 71303 type testpcachePage = struct { 71304 Fpage sqlite3_pcache_page 71305 Fkey uint32 71306 FisPinned int32 71307 } /* test_pcache.c:100:9 */ 71308 71309 // Get a random number using the PRNG in the given page cache. 71310 func testpcacheRandom(tls *libc.TLS, p uintptr) uint32 { /* test_pcache.c:119:17: */ 71311 var x uint32 = uint32(0) 71312 var i int32 71313 for i = 0; i < 4; i++ { 71314 (*testpcache)(unsafe.Pointer(p)).FiRand = (((*testpcache)(unsafe.Pointer(p)).FiRand * uint32(69069)) + uint32(5)) 71315 x = ((x << 8) | (((*testpcache)(unsafe.Pointer(p)).FiRand >> 16) & uint32(0xff))) 71316 } 71317 return x 71318 } 71319 71320 // Allocate a new page cache instance. 71321 func testpcacheCreate(tls *libc.TLS, szPage int32, szExtra int32, bPurgeable int32) uintptr { /* test_pcache.c:133:23: */ 71322 var nMem int32 71323 var x uintptr 71324 var p uintptr 71325 var i int32 71326 71327 szPage = ((szPage + 7) & libc.CplInt32(7)) 71328 nMem = (int32(uint64(unsafe.Sizeof(testpcache{})) + (uint64(TESTPCACHE_NPAGE * (szPage + szExtra))))) 71329 p = sqlite3.Xsqlite3_malloc(tls, nMem) 71330 if p == uintptr(0) { 71331 return uintptr(0) 71332 } 71333 x = (p + 1*5240) 71334 (*testpcache)(unsafe.Pointer(p)).FszPage = szPage 71335 (*testpcache)(unsafe.Pointer(p)).FszExtra = szExtra 71336 (*testpcache)(unsafe.Pointer(p)).FnFree = TESTPCACHE_NPAGE 71337 (*testpcache)(unsafe.Pointer(p)).FnPinned = 0 71338 (*testpcache)(unsafe.Pointer(p)).FiRand = testpcacheGlobal.FprngSeed 71339 (*testpcache)(unsafe.Pointer(p)).FbPurgeable = bPurgeable 71340 (*testpcache)(unsafe.Pointer(p)).FiMagic = uint32(TESTPCACHE_VALID) 71341 i = 0 71342 __1: 71343 if !(i < TESTPCACHE_NPAGE) { 71344 goto __3 71345 } 71346 { 71347 (*testpcachePage)(unsafe.Pointer((p + 32 /* &.a */) + uintptr(i)*24)).Fkey = uint32(0) 71348 (*testpcachePage)(unsafe.Pointer((p + 32 /* &.a */) + uintptr(i)*24)).FisPinned = 0 71349 (*testpcachePage)(unsafe.Pointer((p + 32 /* &.a */) + uintptr(i)*24)).Fpage.FpBuf = x 71350 (*testpcachePage)(unsafe.Pointer((p + 32 /* &.a */) + uintptr(i)*24)).Fpage.FpExtra = (x + uintptr(szPage)) 71351 71352 } 71353 goto __2 71354 __2: 71355 i++ 71356 x += (uintptr(szPage + szExtra)) 71357 goto __1 71358 goto __3 71359 __3: 71360 ; 71361 testpcacheGlobal.FnInstance++ 71362 return p 71363 } 71364 71365 // Set the cache size 71366 func testpcacheCachesize(tls *libc.TLS, pCache uintptr, newSize int32) { /* test_pcache.c:168:13: */ 71367 var p uintptr = pCache 71368 _ = p 71369 71370 } 71371 71372 // Return the number of pages in the cache that are being used. 71373 // This includes both pinned and unpinned pages. 71374 func testpcachePagecount(tls *libc.TLS, pCache uintptr) int32 { /* test_pcache.c:179:12: */ 71375 var p uintptr = pCache 71376 71377 return (TESTPCACHE_NPAGE - (*testpcache)(unsafe.Pointer(p)).FnFree) 71378 } 71379 71380 // Fetch a page. 71381 func testpcacheFetch(tls *libc.TLS, pCache uintptr, key uint32, createFlag int32) uintptr { /* test_pcache.c:190:28: */ 71382 var p uintptr = pCache 71383 var i int32 71384 var j int32 71385 71386 // See if the page is already in cache. Return immediately if it is 71387 for i = 0; i < TESTPCACHE_NPAGE; i++ { 71388 if (*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(i)*24)).Fkey == key { 71389 if !((*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(i)*24)).FisPinned != 0) { 71390 (*testpcache)(unsafe.Pointer(p)).FnPinned++ 71391 71392 (*testpcachePage)(unsafe.Pointer((p + 32 /* &.a */) + uintptr(i)*24)).FisPinned = 1 71393 } 71394 return ((p + 32 /* &.a */) + uintptr(i)*24 /* &.page */) 71395 } 71396 } 71397 71398 // If createFlag is 0, never allocate a new page 71399 if createFlag == 0 { 71400 return uintptr(0) 71401 } 71402 71403 // If no pages are available, always fail 71404 if (*testpcache)(unsafe.Pointer(p)).FnPinned == TESTPCACHE_NPAGE { 71405 return uintptr(0) 71406 } 71407 71408 // Do not allocate the last TESTPCACHE_RESERVE pages unless createFlag is 2 71409 if ((*testpcache)(unsafe.Pointer(p)).FnPinned >= (TESTPCACHE_NPAGE - TESTPCACHE_RESERVE)) && (createFlag < 2) { 71410 return uintptr(0) 71411 } 71412 71413 // Do not allocate if highStress is enabled and createFlag is not 2. 71414 // 71415 // The highStress setting causes pagerStress() to be called much more 71416 // often, which exercises the pager logic more intensely. 71417 if (testpcacheGlobal.FhighStress != 0) && (createFlag < 2) { 71418 return uintptr(0) 71419 } 71420 71421 // Find a free page to allocate if there are any free pages. 71422 // Withhold TESTPCACHE_RESERVE free pages until createFlag is 2. 71423 if ((*testpcache)(unsafe.Pointer(p)).FnFree > TESTPCACHE_RESERVE) || ((createFlag == 2) && ((*testpcache)(unsafe.Pointer(p)).FnFree > 0)) { 71424 j = (int32(testpcacheRandom(tls, p) % uint32(TESTPCACHE_NPAGE))) 71425 i = 0 71426 __1: 71427 if !(i < TESTPCACHE_NPAGE) { 71428 goto __3 71429 } 71430 { 71431 if (*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(j)*24)).Fkey == uint32(0) { 71432 (*testpcachePage)(unsafe.Pointer((p + 32 /* &.a */) + uintptr(j)*24)).Fkey = key 71433 (*testpcachePage)(unsafe.Pointer((p + 32 /* &.a */) + uintptr(j)*24)).FisPinned = 1 71434 libc.Xmemset(tls, (*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(j)*24)).Fpage.FpBuf, 0, uint64((*testpcache)(unsafe.Pointer(p)).FszPage)) 71435 libc.Xmemset(tls, (*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(j)*24)).Fpage.FpExtra, 0, uint64((*testpcache)(unsafe.Pointer(p)).FszExtra)) 71436 (*testpcache)(unsafe.Pointer(p)).FnPinned++ 71437 (*testpcache)(unsafe.Pointer(p)).FnFree-- 71438 71439 return ((p + 32 /* &.a */) + uintptr(j)*24 /* &.page */) 71440 } 71441 71442 } 71443 goto __2 71444 __2: 71445 i++ 71446 j = ((j + 1) % TESTPCACHE_NPAGE) 71447 goto __1 71448 goto __3 71449 __3: 71450 71451 // The prior loop always finds a freepage to allocate 71452 71453 } 71454 71455 // If this cache is not purgeable then we have to fail. 71456 if (*testpcache)(unsafe.Pointer(p)).FbPurgeable == 0 { 71457 return uintptr(0) 71458 } 71459 71460 // If there are no free pages, recycle a page. The page to 71461 // recycle is selected at random from all unpinned pages. 71462 j = (int32(testpcacheRandom(tls, p) % uint32(TESTPCACHE_NPAGE))) 71463 i = 0 71464 __4: 71465 if !(i < TESTPCACHE_NPAGE) { 71466 goto __6 71467 } 71468 { 71469 if ((*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(j)*24)).Fkey > uint32(0)) && ((*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(j)*24)).FisPinned == 0) { 71470 (*testpcachePage)(unsafe.Pointer((p + 32 /* &.a */) + uintptr(j)*24)).Fkey = key 71471 (*testpcachePage)(unsafe.Pointer((p + 32 /* &.a */) + uintptr(j)*24)).FisPinned = 1 71472 libc.Xmemset(tls, (*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(j)*24)).Fpage.FpBuf, 0, uint64((*testpcache)(unsafe.Pointer(p)).FszPage)) 71473 libc.Xmemset(tls, (*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(j)*24)).Fpage.FpExtra, 0, uint64((*testpcache)(unsafe.Pointer(p)).FszExtra)) 71474 (*testpcache)(unsafe.Pointer(p)).FnPinned++ 71475 71476 return ((p + 32 /* &.a */) + uintptr(j)*24 /* &.page */) 71477 } 71478 71479 } 71480 goto __5 71481 __5: 71482 i++ 71483 j = ((j + 1) % TESTPCACHE_NPAGE) 71484 goto __4 71485 goto __6 71486 __6: 71487 ; 71488 71489 // The previous loop always finds a page to recycle. 71490 71491 return uintptr(0) 71492 } 71493 71494 // Unpin a page. 71495 func testpcacheUnpin(tls *libc.TLS, pCache uintptr, pOldPage uintptr, discard int32) { /* test_pcache.c:289:13: */ 71496 var p uintptr = pCache 71497 var i int32 71498 71499 // Randomly discard pages as they are unpinned according to the 71500 // discardChance setting. If discardChance is 0, the random discard 71501 // never happens. If discardChance is 100, it always happens. 71502 if ((*testpcache)(unsafe.Pointer(p)).FbPurgeable != 0) && 71503 ((uint32(100) - testpcacheGlobal.FdiscardChance) <= (testpcacheRandom(tls, p) % uint32(100))) { 71504 discard = 1 71505 } 71506 71507 for i = 0; i < TESTPCACHE_NPAGE; i++ { 71508 if ((p + 32 /* &.a */) + uintptr(i)*24 /* &.page */) == pOldPage { 71509 // The pOldPage pointer always points to a pinned page 71510 71511 (*testpcachePage)(unsafe.Pointer((p + 32 /* &.a */) + uintptr(i)*24)).FisPinned = 0 71512 (*testpcache)(unsafe.Pointer(p)).FnPinned-- 71513 71514 if discard != 0 { 71515 (*testpcachePage)(unsafe.Pointer((p + 32 /* &.a */) + uintptr(i)*24)).Fkey = uint32(0) 71516 (*testpcache)(unsafe.Pointer(p)).FnFree++ 71517 71518 } 71519 return 71520 } 71521 } 71522 71523 // The pOldPage pointer always points to a valid page 71524 71525 } 71526 71527 // Rekey a single page. 71528 func testpcacheRekey(tls *libc.TLS, pCache uintptr, pOldPage uintptr, oldKey uint32, newKey uint32) { /* test_pcache.c:334:13: */ 71529 var p uintptr = pCache 71530 var i int32 71531 71532 // If there already exists another page at newKey, verify that 71533 // the other page is unpinned and discard it. 71534 for i = 0; i < TESTPCACHE_NPAGE; i++ { 71535 if (*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(i)*24)).Fkey == newKey { 71536 // The new key is never a page that is already pinned 71537 71538 (*testpcachePage)(unsafe.Pointer((p + 32 /* &.a */) + uintptr(i)*24)).Fkey = uint32(0) 71539 (*testpcache)(unsafe.Pointer(p)).FnFree++ 71540 71541 break 71542 } 71543 } 71544 71545 // Find the page to be rekeyed and rekey it. 71546 for i = 0; i < TESTPCACHE_NPAGE; i++ { 71547 if (*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(i)*24)).Fkey == oldKey { 71548 // The oldKey and pOldPage parameters match 71549 71550 // Page to be rekeyed must be pinned 71551 71552 (*testpcachePage)(unsafe.Pointer((p + 32 /* &.a */) + uintptr(i)*24)).Fkey = newKey 71553 return 71554 } 71555 } 71556 71557 // Rekey is always given a valid page to work with 71558 71559 } 71560 71561 // Truncate the page cache. Every page with a key of iLimit or larger 71562 // is discarded. 71563 func testpcacheTruncate(tls *libc.TLS, pCache uintptr, iLimit uint32) { /* test_pcache.c:382:13: */ 71564 var p uintptr = pCache 71565 var i uint32 71566 71567 for i = uint32(0); i < uint32(TESTPCACHE_NPAGE); i++ { 71568 if (*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(i)*24)).Fkey >= iLimit { 71569 (*testpcachePage)(unsafe.Pointer((p + 32 /* &.a */) + uintptr(i)*24)).Fkey = uint32(0) 71570 if (*testpcachePage)(unsafe.Pointer((p+32 /* &.a */)+uintptr(i)*24)).FisPinned != 0 { 71571 (*testpcache)(unsafe.Pointer(p)).FnPinned-- 71572 71573 } 71574 (*testpcache)(unsafe.Pointer(p)).FnFree++ 71575 71576 } 71577 } 71578 } 71579 71580 // Destroy a page cache. 71581 func testpcacheDestroy(tls *libc.TLS, pCache uintptr) { /* test_pcache.c:404:13: */ 71582 var p uintptr = pCache 71583 71584 (*testpcache)(unsafe.Pointer(p)).FiMagic = TESTPCACHE_CLEAR 71585 sqlite3.Xsqlite3_free(tls, p) 71586 testpcacheGlobal.FnInstance-- 71587 } 71588 71589 // Invoke this routine to register or unregister the testing pager cache 71590 // implemented by this file. 71591 // 71592 // Install the test pager cache if installFlag is 1 and uninstall it if 71593 // installFlag is 0. 71594 // 71595 // When installing, discardChance is a number between 0 and 100 that 71596 // indicates the probability of discarding a page when unpinning the 71597 // page. 0 means never discard (unless the discard flag is set). 71598 // 100 means always discard. 71599 func installTestPCache(tls *libc.TLS, installFlag int32, discardChance uint32, prngSeed uint32, highStress uint32) { /* test_pcache.c:427:6: */ 71600 bp := tls.Alloc(24) 71601 defer tls.Free(24) 71602 71603 testpcacheGlobal.FdiscardChance = discardChance 71604 testpcacheGlobal.FprngSeed = (prngSeed ^ (prngSeed << 16)) 71605 testpcacheGlobal.FhighStress = highStress 71606 if installFlag != isInstalled { 71607 if installFlag != 0 { 71608 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_GETPCACHE2, libc.VaList(bp, uintptr(unsafe.Pointer(&defaultPcache)))) 71609 71610 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_PCACHE2, libc.VaList(bp+8, uintptr(unsafe.Pointer(&testPcache)))) 71611 } else { 71612 71613 sqlite3.Xsqlite3_config(tls, SQLITE_CONFIG_PCACHE2, libc.VaList(bp+16, uintptr(unsafe.Pointer(&defaultPcache)))) 71614 } 71615 isInstalled = installFlag 71616 } 71617 } 71618 71619 var testPcache = sqlite3_pcache_methods2{ 71620 FiVersion: 1, 71621 FpArg: 0, 71622 FxInit: 0, 71623 FxShutdown: 0, 71624 FxCreate: 0, 71625 FxCachesize: 0, 71626 FxPagecount: 0, 71627 FxFetch: 0, 71628 FxUnpin: 0, 71629 FxRekey: 0, 71630 FxTruncate: 0, 71631 FxDestroy: 0, 71632 } /* test_pcache.c:433:40 */ 71633 var defaultPcache sqlite3_pcache_methods2 /* test_pcache.c:447:34: */ 71634 var isInstalled int32 = 0 /* test_pcache.c:448:14 */ 71635 71636 // The following object serves the same role as FILE in the standard C 71637 // library. It represents an open connection to a file on disk for I/O. 71638 // 71639 // A single quota_FILE should not be used by two or more threads at the 71640 // same time. Multiple threads can be using different quota_FILE objects 71641 // simultaneously, but not the same quota_FILE object. 71642 type quota_FILE1 = struct { 71643 Ff uintptr 71644 FiOfst sqlite3_int64 71645 FpFile uintptr 71646 } /* test_quota.h:145:9 */ 71647 71648 // The following object serves the same role as FILE in the standard C 71649 // library. It represents an open connection to a file on disk for I/O. 71650 // 71651 // A single quota_FILE should not be used by two or more threads at the 71652 // same time. Multiple threads can be using different quota_FILE objects 71653 // simultaneously, but not the same quota_FILE object. 71654 type quota_FILE = quota_FILE1 /* test_quota.h:145:27 */ 71655 71656 // Define some macros helping to catch buffer overflows. 71657 71658 //*********************** Object Definitions ***************************** 71659 71660 // Forward declaration of all object types 71661 type quotaGroup1 = struct { 71662 FzPattern uintptr 71663 FiLimit sqlite3_int64 71664 FiSize sqlite3_int64 71665 FxCallback uintptr 71666 FpArg uintptr 71667 FxDestroy uintptr 71668 FpNext uintptr 71669 FppPrev uintptr 71670 FpFiles uintptr 71671 } /* test_quota.h:145:9 */ 71672 71673 // Define some macros helping to catch buffer overflows. 71674 71675 //*********************** Object Definitions ***************************** 71676 71677 // Forward declaration of all object types 71678 type quotaGroup = quotaGroup1 /* test_quota.c:61:27 */ 71679 type quotaConn1 = struct { 71680 Fbase sqlite3_file 71681 FpFile uintptr 71682 } /* test_quota.c:62:9 */ 71683 71684 type quotaConn = quotaConn1 /* test_quota.c:62:26 */ 71685 type quotaFile1 = struct { 71686 FzFilename uintptr 71687 FpGroup uintptr 71688 FiSize sqlite3_int64 71689 FnRef int32 71690 FdeleteOnClose int32 71691 FpNext uintptr 71692 FppPrev uintptr 71693 } /* test_quota.h:145:9 */ 71694 71695 type quotaFile = quotaFile1 /* test_quota.c:63:26 */ 71696 71697 //************************ Global Variables ********************************* 71698 // All global variables used by this file are containing within the following 71699 // gQuota structure. 71700 var gQuota struct { 71701 FpOrigVfs uintptr 71702 FsThisVfs sqlite3_vfs 71703 FsIoMethodsV1 sqlite3_io_methods 71704 FsIoMethodsV2 sqlite3_io_methods 71705 FisInitialized int32 71706 _ [4]byte 71707 FpMutex uintptr 71708 FpGroup uintptr 71709 } /* test_quota.c:183:3: */ 71710 71711 //************************ Utility Routines ******************************** 71712 // Acquire and release the mutex used to serialize access to the 71713 // list of quotaGroups. 71714 func quotaEnter(tls *libc.TLS) { /* test_quota.c:190:13: */ 71715 sqlite3.Xsqlite3_mutex_enter(tls, gQuota.FpMutex) 71716 } 71717 71718 func quotaLeave(tls *libc.TLS) { /* test_quota.c:191:13: */ 71719 sqlite3.Xsqlite3_mutex_leave(tls, gQuota.FpMutex) 71720 } 71721 71722 // Count the number of open files in a quotaGroup 71723 func quotaGroupOpenFileCount(tls *libc.TLS, pGroup uintptr) int32 { /* test_quota.c:195:12: */ 71724 var N int32 = 0 71725 var pFile uintptr = (*quotaGroup)(unsafe.Pointer(pGroup)).FpFiles 71726 for pFile != 0 { 71727 if (*quotaFile)(unsafe.Pointer(pFile)).FnRef != 0 { 71728 N++ 71729 } 71730 pFile = (*quotaFile)(unsafe.Pointer(pFile)).FpNext 71731 } 71732 return N 71733 } 71734 71735 // Remove a file from a quota group. 71736 func quotaRemoveFile(tls *libc.TLS, pFile uintptr) { /* test_quota.c:207:13: */ 71737 var pGroup uintptr = (*quotaFile)(unsafe.Pointer(pFile)).FpGroup 71738 *(*sqlite3_int64)(unsafe.Pointer(pGroup + 16 /* &.iSize */)) -= ((*quotaFile)(unsafe.Pointer(pFile)).FiSize) 71739 *(*uintptr)(unsafe.Pointer((*quotaFile)(unsafe.Pointer(pFile)).FppPrev)) = (*quotaFile)(unsafe.Pointer(pFile)).FpNext 71740 if (*quotaFile)(unsafe.Pointer(pFile)).FpNext != 0 { 71741 (*quotaFile)(unsafe.Pointer((*quotaFile)(unsafe.Pointer(pFile)).FpNext)).FppPrev = (*quotaFile)(unsafe.Pointer(pFile)).FppPrev 71742 } 71743 sqlite3.Xsqlite3_free(tls, pFile) 71744 } 71745 71746 // Remove all files from a quota group. It is always the case that 71747 // all files will be closed when this routine is called. 71748 func quotaRemoveAllFiles(tls *libc.TLS, pGroup uintptr) { /* test_quota.c:218:13: */ 71749 for (*quotaGroup)(unsafe.Pointer(pGroup)).FpFiles != 0 { 71750 71751 quotaRemoveFile(tls, (*quotaGroup)(unsafe.Pointer(pGroup)).FpFiles) 71752 } 71753 } 71754 71755 // If the reference count and threshold for a quotaGroup are both 71756 // zero, then destroy the quotaGroup. 71757 func quotaGroupDeref(tls *libc.TLS, pGroup uintptr) { /* test_quota.c:229:13: */ 71758 if ((*quotaGroup)(unsafe.Pointer(pGroup)).FiLimit == int64(0)) && (quotaGroupOpenFileCount(tls, pGroup) == 0) { 71759 quotaRemoveAllFiles(tls, pGroup) 71760 *(*uintptr)(unsafe.Pointer((*quotaGroup)(unsafe.Pointer(pGroup)).FppPrev)) = (*quotaGroup)(unsafe.Pointer(pGroup)).FpNext 71761 if (*quotaGroup)(unsafe.Pointer(pGroup)).FpNext != 0 { 71762 (*quotaGroup)(unsafe.Pointer((*quotaGroup)(unsafe.Pointer(pGroup)).FpNext)).FppPrev = (*quotaGroup)(unsafe.Pointer(pGroup)).FppPrev 71763 } 71764 if (*quotaGroup)(unsafe.Pointer(pGroup)).FxDestroy != 0 { 71765 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((pGroup + 40 /* &.xDestroy */))))(tls, (*quotaGroup)(unsafe.Pointer(pGroup)).FpArg) 71766 } 71767 sqlite3.Xsqlite3_free(tls, pGroup) 71768 } 71769 } 71770 71771 // Return TRUE if string z matches glob pattern zGlob. 71772 // 71773 // Globbing rules: 71774 // 71775 // '*' Matches any sequence of zero or more characters. 71776 // 71777 // '?' Matches exactly one character. 71778 // 71779 // [...] Matches one character from the enclosed list of 71780 // characters. 71781 // 71782 // [^...] Matches one character not in the enclosed list. 71783 // 71784 // / Matches "/" or "\\" 71785 // 71786 func quotaStrglob(tls *libc.TLS, zGlob uintptr, z uintptr) int32 { /* test_quota.c:256:12: */ 71787 var c int32 71788 var c2 int32 71789 var cx int32 71790 var invert int32 71791 var seen int32 71792 71793 for (libc.AssignInt32(&c, int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&zGlob, 1)))))) != 0 { 71794 if c == '*' { 71795 for ((libc.AssignInt32(&c, int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&zGlob, 1)))))) == '*') || (c == '?') { 71796 if (c == '?') && ((int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))))) == 0) { 71797 return 0 71798 } 71799 } 71800 if c == 0 { 71801 return 1 71802 } else if c == '[' { 71803 for (*(*int8)(unsafe.Pointer(z)) != 0) && (quotaStrglob(tls, (zGlob-uintptr(1)), z) == 0) { 71804 z++ 71805 } 71806 return (libc.Bool32((int32(*(*int8)(unsafe.Pointer(z)))) != 0)) 71807 } 71808 if c == '/' { 71809 cx = '\\' 71810 } else { 71811 cx = c 71812 } 71813 for (libc.AssignInt32(&c2, int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1)))))) != 0 { 71814 for (c2 != c) && (c2 != cx) { 71815 c2 = int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1)))) 71816 if c2 == 0 { 71817 return 0 71818 } 71819 } 71820 if quotaStrglob(tls, zGlob, z) != 0 { 71821 return 1 71822 } 71823 } 71824 return 0 71825 } else if c == '?' { 71826 if (int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))))) == 0 { 71827 return 0 71828 } 71829 } else if c == '[' { 71830 var prior_c int32 = 0 71831 seen = 0 71832 invert = 0 71833 c = int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1)))) 71834 if c == 0 { 71835 return 0 71836 } 71837 c2 = int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&zGlob, 1)))) 71838 if c2 == '^' { 71839 invert = 1 71840 c2 = int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&zGlob, 1)))) 71841 } 71842 if c2 == ']' { 71843 if c == ']' { 71844 seen = 1 71845 } 71846 c2 = int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&zGlob, 1)))) 71847 } 71848 for (c2 != 0) && (c2 != ']') { 71849 if (((c2 == '-') && (int32(*(*int8)(unsafe.Pointer(zGlob))) != ']')) && (int32(*(*int8)(unsafe.Pointer(zGlob))) != 0)) && (prior_c > 0) { 71850 c2 = int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&zGlob, 1)))) 71851 if (c >= prior_c) && (c <= c2) { 71852 seen = 1 71853 } 71854 prior_c = 0 71855 } else { 71856 if c == c2 { 71857 seen = 1 71858 } 71859 prior_c = c2 71860 } 71861 c2 = int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&zGlob, 1)))) 71862 } 71863 if (c2 == 0) || ((seen ^ invert) == 0) { 71864 return 0 71865 } 71866 } else if c == '/' { 71867 if (int32(*(*int8)(unsafe.Pointer(z))) != '/') && (int32(*(*int8)(unsafe.Pointer(z))) != '\\') { 71868 return 0 71869 } 71870 z++ 71871 } else { 71872 if c != (int32(*(*int8)(unsafe.Pointer(libc.PostIncUintptr(&z, 1))))) { 71873 return 0 71874 } 71875 } 71876 } 71877 return (libc.Bool32(int32(*(*int8)(unsafe.Pointer(z))) == 0)) 71878 } 71879 71880 // Find a quotaGroup given the filename. 71881 // 71882 // Return a pointer to the quotaGroup object. Return NULL if not found. 71883 func quotaGroupFind(tls *libc.TLS, zFilename uintptr) uintptr { /* test_quota.c:329:19: */ 71884 var p uintptr 71885 for p = gQuota.FpGroup; (p != 0) && (quotaStrglob(tls, (*quotaGroup)(unsafe.Pointer(p)).FzPattern, zFilename) == 0); p = (*quotaGroup)(unsafe.Pointer(p)).FpNext { 71886 } 71887 return p 71888 } 71889 71890 // Translate an sqlite3_file* that is really a quotaConn* into 71891 // the sqlite3_file* for the underlying original VFS. 71892 func quotaSubOpen(tls *libc.TLS, pConn uintptr) uintptr { /* test_quota.c:339:21: */ 71893 var p uintptr = pConn 71894 return (p + 1*16) 71895 } 71896 71897 // Find a file in a quota group and return a pointer to that file. 71898 // Return NULL if the file is not in the group. 71899 func quotaFindFile(tls *libc.TLS, pGroup uintptr, zName uintptr, createFlag int32) uintptr { /* test_quota.c:347:18: */ 71900 var pFile uintptr = (*quotaGroup)(unsafe.Pointer(pGroup)).FpFiles 71901 for (pFile != 0) && (libc.Xstrcmp(tls, (*quotaFile)(unsafe.Pointer(pFile)).FzFilename, zName) != 0) { 71902 pFile = (*quotaFile)(unsafe.Pointer(pFile)).FpNext 71903 } 71904 if (pFile == uintptr(0)) && (createFlag != 0) { 71905 var nName int32 = (int32(libc.Xstrlen(tls, zName) & uint64(0x3fffffff))) 71906 pFile = sqlite3.Xsqlite3_malloc(tls, (int32((uint64(unsafe.Sizeof(quotaFile{})) + uint64(nName)) + uint64(1)))) 71907 if pFile != 0 { 71908 libc.Xmemset(tls, pFile, 0, uint64(unsafe.Sizeof(quotaFile{}))) 71909 (*quotaFile)(unsafe.Pointer(pFile)).FzFilename = (pFile + 1*48) 71910 libc.Xmemcpy(tls, (*quotaFile)(unsafe.Pointer(pFile)).FzFilename, zName, (uint64(nName + 1))) 71911 (*quotaFile)(unsafe.Pointer(pFile)).FpNext = (*quotaGroup)(unsafe.Pointer(pGroup)).FpFiles 71912 if (*quotaGroup)(unsafe.Pointer(pGroup)).FpFiles != 0 { 71913 (*quotaFile)(unsafe.Pointer((*quotaGroup)(unsafe.Pointer(pGroup)).FpFiles)).FppPrev = (pFile + 32 /* &.pNext */) 71914 } 71915 (*quotaFile)(unsafe.Pointer(pFile)).FppPrev = (pGroup + 64 /* &.pFiles */) 71916 (*quotaGroup)(unsafe.Pointer(pGroup)).FpFiles = pFile 71917 (*quotaFile)(unsafe.Pointer(pFile)).FpGroup = pGroup 71918 } 71919 } 71920 return pFile 71921 } 71922 71923 // Translate UTF8 to MBCS for use in fopen() calls. Return a pointer to the 71924 // translated text.. Call quota_mbcs_free() to deallocate any memory 71925 // used to store the returned pointer when done. 71926 func quota_utf8_to_mbcs(tls *libc.TLS, zUtf8 uintptr) uintptr { /* test_quota.c:377:13: */ 71927 return zUtf8 // No-op on unix 71928 } 71929 71930 // Deallocate any memory allocated by quota_utf8_to_mbcs(). 71931 func quota_mbcs_free(tls *libc.TLS, zOld uintptr) { /* test_quota.c:408:13: */ 71932 // No-op on unix 71933 } 71934 71935 //************************ VFS Method Wrappers **************************** 71936 // This is the xOpen method used for the "quota" VFS. 71937 // 71938 // Most of the work is done by the underlying original VFS. This method 71939 // simply links the new file into the appropriate quota group if it is a 71940 // file that needs to be tracked. 71941 func quotaOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pConn uintptr, flags int32, pOutFlags uintptr) int32 { /* test_quota.c:424:12: */ 71942 var rc int32 // Result code 71943 var pQuotaOpen uintptr // The new quota file descriptor 71944 var pFile uintptr // Corresponding quotaFile obj 71945 var pGroup uintptr // The group file belongs to 71946 var pSubOpen uintptr // Real file descriptor 71947 var pOrigVfs uintptr = gQuota.FpOrigVfs // Real VFS 71948 71949 // If the file is not a main database file or a WAL, then use the 71950 // normal xOpen method. 71951 if (flags & (SQLITE_OPEN_MAIN_DB | SQLITE_OPEN_WAL)) == 0 { 71952 return (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pOrigVfs + 40 /* &.xOpen */))))(tls, pOrigVfs, zName, pConn, flags, pOutFlags) 71953 } 71954 71955 // If the name of the file does not match any quota group, then 71956 // use the normal xOpen method. 71957 quotaEnter(tls) 71958 pGroup = quotaGroupFind(tls, zName) 71959 if pGroup == uintptr(0) { 71960 rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pOrigVfs + 40 /* &.xOpen */))))(tls, pOrigVfs, zName, pConn, flags, pOutFlags) 71961 } else { 71962 // If we get to this point, it means the file needs to be quota tracked. 71963 pQuotaOpen = pConn 71964 pSubOpen = quotaSubOpen(tls, pConn) 71965 rc = (*(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((pOrigVfs + 40 /* &.xOpen */))))(tls, pOrigVfs, zName, pSubOpen, flags, pOutFlags) 71966 if rc == SQLITE_OK { 71967 pFile = quotaFindFile(tls, pGroup, zName, 1) 71968 if pFile == uintptr(0) { 71969 quotaLeave(tls) 71970 (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 8 /* &.xClose */))))(tls, pSubOpen) 71971 return SQLITE_NOMEM 71972 } 71973 (*quotaFile)(unsafe.Pointer(pFile)).FdeleteOnClose = (libc.Bool32((flags & SQLITE_OPEN_DELETEONCLOSE) != 0)) 71974 (*quotaFile)(unsafe.Pointer(pFile)).FnRef++ 71975 (*quotaConn)(unsafe.Pointer(pQuotaOpen)).FpFile = pFile 71976 if (*sqlite3_io_methods1)(unsafe.Pointer((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods)).FiVersion == 1 { 71977 (*quotaConn)(unsafe.Pointer(pQuotaOpen)).Fbase.FpMethods = (uintptr(unsafe.Pointer(&gQuota)) + 176 /* &.sIoMethodsV1 */) 71978 } else { 71979 (*quotaConn)(unsafe.Pointer(pQuotaOpen)).Fbase.FpMethods = (uintptr(unsafe.Pointer(&gQuota)) + 328 /* &.sIoMethodsV2 */) 71980 } 71981 } 71982 } 71983 quotaLeave(tls) 71984 return rc 71985 } 71986 71987 // This is the xDelete method used for the "quota" VFS. 71988 // 71989 // If the file being deleted is part of the quota group, then reduce 71990 // the size of the quota group accordingly. And remove the file from 71991 // the set of files in the quota group. 71992 func quotaDelete(tls *libc.TLS, pVfs uintptr, zName uintptr, syncDir int32) int32 { /* test_quota.c:486:12: */ 71993 var rc int32 // Result code 71994 var pFile uintptr // Files in the quota 71995 var pGroup uintptr // The group file belongs to 71996 var pOrigVfs uintptr = gQuota.FpOrigVfs // Real VFS 71997 71998 // Do the actual file delete 71999 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer((pOrigVfs + 48 /* &.xDelete */))))(tls, pOrigVfs, zName, syncDir) 72000 72001 // If the file just deleted is a member of a quota group, then remove 72002 // it from that quota group. 72003 if rc == SQLITE_OK { 72004 quotaEnter(tls) 72005 pGroup = quotaGroupFind(tls, zName) 72006 if pGroup != 0 { 72007 pFile = quotaFindFile(tls, pGroup, zName, 0) 72008 if pFile != 0 { 72009 if (*quotaFile)(unsafe.Pointer(pFile)).FnRef != 0 { 72010 (*quotaFile)(unsafe.Pointer(pFile)).FdeleteOnClose = 1 72011 } else { 72012 quotaRemoveFile(tls, pFile) 72013 quotaGroupDeref(tls, pGroup) 72014 } 72015 } 72016 } 72017 quotaLeave(tls) 72018 } 72019 return rc 72020 } 72021 72022 //*********************** I/O Method Wrappers ****************************** 72023 72024 // xClose requests get passed through to the original VFS. But we 72025 // also have to unlink the quotaConn from the quotaFile and quotaGroup. 72026 // The quotaFile and/or quotaGroup are freed if they are no longer in use. 72027 func quotaClose(tls *libc.TLS, pConn uintptr) int32 { /* test_quota.c:528:12: */ 72028 var p uintptr = pConn 72029 var pFile uintptr = (*quotaConn)(unsafe.Pointer(p)).FpFile 72030 var pSubOpen uintptr = quotaSubOpen(tls, pConn) 72031 var rc int32 72032 rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 8 /* &.xClose */))))(tls, pSubOpen) 72033 quotaEnter(tls) 72034 (*quotaFile)(unsafe.Pointer(pFile)).FnRef-- 72035 if (*quotaFile)(unsafe.Pointer(pFile)).FnRef == 0 { 72036 var pGroup uintptr = (*quotaFile)(unsafe.Pointer(pFile)).FpGroup 72037 if (*quotaFile)(unsafe.Pointer(pFile)).FdeleteOnClose != 0 { 72038 (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer((gQuota.FpOrigVfs + 48 /* &.xDelete */))))(tls, gQuota.FpOrigVfs, (*quotaFile)(unsafe.Pointer(pFile)).FzFilename, 0) 72039 quotaRemoveFile(tls, pFile) 72040 } 72041 quotaGroupDeref(tls, pGroup) 72042 } 72043 quotaLeave(tls) 72044 return rc 72045 } 72046 72047 // Pass xRead requests directory thru to the original VFS without 72048 // further processing. 72049 func quotaRead(tls *libc.TLS, pConn uintptr, pBuf uintptr, iAmt int32, iOfst sqlite3_int64) int32 { /* test_quota.c:551:12: */ 72050 var pSubOpen uintptr = quotaSubOpen(tls, pConn) 72051 return (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 16 /* &.xRead */))))(tls, pSubOpen, pBuf, iAmt, iOfst) 72052 } 72053 72054 // Check xWrite requests to see if they expand the file. If they do, 72055 // the perform a quota check before passing them through to the 72056 // original VFS. 72057 func quotaWrite(tls *libc.TLS, pConn uintptr, pBuf uintptr, iAmt int32, iOfst sqlite3_int64) int32 { /* test_quota.c:565:12: */ 72058 var p uintptr = pConn 72059 var pSubOpen uintptr = quotaSubOpen(tls, pConn) 72060 var iEnd sqlite3_int64 = (iOfst + sqlite3_int64(iAmt)) 72061 var pGroup uintptr 72062 var pFile uintptr = (*quotaConn)(unsafe.Pointer(p)).FpFile 72063 var szNew sqlite3_int64 72064 72065 if (*quotaFile)(unsafe.Pointer(pFile)).FiSize < iEnd { 72066 pGroup = (*quotaFile)(unsafe.Pointer(pFile)).FpGroup 72067 quotaEnter(tls) 72068 szNew = (((*quotaGroup)(unsafe.Pointer(pGroup)).FiSize - (*quotaFile)(unsafe.Pointer(pFile)).FiSize) + iEnd) 72069 if (szNew > (*quotaGroup)(unsafe.Pointer(pGroup)).FiLimit) && ((*quotaGroup)(unsafe.Pointer(pGroup)).FiLimit > int64(0)) { 72070 if (*quotaGroup)(unsafe.Pointer(pGroup)).FxCallback != 0 { 72071 (*(*func(*libc.TLS, uintptr, uintptr, sqlite3_int64, uintptr))(unsafe.Pointer((pGroup + 24 /* &.xCallback */))))(tls, (*quotaFile)(unsafe.Pointer(pFile)).FzFilename, (pGroup + 8 /* &.iLimit */), szNew, 72072 (*quotaGroup)(unsafe.Pointer(pGroup)).FpArg) 72073 } 72074 if (szNew > (*quotaGroup)(unsafe.Pointer(pGroup)).FiLimit) && ((*quotaGroup)(unsafe.Pointer(pGroup)).FiLimit > int64(0)) { 72075 quotaLeave(tls) 72076 return SQLITE_FULL 72077 } 72078 } 72079 (*quotaGroup)(unsafe.Pointer(pGroup)).FiSize = szNew 72080 (*quotaFile)(unsafe.Pointer(pFile)).FiSize = iEnd 72081 quotaLeave(tls) 72082 } 72083 return (*(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 24 /* &.xWrite */))))(tls, pSubOpen, pBuf, iAmt, iOfst) 72084 } 72085 72086 // Pass xTruncate requests thru to the original VFS. If the 72087 // success, update the file size. 72088 func quotaTruncate(tls *libc.TLS, pConn uintptr, size sqlite3_int64) int32 { /* test_quota.c:602:12: */ 72089 var p uintptr = pConn 72090 var pSubOpen uintptr = quotaSubOpen(tls, pConn) 72091 var rc int32 = (*(*func(*libc.TLS, uintptr, sqlite3_int64) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 32 /* &.xTruncate */))))(tls, pSubOpen, size) 72092 var pFile uintptr = (*quotaConn)(unsafe.Pointer(p)).FpFile 72093 var pGroup uintptr 72094 if rc == SQLITE_OK { 72095 quotaEnter(tls) 72096 pGroup = (*quotaFile)(unsafe.Pointer(pFile)).FpGroup 72097 *(*sqlite3_int64)(unsafe.Pointer(pGroup + 16 /* &.iSize */)) -= ((*quotaFile)(unsafe.Pointer(pFile)).FiSize) 72098 (*quotaFile)(unsafe.Pointer(pFile)).FiSize = size 72099 *(*sqlite3_int64)(unsafe.Pointer(pGroup + 16 /* &.iSize */)) += (size) 72100 quotaLeave(tls) 72101 } 72102 return rc 72103 } 72104 72105 // Pass xSync requests through to the original VFS without change 72106 func quotaSync(tls *libc.TLS, pConn uintptr, flags int32) int32 { /* test_quota.c:621:12: */ 72107 var pSubOpen uintptr = quotaSubOpen(tls, pConn) 72108 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 40 /* &.xSync */))))(tls, pSubOpen, flags) 72109 } 72110 72111 // Pass xFileSize requests through to the original VFS but then 72112 // update the quotaGroup with the new size before returning. 72113 func quotaFileSize(tls *libc.TLS, pConn uintptr, pSize uintptr) int32 { /* test_quota.c:629:12: */ 72114 bp := tls.Alloc(8) 72115 defer tls.Free(8) 72116 72117 var p uintptr = pConn 72118 var pSubOpen uintptr = quotaSubOpen(tls, pConn) 72119 var pFile uintptr = (*quotaConn)(unsafe.Pointer(p)).FpFile 72120 var pGroup uintptr 72121 // var sz sqlite3_int64 at bp, 8 72122 72123 var rc int32 72124 72125 rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 48 /* &.xFileSize */))))(tls, pSubOpen, bp /* &sz */) 72126 if rc == SQLITE_OK { 72127 quotaEnter(tls) 72128 pGroup = (*quotaFile)(unsafe.Pointer(pFile)).FpGroup 72129 *(*sqlite3_int64)(unsafe.Pointer(pGroup + 16 /* &.iSize */)) -= ((*quotaFile)(unsafe.Pointer(pFile)).FiSize) 72130 (*quotaFile)(unsafe.Pointer(pFile)).FiSize = *(*sqlite3_int64)(unsafe.Pointer(bp /* sz */)) 72131 *(*sqlite3_int64)(unsafe.Pointer(pGroup + 16 /* &.iSize */)) += (*(*sqlite3_int64)(unsafe.Pointer(bp /* sz */))) 72132 quotaLeave(tls) 72133 *(*sqlite3_int64)(unsafe.Pointer(pSize)) = *(*sqlite3_int64)(unsafe.Pointer(bp /* sz */)) 72134 } 72135 return rc 72136 } 72137 72138 // Pass xLock requests through to the original VFS unchanged. 72139 func quotaLock(tls *libc.TLS, pConn uintptr, lock int32) int32 { /* test_quota.c:652:12: */ 72140 var pSubOpen uintptr = quotaSubOpen(tls, pConn) 72141 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 56 /* &.xLock */))))(tls, pSubOpen, lock) 72142 } 72143 72144 // Pass xUnlock requests through to the original VFS unchanged. 72145 func quotaUnlock(tls *libc.TLS, pConn uintptr, lock int32) int32 { /* test_quota.c:659:12: */ 72146 var pSubOpen uintptr = quotaSubOpen(tls, pConn) 72147 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 64 /* &.xUnlock */))))(tls, pSubOpen, lock) 72148 } 72149 72150 // Pass xCheckReservedLock requests through to the original VFS unchanged. 72151 func quotaCheckReservedLock(tls *libc.TLS, pConn uintptr, pResOut uintptr) int32 { /* test_quota.c:666:12: */ 72152 var pSubOpen uintptr = quotaSubOpen(tls, pConn) 72153 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 72 /* &.xCheckReservedLock */))))(tls, pSubOpen, pResOut) 72154 } 72155 72156 // Pass xFileControl requests through to the original VFS unchanged. 72157 func quotaFileControl(tls *libc.TLS, pConn uintptr, op int32, pArg uintptr) int32 { /* test_quota.c:673:12: */ 72158 bp := tls.Alloc(8) 72159 defer tls.Free(8) 72160 72161 var pSubOpen uintptr = quotaSubOpen(tls, pConn) 72162 var rc int32 = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 80 /* &.xFileControl */))))(tls, pSubOpen, op, pArg) 72163 if (op == SQLITE_FCNTL_VFSNAME) && (rc == SQLITE_OK) { 72164 *(*uintptr)(unsafe.Pointer(pArg)) = sqlite3.Xsqlite3_mprintf(tls, ts+35187 /* "quota/%z" */, libc.VaList(bp, *(*uintptr)(unsafe.Pointer(pArg)))) 72165 } 72166 return rc 72167 } 72168 72169 // Pass xSectorSize requests through to the original VFS unchanged. 72170 func quotaSectorSize(tls *libc.TLS, pConn uintptr) int32 { /* test_quota.c:686:12: */ 72171 var pSubOpen uintptr = quotaSubOpen(tls, pConn) 72172 return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 88 /* &.xSectorSize */))))(tls, pSubOpen) 72173 } 72174 72175 // Pass xDeviceCharacteristics requests through to the original VFS unchanged. 72176 func quotaDeviceCharacteristics(tls *libc.TLS, pConn uintptr) int32 { /* test_quota.c:693:12: */ 72177 var pSubOpen uintptr = quotaSubOpen(tls, pConn) 72178 return (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 96 /* &.xDeviceCharacteristics */))))(tls, pSubOpen) 72179 } 72180 72181 // Pass xShmMap requests through to the original VFS unchanged. 72182 func quotaShmMap(tls *libc.TLS, pConn uintptr, iRegion int32, szRegion int32, bExtend int32, pp uintptr) int32 { /* test_quota.c:700:12: */ 72183 var pSubOpen uintptr = quotaSubOpen(tls, pConn) 72184 return (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 104 /* &.xShmMap */))))(tls, pSubOpen, iRegion, szRegion, bExtend, libc.AtomicLoadUintptr(&pp)) 72185 } 72186 72187 // Pass xShmLock requests through to the original VFS unchanged. 72188 func quotaShmLock(tls *libc.TLS, pConn uintptr, ofst int32, n int32, flags int32) int32 { /* test_quota.c:713:12: */ 72189 var pSubOpen uintptr = quotaSubOpen(tls, pConn) 72190 return (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 112 /* &.xShmLock */))))(tls, pSubOpen, ofst, n, flags) 72191 } 72192 72193 // Pass xShmBarrier requests through to the original VFS unchanged. 72194 func quotaShmBarrier(tls *libc.TLS, pConn uintptr) { /* test_quota.c:725:13: */ 72195 var pSubOpen uintptr = quotaSubOpen(tls, pConn) 72196 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 120 /* &.xShmBarrier */))))(tls, pSubOpen) 72197 } 72198 72199 // Pass xShmUnmap requests through to the original VFS unchanged. 72200 func quotaShmUnmap(tls *libc.TLS, pConn uintptr, deleteFlag int32) int32 { /* test_quota.c:732:12: */ 72201 var pSubOpen uintptr = quotaSubOpen(tls, pConn) 72202 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pSubOpen)).FpMethods + 128 /* &.xShmUnmap */))))(tls, pSubOpen, deleteFlag) 72203 } 72204 72205 //************************* Public Interfaces **************************** 72206 // Initialize the quota VFS shim. Use the VFS named zOrigVfsName 72207 // as the VFS that does the actual work. Use the default if 72208 // zOrigVfsName==NULL. 72209 // 72210 // The quota VFS shim is named "quota". It will become the default 72211 // VFS if makeDefault is non-zero. 72212 // 72213 // THIS ROUTINE IS NOT THREADSAFE. Call this routine exactly once 72214 // during start-up. 72215 func sqlite3_quota_initialize(tls *libc.TLS, zOrigVfsName uintptr, makeDefault int32) int32 { /* test_quota.c:749:5: */ 72216 var pOrigVfs uintptr 72217 if gQuota.FisInitialized != 0 { 72218 return SQLITE_MISUSE 72219 } 72220 pOrigVfs = sqlite3.Xsqlite3_vfs_find(tls, zOrigVfsName) 72221 if pOrigVfs == uintptr(0) { 72222 return SQLITE_ERROR 72223 } 72224 72225 gQuota.FpMutex = sqlite3.Xsqlite3_mutex_alloc(tls, SQLITE_MUTEX_FAST) 72226 if !(int32(gQuota.FpMutex) != 0) { 72227 return SQLITE_NOMEM 72228 } 72229 gQuota.FisInitialized = 1 72230 gQuota.FpOrigVfs = pOrigVfs 72231 gQuota.FsThisVfs = *(*sqlite3_vfs)(unsafe.Pointer(pOrigVfs)) 72232 gQuota.FsThisVfs.FxOpen = *(*uintptr)(unsafe.Pointer(&struct { 72233 f func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32 72234 }{quotaOpen})) 72235 gQuota.FsThisVfs.FxDelete = *(*uintptr)(unsafe.Pointer(&struct { 72236 f func(*libc.TLS, uintptr, uintptr, int32) int32 72237 }{quotaDelete})) 72238 *(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&gQuota)) + 8 /* &.sThisVfs */ + 4 /* &.szOsFile */)) += int32((uint64(unsafe.Sizeof(quotaConn{})))) 72239 gQuota.FsThisVfs.FzName = ts + 35196 /* "quota" */ 72240 gQuota.FsIoMethodsV1.FiVersion = 1 72241 gQuota.FsIoMethodsV1.FxClose = *(*uintptr)(unsafe.Pointer(&struct { 72242 f func(*libc.TLS, uintptr) int32 72243 }{quotaClose})) 72244 gQuota.FsIoMethodsV1.FxRead = *(*uintptr)(unsafe.Pointer(&struct { 72245 f func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32 72246 }{quotaRead})) 72247 gQuota.FsIoMethodsV1.FxWrite = *(*uintptr)(unsafe.Pointer(&struct { 72248 f func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32 72249 }{quotaWrite})) 72250 gQuota.FsIoMethodsV1.FxTruncate = *(*uintptr)(unsafe.Pointer(&struct { 72251 f func(*libc.TLS, uintptr, sqlite3_int64) int32 72252 }{quotaTruncate})) 72253 gQuota.FsIoMethodsV1.FxSync = *(*uintptr)(unsafe.Pointer(&struct { 72254 f func(*libc.TLS, uintptr, int32) int32 72255 }{quotaSync})) 72256 gQuota.FsIoMethodsV1.FxFileSize = *(*uintptr)(unsafe.Pointer(&struct { 72257 f func(*libc.TLS, uintptr, uintptr) int32 72258 }{quotaFileSize})) 72259 gQuota.FsIoMethodsV1.FxLock = *(*uintptr)(unsafe.Pointer(&struct { 72260 f func(*libc.TLS, uintptr, int32) int32 72261 }{quotaLock})) 72262 gQuota.FsIoMethodsV1.FxUnlock = *(*uintptr)(unsafe.Pointer(&struct { 72263 f func(*libc.TLS, uintptr, int32) int32 72264 }{quotaUnlock})) 72265 gQuota.FsIoMethodsV1.FxCheckReservedLock = *(*uintptr)(unsafe.Pointer(&struct { 72266 f func(*libc.TLS, uintptr, uintptr) int32 72267 }{quotaCheckReservedLock})) 72268 gQuota.FsIoMethodsV1.FxFileControl = *(*uintptr)(unsafe.Pointer(&struct { 72269 f func(*libc.TLS, uintptr, int32, uintptr) int32 72270 }{quotaFileControl})) 72271 gQuota.FsIoMethodsV1.FxSectorSize = *(*uintptr)(unsafe.Pointer(&struct { 72272 f func(*libc.TLS, uintptr) int32 72273 }{quotaSectorSize})) 72274 gQuota.FsIoMethodsV1.FxDeviceCharacteristics = *(*uintptr)(unsafe.Pointer(&struct { 72275 f func(*libc.TLS, uintptr) int32 72276 }{quotaDeviceCharacteristics})) 72277 gQuota.FsIoMethodsV2 = gQuota.FsIoMethodsV1 72278 gQuota.FsIoMethodsV2.FiVersion = 2 72279 gQuota.FsIoMethodsV2.FxShmMap = *(*uintptr)(unsafe.Pointer(&struct { 72280 f func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32 72281 }{quotaShmMap})) 72282 gQuota.FsIoMethodsV2.FxShmLock = *(*uintptr)(unsafe.Pointer(&struct { 72283 f func(*libc.TLS, uintptr, int32, int32, int32) int32 72284 }{quotaShmLock})) 72285 gQuota.FsIoMethodsV2.FxShmBarrier = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{quotaShmBarrier})) 72286 gQuota.FsIoMethodsV2.FxShmUnmap = *(*uintptr)(unsafe.Pointer(&struct { 72287 f func(*libc.TLS, uintptr, int32) int32 72288 }{quotaShmUnmap})) 72289 sqlite3.Xsqlite3_vfs_register(tls, (uintptr(unsafe.Pointer(&gQuota)) + 8 /* &.sThisVfs */), makeDefault) 72290 return SQLITE_OK 72291 } 72292 72293 // Shutdown the quota system. 72294 // 72295 // All SQLite database connections must be closed before calling this 72296 // routine. 72297 // 72298 // THIS ROUTINE IS NOT THREADSAFE. Call this routine exactly once while 72299 // shutting down in order to free all remaining quota groups. 72300 func sqlite3_quota_shutdown(tls *libc.TLS) int32 { /* test_quota.c:798:5: */ 72301 var pGroup uintptr 72302 if gQuota.FisInitialized == 0 { 72303 return SQLITE_MISUSE 72304 } 72305 for pGroup = gQuota.FpGroup; pGroup != 0; pGroup = (*quotaGroup)(unsafe.Pointer(pGroup)).FpNext { 72306 if quotaGroupOpenFileCount(tls, pGroup) > 0 { 72307 return SQLITE_MISUSE 72308 } 72309 } 72310 for gQuota.FpGroup != 0 { 72311 pGroup = gQuota.FpGroup 72312 gQuota.FpGroup = (*quotaGroup)(unsafe.Pointer(pGroup)).FpNext 72313 (*quotaGroup)(unsafe.Pointer(pGroup)).FiLimit = int64(0) 72314 72315 quotaGroupDeref(tls, pGroup) 72316 } 72317 gQuota.FisInitialized = 0 72318 sqlite3.Xsqlite3_mutex_free(tls, gQuota.FpMutex) 72319 sqlite3.Xsqlite3_vfs_unregister(tls, (uintptr(unsafe.Pointer(&gQuota)) + 8 /* &.sThisVfs */)) 72320 libc.Xmemset(tls, uintptr(unsafe.Pointer(&gQuota)), 0, uint64(unsafe.Sizeof(gQuota))) 72321 return SQLITE_OK 72322 } 72323 72324 // Create or destroy a quota group. 72325 // 72326 // The quota group is defined by the zPattern. When calling this routine 72327 // with a zPattern for a quota group that already exists, this routine 72328 // merely updates the iLimit, xCallback, and pArg values for that quota 72329 // group. If zPattern is new, then a new quota group is created. 72330 // 72331 // If the iLimit for a quota group is set to zero, then the quota group 72332 // is disabled and will be deleted when the last database connection using 72333 // the quota group is closed. 72334 // 72335 // Calling this routine on a zPattern that does not exist and with a 72336 // zero iLimit is a no-op. 72337 // 72338 // A quota group must exist with a non-zero iLimit prior to opening 72339 // database connections if those connections are to participate in the 72340 // quota group. Creating a quota group does not affect database connections 72341 // that are already open. 72342 func sqlite3_quota_set(tls *libc.TLS, zPattern uintptr, iLimit sqlite3_int64, xCallback uintptr, pArg uintptr, xDestroy uintptr) int32 { /* test_quota.c:838:5: */ 72343 var pGroup uintptr 72344 quotaEnter(tls) 72345 pGroup = gQuota.FpGroup 72346 for (pGroup != 0) && (libc.Xstrcmp(tls, (*quotaGroup)(unsafe.Pointer(pGroup)).FzPattern, zPattern) != 0) { 72347 pGroup = (*quotaGroup)(unsafe.Pointer(pGroup)).FpNext 72348 } 72349 if pGroup == uintptr(0) { 72350 var nPattern int32 = (int32(libc.Xstrlen(tls, zPattern) & uint64(0x3fffffff))) 72351 if iLimit <= int64(0) { 72352 quotaLeave(tls) 72353 return SQLITE_OK 72354 } 72355 pGroup = sqlite3.Xsqlite3_malloc(tls, (int32((uint64(unsafe.Sizeof(quotaGroup{})) + uint64(nPattern)) + uint64(1)))) 72356 if pGroup == uintptr(0) { 72357 quotaLeave(tls) 72358 return SQLITE_NOMEM 72359 } 72360 libc.Xmemset(tls, pGroup, 0, uint64(unsafe.Sizeof(quotaGroup{}))) 72361 (*quotaGroup)(unsafe.Pointer(pGroup)).FzPattern = (pGroup + 1*72) 72362 libc.Xmemcpy(tls, (*quotaGroup)(unsafe.Pointer(pGroup)).FzPattern, zPattern, (uint64(nPattern + 1))) 72363 if gQuota.FpGroup != 0 { 72364 (*quotaGroup)(unsafe.Pointer(gQuota.FpGroup)).FppPrev = (pGroup + 48 /* &.pNext */) 72365 } 72366 (*quotaGroup)(unsafe.Pointer(pGroup)).FpNext = gQuota.FpGroup 72367 (*quotaGroup)(unsafe.Pointer(pGroup)).FppPrev = (uintptr(unsafe.Pointer(&gQuota)) + 496 /* &.pGroup */) 72368 gQuota.FpGroup = pGroup 72369 } 72370 (*quotaGroup)(unsafe.Pointer(pGroup)).FiLimit = iLimit 72371 (*quotaGroup)(unsafe.Pointer(pGroup)).FxCallback = xCallback 72372 if ((*quotaGroup)(unsafe.Pointer(pGroup)).FxDestroy != 0) && ((*quotaGroup)(unsafe.Pointer(pGroup)).FpArg != pArg) { 72373 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer((pGroup + 40 /* &.xDestroy */))))(tls, (*quotaGroup)(unsafe.Pointer(pGroup)).FpArg) 72374 } 72375 (*quotaGroup)(unsafe.Pointer(pGroup)).FpArg = pArg 72376 (*quotaGroup)(unsafe.Pointer(pGroup)).FxDestroy = xDestroy 72377 quotaGroupDeref(tls, pGroup) 72378 quotaLeave(tls) 72379 return SQLITE_OK 72380 } 72381 72382 // Bring the named file under quota management. Or if it is already under 72383 // management, update its size. 72384 func sqlite3_quota_file(tls *libc.TLS, zFilename uintptr) int32 { /* test_quota.c:891:5: */ 72385 bp := tls.Alloc(16) 72386 defer tls.Free(16) 72387 72388 var zFull uintptr = uintptr(0) 72389 var fd uintptr 72390 var rc int32 72391 *(*int32)(unsafe.Pointer(bp /* outFlags */)) = 0 72392 // var iSize sqlite3_int64 at bp+8, 8 72393 72394 var nAlloc int32 = ((gQuota.FsThisVfs.FszOsFile + gQuota.FsThisVfs.FmxPathname) + 2) 72395 72396 // Allocate space for a file-handle and the full path for file zFilename 72397 fd = sqlite3.Xsqlite3_malloc(tls, nAlloc) 72398 if fd == uintptr(0) { 72399 rc = SQLITE_NOMEM 72400 } else { 72401 zFull = ((fd) + uintptr(gQuota.FsThisVfs.FszOsFile)) 72402 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((gQuota.FpOrigVfs + 64 /* &.xFullPathname */))))(tls, gQuota.FpOrigVfs, zFilename, 72403 (gQuota.FsThisVfs.FmxPathname + 1), zFull) 72404 } 72405 72406 if rc == SQLITE_OK { 72407 *(*int8)(unsafe.Pointer(zFull + uintptr((libc.Xstrlen(tls, zFull) + uint64(1))))) = int8(0) 72408 rc = quotaOpen(tls, (uintptr(unsafe.Pointer(&gQuota)) + 8 /* &.sThisVfs */), zFull, fd, 72409 (SQLITE_OPEN_READONLY | SQLITE_OPEN_MAIN_DB), bp /* &outFlags */) 72410 if rc == SQLITE_OK { 72411 (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(fd)).FpMethods + 48 /* &.xFileSize */))))(tls, fd, bp+8 /* &iSize */) 72412 (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(fd)).FpMethods + 8 /* &.xClose */))))(tls, fd) 72413 } else if rc == SQLITE_CANTOPEN { 72414 var pGroup uintptr 72415 var pFile uintptr 72416 quotaEnter(tls) 72417 pGroup = quotaGroupFind(tls, zFull) 72418 if pGroup != 0 { 72419 pFile = quotaFindFile(tls, pGroup, zFull, 0) 72420 if pFile != 0 { 72421 quotaRemoveFile(tls, pFile) 72422 } 72423 } 72424 quotaLeave(tls) 72425 } 72426 } 72427 72428 sqlite3.Xsqlite3_free(tls, fd) 72429 return rc 72430 } 72431 72432 // Open a potentially quotaed file for I/O. 72433 func sqlite3_quota_fopen(tls *libc.TLS, zFilename uintptr, zMode uintptr) uintptr { /* test_quota.c:936:12: */ 72434 var p uintptr 72435 var zFull uintptr 72436 var zFullTranslated uintptr 72437 var rc int32 72438 var pGroup uintptr 72439 var pFile uintptr 72440 p = uintptr(0) 72441 zFull = uintptr(0) 72442 zFullTranslated = uintptr(0) 72443 72444 zFull = sqlite3.Xsqlite3_malloc(tls, (gQuota.FsThisVfs.FmxPathname + 1)) 72445 if !(zFull == uintptr(0)) { 72446 goto __1 72447 } 72448 return uintptr(0) 72449 __1: 72450 ; 72451 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((gQuota.FpOrigVfs + 64 /* &.xFullPathname */))))(tls, gQuota.FpOrigVfs, zFilename, 72452 (gQuota.FsThisVfs.FmxPathname + 1), zFull) 72453 if !(rc != 0) { 72454 goto __2 72455 } 72456 goto quota_fopen_error 72457 __2: 72458 ; 72459 p = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(quota_FILE{}))) 72460 if !(p == uintptr(0)) { 72461 goto __3 72462 } 72463 goto quota_fopen_error 72464 __3: 72465 ; 72466 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(quota_FILE{}))) 72467 zFullTranslated = quota_utf8_to_mbcs(tls, zFull) 72468 if !(zFullTranslated == uintptr(0)) { 72469 goto __4 72470 } 72471 goto quota_fopen_error 72472 __4: 72473 ; 72474 (*quota_FILE)(unsafe.Pointer(p)).Ff = libc.Xfopen(tls, zFullTranslated, zMode) 72475 if !((*quota_FILE)(unsafe.Pointer(p)).Ff == uintptr(0)) { 72476 goto __5 72477 } 72478 goto quota_fopen_error 72479 __5: 72480 ; 72481 quotaEnter(tls) 72482 pGroup = quotaGroupFind(tls, zFull) 72483 if !(pGroup != 0) { 72484 goto __6 72485 } 72486 pFile = quotaFindFile(tls, pGroup, zFull, 1) 72487 if !(pFile == uintptr(0)) { 72488 goto __7 72489 } 72490 quotaLeave(tls) 72491 goto quota_fopen_error 72492 __7: 72493 ; 72494 (*quotaFile)(unsafe.Pointer(pFile)).FnRef++ 72495 (*quota_FILE)(unsafe.Pointer(p)).FpFile = pFile 72496 __6: 72497 ; 72498 quotaLeave(tls) 72499 sqlite3.Xsqlite3_free(tls, zFull) 72500 return p 72501 72502 quota_fopen_error: 72503 quota_mbcs_free(tls, zFullTranslated) 72504 sqlite3.Xsqlite3_free(tls, zFull) 72505 if !((p != 0) && ((*quota_FILE)(unsafe.Pointer(p)).Ff != 0)) { 72506 goto __8 72507 } 72508 libc.Xfclose(tls, (*quota_FILE)(unsafe.Pointer(p)).Ff) 72509 __8: 72510 ; 72511 sqlite3.Xsqlite3_free(tls, p) 72512 return uintptr(0) 72513 } 72514 72515 // Read content from a quota_FILE 72516 func sqlite3_quota_fread(tls *libc.TLS, pBuf uintptr, size size_t, nmemb size_t, p uintptr) size_t { /* test_quota.c:985:8: */ 72517 return libc.Xfread(tls, pBuf, size, nmemb, (*quota_FILE)(unsafe.Pointer(p)).Ff) 72518 } 72519 72520 // Write content into a quota_FILE. Invoke the quota callback and block 72521 // the write if we exceed quota. 72522 func sqlite3_quota_fwrite(tls *libc.TLS, pBuf uintptr, size size_t, nmemb size_t, p uintptr) size_t { /* test_quota.c:998:8: */ 72523 var iOfst sqlite3_int64 72524 var iEnd sqlite3_int64 72525 var szNew sqlite3_int64 72526 var pFile uintptr 72527 var rc size_t 72528 72529 iOfst = sqlite3_int64(libc.Xftell(tls, (*quota_FILE)(unsafe.Pointer(p)).Ff)) 72530 iEnd = (sqlite3_int64(uint64(iOfst) + (uint64(size * nmemb)))) 72531 pFile = (*quota_FILE)(unsafe.Pointer(p)).FpFile 72532 if (pFile != 0) && ((*quotaFile)(unsafe.Pointer(pFile)).FiSize < iEnd) { 72533 var pGroup uintptr = (*quotaFile)(unsafe.Pointer(pFile)).FpGroup 72534 quotaEnter(tls) 72535 szNew = (((*quotaGroup)(unsafe.Pointer(pGroup)).FiSize - (*quotaFile)(unsafe.Pointer(pFile)).FiSize) + iEnd) 72536 if (szNew > (*quotaGroup)(unsafe.Pointer(pGroup)).FiLimit) && ((*quotaGroup)(unsafe.Pointer(pGroup)).FiLimit > int64(0)) { 72537 if (*quotaGroup)(unsafe.Pointer(pGroup)).FxCallback != 0 { 72538 (*(*func(*libc.TLS, uintptr, uintptr, sqlite3_int64, uintptr))(unsafe.Pointer((pGroup + 24 /* &.xCallback */))))(tls, (*quotaFile)(unsafe.Pointer(pFile)).FzFilename, (pGroup + 8 /* &.iLimit */), szNew, 72539 (*quotaGroup)(unsafe.Pointer(pGroup)).FpArg) 72540 } 72541 if (szNew > (*quotaGroup)(unsafe.Pointer(pGroup)).FiLimit) && ((*quotaGroup)(unsafe.Pointer(pGroup)).FiLimit > int64(0)) { 72542 iEnd = (((*quotaGroup)(unsafe.Pointer(pGroup)).FiLimit - (*quotaGroup)(unsafe.Pointer(pGroup)).FiSize) + (*quotaFile)(unsafe.Pointer(pFile)).FiSize) 72543 nmemb = (size_t((uint64(iEnd - iOfst)) / uint64(size))) 72544 iEnd = (sqlite3_int64(uint64(iOfst) + (uint64(size * nmemb)))) 72545 szNew = (((*quotaGroup)(unsafe.Pointer(pGroup)).FiSize - (*quotaFile)(unsafe.Pointer(pFile)).FiSize) + iEnd) 72546 } 72547 } 72548 (*quotaGroup)(unsafe.Pointer(pGroup)).FiSize = szNew 72549 (*quotaFile)(unsafe.Pointer(pFile)).FiSize = iEnd 72550 quotaLeave(tls) 72551 } else { 72552 pFile = uintptr(0) 72553 } 72554 rc = libc.Xfwrite(tls, pBuf, size, nmemb, (*quota_FILE)(unsafe.Pointer(p)).Ff) 72555 72556 // If the write was incomplete, adjust the file size and group size 72557 // downward 72558 if (rc < nmemb) && (pFile != 0) { 72559 var nWritten size_t = rc 72560 var iNewEnd sqlite3_int64 = (sqlite3_int64(uint64(iOfst) + (uint64(size * nWritten)))) 72561 if iNewEnd < iEnd { 72562 iNewEnd = iEnd 72563 } 72564 quotaEnter(tls) 72565 *(*sqlite3_int64)(unsafe.Pointer((*quotaFile)(unsafe.Pointer(pFile)).FpGroup + 16 /* &.iSize */)) += (iNewEnd - (*quotaFile)(unsafe.Pointer(pFile)).FiSize) 72566 (*quotaFile)(unsafe.Pointer(pFile)).FiSize = iNewEnd 72567 quotaLeave(tls) 72568 } 72569 return rc 72570 } 72571 72572 // Close an open quota_FILE stream. 72573 func sqlite3_quota_fclose(tls *libc.TLS, p uintptr) int32 { /* test_quota.c:1054:5: */ 72574 var rc int32 72575 var pFile uintptr 72576 rc = libc.Xfclose(tls, (*quota_FILE)(unsafe.Pointer(p)).Ff) 72577 pFile = (*quota_FILE)(unsafe.Pointer(p)).FpFile 72578 if pFile != 0 { 72579 quotaEnter(tls) 72580 (*quotaFile)(unsafe.Pointer(pFile)).FnRef-- 72581 if (*quotaFile)(unsafe.Pointer(pFile)).FnRef == 0 { 72582 var pGroup uintptr = (*quotaFile)(unsafe.Pointer(pFile)).FpGroup 72583 if (*quotaFile)(unsafe.Pointer(pFile)).FdeleteOnClose != 0 { 72584 (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer((gQuota.FpOrigVfs + 48 /* &.xDelete */))))(tls, gQuota.FpOrigVfs, (*quotaFile)(unsafe.Pointer(pFile)).FzFilename, 0) 72585 quotaRemoveFile(tls, pFile) 72586 } 72587 quotaGroupDeref(tls, pGroup) 72588 } 72589 quotaLeave(tls) 72590 } 72591 sqlite3.Xsqlite3_free(tls, p) 72592 return rc 72593 } 72594 72595 // Flush memory buffers for a quota_FILE to disk. 72596 func sqlite3_quota_fflush(tls *libc.TLS, p uintptr, doFsync int32) int32 { /* test_quota.c:1082:5: */ 72597 var rc int32 72598 rc = libc.Xfflush(tls, (*quota_FILE)(unsafe.Pointer(p)).Ff) 72599 if (rc == 0) && (doFsync != 0) { 72600 rc = libc.Xfsync(tls, libc.Xfileno(tls, (*quota_FILE)(unsafe.Pointer(p)).Ff)) 72601 } 72602 return (libc.Bool32(rc != 0)) 72603 } 72604 72605 // Seek on a quota_FILE stream. 72606 func sqlite3_quota_fseek(tls *libc.TLS, p uintptr, offset int64, whence int32) int32 { /* test_quota.c:1099:5: */ 72607 return libc.Xfseek(tls, (*quota_FILE)(unsafe.Pointer(p)).Ff, offset, whence) 72608 } 72609 72610 // rewind a quota_FILE stream. 72611 func sqlite3_quota_rewind(tls *libc.TLS, p uintptr) { /* test_quota.c:1106:6: */ 72612 libc.Xrewind(tls, (*quota_FILE)(unsafe.Pointer(p)).Ff) 72613 } 72614 72615 // Tell the current location of a quota_FILE stream. 72616 func sqlite3_quota_ftell(tls *libc.TLS, p uintptr) int64 { /* test_quota.c:1113:6: */ 72617 return libc.Xftell(tls, (*quota_FILE)(unsafe.Pointer(p)).Ff) 72618 } 72619 72620 // Test the error indicator for the given file. 72621 func sqlite3_quota_ferror(tls *libc.TLS, p uintptr) int32 { /* test_quota.c:1120:5: */ 72622 return libc.Xferror(tls, (*quota_FILE)(unsafe.Pointer(p)).Ff) 72623 } 72624 72625 // Truncate a file to szNew bytes. 72626 func sqlite3_quota_ftruncate(tls *libc.TLS, p uintptr, szNew sqlite3_int64) int32 { /* test_quota.c:1127:5: */ 72627 var pFile uintptr = (*quota_FILE)(unsafe.Pointer(p)).FpFile 72628 var rc int32 72629 if ((libc.AssignUintptr(&pFile, (*quota_FILE)(unsafe.Pointer(p)).FpFile)) != uintptr(0)) && ((*quotaFile)(unsafe.Pointer(pFile)).FiSize < szNew) { 72630 var pGroup uintptr 72631 if (*quotaFile)(unsafe.Pointer(pFile)).FiSize < szNew { 72632 // This routine cannot be used to extend a file that is under 72633 // quota management. Only true truncation is allowed. 72634 return -1 72635 } 72636 pGroup = (*quotaFile)(unsafe.Pointer(pFile)).FpGroup 72637 quotaEnter(tls) 72638 *(*sqlite3_int64)(unsafe.Pointer(pGroup + 16 /* &.iSize */)) += (szNew - (*quotaFile)(unsafe.Pointer(pFile)).FiSize) 72639 quotaLeave(tls) 72640 } 72641 rc = libc.Xftruncate(tls, libc.Xfileno(tls, (*quota_FILE)(unsafe.Pointer(p)).Ff), int64(szNew)) 72642 if (pFile != 0) && (rc == 0) { 72643 var pGroup uintptr = (*quotaFile)(unsafe.Pointer(pFile)).FpGroup 72644 quotaEnter(tls) 72645 *(*sqlite3_int64)(unsafe.Pointer(pGroup + 16 /* &.iSize */)) += (szNew - (*quotaFile)(unsafe.Pointer(pFile)).FiSize) 72646 (*quotaFile)(unsafe.Pointer(pFile)).FiSize = szNew 72647 quotaLeave(tls) 72648 } 72649 return rc 72650 } 72651 72652 // Determine the time that the given file was last modified, in 72653 // seconds size 1970. Write the result into *pTime. Return 0 on 72654 // success and non-zero on any kind of error. 72655 func sqlite3_quota_file_mtime(tls *libc.TLS, p uintptr, pTime uintptr) int32 { /* test_quota.c:1169:5: */ 72656 bp := tls.Alloc(144) 72657 defer tls.Free(144) 72658 72659 var rc int32 72660 // var buf stat at bp, 144 72661 72662 rc = libc.Xfstat(tls, libc.Xfileno(tls, (*quota_FILE)(unsafe.Pointer(p)).Ff), bp /* &buf */) 72663 if rc == 0 { 72664 *(*time_t)(unsafe.Pointer(pTime)) = (*stat)(unsafe.Pointer(bp /* &buf */)).Fst_mtim.Ftv_sec 72665 } 72666 return rc 72667 } 72668 72669 // Return the true size of the file, as reported by the operating 72670 // system. 72671 func sqlite3_quota_file_truesize(tls *libc.TLS, p uintptr) sqlite3_int64 { /* test_quota.c:1187:15: */ 72672 bp := tls.Alloc(144) 72673 defer tls.Free(144) 72674 72675 var rc int32 72676 // var buf stat at bp, 144 72677 72678 rc = libc.Xfstat(tls, libc.Xfileno(tls, (*quota_FILE)(unsafe.Pointer(p)).Ff), bp /* &buf */) 72679 if rc == 0 { 72680 return int64((*stat)(unsafe.Pointer(bp /* &buf */)).Fst_size) 72681 } 72682 return int64(-1) 72683 } 72684 72685 // Return the size of the file, as it is known to the quota subsystem. 72686 func sqlite3_quota_file_size(tls *libc.TLS, p uintptr) sqlite3_int64 { /* test_quota.c:1203:15: */ 72687 if (*quota_FILE)(unsafe.Pointer(p)).FpFile != 0 { 72688 return (*quotaFile)(unsafe.Pointer((*quota_FILE)(unsafe.Pointer(p)).FpFile)).FiSize 72689 } 72690 return int64(-1) 72691 } 72692 72693 // Determine the amount of data in bytes available for reading 72694 // in the given file. 72695 func sqlite3_quota_file_available(tls *libc.TLS, p uintptr) int64 { /* test_quota.c:1211:6: */ 72696 var f uintptr = (*quota_FILE)(unsafe.Pointer(p)).Ff 72697 var pos1 int64 72698 var pos2 int64 72699 var rc int32 72700 pos1 = libc.Xftell(tls, f) 72701 if pos1 < int64(0) { 72702 return int64(-1) 72703 } 72704 rc = libc.Xfseek(tls, f, int64(0), SEEK_END) 72705 if rc != 0 { 72706 return int64(-1) 72707 } 72708 pos2 = libc.Xftell(tls, f) 72709 if pos2 < int64(0) { 72710 return int64(-1) 72711 } 72712 rc = libc.Xfseek(tls, f, pos1, SEEK_SET) 72713 if rc != 0 { 72714 return int64(-1) 72715 } 72716 return (pos2 - pos1) 72717 } 72718 72719 // Remove a managed file. Update quotas accordingly. 72720 func sqlite3_quota_remove(tls *libc.TLS, zFilename uintptr) int32 { /* test_quota.c:1229:5: */ 72721 var zFull uintptr // Full pathname for zFilename 72722 var nFull size_t // Number of bytes in zFilename 72723 var rc int32 // Result code 72724 var pGroup uintptr // Group containing zFilename 72725 var pFile uintptr // A file in the group 72726 var pNextFile uintptr // next file in the group 72727 var diff int32 // Difference between filenames 72728 var c int8 // First character past end of pattern 72729 72730 zFull = sqlite3.Xsqlite3_malloc(tls, (gQuota.FsThisVfs.FmxPathname + 1)) 72731 if zFull == uintptr(0) { 72732 return SQLITE_NOMEM 72733 } 72734 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer((gQuota.FpOrigVfs + 64 /* &.xFullPathname */))))(tls, gQuota.FpOrigVfs, zFilename, 72735 (gQuota.FsThisVfs.FmxPathname + 1), zFull) 72736 if rc != 0 { 72737 sqlite3.Xsqlite3_free(tls, zFull) 72738 return rc 72739 } 72740 72741 // Figure out the length of the full pathname. If the name ends with 72742 // / (or \ on windows) then remove the trailing /. 72743 nFull = libc.Xstrlen(tls, zFull) 72744 if (nFull > uint64(0)) && ((int32(*(*int8)(unsafe.Pointer(zFull + uintptr((nFull - uint64(1)))))) == '/') || (int32(*(*int8)(unsafe.Pointer(zFull + uintptr((nFull - uint64(1)))))) == '\\')) { 72745 nFull-- 72746 *(*int8)(unsafe.Pointer(zFull + uintptr(nFull))) = int8(0) 72747 } 72748 72749 quotaEnter(tls) 72750 pGroup = quotaGroupFind(tls, zFull) 72751 if pGroup != 0 { 72752 for pFile = (*quotaGroup)(unsafe.Pointer(pGroup)).FpFiles; (pFile != 0) && (rc == SQLITE_OK); pFile = pNextFile { 72753 pNextFile = (*quotaFile)(unsafe.Pointer(pFile)).FpNext 72754 diff = libc.Xstrncmp(tls, zFull, (*quotaFile)(unsafe.Pointer(pFile)).FzFilename, nFull) 72755 if (diff == 0) && ((((int32(libc.AssignInt8(&c, *(*int8)(unsafe.Pointer((*quotaFile)(unsafe.Pointer(pFile)).FzFilename + uintptr(nFull)))))) == 0) || (int32(c) == '/')) || (int32(c) == '\\')) { 72756 if (*quotaFile)(unsafe.Pointer(pFile)).FnRef != 0 { 72757 (*quotaFile)(unsafe.Pointer(pFile)).FdeleteOnClose = 1 72758 } else { 72759 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer((gQuota.FpOrigVfs + 48 /* &.xDelete */))))(tls, gQuota.FpOrigVfs, (*quotaFile)(unsafe.Pointer(pFile)).FzFilename, 0) 72760 quotaRemoveFile(tls, pFile) 72761 quotaGroupDeref(tls, pGroup) 72762 } 72763 } 72764 } 72765 } 72766 quotaLeave(tls) 72767 sqlite3.Xsqlite3_free(tls, zFull) 72768 return rc 72769 } 72770 72771 // end block for C++ 72772 72773 // Local Variables: 72774 // mode: c 72775 // c-basic-offset: 4 72776 // fill-column: 78 72777 // End: 72778 72779 // Argument passed to a TCL quota-over-limit callback. 72780 type TclQuotaCallback1 = struct { 72781 Finterp uintptr 72782 FpScript uintptr 72783 } /* test_quota.c:1293:9 */ 72784 72785 // end block for C++ 72786 72787 // Local Variables: 72788 // mode: c 72789 // c-basic-offset: 4 72790 // fill-column: 78 72791 // End: 72792 72793 // Argument passed to a TCL quota-over-limit callback. 72794 type TclQuotaCallback = TclQuotaCallback1 /* test_quota.c:1293:33 */ 72795 72796 // This is the callback from a quota-over-limit. 72797 func tclQuotaCallback(tls *libc.TLS, zFilename uintptr, piLimit uintptr, iSize sqlite3_int64, pArg uintptr) { /* test_quota.c:1305:13: */ 72798 bp := tls.Alloc(16) 72799 defer tls.Free(16) 72800 72801 var p uintptr // Callback script object 72802 var pEval uintptr // Script to evaluate 72803 var pVarname uintptr // Name of variable to pass as 2nd arg 72804 // var rnd uint32 at bp, 4 72805 // Random part of pVarname 72806 var rc int32 // Tcl error code 72807 72808 p = pArg 72809 if p == uintptr(0) { 72810 return 72811 } 72812 72813 pVarname = tcl.XTcl_NewStringObj(tls, ts+35202 /* "::piLimit_" */, -1) 72814 (*Tcl_Obj)(unsafe.Pointer(pVarname)).FrefCount++ 72815 sqlite3.Xsqlite3_randomness(tls, int32(unsafe.Sizeof(uint32(0))), bp /* &rnd */) 72816 tcl.XTcl_AppendObjToObj(tls, pVarname, tcl.XTcl_NewIntObj(tls, (int32(*(*uint32)(unsafe.Pointer(bp /* rnd */))&uint32(0x7FFFFFFF))))) 72817 tcl.XTcl_ObjSetVar2(tls, (*TclQuotaCallback)(unsafe.Pointer(p)).Finterp, pVarname, uintptr(0), tcl.XTcl_NewWideIntObj(tls, *(*sqlite3_int64)(unsafe.Pointer(piLimit))), 0) 72818 72819 pEval = tcl.XTcl_DuplicateObj(tls, (*TclQuotaCallback)(unsafe.Pointer(p)).FpScript) 72820 (*Tcl_Obj)(unsafe.Pointer(pEval)).FrefCount++ 72821 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pEval, tcl.XTcl_NewStringObj(tls, zFilename, -1)) 72822 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pEval, pVarname) 72823 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pEval, tcl.XTcl_NewWideIntObj(tls, iSize)) 72824 rc = tcl.XTcl_EvalObjEx(tls, (*TclQuotaCallback)(unsafe.Pointer(p)).Finterp, pEval, TCL_EVAL_GLOBAL) 72825 72826 if rc == TCL_OK { 72827 // var x Tcl_WideInt at bp+8, 8 72828 72829 var pLimit uintptr = tcl.XTcl_ObjGetVar2(tls, (*TclQuotaCallback)(unsafe.Pointer(p)).Finterp, pVarname, uintptr(0), 0) 72830 rc = tcl.XTcl_GetWideIntFromObj(tls, (*TclQuotaCallback)(unsafe.Pointer(p)).Finterp, pLimit, bp+8 /* &x */) 72831 *(*sqlite3_int64)(unsafe.Pointer(piLimit)) = *(*Tcl_WideInt)(unsafe.Pointer(bp + 8 /* x */)) 72832 tcl.XTcl_UnsetVar2(tls, (*TclQuotaCallback)(unsafe.Pointer(p)).Finterp, tcl.XTcl_GetString(tls, pVarname), uintptr(0), 0) 72833 } 72834 72835 for ok := true; ok; ok = 0 != 0 { 72836 var _objPtr uintptr = pEval 72837 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 72838 tcl.XTclFreeObj(tls, _objPtr) 72839 } 72840 } 72841 for ok1 := true; ok1; ok1 = 0 != 0 { 72842 var _objPtr uintptr = pVarname 72843 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 72844 tcl.XTclFreeObj(tls, _objPtr) 72845 } 72846 } 72847 if rc != TCL_OK { 72848 tcl.XTcl_BackgroundError(tls, (*TclQuotaCallback)(unsafe.Pointer(p)).Finterp) 72849 } 72850 } 72851 72852 // Destructor for a TCL quota-over-limit callback. 72853 func tclCallbackDestructor(tls *libc.TLS, pObj uintptr) { /* test_quota.c:1349:13: */ 72854 var p uintptr = pObj 72855 if p != 0 { 72856 for ok := true; ok; ok = 0 != 0 { 72857 var _objPtr uintptr = (*TclQuotaCallback)(unsafe.Pointer(p)).FpScript 72858 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 72859 tcl.XTclFreeObj(tls, _objPtr) 72860 } 72861 } 72862 sqlite3.Xsqlite3_free(tls, p) 72863 } 72864 } 72865 72866 // tclcmd: sqlite3_quota_initialize NAME MAKEDEFAULT 72867 func test_quota_initialize(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1360:26: */ 72868 bp := tls.Alloc(4) 72869 defer tls.Free(4) 72870 72871 var zName uintptr // Name of new quota VFS 72872 // var makeDefault int32 at bp, 4 72873 // True to make the new VFS the default 72874 var rc int32 // Value returned by quota_initialize() 72875 72876 // Process arguments 72877 if objc != 3 { 72878 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+34084 /* "NAME MAKEDEFAULT" */) 72879 return TCL_ERROR 72880 } 72881 zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 72882 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &makeDefault */) != 0 { 72883 return TCL_ERROR 72884 } 72885 if int32(*(*int8)(unsafe.Pointer(zName))) == 0 { 72886 zName = uintptr(0) 72887 } 72888 72889 // Call sqlite3_quota_initialize() 72890 rc = sqlite3_quota_initialize(tls, zName, *(*int32)(unsafe.Pointer(bp /* makeDefault */))) 72891 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 72892 72893 return TCL_OK 72894 } 72895 72896 // tclcmd: sqlite3_quota_shutdown 72897 func test_quota_shutdown(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1389:26: */ 72898 var rc int32 // Value returned by quota_shutdown() 72899 72900 if objc != 1 { 72901 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 72902 return TCL_ERROR 72903 } 72904 72905 // Call sqlite3_quota_shutdown() 72906 rc = sqlite3_quota_shutdown(tls) 72907 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 72908 72909 return TCL_OK 72910 } 72911 72912 // tclcmd: sqlite3_quota_set PATTERN LIMIT SCRIPT 72913 func test_quota_set(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1412:26: */ 72914 bp := tls.Alloc(12) 72915 defer tls.Free(12) 72916 72917 var zPattern uintptr // File pattern to configure 72918 // var iLimit Tcl_WideInt at bp, 8 72919 // Initial quota in bytes 72920 var pScript uintptr // Tcl script to invoke to increase quota 72921 var rc int32 // Value returned by quota_set() 72922 var p uintptr // Callback object 72923 // var nScript int32 at bp+8, 4 72924 // Length of callback script 72925 var xDestroy uintptr // Optional destructor for pArg 72926 var xCallback uintptr 72927 72928 // Process arguments 72929 if objc != 4 { 72930 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+35213 /* "PATTERN LIMIT SC..." */) 72931 return TCL_ERROR 72932 } 72933 zPattern = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 72934 if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &iLimit */) != 0 { 72935 return TCL_ERROR 72936 } 72937 pScript = *(*uintptr)(unsafe.Pointer(objv + 3*8)) 72938 tcl.XTcl_GetStringFromObj(tls, pScript, bp+8 /* &nScript */) 72939 72940 if *(*int32)(unsafe.Pointer(bp + 8 /* nScript */)) > 0 { 72941 // Allocate a TclQuotaCallback object 72942 p = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(TclQuotaCallback{}))) 72943 if !(p != 0) { 72944 tcl.XTcl_SetResult(tls, interp, ts+32082 /* "SQLITE_NOMEM" */, uintptr(0)) 72945 return TCL_OK 72946 } 72947 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(TclQuotaCallback{}))) 72948 (*TclQuotaCallback)(unsafe.Pointer(p)).Finterp = interp 72949 (*Tcl_Obj)(unsafe.Pointer(pScript)).FrefCount++ 72950 (*TclQuotaCallback)(unsafe.Pointer(p)).FpScript = pScript 72951 xDestroy = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{tclCallbackDestructor})) 72952 xCallback = *(*uintptr)(unsafe.Pointer(&struct { 72953 f func(*libc.TLS, uintptr, uintptr, sqlite3_int64, uintptr) 72954 }{tclQuotaCallback})) 72955 } else { 72956 p = uintptr(0) 72957 xDestroy = uintptr(0) 72958 xCallback = uintptr(0) 72959 } 72960 72961 // Invoke sqlite3_quota_set() 72962 rc = sqlite3_quota_set(tls, zPattern, *(*Tcl_WideInt)(unsafe.Pointer(bp /* iLimit */)), xCallback, p, xDestroy) 72963 72964 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 72965 return TCL_OK 72966 } 72967 72968 // tclcmd: sqlite3_quota_file FILENAME 72969 func test_quota_file(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1466:26: */ 72970 var zFilename uintptr // File pattern to configure 72971 var rc int32 // Value returned by quota_file() 72972 72973 // Process arguments 72974 if objc != 2 { 72975 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32266 /* "FILENAME" */) 72976 return TCL_ERROR 72977 } 72978 zFilename = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 72979 72980 // Invoke sqlite3_quota_file() 72981 rc = sqlite3_quota_file(tls, zFilename) 72982 72983 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 72984 return TCL_OK 72985 } 72986 72987 // tclcmd: sqlite3_quota_dump 72988 func test_quota_dump(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1492:26: */ 72989 bp := tls.Alloc(1008) 72990 defer tls.Free(1008) 72991 72992 var pResult uintptr 72993 var pGroupTerm uintptr 72994 var pFileTerm uintptr 72995 var pGroup uintptr 72996 var pFile uintptr 72997 72998 pResult = tcl.XTcl_NewObj(tls) 72999 quotaEnter(tls) 73000 for pGroup = gQuota.FpGroup; pGroup != 0; pGroup = (*quotaGroup)(unsafe.Pointer(pGroup)).FpNext { 73001 pGroupTerm = tcl.XTcl_NewObj(tls) 73002 tcl.XTcl_ListObjAppendElement(tls, interp, pGroupTerm, 73003 tcl.XTcl_NewStringObj(tls, (*quotaGroup)(unsafe.Pointer(pGroup)).FzPattern, -1)) 73004 tcl.XTcl_ListObjAppendElement(tls, interp, pGroupTerm, 73005 tcl.XTcl_NewWideIntObj(tls, (*quotaGroup)(unsafe.Pointer(pGroup)).FiLimit)) 73006 tcl.XTcl_ListObjAppendElement(tls, interp, pGroupTerm, 73007 tcl.XTcl_NewWideIntObj(tls, (*quotaGroup)(unsafe.Pointer(pGroup)).FiSize)) 73008 for pFile = (*quotaGroup)(unsafe.Pointer(pGroup)).FpFiles; pFile != 0; pFile = (*quotaFile)(unsafe.Pointer(pFile)).FpNext { 73009 var i int32 73010 // var zTemp [1000]int8 at bp+8, 1000 73011 73012 pFileTerm = tcl.XTcl_NewObj(tls) 73013 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([1000]int8{})), bp+8 /* &zTemp[0] */, ts /* "%s" */, libc.VaList(bp, (*quotaFile)(unsafe.Pointer(pFile)).FzFilename)) 73014 for i = 0; *(*int8)(unsafe.Pointer(bp + 8 /* &zTemp[0] */ + uintptr(i))) != 0; i++ { 73015 if int32(*(*int8)(unsafe.Pointer(bp + 8 /* &zTemp[0] */ + uintptr(i)))) == '\\' { 73016 *(*int8)(unsafe.Pointer(bp + 8 /* &zTemp[0] */ + uintptr(i))) = int8('/') 73017 } 73018 } 73019 tcl.XTcl_ListObjAppendElement(tls, interp, pFileTerm, 73020 tcl.XTcl_NewStringObj(tls, bp+8 /* &zTemp[0] */, -1)) 73021 tcl.XTcl_ListObjAppendElement(tls, interp, pFileTerm, 73022 tcl.XTcl_NewWideIntObj(tls, (*quotaFile)(unsafe.Pointer(pFile)).FiSize)) 73023 tcl.XTcl_ListObjAppendElement(tls, interp, pFileTerm, 73024 tcl.XTcl_NewWideIntObj(tls, int64((*quotaFile)(unsafe.Pointer(pFile)).FnRef))) 73025 tcl.XTcl_ListObjAppendElement(tls, interp, pFileTerm, 73026 tcl.XTcl_NewWideIntObj(tls, int64((*quotaFile)(unsafe.Pointer(pFile)).FdeleteOnClose))) 73027 tcl.XTcl_ListObjAppendElement(tls, interp, pGroupTerm, pFileTerm) 73028 } 73029 tcl.XTcl_ListObjAppendElement(tls, interp, pResult, pGroupTerm) 73030 } 73031 quotaLeave(tls) 73032 tcl.XTcl_SetObjResult(tls, interp, pResult) 73033 return TCL_OK 73034 } 73035 73036 // tclcmd: sqlite3_quota_fopen FILENAME MODE 73037 func test_quota_fopen(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1540:26: */ 73038 bp := tls.Alloc(58) 73039 defer tls.Free(58) 73040 73041 var zFilename uintptr // File pattern to configure 73042 var zMode uintptr // Mode string 73043 var p uintptr // Open string object 73044 // var zReturn [50]int8 at bp+8, 50 73045 // Name of pointer to return 73046 73047 // Process arguments 73048 if objc != 3 { 73049 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+35234 /* "FILENAME MODE" */) 73050 return TCL_ERROR 73051 } 73052 zFilename = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 73053 zMode = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 73054 p = sqlite3_quota_fopen(tls, zFilename, zMode) 73055 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+8 /* &zReturn[0] */, ts+13023 /* "%p" */, libc.VaList(bp, p)) 73056 tcl.XTcl_SetResult(tls, interp, bp+8 /* &zReturn[0] */, uintptr(1)) 73057 return TCL_OK 73058 } 73059 73060 // tclcmd: sqlite3_quota_fread HANDLE SIZE NELEM 73061 func test_quota_fread(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1570:26: */ 73062 bp := tls.Alloc(8) 73063 defer tls.Free(8) 73064 73065 var p uintptr 73066 var zBuf uintptr 73067 // var sz int32 at bp, 4 73068 73069 // var nElem int32 at bp+4, 4 73070 73071 var got size_t 73072 73073 if objc != 4 { 73074 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+35248 /* "HANDLE SIZE NELE..." */) 73075 return TCL_ERROR 73076 } 73077 p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 73078 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &sz */) != 0 { 73079 return TCL_ERROR 73080 } 73081 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+4 /* &nElem */) != 0 { 73082 return TCL_ERROR 73083 } 73084 zBuf = sqlite3.Xsqlite3_malloc(tls, ((*(*int32)(unsafe.Pointer(bp /* sz */)) * *(*int32)(unsafe.Pointer(bp + 4 /* nElem */))) + 1)) 73085 if zBuf == uintptr(0) { 73086 tcl.XTcl_SetResult(tls, interp, ts+1930 /* "out of memory" */, uintptr(0)) 73087 return TCL_ERROR 73088 } 73089 got = sqlite3_quota_fread(tls, zBuf, uint64(*(*int32)(unsafe.Pointer(bp /* sz */))), uint64(*(*int32)(unsafe.Pointer(bp + 4 /* nElem */))), p) 73090 *(*int8)(unsafe.Pointer(zBuf + uintptr((got * size_t(*(*int32)(unsafe.Pointer(bp /* sz */))))))) = int8(0) 73091 tcl.XTcl_SetResult(tls, interp, zBuf, uintptr(1)) 73092 sqlite3.Xsqlite3_free(tls, zBuf) 73093 return TCL_OK 73094 } 73095 73096 // tclcmd: sqlite3_quota_fwrite HANDLE SIZE NELEM CONTENT 73097 func test_quota_fwrite(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1604:26: */ 73098 bp := tls.Alloc(8) 73099 defer tls.Free(8) 73100 73101 var p uintptr 73102 var zBuf uintptr 73103 // var sz int32 at bp, 4 73104 73105 // var nElem int32 at bp+4, 4 73106 73107 var got size_t 73108 73109 if objc != 5 { 73110 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+35266 /* "HANDLE SIZE NELE..." */) 73111 return TCL_ERROR 73112 } 73113 p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 73114 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &sz */) != 0 { 73115 return TCL_ERROR 73116 } 73117 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+4 /* &nElem */) != 0 { 73118 return TCL_ERROR 73119 } 73120 zBuf = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8))) 73121 got = sqlite3_quota_fwrite(tls, zBuf, uint64(*(*int32)(unsafe.Pointer(bp /* sz */))), uint64(*(*int32)(unsafe.Pointer(bp + 4 /* nElem */))), p) 73122 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, int64(got))) 73123 return TCL_OK 73124 } 73125 73126 // tclcmd: sqlite3_quota_fclose HANDLE 73127 func test_quota_fclose(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1632:26: */ 73128 var p uintptr 73129 var rc int32 73130 73131 if objc != 2 { 73132 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+28011 /* "HANDLE" */) 73133 return TCL_ERROR 73134 } 73135 p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 73136 rc = sqlite3_quota_fclose(tls, p) 73137 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) 73138 return TCL_OK 73139 } 73140 73141 // tclcmd: sqlite3_quota_fflush HANDLE ?HARDSYNC? 73142 func test_quota_fflush(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1654:26: */ 73143 bp := tls.Alloc(4) 73144 defer tls.Free(4) 73145 73146 var p uintptr 73147 var rc int32 73148 *(*int32)(unsafe.Pointer(bp /* doSync */)) = 0 73149 73150 if (objc != 2) && (objc != 3) { 73151 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+35292 /* "HANDLE ?HARDSYNC..." */) 73152 return TCL_ERROR 73153 } 73154 p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 73155 if objc == 3 { 73156 if tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &doSync */) != 0 { 73157 return TCL_ERROR 73158 } 73159 } 73160 rc = sqlite3_quota_fflush(tls, p, *(*int32)(unsafe.Pointer(bp /* doSync */))) 73161 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) 73162 return TCL_OK 73163 } 73164 73165 // tclcmd: sqlite3_quota_fseek HANDLE OFFSET WHENCE 73166 func test_quota_fseek(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1680:26: */ 73167 bp := tls.Alloc(20) 73168 defer tls.Free(20) 73169 73170 var p uintptr 73171 // var ofst int32 at bp+16, 4 73172 73173 var zWhence uintptr 73174 var whence int32 73175 var rc int32 73176 73177 if objc != 4 { 73178 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+35310 /* "HANDLE OFFSET WH..." */) 73179 return TCL_ERROR 73180 } 73181 p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 73182 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+16 /* &ofst */) != 0 { 73183 return TCL_ERROR 73184 } 73185 zWhence = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 73186 if libc.Xstrcmp(tls, zWhence, ts+35331 /* "SEEK_SET" */) == 0 { 73187 whence = SEEK_SET 73188 } else if libc.Xstrcmp(tls, zWhence, ts+35340 /* "SEEK_CUR" */) == 0 { 73189 whence = SEEK_CUR 73190 } else if libc.Xstrcmp(tls, zWhence, ts+35349 /* "SEEK_END" */) == 0 { 73191 whence = SEEK_END 73192 } else { 73193 tcl.XTcl_AppendResult(tls, interp, 73194 libc.VaList(bp, ts+35358 /* "WHENCE should be..." */, uintptr(0))) 73195 return TCL_ERROR 73196 } 73197 rc = sqlite3_quota_fseek(tls, p, int64(*(*int32)(unsafe.Pointer(bp + 16 /* ofst */))), whence) 73198 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) 73199 return TCL_OK 73200 } 73201 73202 // tclcmd: sqlite3_quota_rewind HANDLE 73203 func test_quota_rewind(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1718:26: */ 73204 var p uintptr 73205 if objc != 2 { 73206 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+28011 /* "HANDLE" */) 73207 return TCL_ERROR 73208 } 73209 p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 73210 sqlite3_quota_rewind(tls, p) 73211 return TCL_OK 73212 } 73213 73214 // tclcmd: sqlite3_quota_ftell HANDLE 73215 func test_quota_ftell(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1737:26: */ 73216 var p uintptr 73217 var x sqlite3_int64 73218 if objc != 2 { 73219 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+28011 /* "HANDLE" */) 73220 return TCL_ERROR 73221 } 73222 p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 73223 x = sqlite3_int64(sqlite3_quota_ftell(tls, p)) 73224 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, x)) 73225 return TCL_OK 73226 } 73227 73228 // tclcmd: sqlite3_quota_ftruncate HANDLE SIZE 73229 func test_quota_ftruncate(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1758:26: */ 73230 bp := tls.Alloc(8) 73231 defer tls.Free(8) 73232 73233 var p uintptr 73234 var x sqlite3_int64 73235 // var w Tcl_WideInt at bp, 8 73236 73237 var rc int32 73238 if objc != 3 { 73239 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+35407 /* "HANDLE SIZE" */) 73240 return TCL_ERROR 73241 } 73242 p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 73243 if tcl.XTcl_GetWideIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &w */) != 0 { 73244 return TCL_ERROR 73245 } 73246 x = *(*Tcl_WideInt)(unsafe.Pointer(bp /* w */)) 73247 rc = sqlite3_quota_ftruncate(tls, p, x) 73248 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) 73249 return TCL_OK 73250 } 73251 73252 // tclcmd: sqlite3_quota_file_size HANDLE 73253 func test_quota_file_size(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1783:26: */ 73254 var p uintptr 73255 var x sqlite3_int64 73256 if objc != 2 { 73257 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+28011 /* "HANDLE" */) 73258 return TCL_ERROR 73259 } 73260 p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 73261 x = sqlite3_quota_file_size(tls, p) 73262 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, x)) 73263 return TCL_OK 73264 } 73265 73266 // tclcmd: sqlite3_quota_file_truesize HANDLE 73267 func test_quota_file_truesize(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1804:26: */ 73268 var p uintptr 73269 var x sqlite3_int64 73270 if objc != 2 { 73271 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+28011 /* "HANDLE" */) 73272 return TCL_ERROR 73273 } 73274 p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 73275 x = sqlite3_quota_file_truesize(tls, p) 73276 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, x)) 73277 return TCL_OK 73278 } 73279 73280 // tclcmd: sqlite3_quota_file_mtime HANDLE 73281 func test_quota_file_mtime(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1825:26: */ 73282 bp := tls.Alloc(8) 73283 defer tls.Free(8) 73284 73285 var p uintptr 73286 // var t time_t at bp, 8 73287 73288 if objc != 2 { 73289 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+28011 /* "HANDLE" */) 73290 return TCL_ERROR 73291 } 73292 p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 73293 *(*time_t)(unsafe.Pointer(bp /* t */)) = int64(0) 73294 sqlite3_quota_file_mtime(tls, p, bp /* &t */) 73295 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, int64(*(*time_t)(unsafe.Pointer(bp /* t */))))) 73296 return TCL_OK 73297 } 73298 73299 // tclcmd: sqlite3_quota_remove FILENAME 73300 func test_quota_remove(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1848:26: */ 73301 var zFilename uintptr // File pattern to configure 73302 var rc int32 73303 if objc != 2 { 73304 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32266 /* "FILENAME" */) 73305 return TCL_ERROR 73306 } 73307 zFilename = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 73308 rc = sqlite3_quota_remove(tls, zFilename) 73309 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) 73310 return TCL_OK 73311 } 73312 73313 // tclcmd: sqlite3_quota_glob PATTERN TEXT 73314 // 73315 // Test the glob pattern matching. Return 1 if TEXT matches PATTERN 73316 // and return 0 if it does not. 73317 func test_quota_glob(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1872:26: */ 73318 var zPattern uintptr // The glob pattern 73319 var zText uintptr // Text to compare agains the pattern 73320 var rc int32 73321 if objc != 3 { 73322 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+35419 /* "PATTERN TEXT" */) 73323 return TCL_ERROR 73324 } 73325 zPattern = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 73326 zText = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 73327 rc = quotaStrglob(tls, zPattern, zText) 73328 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, rc)) 73329 return TCL_OK 73330 } 73331 73332 // tclcmd: sqlite3_quota_file_available HANDLE 73333 // 73334 // Return the number of bytes from the current file point to the end of 73335 // the file. 73336 func test_quota_file_available(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1898:26: */ 73337 var p uintptr 73338 var x sqlite3_int64 73339 if objc != 2 { 73340 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+28011 /* "HANDLE" */) 73341 return TCL_ERROR 73342 } 73343 p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 73344 x = sqlite3_int64(sqlite3_quota_file_available(tls, p)) 73345 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewWideIntObj(tls, x)) 73346 return TCL_OK 73347 } 73348 73349 // tclcmd: sqlite3_quota_ferror HANDLE 73350 // 73351 // Return true if the file handle is in the error state. 73352 func test_quota_ferror(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_quota.c:1921:26: */ 73353 var p uintptr 73354 var x int32 73355 if objc != 2 { 73356 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+28011 /* "HANDLE" */) 73357 return TCL_ERROR 73358 } 73359 p = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 73360 x = sqlite3_quota_ferror(tls, p) 73361 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, x)) 73362 return TCL_OK 73363 } 73364 73365 // This routine registers the custom TCL commands defined in this 73366 // module. This should be the only procedure visible from outside 73367 // of this module. 73368 func Sqlitequota_Init(tls *libc.TLS, interp uintptr) int32 { /* test_quota.c:1944:5: */ 73369 var i int32 73370 73371 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aCmd9)) / uint64(unsafe.Sizeof(struct { 73372 FzName uintptr 73373 FxProc uintptr 73374 }{}))); i++ { 73375 tcl.XTcl_CreateObjCommand(tls, interp, aCmd9[i].FzName, aCmd9[i].FxProc, uintptr(0), uintptr(0)) 73376 } 73377 73378 return TCL_OK 73379 } 73380 73381 var aCmd9 = [21]struct { 73382 FzName uintptr 73383 FxProc uintptr 73384 }{ 73385 {FzName: ts + 35432 /* "sqlite3_quota_in..." */, FxProc: 0}, 73386 {FzName: ts + 35457 /* "sqlite3_quota_sh..." */, FxProc: 0}, 73387 {FzName: ts + 35480 /* "sqlite3_quota_se..." */, FxProc: 0}, 73388 {FzName: ts + 35498 /* "sqlite3_quota_fi..." */, FxProc: 0}, 73389 {FzName: ts + 35517 /* "sqlite3_quota_du..." */, FxProc: 0}, 73390 {FzName: ts + 35536 /* "sqlite3_quota_fo..." */, FxProc: 0}, 73391 {FzName: ts + 35556 /* "sqlite3_quota_fr..." */, FxProc: 0}, 73392 {FzName: ts + 35576 /* "sqlite3_quota_fw..." */, FxProc: 0}, 73393 {FzName: ts + 35597 /* "sqlite3_quota_fc..." */, FxProc: 0}, 73394 {FzName: ts + 35618 /* "sqlite3_quota_ff..." */, FxProc: 0}, 73395 {FzName: ts + 35639 /* "sqlite3_quota_fs..." */, FxProc: 0}, 73396 {FzName: ts + 35659 /* "sqlite3_quota_re..." */, FxProc: 0}, 73397 {FzName: ts + 35680 /* "sqlite3_quota_ft..." */, FxProc: 0}, 73398 {FzName: ts + 35700 /* "sqlite3_quota_ft..." */, FxProc: 0}, 73399 {FzName: ts + 35724 /* "sqlite3_quota_fi..." */, FxProc: 0}, 73400 {FzName: ts + 35748 /* "sqlite3_quota_fi..." */, FxProc: 0}, 73401 {FzName: ts + 35776 /* "sqlite3_quota_fi..." */, FxProc: 0}, 73402 {FzName: ts + 35801 /* "sqlite3_quota_re..." */, FxProc: 0}, 73403 {FzName: ts + 35822 /* "sqlite3_quota_gl..." */, FxProc: 0}, 73404 {FzName: ts + 35841 /* "sqlite3_quota_fi..." */, FxProc: 0}, 73405 {FzName: ts + 35870 /* "sqlite3_quota_fe..." */, FxProc: 0}, 73406 } /* test_quota.c:1948:5 */ 73407 73408 // Type used to cache parameter information for the "circle" r-tree geometry 73409 // callback. 73410 type Circle1 = struct { 73411 FaBox [2]struct { 73412 Fxmin float64 73413 Fxmax float64 73414 Fymin float64 73415 Fymax float64 73416 } 73417 Fcenterx float64 73418 Fcentery float64 73419 Fradius float64 73420 FmxArea float64 73421 FeScoreType int32 73422 _ [4]byte 73423 } /* test_rtree.c:31:9 */ 73424 73425 // Type used to cache parameter information for the "circle" r-tree geometry 73426 // callback. 73427 type Circle = Circle1 /* test_rtree.c:31:23 */ 73428 type Box = struct { 73429 Fxmin float64 73430 Fxmax float64 73431 Fymin float64 73432 Fymax float64 73433 } /* test_rtree.c:31:9 */ 73434 73435 // Destructor function for Circle objects allocated by circle_geom(). 73436 func circle_del(tls *libc.TLS, p uintptr) { /* test_rtree.c:49:13: */ 73437 sqlite3.Xsqlite3_free(tls, p) 73438 } 73439 73440 // Implementation of "circle" r-tree geometry callback. 73441 func circle_geom(tls *libc.TLS, p uintptr, nCoord int32, aCoord uintptr, pRes uintptr) int32 { /* test_rtree.c:56:12: */ 73442 var i int32 // Iterator variable 73443 var pCircle uintptr // Structure defining circular region 73444 var xmin float64 73445 var xmax float64 // X dimensions of box being tested 73446 var ymin float64 73447 var ymax float64 // X dimensions of box being tested 73448 73449 xmin = *(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord)) 73450 xmax = *(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + 1*8)) 73451 ymin = *(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + 2*8)) 73452 ymax = *(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + 3*8)) 73453 pCircle = (*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FpUser 73454 if pCircle == uintptr(0) { 73455 // If pUser is still 0, then the parameter values have not been tested 73456 // for correctness or stored into a Circle structure yet. Do this now. 73457 73458 // This geometry callback is for use with a 2-dimensional r-tree table. 73459 // Return an error if the table does not have exactly 2 dimensions. 73460 if nCoord != 4 { 73461 return SQLITE_ERROR 73462 } 73463 73464 // Test that the correct number of parameters (3) have been supplied, 73465 // and that the parameters are in range (that the radius of the circle 73466 // radius is greater than zero). 73467 if ((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FnParam != 3) || (*(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + 2*8)) < 0.0) { 73468 return SQLITE_ERROR 73469 } 73470 73471 // Allocate a structure to cache parameter data in. Return SQLITE_NOMEM 73472 // if the allocation fails. 73473 pCircle = libc.AssignPtrUintptr(p+24 /* &.pUser */, sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Circle{})))) 73474 if !(pCircle != 0) { 73475 return SQLITE_NOMEM 73476 } 73477 (*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FxDelUser = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{circle_del})) 73478 73479 // Record the center and radius of the circular region. One way that 73480 // tested bounding boxes that intersect the circular region are detected 73481 // is by testing if each corner of the bounding box lies within radius 73482 // units of the center of the circle. 73483 (*Circle)(unsafe.Pointer(pCircle)).Fcenterx = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam)) 73484 (*Circle)(unsafe.Pointer(pCircle)).Fcentery = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + 1*8)) 73485 (*Circle)(unsafe.Pointer(pCircle)).Fradius = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + 2*8)) 73486 73487 // Define two bounding box regions. The first, aBox[0], extends to 73488 // infinity in the X dimension. It covers the same range of the Y dimension 73489 // as the circular region. The second, aBox[1], extends to infinity in 73490 // the Y dimension and is constrained to the range of the circle in the 73491 // X dimension. 73492 // 73493 // Then imagine each box is split in half along its short axis by a line 73494 // that intersects the center of the circular region. A bounding box 73495 // being tested can be said to intersect the circular region if it contains 73496 // points from each half of either of the two infinite bounding boxes. 73497 (*Box)(unsafe.Pointer((pCircle /* &.aBox */))).Fxmin = (*Circle)(unsafe.Pointer(pCircle)).Fcenterx 73498 (*Box)(unsafe.Pointer((pCircle /* &.aBox */))).Fxmax = (*Circle)(unsafe.Pointer(pCircle)).Fcenterx 73499 (*Box)(unsafe.Pointer((pCircle /* &.aBox */))).Fymin = ((*Circle)(unsafe.Pointer(pCircle)).Fcentery + (*Circle)(unsafe.Pointer(pCircle)).Fradius) 73500 (*Box)(unsafe.Pointer((pCircle /* &.aBox */))).Fymax = ((*Circle)(unsafe.Pointer(pCircle)).Fcentery - (*Circle)(unsafe.Pointer(pCircle)).Fradius) 73501 (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + 1*32)).Fxmin = ((*Circle)(unsafe.Pointer(pCircle)).Fcenterx + (*Circle)(unsafe.Pointer(pCircle)).Fradius) 73502 (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + 1*32)).Fxmax = ((*Circle)(unsafe.Pointer(pCircle)).Fcenterx - (*Circle)(unsafe.Pointer(pCircle)).Fradius) 73503 (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + 1*32)).Fymin = (*Circle)(unsafe.Pointer(pCircle)).Fcentery 73504 (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + 1*32)).Fymax = (*Circle)(unsafe.Pointer(pCircle)).Fcentery 73505 (*Circle)(unsafe.Pointer(pCircle)).FmxArea = (((xmax - xmin) * (ymax - ymin)) + 1.0) 73506 } 73507 73508 // Check if any of the 4 corners of the bounding-box being tested lie 73509 // inside the circular region. If they do, then the bounding-box does 73510 // intersect the region of interest. Set the output variable to true and 73511 // return SQLITE_OK in this case. 73512 for i = 0; i < 4; i++ { 73513 var x float64 73514 if (i & 0x01) != 0 { 73515 x = xmax 73516 } else { 73517 x = xmin 73518 } 73519 var y float64 73520 if (i & 0x02) != 0 { 73521 y = ymax 73522 } else { 73523 y = ymin 73524 } 73525 var d2 float64 73526 73527 d2 = ((x - (*Circle)(unsafe.Pointer(pCircle)).Fcenterx) * (x - (*Circle)(unsafe.Pointer(pCircle)).Fcenterx)) 73528 d2 = d2 + ((y - (*Circle)(unsafe.Pointer(pCircle)).Fcentery) * (y - (*Circle)(unsafe.Pointer(pCircle)).Fcentery)) 73529 if d2 < ((*Circle)(unsafe.Pointer(pCircle)).Fradius * (*Circle)(unsafe.Pointer(pCircle)).Fradius) { 73530 *(*int32)(unsafe.Pointer(pRes)) = 1 73531 return SQLITE_OK 73532 } 73533 } 73534 73535 // Check if the bounding box covers any other part of the circular region. 73536 // See comments above for a description of how this test works. If it does 73537 // cover part of the circular region, set the output variable to true 73538 // and return SQLITE_OK. 73539 for i = 0; i < 2; i++ { 73540 if (((xmin <= (*Box)(unsafe.Pointer((pCircle /* &.aBox */)+uintptr(i)*32)).Fxmin) && 73541 (xmax >= (*Box)(unsafe.Pointer((pCircle /* &.aBox */)+uintptr(i)*32)).Fxmax)) && 73542 (ymin <= (*Box)(unsafe.Pointer((pCircle /* &.aBox */)+uintptr(i)*32)).Fymin)) && 73543 (ymax >= (*Box)(unsafe.Pointer((pCircle /* &.aBox */)+uintptr(i)*32)).Fymax) { 73544 *(*int32)(unsafe.Pointer(pRes)) = 1 73545 return SQLITE_OK 73546 } 73547 } 73548 73549 // The specified bounding box does not intersect the circular region. Set 73550 // the output variable to zero and return SQLITE_OK. 73551 *(*int32)(unsafe.Pointer(pRes)) = 0 73552 return SQLITE_OK 73553 } 73554 73555 // Implementation of "circle" r-tree geometry callback using the 73556 // 2nd-generation interface that allows scoring. 73557 // 73558 // Two calling forms: 73559 // 73560 // Qcircle(X,Y,Radius,eType) -- All values are doubles 73561 // Qcircle('x:X y:Y r:R e:ETYPE') -- Single string parameter 73562 func circle_query_func(tls *libc.TLS, p uintptr) int32 { /* test_rtree.c:168:12: */ 73563 var i int32 // Iterator variable 73564 var pCircle uintptr // Structure defining circular region 73565 var xmin float64 73566 var xmax float64 // X dimensions of box being tested 73567 var ymin float64 73568 var ymax float64 // X dimensions of box being tested 73569 var nWithin int32 = 0 // Number of corners inside the circle 73570 73571 xmin = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord)) 73572 xmax = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + 1*8)) 73573 ymin = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + 2*8)) 73574 ymax = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + 3*8)) 73575 pCircle = (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FpUser 73576 if pCircle == uintptr(0) { 73577 // If pUser is still 0, then the parameter values have not been tested 73578 // for correctness or stored into a Circle structure yet. Do this now. 73579 73580 // This geometry callback is for use with a 2-dimensional r-tree table. 73581 // Return an error if the table does not have exactly 2 dimensions. 73582 if (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FnCoord != 4 { 73583 return SQLITE_ERROR 73584 } 73585 73586 // Test that the correct number of parameters (1 or 4) have been supplied. 73587 if ((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FnParam != 4) && ((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FnParam != 1) { 73588 return SQLITE_ERROR 73589 } 73590 73591 // Allocate a structure to cache parameter data in. Return SQLITE_NOMEM 73592 // if the allocation fails. 73593 pCircle = libc.AssignPtrUintptr(p+24 /* &.pUser */, sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Circle{})))) 73594 if !(pCircle != 0) { 73595 return SQLITE_NOMEM 73596 } 73597 (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FxDelUser = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{circle_del})) 73598 73599 // Record the center and radius of the circular region. One way that 73600 // tested bounding boxes that intersect the circular region are detected 73601 // is by testing if each corner of the bounding box lies within radius 73602 // units of the center of the circle. 73603 if (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FnParam == 4 { 73604 (*Circle)(unsafe.Pointer(pCircle)).Fcenterx = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam)) 73605 (*Circle)(unsafe.Pointer(pCircle)).Fcentery = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + 1*8)) 73606 (*Circle)(unsafe.Pointer(pCircle)).Fradius = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + 2*8)) 73607 (*Circle)(unsafe.Pointer(pCircle)).FeScoreType = int32(*(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + 3*8))) 73608 } else { 73609 var z uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FapSqlParam))) 73610 (*Circle)(unsafe.Pointer(pCircle)).Fcenterx = 0.0 73611 (*Circle)(unsafe.Pointer(pCircle)).Fcentery = 0.0 73612 (*Circle)(unsafe.Pointer(pCircle)).Fradius = 0.0 73613 (*Circle)(unsafe.Pointer(pCircle)).FeScoreType = 0 73614 for (z != 0) && (*(*int8)(unsafe.Pointer(z)) != 0) { 73615 if (int32(*(*int8)(unsafe.Pointer(z))) == 'r') && (int32(*(*int8)(unsafe.Pointer(z + 1))) == ':') { 73616 (*Circle)(unsafe.Pointer(pCircle)).Fradius = libc.Xatof(tls, (z + 2)) 73617 } else if (int32(*(*int8)(unsafe.Pointer(z))) == 'x') && (int32(*(*int8)(unsafe.Pointer(z + 1))) == ':') { 73618 (*Circle)(unsafe.Pointer(pCircle)).Fcenterx = libc.Xatof(tls, (z + 2)) 73619 } else if (int32(*(*int8)(unsafe.Pointer(z))) == 'y') && (int32(*(*int8)(unsafe.Pointer(z + 1))) == ':') { 73620 (*Circle)(unsafe.Pointer(pCircle)).Fcentery = libc.Xatof(tls, (z + 2)) 73621 } else if (int32(*(*int8)(unsafe.Pointer(z))) == 'e') && (int32(*(*int8)(unsafe.Pointer(z + 1))) == ':') { 73622 (*Circle)(unsafe.Pointer(pCircle)).FeScoreType = int32(libc.Xatof(tls, (z + 2))) 73623 } else if int32(*(*int8)(unsafe.Pointer(z))) == ' ' { 73624 z++ 73625 continue 73626 } 73627 for (int32(*(*int8)(unsafe.Pointer(z))) != 0) && (int32(*(*int8)(unsafe.Pointer(z))) != ' ') { 73628 z++ 73629 } 73630 for int32(*(*int8)(unsafe.Pointer(z))) == ' ' { 73631 z++ 73632 } 73633 } 73634 } 73635 if (*Circle)(unsafe.Pointer(pCircle)).Fradius < 0.0 { 73636 sqlite3.Xsqlite3_free(tls, pCircle) 73637 return SQLITE_NOMEM 73638 } 73639 73640 // Define two bounding box regions. The first, aBox[0], extends to 73641 // infinity in the X dimension. It covers the same range of the Y dimension 73642 // as the circular region. The second, aBox[1], extends to infinity in 73643 // the Y dimension and is constrained to the range of the circle in the 73644 // X dimension. 73645 // 73646 // Then imagine each box is split in half along its short axis by a line 73647 // that intersects the center of the circular region. A bounding box 73648 // being tested can be said to intersect the circular region if it contains 73649 // points from each half of either of the two infinite bounding boxes. 73650 (*Box)(unsafe.Pointer((pCircle /* &.aBox */))).Fxmin = (*Circle)(unsafe.Pointer(pCircle)).Fcenterx 73651 (*Box)(unsafe.Pointer((pCircle /* &.aBox */))).Fxmax = (*Circle)(unsafe.Pointer(pCircle)).Fcenterx 73652 (*Box)(unsafe.Pointer((pCircle /* &.aBox */))).Fymin = ((*Circle)(unsafe.Pointer(pCircle)).Fcentery + (*Circle)(unsafe.Pointer(pCircle)).Fradius) 73653 (*Box)(unsafe.Pointer((pCircle /* &.aBox */))).Fymax = ((*Circle)(unsafe.Pointer(pCircle)).Fcentery - (*Circle)(unsafe.Pointer(pCircle)).Fradius) 73654 (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + 1*32)).Fxmin = ((*Circle)(unsafe.Pointer(pCircle)).Fcenterx + (*Circle)(unsafe.Pointer(pCircle)).Fradius) 73655 (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + 1*32)).Fxmax = ((*Circle)(unsafe.Pointer(pCircle)).Fcenterx - (*Circle)(unsafe.Pointer(pCircle)).Fradius) 73656 (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + 1*32)).Fymin = (*Circle)(unsafe.Pointer(pCircle)).Fcentery 73657 (*Box)(unsafe.Pointer((pCircle /* &.aBox */) + 1*32)).Fymax = (*Circle)(unsafe.Pointer(pCircle)).Fcentery 73658 (*Circle)(unsafe.Pointer(pCircle)).FmxArea = (float64(200.0) * 200.0) 73659 } 73660 73661 // Check if any of the 4 corners of the bounding-box being tested lie 73662 // inside the circular region. If they do, then the bounding-box does 73663 // intersect the region of interest. Set the output variable to true and 73664 // return SQLITE_OK in this case. 73665 for i = 0; i < 4; i++ { 73666 var x float64 73667 if (i & 0x01) != 0 { 73668 x = xmax 73669 } else { 73670 x = xmin 73671 } 73672 var y float64 73673 if (i & 0x02) != 0 { 73674 y = ymax 73675 } else { 73676 y = ymin 73677 } 73678 var d2 float64 73679 73680 d2 = ((x - (*Circle)(unsafe.Pointer(pCircle)).Fcenterx) * (x - (*Circle)(unsafe.Pointer(pCircle)).Fcenterx)) 73681 d2 = d2 + ((y - (*Circle)(unsafe.Pointer(pCircle)).Fcentery) * (y - (*Circle)(unsafe.Pointer(pCircle)).Fcentery)) 73682 if d2 < ((*Circle)(unsafe.Pointer(pCircle)).Fradius * (*Circle)(unsafe.Pointer(pCircle)).Fradius) { 73683 nWithin++ 73684 } 73685 } 73686 73687 // Check if the bounding box covers any other part of the circular region. 73688 // See comments above for a description of how this test works. If it does 73689 // cover part of the circular region, set the output variable to true 73690 // and return SQLITE_OK. 73691 if nWithin == 0 { 73692 for i = 0; i < 2; i++ { 73693 if (((xmin <= (*Box)(unsafe.Pointer((pCircle /* &.aBox */)+uintptr(i)*32)).Fxmin) && 73694 (xmax >= (*Box)(unsafe.Pointer((pCircle /* &.aBox */)+uintptr(i)*32)).Fxmax)) && 73695 (ymin <= (*Box)(unsafe.Pointer((pCircle /* &.aBox */)+uintptr(i)*32)).Fymin)) && 73696 (ymax >= (*Box)(unsafe.Pointer((pCircle /* &.aBox */)+uintptr(i)*32)).Fymax) { 73697 nWithin = 1 73698 break 73699 } 73700 } 73701 } 73702 73703 if (*Circle)(unsafe.Pointer(pCircle)).FeScoreType == 1 { 73704 // Depth first search 73705 (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FrScore = sqlite3_rtree_dbl((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FiLevel) 73706 } else if (*Circle)(unsafe.Pointer(pCircle)).FeScoreType == 2 { 73707 // Breadth first search 73708 (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FrScore = (sqlite3_rtree_dbl(100 - (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FiLevel)) 73709 } else if (*Circle)(unsafe.Pointer(pCircle)).FeScoreType == 3 { 73710 // Depth-first search, except sort the leaf nodes by area with 73711 // the largest area first 73712 if (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FiLevel == 1 { 73713 (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FrScore = (1.0 - (((xmax - xmin) * (ymax - ymin)) / (*Circle)(unsafe.Pointer(pCircle)).FmxArea)) 73714 if (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FrScore < 0.01 { 73715 (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FrScore = 0.01 73716 } 73717 } else { 73718 (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FrScore = 0.0 73719 } 73720 } else if (*Circle)(unsafe.Pointer(pCircle)).FeScoreType == 4 { 73721 // Depth-first search, except exclude odd rowids 73722 (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FrScore = sqlite3_rtree_dbl((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FiLevel) 73723 if ((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FiRowid & int64(1)) != 0 { 73724 nWithin = 0 73725 } 73726 } else { 73727 // Breadth-first search, except exclude odd rowids 73728 (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FrScore = (sqlite3_rtree_dbl(100 - (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FiLevel)) 73729 if ((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FiRowid & int64(1)) != 0 { 73730 nWithin = 0 73731 } 73732 } 73733 if nWithin == 0 { 73734 (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = NOT_WITHIN 73735 } else if nWithin >= 4 { 73736 (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = FULLY_WITHIN 73737 } else { 73738 (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = PARTLY_WITHIN 73739 } 73740 return SQLITE_OK 73741 } 73742 73743 // Implementation of "breadthfirstsearch" r-tree geometry callback using the 73744 // 2nd-generation interface that allows scoring. 73745 // 73746 // ... WHERE id MATCH breadthfirstsearch($x0,$x1,$y0,$y1) ... 73747 // 73748 // It returns all entries whose bounding boxes overlap with $x0,$x1,$y0,$y1. 73749 func bfs_query_func(tls *libc.TLS, p uintptr) int32 { /* test_rtree.c:329:12: */ 73750 var x0 float64 73751 var x1 float64 73752 var y0 float64 73753 var y1 float64 // Dimensions of box being tested 73754 var bx0 float64 73755 var bx1 float64 73756 var by0 float64 73757 var by1 float64 // Boundary of the query function 73758 73759 if (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FnParam != 4 { 73760 return SQLITE_ERROR 73761 } 73762 x0 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord)) 73763 x1 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + 1*8)) 73764 y0 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + 2*8)) 73765 y1 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaCoord + 3*8)) 73766 bx0 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam)) 73767 bx1 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + 1*8)) 73768 by0 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + 2*8)) 73769 by1 = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FaParam + 3*8)) 73770 (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FrScore = (sqlite3_rtree_dbl(100 - (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FiLevel)) 73771 if (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeParentWithin == FULLY_WITHIN { 73772 (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = FULLY_WITHIN 73773 } else if (((x0 >= bx0) && (x1 <= bx1)) && (y0 >= by0)) && (y1 <= by1) { 73774 (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = FULLY_WITHIN 73775 } else if (((x1 >= bx0) && (x0 <= bx1)) && (y1 >= by0)) && (y0 <= by1) { 73776 (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = PARTLY_WITHIN 73777 } else { 73778 (*sqlite3_rtree_query_info)(unsafe.Pointer(p)).FeWithin = NOT_WITHIN 73779 } 73780 return SQLITE_OK 73781 } 73782 73783 // END of implementation of "circle" geometry callback. 73784 // 73785 // 73786 73787 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 73788 // This file is part of the GNU C Library. 73789 // 73790 // The GNU C Library is free software; you can redistribute it and/or 73791 // modify it under the terms of the GNU Lesser General Public 73792 // License as published by the Free Software Foundation; either 73793 // version 2.1 of the License, or (at your option) any later version. 73794 // 73795 // The GNU C Library is distributed in the hope that it will be useful, 73796 // but WITHOUT ANY WARRANTY; without even the implied warranty of 73797 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 73798 // Lesser General Public License for more details. 73799 // 73800 // You should have received a copy of the GNU Lesser General Public 73801 // License along with the GNU C Library; if not, see 73802 // <http://www.gnu.org/licenses/>. 73803 73804 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 73805 73806 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 73807 // This file is part of the GNU C Library. 73808 // 73809 // The GNU C Library is free software; you can redistribute it and/or 73810 // modify it under the terms of the GNU Lesser General Public 73811 // License as published by the Free Software Foundation; either 73812 // version 2.1 of the License, or (at your option) any later version. 73813 // 73814 // The GNU C Library is distributed in the hope that it will be useful, 73815 // but WITHOUT ANY WARRANTY; without even the implied warranty of 73816 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 73817 // Lesser General Public License for more details. 73818 // 73819 // You should have received a copy of the GNU Lesser General Public 73820 // License along with the GNU C Library; if not, see 73821 // <http://www.gnu.org/licenses/>. 73822 73823 // void assert (int expression); 73824 // 73825 // If NDEBUG is defined, do nothing. 73826 // If not, and EXPRESSION is zero, print an error message and abort. 73827 73828 // void assert_perror (int errnum); 73829 // 73830 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 73831 // error message with the error text for ERRNUM and abort. 73832 // (This is a GNU extension.) 73833 73834 // tcl.h -- 73835 // 73836 // This header file describes the externally-visible facilities of the 73837 // Tcl interpreter. 73838 // 73839 // Copyright (c) 1987-1994 The Regents of the University of California. 73840 // Copyright (c) 1993-1996 Lucent Technologies. 73841 // Copyright (c) 1994-1998 Sun Microsystems, Inc. 73842 // Copyright (c) 1998-2000 by Scriptics Corporation. 73843 // Copyright (c) 2002 by Kevin B. Kenny. All rights reserved. 73844 // 73845 // See the file "license.terms" for information on usage and redistribution of 73846 // this file, and for a DISCLAIMER OF ALL WARRANTIES. 73847 73848 // Local Variables: 73849 // mode: c 73850 // c-basic-offset: 4 73851 // fill-column: 78 73852 // End: 73853 73854 type Cube1 = struct { 73855 Fx float64 73856 Fy float64 73857 Fz float64 73858 Fwidth float64 73859 Fheight float64 73860 Fdepth float64 73861 } /* test_rtree.c:366:9 */ 73862 73863 // END of implementation of "circle" geometry callback. 73864 // 73865 // 73866 73867 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 73868 // This file is part of the GNU C Library. 73869 // 73870 // The GNU C Library is free software; you can redistribute it and/or 73871 // modify it under the terms of the GNU Lesser General Public 73872 // License as published by the Free Software Foundation; either 73873 // version 2.1 of the License, or (at your option) any later version. 73874 // 73875 // The GNU C Library is distributed in the hope that it will be useful, 73876 // but WITHOUT ANY WARRANTY; without even the implied warranty of 73877 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 73878 // Lesser General Public License for more details. 73879 // 73880 // You should have received a copy of the GNU Lesser General Public 73881 // License along with the GNU C Library; if not, see 73882 // <http://www.gnu.org/licenses/>. 73883 73884 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 73885 73886 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 73887 // This file is part of the GNU C Library. 73888 // 73889 // The GNU C Library is free software; you can redistribute it and/or 73890 // modify it under the terms of the GNU Lesser General Public 73891 // License as published by the Free Software Foundation; either 73892 // version 2.1 of the License, or (at your option) any later version. 73893 // 73894 // The GNU C Library is distributed in the hope that it will be useful, 73895 // but WITHOUT ANY WARRANTY; without even the implied warranty of 73896 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 73897 // Lesser General Public License for more details. 73898 // 73899 // You should have received a copy of the GNU Lesser General Public 73900 // License along with the GNU C Library; if not, see 73901 // <http://www.gnu.org/licenses/>. 73902 73903 // void assert (int expression); 73904 // 73905 // If NDEBUG is defined, do nothing. 73906 // If not, and EXPRESSION is zero, print an error message and abort. 73907 73908 // void assert_perror (int errnum); 73909 // 73910 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 73911 // error message with the error text for ERRNUM and abort. 73912 // (This is a GNU extension.) 73913 73914 // tcl.h -- 73915 // 73916 // This header file describes the externally-visible facilities of the 73917 // Tcl interpreter. 73918 // 73919 // Copyright (c) 1987-1994 The Regents of the University of California. 73920 // Copyright (c) 1993-1996 Lucent Technologies. 73921 // Copyright (c) 1994-1998 Sun Microsystems, Inc. 73922 // Copyright (c) 1998-2000 by Scriptics Corporation. 73923 // Copyright (c) 2002 by Kevin B. Kenny. All rights reserved. 73924 // 73925 // See the file "license.terms" for information on usage and redistribution of 73926 // this file, and for a DISCLAIMER OF ALL WARRANTIES. 73927 73928 // Local Variables: 73929 // mode: c 73930 // c-basic-offset: 4 73931 // fill-column: 78 73932 // End: 73933 73934 type Cube = Cube1 /* test_rtree.c:366:21 */ 73935 73936 func cube_context_free(tls *libc.TLS, p uintptr) { /* test_rtree.c:376:13: */ 73937 sqlite3.Xsqlite3_free(tls, p) 73938 } 73939 73940 // The context pointer registered along with the 'cube' callback is 73941 // always ((void *)&gHere). This is just to facilitate testing, it is not 73942 // actually used for anything. 73943 var gHere int32 = 42 /* test_rtree.c:385:12 */ 73944 73945 // Implementation of a simple r-tree geom callback to test for intersection 73946 // of r-tree rows with a "cube" shape. Cubes are defined by six scalar 73947 // coordinates as follows: 73948 // 73949 // cube(x, y, z, width, height, depth) 73950 // 73951 // The width, height and depth parameters must all be greater than zero. 73952 func cube_geom(tls *libc.TLS, p uintptr, nCoord int32, aCoord uintptr, piRes uintptr) int32 { /* test_rtree.c:396:12: */ 73953 var pCube uintptr = (*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FpUser 73954 73955 if pCube == uintptr(0) { 73956 if (((((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FnParam != 6) || (nCoord != 6)) || 73957 (*(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + 3*8)) <= 0.0)) || (*(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + 4*8)) <= 0.0)) || (*(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + 5*8)) <= 0.0) { 73958 return SQLITE_ERROR 73959 } 73960 pCube = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Cube{}))) 73961 if !(pCube != 0) { 73962 return SQLITE_NOMEM 73963 } 73964 (*Cube)(unsafe.Pointer(pCube)).Fx = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam)) 73965 (*Cube)(unsafe.Pointer(pCube)).Fy = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + 1*8)) 73966 (*Cube)(unsafe.Pointer(pCube)).Fz = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + 2*8)) 73967 (*Cube)(unsafe.Pointer(pCube)).Fwidth = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + 3*8)) 73968 (*Cube)(unsafe.Pointer(pCube)).Fheight = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + 4*8)) 73969 (*Cube)(unsafe.Pointer(pCube)).Fdepth = *(*sqlite3_rtree_dbl)(unsafe.Pointer((*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FaParam + 5*8)) 73970 73971 (*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FpUser = pCube 73972 (*sqlite3_rtree_geometry)(unsafe.Pointer(p)).FxDelUser = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{cube_context_free})) 73973 } 73974 73975 *(*int32)(unsafe.Pointer(piRes)) = 0 73976 if (((((*(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord)) <= ((*Cube)(unsafe.Pointer(pCube)).Fx + (*Cube)(unsafe.Pointer(pCube)).Fwidth)) && 73977 (*(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + 1*8)) >= (*Cube)(unsafe.Pointer(pCube)).Fx)) && 73978 (*(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + 2*8)) <= ((*Cube)(unsafe.Pointer(pCube)).Fy + (*Cube)(unsafe.Pointer(pCube)).Fheight))) && 73979 (*(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + 3*8)) >= (*Cube)(unsafe.Pointer(pCube)).Fy)) && 73980 (*(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + 4*8)) <= ((*Cube)(unsafe.Pointer(pCube)).Fz + (*Cube)(unsafe.Pointer(pCube)).Fdepth))) && 73981 (*(*sqlite3_rtree_dbl)(unsafe.Pointer(aCoord + 5*8)) >= (*Cube)(unsafe.Pointer(pCube)).Fz) { 73982 *(*int32)(unsafe.Pointer(piRes)) = 1 73983 } 73984 73985 return SQLITE_OK 73986 } 73987 73988 func register_cube_geom(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_rtree.c:443:26: */ 73989 bp := tls.Alloc(8) 73990 defer tls.Free(8) 73991 73992 // var db uintptr at bp, 8 73993 73994 var rc int32 73995 73996 if objc != 2 { 73997 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 73998 return TCL_ERROR 73999 } 74000 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 74001 return TCL_ERROR 74002 } 74003 rc = sqlite3.Xsqlite3_rtree_geometry_callback(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+35891 /* "cube" */, *(*uintptr)(unsafe.Pointer(&struct { 74004 f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 74005 }{cube_geom})), uintptr(unsafe.Pointer(&gHere))) 74006 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 74007 return TCL_OK 74008 } 74009 74010 func register_circle_geom(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_rtree.c:471:26: */ 74011 bp := tls.Alloc(8) 74012 defer tls.Free(8) 74013 74014 // var db uintptr at bp, 8 74015 74016 var rc int32 74017 74018 if objc != 2 { 74019 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 74020 return TCL_ERROR 74021 } 74022 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 74023 return TCL_ERROR 74024 } 74025 rc = sqlite3.Xsqlite3_rtree_geometry_callback(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+35896 /* "circle" */, *(*uintptr)(unsafe.Pointer(&struct { 74026 f func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32 74027 }{circle_geom})), uintptr(0)) 74028 if rc == SQLITE_OK { 74029 rc = sqlite3.Xsqlite3_rtree_query_callback(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+35903, /* "Qcircle" */ 74030 *(*uintptr)(unsafe.Pointer(&struct { 74031 f func(*libc.TLS, uintptr) int32 74032 }{circle_query_func})), uintptr(0), uintptr(0)) 74033 } 74034 if rc == SQLITE_OK { 74035 rc = sqlite3.Xsqlite3_rtree_query_callback(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+35911, /* "breadthfirstsear..." */ 74036 *(*uintptr)(unsafe.Pointer(&struct { 74037 f func(*libc.TLS, uintptr) int32 74038 }{bfs_query_func})), uintptr(0), uintptr(0)) 74039 } 74040 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 74041 return TCL_OK 74042 } 74043 74044 func Sqlitetestrtree_Init(tls *libc.TLS, interp uintptr) int32 { /* test_rtree.c:507:5: */ 74045 tcl.XTcl_CreateObjCommand(tls, interp, ts+35930 /* "register_cube_ge..." */, *(*uintptr)(unsafe.Pointer(&struct { 74046 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 74047 }{register_cube_geom})), uintptr(0), uintptr(0)) 74048 tcl.XTcl_CreateObjCommand(tls, interp, ts+35949 /* "register_circle_..." */, *(*uintptr)(unsafe.Pointer(&struct { 74049 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 74050 }{register_circle_geom})), uintptr(0), uintptr(0)) 74051 return TCL_OK 74052 } 74053 74054 // Some versions of <linux/posix_types.h> define this macros. 74055 // It's easier to assume 8-bit bytes than to get CHAR_BIT. 74056 74057 // fd_set for select and pselect. 74058 type fd_set5 = struct{ Ffds_bits [16]int64 } /* select.h:70:5 */ 74059 74060 // end block for C++ 74061 74062 // Local Variables: 74063 // mode: c 74064 // c-basic-offset: 4 74065 // fill-column: 78 74066 // End: 74067 74068 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 74069 // This file is part of the GNU C Library. 74070 // 74071 // The GNU C Library is free software; you can redistribute it and/or 74072 // modify it under the terms of the GNU Lesser General Public 74073 // License as published by the Free Software Foundation; either 74074 // version 2.1 of the License, or (at your option) any later version. 74075 // 74076 // The GNU C Library is distributed in the hope that it will be useful, 74077 // but WITHOUT ANY WARRANTY; without even the implied warranty of 74078 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 74079 // Lesser General Public License for more details. 74080 // 74081 // You should have received a copy of the GNU Lesser General Public 74082 // License along with the GNU C Library; if not, see 74083 // <http://www.gnu.org/licenses/>. 74084 74085 // ISO C99 Standard: 7.20 General utilities <stdlib.h> 74086 74087 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 74088 // This file is part of the GNU C Library. 74089 // 74090 // The GNU C Library is free software; you can redistribute it and/or 74091 // modify it under the terms of the GNU Lesser General Public 74092 // License as published by the Free Software Foundation; either 74093 // version 2.1 of the License, or (at your option) any later version. 74094 // 74095 // The GNU C Library is distributed in the hope that it will be useful, 74096 // but WITHOUT ANY WARRANTY; without even the implied warranty of 74097 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 74098 // Lesser General Public License for more details. 74099 // 74100 // You should have received a copy of the GNU Lesser General Public 74101 // License along with the GNU C Library; if not, see 74102 // <http://www.gnu.org/licenses/>. 74103 74104 // ISO C99 Standard: 7.21 String handling <string.h> 74105 74106 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 74107 // This file is part of the GNU C Library. 74108 // 74109 // The GNU C Library is free software; you can redistribute it and/or 74110 // modify it under the terms of the GNU Lesser General Public 74111 // License as published by the Free Software Foundation; either 74112 // version 2.1 of the License, or (at your option) any later version. 74113 // 74114 // The GNU C Library is distributed in the hope that it will be useful, 74115 // but WITHOUT ANY WARRANTY; without even the implied warranty of 74116 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 74117 // Lesser General Public License for more details. 74118 // 74119 // You should have received a copy of the GNU Lesser General Public 74120 // License along with the GNU C Library; if not, see 74121 // <http://www.gnu.org/licenses/>. 74122 74123 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 74124 74125 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 74126 // This file is part of the GNU C Library. 74127 // 74128 // The GNU C Library is free software; you can redistribute it and/or 74129 // modify it under the terms of the GNU Lesser General Public 74130 // License as published by the Free Software Foundation; either 74131 // version 2.1 of the License, or (at your option) any later version. 74132 // 74133 // The GNU C Library is distributed in the hope that it will be useful, 74134 // but WITHOUT ANY WARRANTY; without even the implied warranty of 74135 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 74136 // Lesser General Public License for more details. 74137 // 74138 // You should have received a copy of the GNU Lesser General Public 74139 // License along with the GNU C Library; if not, see 74140 // <http://www.gnu.org/licenses/>. 74141 74142 // void assert (int expression); 74143 // 74144 // If NDEBUG is defined, do nothing. 74145 // If not, and EXPRESSION is zero, print an error message and abort. 74146 74147 // void assert_perror (int errnum); 74148 // 74149 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 74150 // error message with the error text for ERRNUM and abort. 74151 // (This is a GNU extension.) 74152 74153 type schema_vtab1 = struct { 74154 Fbase sqlite3_vtab 74155 Fdb uintptr 74156 } /* test_schema.c:53:9 */ 74157 74158 // end block for C++ 74159 74160 // Local Variables: 74161 // mode: c 74162 // c-basic-offset: 4 74163 // fill-column: 78 74164 // End: 74165 74166 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 74167 // This file is part of the GNU C Library. 74168 // 74169 // The GNU C Library is free software; you can redistribute it and/or 74170 // modify it under the terms of the GNU Lesser General Public 74171 // License as published by the Free Software Foundation; either 74172 // version 2.1 of the License, or (at your option) any later version. 74173 // 74174 // The GNU C Library is distributed in the hope that it will be useful, 74175 // but WITHOUT ANY WARRANTY; without even the implied warranty of 74176 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 74177 // Lesser General Public License for more details. 74178 // 74179 // You should have received a copy of the GNU Lesser General Public 74180 // License along with the GNU C Library; if not, see 74181 // <http://www.gnu.org/licenses/>. 74182 74183 // ISO C99 Standard: 7.20 General utilities <stdlib.h> 74184 74185 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 74186 // This file is part of the GNU C Library. 74187 // 74188 // The GNU C Library is free software; you can redistribute it and/or 74189 // modify it under the terms of the GNU Lesser General Public 74190 // License as published by the Free Software Foundation; either 74191 // version 2.1 of the License, or (at your option) any later version. 74192 // 74193 // The GNU C Library is distributed in the hope that it will be useful, 74194 // but WITHOUT ANY WARRANTY; without even the implied warranty of 74195 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 74196 // Lesser General Public License for more details. 74197 // 74198 // You should have received a copy of the GNU Lesser General Public 74199 // License along with the GNU C Library; if not, see 74200 // <http://www.gnu.org/licenses/>. 74201 74202 // ISO C99 Standard: 7.21 String handling <string.h> 74203 74204 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 74205 // This file is part of the GNU C Library. 74206 // 74207 // The GNU C Library is free software; you can redistribute it and/or 74208 // modify it under the terms of the GNU Lesser General Public 74209 // License as published by the Free Software Foundation; either 74210 // version 2.1 of the License, or (at your option) any later version. 74211 // 74212 // The GNU C Library is distributed in the hope that it will be useful, 74213 // but WITHOUT ANY WARRANTY; without even the implied warranty of 74214 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 74215 // Lesser General Public License for more details. 74216 // 74217 // You should have received a copy of the GNU Lesser General Public 74218 // License along with the GNU C Library; if not, see 74219 // <http://www.gnu.org/licenses/>. 74220 74221 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 74222 74223 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 74224 // This file is part of the GNU C Library. 74225 // 74226 // The GNU C Library is free software; you can redistribute it and/or 74227 // modify it under the terms of the GNU Lesser General Public 74228 // License as published by the Free Software Foundation; either 74229 // version 2.1 of the License, or (at your option) any later version. 74230 // 74231 // The GNU C Library is distributed in the hope that it will be useful, 74232 // but WITHOUT ANY WARRANTY; without even the implied warranty of 74233 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 74234 // Lesser General Public License for more details. 74235 // 74236 // You should have received a copy of the GNU Lesser General Public 74237 // License along with the GNU C Library; if not, see 74238 // <http://www.gnu.org/licenses/>. 74239 74240 // void assert (int expression); 74241 // 74242 // If NDEBUG is defined, do nothing. 74243 // If not, and EXPRESSION is zero, print an error message and abort. 74244 74245 // void assert_perror (int errnum); 74246 // 74247 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 74248 // error message with the error text for ERRNUM and abort. 74249 // (This is a GNU extension.) 74250 74251 type schema_vtab = schema_vtab1 /* test_schema.c:53:28 */ 74252 type schema_cursor1 = struct { 74253 Fbase sqlite3_vtab_cursor 74254 FpDbList uintptr 74255 FpTableList uintptr 74256 FpColumnList uintptr 74257 Frowid int32 74258 _ [4]byte 74259 } /* test_schema.c:54:9 */ 74260 74261 type schema_cursor = schema_cursor1 /* test_schema.c:54:30 */ 74262 74263 // None of this works unless we have virtual tables. 74264 74265 // Table destructor for the schema module. 74266 func schemaDestroy(tls *libc.TLS, pVtab uintptr) int32 { /* test_schema.c:79:12: */ 74267 sqlite3.Xsqlite3_free(tls, pVtab) 74268 return 0 74269 } 74270 74271 // Table constructor for the schema module. 74272 func schemaCreate(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* test_schema.c:87:12: */ 74273 var rc int32 = SQLITE_NOMEM 74274 var pVtab uintptr = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(schema_vtab{}))) 74275 if pVtab != 0 { 74276 libc.Xmemset(tls, pVtab, 0, uint64(unsafe.Sizeof(schema_vtab{}))) 74277 (*schema_vtab)(unsafe.Pointer(pVtab)).Fdb = db 74278 rc = sqlite3.Xsqlite3_declare_vtab(tls, db /* Name of database (i.e. main, temp etc.) */ /* Name of table */ /* Column number (from left-to-right, 0 upward) */ /* Column name */ /* Specified type (i.e. VARCHAR(32)) */ /* Boolean. True if NOT NULL was specified */ /* Default value for this column */ /* True if this column is part of the primary key */, ts+35970 /* "CREATE TABLE x(d..." */) 74279 } 74280 *(*uintptr)(unsafe.Pointer(ppVtab)) = pVtab 74281 return rc 74282 } 74283 74284 // Open a new cursor on the schema table. 74285 func schemaOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* test_schema.c:110:12: */ 74286 var rc int32 = SQLITE_NOMEM 74287 var pCur uintptr 74288 pCur = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(schema_cursor{}))) 74289 if pCur != 0 { 74290 libc.Xmemset(tls, pCur, 0, uint64(unsafe.Sizeof(schema_cursor{}))) 74291 *(*uintptr)(unsafe.Pointer(ppCursor)) = pCur 74292 rc = SQLITE_OK 74293 } 74294 return rc 74295 } 74296 74297 // Close a schema table cursor. 74298 func schemaClose(tls *libc.TLS, cur uintptr) int32 { /* test_schema.c:125:12: */ 74299 var pCur uintptr = cur 74300 sqlite3.Xsqlite3_finalize(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpDbList) 74301 sqlite3.Xsqlite3_finalize(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpTableList) 74302 sqlite3.Xsqlite3_finalize(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpColumnList) 74303 sqlite3.Xsqlite3_free(tls, pCur) 74304 return SQLITE_OK 74305 } 74306 74307 // Retrieve a column of data. 74308 func schemaColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* test_schema.c:137:12: */ 74309 var pCur uintptr = cur 74310 switch i { 74311 case 0: 74312 sqlite3.Xsqlite3_result_value(tls, ctx, sqlite3.Xsqlite3_column_value(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpDbList, 1)) 74313 break 74314 case 1: 74315 sqlite3.Xsqlite3_result_value(tls, ctx, sqlite3.Xsqlite3_column_value(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpTableList, 0)) 74316 break 74317 default: 74318 sqlite3.Xsqlite3_result_value(tls, ctx, sqlite3.Xsqlite3_column_value(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpColumnList, (i-2))) 74319 break 74320 } 74321 return SQLITE_OK 74322 } 74323 74324 // Retrieve the current rowid. 74325 func schemaRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* test_schema.c:156:12: */ 74326 var pCur uintptr = cur 74327 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = sqlite_int64((*schema_cursor)(unsafe.Pointer(pCur)).Frowid) 74328 return SQLITE_OK 74329 } 74330 74331 func finalize(tls *libc.TLS, ppStmt uintptr) int32 { /* test_schema.c:162:12: */ 74332 var rc int32 = sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(ppStmt))) 74333 *(*uintptr)(unsafe.Pointer(ppStmt)) = uintptr(0) 74334 return rc 74335 } 74336 74337 func schemaEof(tls *libc.TLS, cur uintptr) int32 { /* test_schema.c:168:12: */ 74338 var pCur uintptr = cur 74339 return func() int32 { 74340 if (*schema_cursor)(unsafe.Pointer(pCur)).FpDbList != 0 { 74341 return 0 74342 } 74343 return 1 74344 }() 74345 } 74346 74347 // Advance the cursor to the next row. 74348 func schemaNext(tls *libc.TLS, cur uintptr) int32 { /* test_schema.c:176:12: */ 74349 bp := tls.Alloc(24) 74350 defer tls.Free(24) 74351 74352 var rc int32 74353 var pCur uintptr 74354 var pVtab uintptr 74355 var zSql uintptr 74356 var pDbList uintptr 74357 rc = SQLITE_OK 74358 pCur = cur 74359 pVtab = (*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab 74360 zSql = uintptr(0) 74361 74362 __1: 74363 if !(!(int32((*schema_cursor)(unsafe.Pointer(pCur)).FpColumnList) != 0) || (SQLITE_ROW != sqlite3.Xsqlite3_step(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpColumnList))) { 74364 goto __2 74365 } 74366 if !(SQLITE_OK != (libc.AssignInt32(&rc, finalize(tls, (pCur+24 /* &.pColumnList */))))) { 74367 goto __3 74368 } 74369 goto next_exit 74370 __3: 74371 ; 74372 74373 __4: 74374 if !(!(int32((*schema_cursor)(unsafe.Pointer(pCur)).FpTableList) != 0) || (SQLITE_ROW != sqlite3.Xsqlite3_step(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpTableList))) { 74375 goto __5 74376 } 74377 if !(SQLITE_OK != (libc.AssignInt32(&rc, finalize(tls, (pCur+16 /* &.pTableList */))))) { 74378 goto __6 74379 } 74380 goto next_exit 74381 __6: 74382 ; 74383 74384 __7: 74385 if !(SQLITE_ROW != sqlite3.Xsqlite3_step(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpDbList)) { 74386 goto __8 74387 } 74388 rc = finalize(tls, (pCur + 8 /* &.pDbList */)) 74389 goto next_exit 74390 goto __7 74391 __8: 74392 ; 74393 74394 // Set zSql to the SQL to pull the list of tables from the 74395 // sqlite_schema (or sqlite_temp_schema) table of the database 74396 // identified by the row pointed to by the SQL statement pCur->pDbList 74397 // (iterating through a "PRAGMA database_list;" statement). 74398 if !(sqlite3.Xsqlite3_column_int(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpDbList, 0) == 1) { 74399 goto __9 74400 } 74401 zSql = sqlite3.Xsqlite3_mprintf(tls, 74402 ts+36042 /* "SELECT name FROM..." */, 0) 74403 goto __10 74404 __9: 74405 pDbList = (*schema_cursor)(unsafe.Pointer(pCur)).FpDbList 74406 zSql = sqlite3.Xsqlite3_mprintf(tls, 74407 ts+36097, /* "SELECT name FROM..." */ 74408 libc.VaList(bp, sqlite3.Xsqlite3_column_text(tls, pDbList, 1))) 74409 __10: 74410 ; 74411 if !(!(zSql != 0)) { 74412 goto __11 74413 } 74414 rc = SQLITE_NOMEM 74415 goto next_exit 74416 __11: 74417 ; 74418 74419 rc = sqlite3.Xsqlite3_prepare(tls, (*schema_vtab)(unsafe.Pointer(pVtab)).Fdb, zSql, -1, (pCur + 16 /* &.pTableList */), uintptr(0)) 74420 sqlite3.Xsqlite3_free(tls, zSql) 74421 if !(rc != SQLITE_OK) { 74422 goto __12 74423 } 74424 goto next_exit 74425 __12: 74426 ; 74427 goto __4 74428 __5: 74429 ; 74430 74431 // Set zSql to the SQL to the table_info pragma for the table currently 74432 // identified by the rows pointed to by statements pCur->pDbList and 74433 // pCur->pTableList. 74434 zSql = sqlite3.Xsqlite3_mprintf(tls, ts+36150, /* "PRAGMA %Q.table_..." */ 74435 libc.VaList(bp+8, sqlite3.Xsqlite3_column_text(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpDbList, 1), 74436 sqlite3.Xsqlite3_column_text(tls, (*schema_cursor)(unsafe.Pointer(pCur)).FpTableList, 0))) 74437 74438 if !(!(zSql != 0)) { 74439 goto __13 74440 } 74441 rc = SQLITE_NOMEM 74442 goto next_exit 74443 __13: 74444 ; 74445 rc = sqlite3.Xsqlite3_prepare(tls, (*schema_vtab)(unsafe.Pointer(pVtab)).Fdb, zSql, -1, (pCur + 24 /* &.pColumnList */), uintptr(0)) 74446 sqlite3.Xsqlite3_free(tls, zSql) 74447 if !(rc != SQLITE_OK) { 74448 goto __14 74449 } 74450 goto next_exit 74451 __14: 74452 ; 74453 goto __1 74454 __2: 74455 ; 74456 (*schema_cursor)(unsafe.Pointer(pCur)).Frowid++ 74457 74458 next_exit: 74459 // TODO: Handle rc 74460 return rc 74461 } 74462 74463 // Reset a schema table cursor. 74464 func schemaFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* test_schema.c:247:12: */ 74465 var rc int32 74466 var pVtab uintptr = (*sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab 74467 var pCur uintptr = pVtabCursor 74468 (*schema_cursor)(unsafe.Pointer(pCur)).Frowid = 0 74469 finalize(tls, (pCur + 16 /* &.pTableList */)) 74470 finalize(tls, (pCur + 24 /* &.pColumnList */)) 74471 finalize(tls, (pCur + 8 /* &.pDbList */)) 74472 rc = sqlite3.Xsqlite3_prepare(tls, (*schema_vtab)(unsafe.Pointer(pVtab)).Fdb, ts+36175 /* "PRAGMA database_..." */, -1, (pCur + 8 /* &.pDbList */), uintptr(0)) 74473 return func() int32 { 74474 if rc == SQLITE_OK { 74475 return schemaNext(tls, pVtabCursor) 74476 } 74477 return rc 74478 }() 74479 } 74480 74481 // Analyse the WHERE condition. 74482 func schemaBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_schema.c:266:12: */ 74483 return SQLITE_OK 74484 } 74485 74486 // A virtual table module that merely echos method calls into TCL 74487 // variables. 74488 var schemaModule = sqlite3_module{ // iVersion 74489 FxCreate: 0, 74490 FxConnect: 0, 74491 FxBestIndex: 0, 74492 FxDisconnect: 0, 74493 FxDestroy: 0, 74494 FxOpen: 0, // xOpen - open a cursor 74495 FxClose: 0, // xClose - close a cursor 74496 FxFilter: 0, // xFilter - configure scan constraints 74497 FxNext: 0, // xNext - advance a cursor 74498 FxEof: 0, // xEof 74499 FxColumn: 0, // xColumn - read data 74500 FxRowid: 0, // xRename 74501 } /* test_schema.c:274:23 */ 74502 74503 // Register the schema virtual table module. 74504 func register_schema_module(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_schema.c:309:26: */ 74505 bp := tls.Alloc(8) 74506 defer tls.Free(8) 74507 74508 // var db uintptr at bp, 8 74509 74510 if objc != 2 { 74511 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 74512 return TCL_ERROR 74513 } 74514 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 74515 return TCL_ERROR 74516 } 74517 sqlite3.Xsqlite3_create_module(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+4679 /* "schema" */, uintptr(unsafe.Pointer(&schemaModule)), uintptr(0)) 74518 return TCL_OK 74519 } 74520 74521 // Register commands with the TCL interpreter. 74522 func Sqlitetestschema_Init(tls *libc.TLS, interp uintptr) int32 { /* test_schema.c:330:5: */ 74523 var i int32 74524 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aObjCmd12)) / uint64(unsafe.Sizeof(struct { 74525 FzName uintptr 74526 FxProc uintptr 74527 FclientData uintptr 74528 }{}))); i++ { 74529 tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd12[i].FzName, 74530 aObjCmd12[i].FxProc, aObjCmd12[i].FclientData, uintptr(0)) 74531 } 74532 return TCL_OK 74533 } 74534 74535 var aObjCmd12 = [1]struct { 74536 FzName uintptr 74537 FxProc uintptr 74538 FclientData uintptr 74539 }{ 74540 {FzName: ts + 36196 /* "register_schema_..." */, FxProc: 0}, 74541 } /* test_schema.c:335:5 */ 74542 74543 // 2001-09-15 74544 // 74545 // The author disclaims copyright to this source code. In place of 74546 // a legal notice, here is a blessing: 74547 // 74548 // May you do good and not evil. 74549 // May you find forgiveness for yourself and forgive others. 74550 // May you share freely, never taking more than you give. 74551 // 74552 // 74553 // This header file defines the interface that the SQLite library 74554 // presents to client programs. If a C-function, structure, datatype, 74555 // or constant definition does not appear in this file, then it is 74556 // not a published API of SQLite, is subject to change without 74557 // notice, and should not be referenced by programs that use SQLite. 74558 // 74559 // Some of the definitions that are in this file are marked as 74560 // "experimental". Experimental interfaces are normally new 74561 // features recently added to SQLite. We do not anticipate changes 74562 // to experimental interfaces but reserve the right to make minor changes 74563 // if experience from use "in the wild" suggest such changes are prudent. 74564 // 74565 // The official C-language API documentation for SQLite is derived 74566 // from comments in this file. This file is the authoritative source 74567 // on how SQLite interfaces are supposed to operate. 74568 // 74569 // The name of this file under configuration management is "sqlite.h.in". 74570 // The makefile makes some minor changes to this file (such as inserting 74571 // the version number) and changes its name to "sqlite3.h" as 74572 // part of the build process. 74573 74574 //******* Begin file sqlite3rtree.h ******** 74575 // 2010 August 30 74576 // 74577 // The author disclaims copyright to this source code. In place of 74578 // a legal notice, here is a blessing: 74579 // 74580 // May you do good and not evil. 74581 // May you find forgiveness for yourself and forgive others. 74582 // May you share freely, never taking more than you give. 74583 // 74584 // 74585 74586 //******* End of sqlite3rtree.h ******** 74587 //******* Begin file sqlite3session.h ******** 74588 74589 //******* End of sqlite3session.h ******** 74590 //******* Begin file fts5.h ******** 74591 // 2014 May 31 74592 // 74593 // The author disclaims copyright to this source code. In place of 74594 // a legal notice, here is a blessing: 74595 // 74596 // May you do good and not evil. 74597 // May you find forgiveness for yourself and forgive others. 74598 // May you share freely, never taking more than you give. 74599 // 74600 // 74601 // 74602 // Interfaces to extend FTS5. Using the interfaces defined in this file, 74603 // FTS5 may be extended with: 74604 // 74605 // * custom tokenizers, and 74606 // * custom auxiliary functions. 74607 74608 //******* End of fts5.h ******** 74609 74610 // Messages are passed from client to server and back again as 74611 // instances of the following structure. 74612 type SqlMessage1 = struct { 74613 Fop int32 74614 _ [4]byte 74615 FpDb uintptr 74616 FpStmt uintptr 74617 FerrCode int32 74618 _ [4]byte 74619 FzIn uintptr 74620 FnByte int32 74621 _ [4]byte 74622 FzOut uintptr 74623 FpNext uintptr 74624 FpPrev uintptr 74625 FclientMutex pthread_mutex_t 74626 FclientWakeup pthread_cond_t 74627 } /* test_server.c:221:9 */ 74628 74629 // 2001-09-15 74630 // 74631 // The author disclaims copyright to this source code. In place of 74632 // a legal notice, here is a blessing: 74633 // 74634 // May you do good and not evil. 74635 // May you find forgiveness for yourself and forgive others. 74636 // May you share freely, never taking more than you give. 74637 // 74638 // 74639 // This header file defines the interface that the SQLite library 74640 // presents to client programs. If a C-function, structure, datatype, 74641 // or constant definition does not appear in this file, then it is 74642 // not a published API of SQLite, is subject to change without 74643 // notice, and should not be referenced by programs that use SQLite. 74644 // 74645 // Some of the definitions that are in this file are marked as 74646 // "experimental". Experimental interfaces are normally new 74647 // features recently added to SQLite. We do not anticipate changes 74648 // to experimental interfaces but reserve the right to make minor changes 74649 // if experience from use "in the wild" suggest such changes are prudent. 74650 // 74651 // The official C-language API documentation for SQLite is derived 74652 // from comments in this file. This file is the authoritative source 74653 // on how SQLite interfaces are supposed to operate. 74654 // 74655 // The name of this file under configuration management is "sqlite.h.in". 74656 // The makefile makes some minor changes to this file (such as inserting 74657 // the version number) and changes its name to "sqlite3.h" as 74658 // part of the build process. 74659 74660 //******* Begin file sqlite3rtree.h ******** 74661 // 2010 August 30 74662 // 74663 // The author disclaims copyright to this source code. In place of 74664 // a legal notice, here is a blessing: 74665 // 74666 // May you do good and not evil. 74667 // May you find forgiveness for yourself and forgive others. 74668 // May you share freely, never taking more than you give. 74669 // 74670 // 74671 74672 //******* End of sqlite3rtree.h ******** 74673 //******* Begin file sqlite3session.h ******** 74674 74675 //******* End of sqlite3session.h ******** 74676 //******* Begin file fts5.h ******** 74677 // 2014 May 31 74678 // 74679 // The author disclaims copyright to this source code. In place of 74680 // a legal notice, here is a blessing: 74681 // 74682 // May you do good and not evil. 74683 // May you find forgiveness for yourself and forgive others. 74684 // May you share freely, never taking more than you give. 74685 // 74686 // 74687 // 74688 // Interfaces to extend FTS5. Using the interfaces defined in this file, 74689 // FTS5 may be extended with: 74690 // 74691 // * custom tokenizers, and 74692 // * custom auxiliary functions. 74693 74694 //******* End of fts5.h ******** 74695 74696 // Messages are passed from client to server and back again as 74697 // instances of the following structure. 74698 type SqlMessage = SqlMessage1 /* test_server.c:221:27 */ 74699 74700 // Legal values for SqlMessage.op 74701 74702 // State information about the server is stored in a static variable 74703 // named "g" as follows: 74704 type ServerState = struct { 74705 FqueueMutex pthread_mutex_t 74706 FserverMutex pthread_mutex_t 74707 FserverWakeup pthread_cond_t 74708 FserverHalt int32 74709 _ [4]byte 74710 FpQueueHead uintptr 74711 FpQueueTail uintptr 74712 } /* test_server.c:252:8 */ 74713 74714 // Legal values for SqlMessage.op 74715 74716 // State information about the server is stored in a static variable 74717 // named "g" as follows: 74718 var g4 = ServerState{} /* test_server.c:259:3 */ 74719 74720 // Send a message to the server. Block until we get a reply. 74721 // 74722 // The mutex and condition variable in the message are uninitialized 74723 // when this routine is called. This routine takes care of 74724 // initializing them and destroying them when it has finished. 74725 func sendToServer(tls *libc.TLS, pMsg uintptr) { /* test_server.c:272:13: */ 74726 // Initialize the mutex and condition variable on the message 74727 libc2.Xpthread_mutex_init(tls, (pMsg + 72 /* &.clientMutex */), uintptr(0)) 74728 libc2.Xpthread_cond_init(tls, (pMsg + 112 /* &.clientWakeup */), uintptr(0)) 74729 74730 // Add the message to the head of the server's message queue. 74731 libc2.Xpthread_mutex_lock(tls, (uintptr(unsafe.Pointer(&g4)) /* &.queueMutex */)) 74732 (*SqlMessage)(unsafe.Pointer(pMsg)).FpNext = g4.FpQueueHead 74733 if g4.FpQueueHead == uintptr(0) { 74734 g4.FpQueueTail = pMsg 74735 } else { 74736 (*SqlMessage)(unsafe.Pointer(g4.FpQueueHead)).FpPrev = pMsg 74737 } 74738 (*SqlMessage)(unsafe.Pointer(pMsg)).FpPrev = uintptr(0) 74739 g4.FpQueueHead = pMsg 74740 libc2.Xpthread_mutex_unlock(tls, (uintptr(unsafe.Pointer(&g4)) /* &.queueMutex */)) 74741 74742 // Signal the server that the new message has be queued, then 74743 // block waiting for the server to process the message. 74744 libc2.Xpthread_mutex_lock(tls, (pMsg + 72 /* &.clientMutex */)) 74745 libc2.Xpthread_cond_signal(tls, (uintptr(unsafe.Pointer(&g4)) + 80 /* &.serverWakeup */)) 74746 for (*SqlMessage)(unsafe.Pointer(pMsg)).Fop != MSG_Done { 74747 libc2.Xpthread_cond_wait(tls, (pMsg + 112 /* &.clientWakeup */), (pMsg + 72 /* &.clientMutex */)) 74748 } 74749 libc2.Xpthread_mutex_unlock(tls, (pMsg + 72 /* &.clientMutex */)) 74750 74751 // Destroy the mutex and condition variable of the message. 74752 libc2.Xpthread_mutex_destroy(tls, (pMsg + 72 /* &.clientMutex */)) 74753 libc2.Xpthread_cond_destroy(tls, (pMsg + 112 /* &.clientWakeup */)) 74754 } 74755 74756 // The following 6 routines are client-side implementations of the 74757 // core SQLite interfaces: 74758 // 74759 // sqlite3_open 74760 // sqlite3_prepare 74761 // sqlite3_step 74762 // sqlite3_reset 74763 // sqlite3_finalize 74764 // sqlite3_close 74765 // 74766 // Clients should use the following client-side routines instead of 74767 // the core routines above. 74768 // 74769 // sqlite3_client_open 74770 // sqlite3_client_prepare 74771 // sqlite3_client_step 74772 // sqlite3_client_reset 74773 // sqlite3_client_finalize 74774 // sqlite3_client_close 74775 // 74776 // Each of these routines creates a message for the desired operation, 74777 // sends that message to the server, waits for the server to process 74778 // then message and return a response. 74779 func sqlite3_client_open(tls *libc.TLS, zDatabaseName uintptr, ppDb uintptr) int32 { /* test_server.c:332:5: */ 74780 bp := tls.Alloc(160) 74781 defer tls.Free(160) 74782 74783 // var msg SqlMessage at bp, 160 74784 74785 (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).Fop = MSG_Open 74786 (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FzIn = zDatabaseName 74787 sendToServer(tls, bp /* &msg */) 74788 *(*uintptr)(unsafe.Pointer(ppDb)) = (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FpDb 74789 return (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FerrCode 74790 } 74791 74792 func sqlite3_client_prepare(tls *libc.TLS, pDb uintptr, zSql uintptr, nByte int32, ppStmt uintptr, pzTail uintptr) int32 { /* test_server.c:340:5: */ 74793 bp := tls.Alloc(160) 74794 defer tls.Free(160) 74795 74796 // var msg SqlMessage at bp, 160 74797 74798 (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).Fop = MSG_Prepare 74799 (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FpDb = pDb 74800 (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FzIn = zSql 74801 (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FnByte = nByte 74802 sendToServer(tls, bp /* &msg */) 74803 *(*uintptr)(unsafe.Pointer(ppStmt)) = (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FpStmt 74804 if pzTail != 0 { 74805 *(*uintptr)(unsafe.Pointer(pzTail)) = (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FzOut 74806 } 74807 return (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FerrCode 74808 } 74809 74810 func sqlite3_client_step(tls *libc.TLS, pStmt uintptr) int32 { /* test_server.c:357:5: */ 74811 bp := tls.Alloc(160) 74812 defer tls.Free(160) 74813 74814 // var msg SqlMessage at bp, 160 74815 74816 (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).Fop = MSG_Step 74817 (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FpStmt = pStmt 74818 sendToServer(tls, bp /* &msg */) 74819 return (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FerrCode 74820 } 74821 74822 func sqlite3_client_reset(tls *libc.TLS, pStmt uintptr) int32 { /* test_server.c:364:5: */ 74823 bp := tls.Alloc(160) 74824 defer tls.Free(160) 74825 74826 // var msg SqlMessage at bp, 160 74827 74828 (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).Fop = MSG_Reset 74829 (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FpStmt = pStmt 74830 sendToServer(tls, bp /* &msg */) 74831 return (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FerrCode 74832 } 74833 74834 func sqlite3_client_finalize(tls *libc.TLS, pStmt uintptr) int32 { /* test_server.c:371:5: */ 74835 bp := tls.Alloc(160) 74836 defer tls.Free(160) 74837 74838 // var msg SqlMessage at bp, 160 74839 74840 (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).Fop = MSG_Finalize 74841 (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FpStmt = pStmt 74842 sendToServer(tls, bp /* &msg */) 74843 return (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FerrCode 74844 } 74845 74846 func sqlite3_client_close(tls *libc.TLS, pDb uintptr) int32 { /* test_server.c:378:5: */ 74847 bp := tls.Alloc(160) 74848 defer tls.Free(160) 74849 74850 // var msg SqlMessage at bp, 160 74851 74852 (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).Fop = MSG_Close 74853 (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FpDb = pDb 74854 sendToServer(tls, bp /* &msg */) 74855 return (*SqlMessage)(unsafe.Pointer(bp /* &msg */)).FerrCode 74856 } 74857 74858 // This routine implements the server. To start the server, first 74859 // make sure g.serverHalt is false, then create a new detached thread 74860 // on this procedure. See the sqlite3_server_start() routine below 74861 // for an example. This procedure loops until g.serverHalt becomes 74862 // true. 74863 func sqlite3_server(tls *libc.TLS, NotUsed uintptr) uintptr { /* test_server.c:393:6: */ 74864 if libc2.Xpthread_mutex_trylock(tls, (uintptr(unsafe.Pointer(&g4))+40 /* &.serverMutex */)) != 0 { 74865 return uintptr(0) // Another server is already running 74866 } 74867 sqlite3.Xsqlite3_enable_shared_cache(tls, 1) 74868 for !(g4.FserverHalt != 0) { 74869 var pMsg uintptr 74870 74871 // Remove the last message from the message queue. 74872 libc2.Xpthread_mutex_lock(tls, (uintptr(unsafe.Pointer(&g4)) /* &.queueMutex */)) 74873 for (g4.FpQueueTail == uintptr(0)) && (g4.FserverHalt == 0) { 74874 libc2.Xpthread_cond_wait(tls, (uintptr(unsafe.Pointer(&g4)) + 80 /* &.serverWakeup */), (uintptr(unsafe.Pointer(&g4)) /* &.queueMutex */)) 74875 } 74876 pMsg = g4.FpQueueTail 74877 if pMsg != 0 { 74878 if (*SqlMessage)(unsafe.Pointer(pMsg)).FpPrev != 0 { 74879 (*SqlMessage)(unsafe.Pointer((*SqlMessage)(unsafe.Pointer(pMsg)).FpPrev)).FpNext = uintptr(0) 74880 } else { 74881 g4.FpQueueHead = uintptr(0) 74882 } 74883 g4.FpQueueTail = (*SqlMessage)(unsafe.Pointer(pMsg)).FpPrev 74884 } 74885 libc2.Xpthread_mutex_unlock(tls, (uintptr(unsafe.Pointer(&g4)) /* &.queueMutex */)) 74886 if pMsg == uintptr(0) { 74887 break 74888 } 74889 74890 // Process the message just removed 74891 libc2.Xpthread_mutex_lock(tls, (pMsg + 72 /* &.clientMutex */)) 74892 switch (*SqlMessage)(unsafe.Pointer(pMsg)).Fop { 74893 case MSG_Open: 74894 { 74895 (*SqlMessage)(unsafe.Pointer(pMsg)).FerrCode = sqlite3.Xsqlite3_open(tls, (*SqlMessage)(unsafe.Pointer(pMsg)).FzIn, (pMsg + 8 /* &.pDb */)) 74896 break 74897 74898 } 74899 case MSG_Prepare: 74900 { 74901 (*SqlMessage)(unsafe.Pointer(pMsg)).FerrCode = sqlite3.Xsqlite3_prepare(tls, (*SqlMessage)(unsafe.Pointer(pMsg)).FpDb, (*SqlMessage)(unsafe.Pointer(pMsg)).FzIn, (*SqlMessage)(unsafe.Pointer(pMsg)).FnByte, 74902 (pMsg + 16 /* &.pStmt */), (pMsg + 48 /* &.zOut */)) 74903 break 74904 74905 } 74906 case MSG_Step: 74907 { 74908 (*SqlMessage)(unsafe.Pointer(pMsg)).FerrCode = sqlite3.Xsqlite3_step(tls, (*SqlMessage)(unsafe.Pointer(pMsg)).FpStmt) 74909 break 74910 74911 } 74912 case MSG_Reset: 74913 { 74914 (*SqlMessage)(unsafe.Pointer(pMsg)).FerrCode = sqlite3.Xsqlite3_reset(tls, (*SqlMessage)(unsafe.Pointer(pMsg)).FpStmt) 74915 break 74916 74917 } 74918 case MSG_Finalize: 74919 { 74920 (*SqlMessage)(unsafe.Pointer(pMsg)).FerrCode = sqlite3.Xsqlite3_finalize(tls, (*SqlMessage)(unsafe.Pointer(pMsg)).FpStmt) 74921 break 74922 74923 } 74924 case MSG_Close: 74925 { 74926 (*SqlMessage)(unsafe.Pointer(pMsg)).FerrCode = sqlite3.Xsqlite3_close(tls, (*SqlMessage)(unsafe.Pointer(pMsg)).FpDb) 74927 break 74928 74929 } 74930 } 74931 74932 // Signal the client that the message has been processed. 74933 (*SqlMessage)(unsafe.Pointer(pMsg)).Fop = MSG_Done 74934 libc2.Xpthread_mutex_unlock(tls, (pMsg + 72 /* &.clientMutex */)) 74935 libc2.Xpthread_cond_signal(tls, (pMsg + 112 /* &.clientWakeup */)) 74936 } 74937 libc2.Xpthread_mutex_unlock(tls, (uintptr(unsafe.Pointer(&g4)) + 40 /* &.serverMutex */)) 74938 return uintptr(0) 74939 } 74940 74941 // Start a server thread if one is not already running. If there 74942 // is aleady a server thread running, the new thread will quickly 74943 // die and this routine is effectively a no-op. 74944 func sqlite3_server_start(tls *libc.TLS) { /* test_server.c:465:6: */ 74945 bp := tls.Alloc(8) 74946 defer tls.Free(8) 74947 74948 // var x pthread_t at bp, 8 74949 74950 var rc int32 74951 g4.FserverHalt = 0 74952 rc = libc2.Xpthread_create(tls, bp /* &x */, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 74953 f func(*libc.TLS, uintptr) uintptr 74954 }{sqlite3_server})), uintptr(0)) 74955 if rc == 0 { 74956 libc2.Xpthread_detach(tls, *(*pthread_t)(unsafe.Pointer(bp /* x */))) 74957 } 74958 } 74959 74960 // A wrapper around sqlite3_server() that decrements the int variable 74961 // pointed to by the first argument after the sqlite3_server() call 74962 // returns. 74963 func serverWrapper(tls *libc.TLS, pnDecr uintptr) uintptr { /* test_server.c:480:13: */ 74964 var p uintptr = sqlite3_server(tls, uintptr(0)) 74965 (*(*int32)(unsafe.Pointer(pnDecr)))-- 74966 return p 74967 } 74968 74969 // This function is the similar to sqlite3_server_start(), except that 74970 // the integer pointed to by the first argument is decremented when 74971 // the server thread exits. 74972 func sqlite3_server_start2(tls *libc.TLS, pnDecr uintptr) { /* test_server.c:491:6: */ 74973 bp := tls.Alloc(8) 74974 defer tls.Free(8) 74975 74976 // var x pthread_t at bp, 8 74977 74978 var rc int32 74979 g4.FserverHalt = 0 74980 rc = libc2.Xpthread_create(tls, bp /* &x */, uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 74981 f func(*libc.TLS, uintptr) uintptr 74982 }{serverWrapper})), pnDecr) 74983 if rc == 0 { 74984 libc2.Xpthread_detach(tls, *(*pthread_t)(unsafe.Pointer(bp /* x */))) 74985 } 74986 } 74987 74988 // If a server thread is running, then stop it. If no server is 74989 // running, this routine is effectively a no-op. 74990 // 74991 // This routine waits until the server has actually stopped before 74992 // returning. 74993 func sqlite3_server_stop(tls *libc.TLS) { /* test_server.c:508:6: */ 74994 g4.FserverHalt = 1 74995 libc2.Xpthread_cond_broadcast(tls, (uintptr(unsafe.Pointer(&g4)) + 80 /* &.serverWakeup */)) 74996 libc2.Xpthread_mutex_lock(tls, (uintptr(unsafe.Pointer(&g4)) + 40 /* &.serverMutex */)) 74997 libc2.Xpthread_mutex_unlock(tls, (uintptr(unsafe.Pointer(&g4)) + 40 /* &.serverMutex */)) 74998 } 74999 75000 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 75001 // This file is part of the GNU C Library. 75002 // 75003 // The GNU C Library is free software; you can redistribute it and/or 75004 // modify it under the terms of the GNU Lesser General Public 75005 // License as published by the Free Software Foundation; either 75006 // version 2.1 of the License, or (at your option) any later version. 75007 // 75008 // The GNU C Library is distributed in the hope that it will be useful, 75009 // but WITHOUT ANY WARRANTY; without even the implied warranty of 75010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 75011 // Lesser General Public License for more details. 75012 // 75013 // You should have received a copy of the GNU Lesser General Public 75014 // License along with the GNU C Library; if not, see 75015 // <http://www.gnu.org/licenses/>. 75016 75017 // ISO C99 Standard: 7.2 Diagnostics <assert.h> 75018 75019 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 75020 // This file is part of the GNU C Library. 75021 // 75022 // The GNU C Library is free software; you can redistribute it and/or 75023 // modify it under the terms of the GNU Lesser General Public 75024 // License as published by the Free Software Foundation; either 75025 // version 2.1 of the License, or (at your option) any later version. 75026 // 75027 // The GNU C Library is distributed in the hope that it will be useful, 75028 // but WITHOUT ANY WARRANTY; without even the implied warranty of 75029 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 75030 // Lesser General Public License for more details. 75031 // 75032 // You should have received a copy of the GNU Lesser General Public 75033 // License along with the GNU C Library; if not, see 75034 // <http://www.gnu.org/licenses/>. 75035 75036 // void assert (int expression); 75037 // 75038 // If NDEBUG is defined, do nothing. 75039 // If not, and EXPRESSION is zero, print an error message and abort. 75040 75041 // void assert_perror (int errnum); 75042 // 75043 // If NDEBUG is defined, do nothing. If not, and ERRNUM is not zero, print an 75044 // error message with the error text for ERRNUM and abort. 75045 // (This is a GNU extension.) 75046 75047 // A structure to collect a busy-handler callback and argument and a count 75048 // of the number of times it has been invoked. 75049 type SuperlockBusy1 = struct { 75050 FxBusy uintptr 75051 FpBusyArg uintptr 75052 FnBusy int32 75053 _ [4]byte 75054 } /* test_superlock.c:29:1 */ 75055 75056 type SuperlockBusy = SuperlockBusy1 /* test_superlock.c:34:30 */ 75057 75058 // An instance of the following structure is allocated for each active 75059 // superlock. The opaque handle returned by sqlite3demo_superlock() is 75060 // actually a pointer to an instance of this structure. 75061 type Superlock1 = struct { 75062 Fdb uintptr 75063 FbWal int32 75064 _ [4]byte 75065 } /* test_superlock.c:41:1 */ 75066 75067 type Superlock = Superlock1 /* test_superlock.c:45:26 */ 75068 75069 // The pCtx pointer passed to this function is actually a pointer to a 75070 // SuperlockBusy structure. Invoke the busy-handler function encapsulated 75071 // by the structure and return the result. 75072 func superlockBusyHandler(tls *libc.TLS, pCtx uintptr, UNUSED int32) int32 { /* test_superlock.c:52:12: */ 75073 var pBusy uintptr = pCtx 75074 if (*SuperlockBusy)(unsafe.Pointer(pBusy)).FxBusy == uintptr(0) { 75075 return 0 75076 } 75077 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((pBusy /* &.xBusy */))))(tls, (*SuperlockBusy)(unsafe.Pointer(pBusy)).FpBusyArg, libc.PostIncInt32(&(*SuperlockBusy)(unsafe.Pointer(pBusy)).FnBusy, 1)) 75078 } 75079 75080 // This function is used to determine if the main database file for 75081 // connection db is open in WAL mode or not. If no error occurs and the 75082 // database file is in WAL mode, set *pbWal to true and return SQLITE_OK. 75083 // If it is not in WAL mode, set *pbWal to false. 75084 // 75085 // If an error occurs, return an SQLite error code. The value of *pbWal 75086 // is undefined in this case. 75087 func superlockIsWal(tls *libc.TLS, pLock uintptr) int32 { /* test_superlock.c:67:12: */ 75088 bp := tls.Alloc(8) 75089 defer tls.Free(8) 75090 75091 var rc int32 // Return Code 75092 // var pStmt uintptr at bp, 8 75093 // Compiled PRAGMA journal_mode statement 75094 75095 rc = sqlite3.Xsqlite3_prepare(tls, (*Superlock)(unsafe.Pointer(pLock)).Fdb, ts+36219 /* "PRAGMA main.jour..." */, -1, bp /* &pStmt */, uintptr(0)) 75096 if rc != SQLITE_OK { 75097 return rc 75098 } 75099 75100 (*Superlock)(unsafe.Pointer(pLock)).FbWal = 0 75101 if SQLITE_ROW == sqlite3.Xsqlite3_step(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) { 75102 var zMode uintptr = sqlite3.Xsqlite3_column_text(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */)), 0) 75103 if ((zMode != 0) && (libc.Xstrlen(tls, zMode) == uint64(3))) && (sqlite3.Xsqlite3_strnicmp(tls, ts+29279 /* "wal" */, zMode, 3) == 0) { 75104 (*Superlock)(unsafe.Pointer(pLock)).FbWal = 1 75105 } 75106 } 75107 75108 return sqlite3.Xsqlite3_finalize(tls, *(*uintptr)(unsafe.Pointer(bp /* pStmt */))) 75109 } 75110 75111 // Obtain an exclusive shm-lock on nByte bytes starting at offset idx 75112 // of the file fd. If the lock cannot be obtained immediately, invoke 75113 // the busy-handler until either it is obtained or the busy-handler 75114 // callback returns 0. 75115 func superlockShmLock(tls *libc.TLS, fd uintptr, idx int32, nByte int32, pBusy uintptr) int32 { /* test_superlock.c:91:12: */ 75116 var rc int32 75117 var xShmLock uintptr = (*sqlite3_io_methods1)(unsafe.Pointer((*sqlite3_file)(unsafe.Pointer(fd)).FpMethods)).FxShmLock 75118 for ok := true; ok; ok = ((rc == SQLITE_BUSY) && (superlockBusyHandler(tls, pBusy, 0) != 0)) { 75119 rc = (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(&xShmLock)))(tls, fd, idx, nByte, (SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE)) 75120 } 75121 return rc 75122 } 75123 75124 // Obtain the extra locks on the database file required for WAL databases. 75125 // Invoke the supplied busy-handler as required. 75126 func superlockWalLock(tls *libc.TLS, db uintptr, pBusy uintptr) int32 { /* test_superlock.c:109:12: */ 75127 bp := tls.Alloc(16) 75128 defer tls.Free(16) 75129 75130 var rc int32 // Return code 75131 *(*uintptr)(unsafe.Pointer(bp /* fd */)) = uintptr(0) // Main database file handle 75132 *(*uintptr)(unsafe.Pointer(bp + 8 /* p */)) = uintptr(0) // Pointer to first page of shared memory 75133 75134 // Obtain a pointer to the sqlite3_file object open on the main db file. 75135 rc = sqlite3.Xsqlite3_file_control(tls, db, ts+85 /* "main" */, SQLITE_FCNTL_FILE_POINTER, bp /* &fd */) 75136 if rc != SQLITE_OK { 75137 return rc 75138 } 75139 75140 // Obtain the "recovery" lock. Normally, this lock is only obtained by 75141 // clients running database recovery. 75142 rc = superlockShmLock(tls, *(*uintptr)(unsafe.Pointer(bp /* fd */)), 2, 1, pBusy) 75143 if rc != SQLITE_OK { 75144 return rc 75145 } 75146 75147 // Zero the start of the first shared-memory page. This means that any 75148 // clients that open read or write transactions from this point on will 75149 // have to run recovery before proceeding. Since they need the "recovery" 75150 // lock that this process is holding to do that, no new read or write 75151 // transactions may now be opened. Nor can a checkpoint be run, for the 75152 // same reason. 75153 rc = (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* fd */)))).FpMethods + 104 /* &.xShmMap */))))(tls, *(*uintptr)(unsafe.Pointer(bp /* fd */)), 0, (32 * 1024), 1, bp+8 /* &p */) 75154 if rc != SQLITE_OK { 75155 return rc 75156 } 75157 libc.Xmemset(tls, libc.AtomicLoadPUintptr(bp+8 /* p */), 0, uint64(32)) 75158 75159 // Obtain exclusive locks on all the "read-lock" slots. Once these locks 75160 // are held, it is guaranteed that there are no active reader, writer or 75161 // checkpointer clients. 75162 rc = superlockShmLock(tls, *(*uintptr)(unsafe.Pointer(bp /* fd */)), 3, (SQLITE_SHM_NLOCK - 3), pBusy) 75163 return rc 75164 } 75165 75166 // Release a superlock held on a database file. The argument passed to 75167 // this function must have been obtained from a successful call to 75168 // sqlite3demo_superlock(). 75169 func sqlite3demo_superunlock(tls *libc.TLS, pLock uintptr) { /* test_superlock.c:151:6: */ 75170 bp := tls.Alloc(8) 75171 defer tls.Free(8) 75172 75173 var p uintptr = pLock 75174 if (*Superlock)(unsafe.Pointer(p)).FbWal != 0 { 75175 var rc int32 // Return code 75176 var flags int32 = (SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE) 75177 *(*uintptr)(unsafe.Pointer(bp /* fd */)) = uintptr(0) 75178 rc = sqlite3.Xsqlite3_file_control(tls, (*Superlock)(unsafe.Pointer(p)).Fdb, ts+85 /* "main" */, SQLITE_FCNTL_FILE_POINTER, bp /* &fd */) 75179 if rc == SQLITE_OK { 75180 (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* fd */)))).FpMethods + 112 /* &.xShmLock */))))(tls, *(*uintptr)(unsafe.Pointer(bp /* fd */)), 2, 1, flags) 75181 (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp /* fd */)))).FpMethods + 112 /* &.xShmLock */))))(tls, *(*uintptr)(unsafe.Pointer(bp /* fd */)), 3, (SQLITE_SHM_NLOCK - 3), flags) 75182 } 75183 } 75184 sqlite3.Xsqlite3_close(tls, (*Superlock)(unsafe.Pointer(p)).Fdb) 75185 sqlite3.Xsqlite3_free(tls, p) 75186 } 75187 75188 // Obtain a superlock on the database file identified by zPath, using the 75189 // locking primitives provided by VFS zVfs. If successful, SQLITE_OK is 75190 // returned and output variable *ppLock is populated with an opaque handle 75191 // that may be used with sqlite3demo_superunlock() to release the lock. 75192 // 75193 // If an error occurs, *ppLock is set to 0 and an SQLite error code 75194 // (e.g. SQLITE_BUSY) is returned. 75195 // 75196 // If a required lock cannot be obtained immediately and the xBusy parameter 75197 // to this function is not NULL, then xBusy is invoked in the same way 75198 // as a busy-handler registered with SQLite (using sqlite3_busy_handler()) 75199 // until either the lock can be obtained or the busy-handler function returns 75200 // 0 (indicating "give up"). 75201 func sqlite3demo_superlock(tls *libc.TLS, zPath uintptr, zVfs uintptr, xBusy uintptr, pBusyArg uintptr, ppLock uintptr) int32 { /* test_superlock.c:182:5: */ 75202 bp := tls.Alloc(24) 75203 defer tls.Free(24) 75204 75205 *(*SuperlockBusy)(unsafe.Pointer(bp /* busy */)) = SuperlockBusy{} // Busy handler wrapper object 75206 var rc int32 // Return code 75207 var pLock uintptr 75208 75209 pLock = sqlite3.Xsqlite3_malloc(tls, int32(unsafe.Sizeof(Superlock{}))) 75210 if !(pLock != 0) { 75211 return SQLITE_NOMEM 75212 } 75213 libc.Xmemset(tls, pLock, 0, uint64(unsafe.Sizeof(Superlock{}))) 75214 75215 // Open a database handle on the file to superlock. 75216 rc = sqlite3.Xsqlite3_open_v2(tls, 75217 zPath, (pLock /* &.db */), (SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE), zVfs) 75218 75219 // Install a busy-handler and execute a BEGIN EXCLUSIVE. If this is not 75220 // a WAL database, this is all we need to do. 75221 // 75222 // A wrapper function is used to invoke the busy-handler instead of 75223 // registering the busy-handler function supplied by the user directly 75224 // with SQLite. This is because the same busy-handler function may be 75225 // invoked directly later on when attempting to obtain the extra locks 75226 // required in WAL mode. By using the wrapper, we are able to guarantee 75227 // that the "nBusy" integer parameter passed to the users busy-handler 75228 // represents the total number of busy-handler invocations made within 75229 // this call to sqlite3demo_superlock(), including any made during the 75230 // "BEGIN EXCLUSIVE". 75231 if rc == SQLITE_OK { 75232 (*SuperlockBusy)(unsafe.Pointer(bp /* &busy */)).FxBusy = xBusy 75233 (*SuperlockBusy)(unsafe.Pointer(bp /* &busy */)).FpBusyArg = pBusyArg 75234 sqlite3.Xsqlite3_busy_handler(tls, (*Superlock)(unsafe.Pointer(pLock)).Fdb, *(*uintptr)(unsafe.Pointer(&struct { 75235 f func(*libc.TLS, uintptr, int32) int32 75236 }{superlockBusyHandler})), bp /* &busy */) 75237 rc = sqlite3.Xsqlite3_exec(tls, (*Superlock)(unsafe.Pointer(pLock)).Fdb, ts+12908 /* "BEGIN EXCLUSIVE" */, uintptr(0), uintptr(0), uintptr(0)) 75238 } 75239 75240 // If the BEGIN EXCLUSIVE was executed successfully and this is a WAL 75241 // database, call superlockWalLock() to obtain the extra locks required 75242 // to prevent readers, writers and/or checkpointers from accessing the 75243 // db while this process is holding the superlock. 75244 // 75245 // Before attempting any WAL locks, commit the transaction started above 75246 // to drop the WAL read and write locks currently held. Otherwise, the 75247 // new WAL locks may conflict with the old. 75248 if rc == SQLITE_OK { 75249 if (SQLITE_OK == (libc.AssignInt32(&rc, superlockIsWal(tls, pLock)))) && ((*Superlock)(unsafe.Pointer(pLock)).FbWal != 0) { 75250 rc = sqlite3.Xsqlite3_exec(tls, (*Superlock)(unsafe.Pointer(pLock)).Fdb, ts+11312 /* "COMMIT" */, uintptr(0), uintptr(0), uintptr(0)) 75251 if rc == SQLITE_OK { 75252 rc = superlockWalLock(tls, (*Superlock)(unsafe.Pointer(pLock)).Fdb, bp /* &busy */) 75253 } 75254 } 75255 } 75256 75257 if rc != SQLITE_OK { 75258 sqlite3demo_superunlock(tls, pLock) 75259 *(*uintptr)(unsafe.Pointer(ppLock)) = uintptr(0) 75260 } else { 75261 *(*uintptr)(unsafe.Pointer(ppLock)) = pLock 75262 } 75263 75264 return rc 75265 } 75266 75267 // end block for C++ 75268 75269 // Local Variables: 75270 // mode: c 75271 // c-basic-offset: 4 75272 // fill-column: 78 75273 // End: 75274 75275 type InterpAndScript1 = struct { 75276 Finterp uintptr 75277 FpScript uintptr 75278 } /* test_superlock.c:268:1 */ 75279 75280 type InterpAndScript = InterpAndScript1 /* test_superlock.c:272:32 */ 75281 75282 func superunlock_del(tls *libc.TLS, cd ClientData) { /* test_superlock.c:274:27: */ 75283 sqlite3demo_superunlock(tls, cd) 75284 } 75285 75286 func superunlock_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_superlock.c:278:26: */ 75287 if objc != 1 { 75288 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+489 /* "" */) 75289 return TCL_ERROR 75290 } 75291 tcl.XTcl_DeleteCommand(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv)))) 75292 return TCL_OK 75293 } 75294 75295 func superlock_busy(tls *libc.TLS, pCtx uintptr, nBusy int32) int32 { /* test_superlock.c:292:12: */ 75296 bp := tls.Alloc(4) 75297 defer tls.Free(4) 75298 75299 var p uintptr = pCtx 75300 var pEval uintptr // Script to evaluate 75301 *(*int32)(unsafe.Pointer(bp /* iVal */)) = 0 // Value to return 75302 75303 pEval = tcl.XTcl_DuplicateObj(tls, (*InterpAndScript)(unsafe.Pointer(p)).FpScript) 75304 (*Tcl_Obj)(unsafe.Pointer(pEval)).FrefCount++ 75305 tcl.XTcl_ListObjAppendElement(tls, (*InterpAndScript)(unsafe.Pointer(p)).Finterp, pEval, tcl.XTcl_NewIntObj(tls, nBusy)) 75306 tcl.XTcl_EvalObjEx(tls, (*InterpAndScript)(unsafe.Pointer(p)).Finterp, pEval, TCL_EVAL_GLOBAL) 75307 tcl.XTcl_GetIntFromObj(tls, (*InterpAndScript)(unsafe.Pointer(p)).Finterp, tcl.XTcl_GetObjResult(tls, (*InterpAndScript)(unsafe.Pointer(p)).Finterp), bp /* &iVal */) 75308 for ok := true; ok; ok = 0 != 0 { 75309 var _objPtr uintptr = pEval 75310 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 75311 tcl.XTclFreeObj(tls, _objPtr) 75312 } 75313 } 75314 75315 return *(*int32)(unsafe.Pointer(bp /* iVal */)) 75316 } 75317 75318 // Tclcmd: sqlite3demo_superlock CMDNAME PATH VFS BUSY-HANDLER-SCRIPT 75319 func superlock_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_superlock.c:310:26: */ 75320 bp := tls.Alloc(40) 75321 defer tls.Free(40) 75322 75323 // var pLock uintptr at bp+32, 8 75324 // Lock context 75325 var zPath uintptr 75326 var zVfs uintptr = uintptr(0) 75327 *(*InterpAndScript)(unsafe.Pointer(bp + 16 /* busy */)) = InterpAndScript{} 75328 var xBusy uintptr = uintptr(0) // Busy handler callback 75329 var rc int32 // Return code from sqlite3demo_superlock() 75330 75331 if (objc < 3) || (objc > 5) { 75332 tcl.XTcl_WrongNumArgs(tls, 75333 interp, 1, objv, ts+36244 /* "CMDNAME PATH ?VF..." */) 75334 return TCL_ERROR 75335 } 75336 75337 zPath = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 75338 75339 if objc > 3 { 75340 zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 75341 if libc.Xstrlen(tls, zVfs) == uint64(0) { 75342 zVfs = uintptr(0) 75343 } 75344 } 75345 if objc > 4 { 75346 (*InterpAndScript)(unsafe.Pointer(bp + 16 /* &busy */)).Finterp = interp 75347 (*InterpAndScript)(unsafe.Pointer(bp + 16 /* &busy */)).FpScript = *(*uintptr)(unsafe.Pointer(objv + 4*8)) 75348 xBusy = *(*uintptr)(unsafe.Pointer(&struct { 75349 f func(*libc.TLS, uintptr, int32) int32 75350 }{superlock_busy})) 75351 } 75352 75353 rc = sqlite3demo_superlock(tls, zPath, zVfs, xBusy, bp+16 /* &busy */, bp+32 /* &pLock */) 75354 75355 if rc != SQLITE_OK { 75356 tcl.XTcl_ResetResult(tls, interp) 75357 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, sqlite3.Xsqlite3ErrStr(tls, rc), 0)) 75358 return TCL_ERROR 75359 } 75360 75361 tcl.XTcl_CreateObjCommand(tls, 75362 interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), *(*uintptr)(unsafe.Pointer(&struct { 75363 f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 75364 }{superunlock_cmd})), *(*uintptr)(unsafe.Pointer(bp + 32 /* pLock */)), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, ClientData) }{superunlock_del}))) 75365 tcl.XTcl_SetObjResult(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 75366 return TCL_OK 75367 } 75368 75369 func SqliteSuperlock_Init(tls *libc.TLS, interp uintptr) int32 { /* test_superlock.c:359:5: */ 75370 tcl.XTcl_CreateObjCommand(tls, interp, ts+36285 /* "sqlite3demo_supe..." */, *(*uintptr)(unsafe.Pointer(&struct { 75371 f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 75372 }{superlock_cmd})), uintptr(0), uintptr(0)) 75373 return TCL_OK 75374 } 75375 75376 // Define error_t. 75377 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 75378 // This file is part of the GNU C Library. 75379 // 75380 // The GNU C Library is free software; you can redistribute it and/or 75381 // modify it under the terms of the GNU Lesser General Public 75382 // License as published by the Free Software Foundation; either 75383 // version 2.1 of the License, or (at your option) any later version. 75384 // 75385 // The GNU C Library is distributed in the hope that it will be useful, 75386 // but WITHOUT ANY WARRANTY; without even the implied warranty of 75387 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 75388 // Lesser General Public License for more details. 75389 // 75390 // You should have received a copy of the GNU Lesser General Public 75391 // License along with the GNU C Library; if not, see 75392 // <http://www.gnu.org/licenses/>. 75393 75394 type error_t = int32 /* error_t.h:22:13 */ 75395 75396 type TestSyscallGlobal = struct { 75397 FbPersist int32 75398 FnCount int32 75399 FnFail int32 75400 Fpgsz int32 75401 Forig_getpagesize sqlite3_syscall_ptr 75402 } /* test_syscall.c:97:8 */ 75403 75404 var gSyscall = TestSyscallGlobal{} /* test_syscall.c:103:3 */ 75405 75406 type TestSyscallArray = struct { 75407 FzName uintptr 75408 FxTest sqlite3_syscall_ptr 75409 FxOrig sqlite3_syscall_ptr 75410 Fdefault_errno int32 75411 Fcustom_errno int32 75412 } /* test_syscall.c:127:1 */ 75413 75414 var aSyscall = [19]TestSyscallArray{ 75415 /* 0 */ {FzName: ts + 36307 /* "open" */, FxTest: 0, Fdefault_errno: EACCES}, 75416 /* 1 */ {FzName: ts + 10127 /* "close" */, FxTest: 0}, 75417 /* 2 */ {FzName: ts + 36312 /* "access" */, FxTest: 0}, 75418 /* 3 */ {FzName: ts + 36319 /* "getcwd" */, FxTest: 0}, 75419 /* 4 */ {FzName: ts + 36326 /* "stat" */, FxTest: 0}, 75420 /* 5 */ {FzName: ts + 36331 /* "fstat" */, FxTest: 0}, 75421 /* 6 */ {FzName: ts + 36337 /* "ftruncate" */, FxTest: 0, Fdefault_errno: EIO}, 75422 /* 7 */ {FzName: ts + 36347 /* "fcntl" */, FxTest: 0, Fdefault_errno: EACCES}, 75423 /* 8 */ {FzName: ts + 24593 /* "read" */, FxTest: 0}, 75424 /* 9 */ {FzName: ts + 36353 /* "pread" */, FxTest: 0}, 75425 /* 10 */ {FzName: ts + 36359 /* "pread64" */, FxTest: 0}, 75426 /* 11 */ {FzName: ts + 24598 /* "write" */, FxTest: 0}, 75427 /* 12 */ {FzName: ts + 36367 /* "pwrite" */, FxTest: 0}, 75428 /* 13 */ {FzName: ts + 36374 /* "pwrite64" */, FxTest: 0}, 75429 /* 14 */ {FzName: ts + 36383 /* "fchmod" */, FxTest: 0}, 75430 /* 15 */ {FzName: ts + 36390 /* "fallocate" */, FxTest: 0}, 75431 /* 16 */ {FzName: ts + 28374 /* "mmap" */, FxTest: 0}, 75432 /* 17 */ {FzName: ts + 36400 /* "mremap" */, FxTest: 0}, 75433 {}, 75434 } /* test_syscall.c:133:3 */ 75435 75436 // This function is called exactly once from within each invocation of a 75437 // system call wrapper in this file. It returns 1 if the function should 75438 // fail, or 0 if it should succeed. 75439 func tsIsFail(tls *libc.TLS) int32 { /* test_syscall.c:181:12: */ 75440 gSyscall.FnCount-- 75441 if (gSyscall.FnCount == 0) || ((gSyscall.FnFail != 0) && (gSyscall.FbPersist != 0)) { 75442 gSyscall.FnFail++ 75443 return 1 75444 } 75445 return 0 75446 } 75447 75448 // Return the current error-number value for function zFunc. zFunc must be 75449 // the name of a system call in the aSyscall[] table. 75450 // 75451 // Usually, the current error-number is the value that errno should be set 75452 // to if the named system call fails. The exception is "fallocate". See 75453 // comments above the implementation of ts_fallocate() for details. 75454 func tsErrno(tls *libc.TLS, zFunc uintptr) int32 { /* test_syscall.c:198:12: */ 75455 var i int32 75456 var nFunc int32 = int32(libc.Xstrlen(tls, zFunc)) 75457 for i = 0; aSyscall[i].FzName != 0; i++ { 75458 if libc.Xstrlen(tls, aSyscall[i].FzName) != size_t(nFunc) { 75459 continue 75460 } 75461 if libc.Xmemcmp(tls, aSyscall[i].FzName, zFunc, uint64(nFunc)) != 0 { 75462 continue 75463 } 75464 return aSyscall[i].Fcustom_errno 75465 } 75466 75467 return 0 75468 } 75469 75470 /* 75471 ** A wrapper around tsIsFail(). If tsIsFail() returns non-zero, set the 75472 ** value of errno before returning. 75473 */ 75474 func tsIsFailErrno(tls *libc.TLS, zFunc uintptr) int32 { /* test_syscall.c:215:12: */ 75475 if tsIsFail(tls) != 0 { 75476 (*(*int32)(unsafe.Pointer(libc.X__errno_location(tls)))) = tsErrno(tls, zFunc) 75477 return 1 75478 } 75479 return 0 75480 } 75481 75482 // A wrapper around open(). 75483 func ts_open(tls *libc.TLS, zFile uintptr, flags int32, mode int32) int32 { /* test_syscall.c:226:12: */ 75484 if tsIsFailErrno(tls, ts+36307 /* "open" */) != 0 { 75485 return -1 75486 } 75487 return (*(*func(*libc.TLS, uintptr, int32, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 16 /* &.xOrig */))))(tls, zFile, flags, mode) 75488 } 75489 75490 // A wrapper around close(). 75491 func ts_close(tls *libc.TLS, fd int32) int32 { /* test_syscall.c:236:12: */ 75492 if tsIsFail(tls) != 0 { 75493 // Even if simulating an error, close the original file-descriptor. 75494 // This is to stop the test process from running out of file-descriptors 75495 // when running a long test. If a call to close() appears to fail, SQLite 75496 // never attempts to use the file-descriptor afterwards (or even to close 75497 // it a second time). 75498 (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 1*32 + 16 /* &.xOrig */))))(tls, fd) 75499 return -1 75500 } 75501 return (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 1*32 + 16 /* &.xOrig */))))(tls, fd) 75502 } 75503 75504 // A wrapper around access(). 75505 func ts_access(tls *libc.TLS, zPath uintptr, mode int32) int32 { /* test_syscall.c:252:12: */ 75506 if tsIsFail(tls) != 0 { 75507 return -1 75508 } 75509 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 2*32 + 16 /* &.xOrig */))))(tls, zPath, mode) 75510 } 75511 75512 // A wrapper around getcwd(). 75513 func ts_getcwd(tls *libc.TLS, zPath uintptr, nPath size_t) uintptr { /* test_syscall.c:262:13: */ 75514 if tsIsFail(tls) != 0 { 75515 return uintptr(0) 75516 } 75517 return (*(*func(*libc.TLS, uintptr, size_t) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 3*32 + 16 /* &.xOrig */))))(tls, zPath, nPath) 75518 } 75519 75520 // A wrapper around stat(). 75521 func ts_stat(tls *libc.TLS, zPath uintptr, p uintptr) int32 { /* test_syscall.c:272:12: */ 75522 if tsIsFail(tls) != 0 { 75523 return -1 75524 } 75525 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 4*32 + 16 /* &.xOrig */))))(tls, zPath, p) 75526 } 75527 75528 // A wrapper around fstat(). 75529 func ts_fstat(tls *libc.TLS, fd int32, p uintptr) int32 { /* test_syscall.c:282:12: */ 75530 if tsIsFailErrno(tls, ts+36331 /* "fstat" */) != 0 { 75531 return -1 75532 } 75533 return (*(*func(*libc.TLS, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 5*32 + 16 /* &.xOrig */))))(tls, fd, p) 75534 } 75535 75536 // A wrapper around ftruncate(). 75537 func ts_ftruncate(tls *libc.TLS, fd int32, n off_t) int32 { /* test_syscall.c:292:12: */ 75538 if tsIsFailErrno(tls, ts+36337 /* "ftruncate" */) != 0 { 75539 return -1 75540 } 75541 return (*(*func(*libc.TLS, int32, off_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 6*32 + 16 /* &.xOrig */))))(tls, fd, n) 75542 } 75543 75544 // A wrapper around fcntl(). 75545 func ts_fcntl(tls *libc.TLS, fd int32, cmd int32, va uintptr) int32 { /* test_syscall.c:302:12: */ 75546 bp := tls.Alloc(8) 75547 defer tls.Free(8) 75548 75549 var ap va_list 75550 _ = ap 75551 var pArg uintptr 75552 if tsIsFailErrno(tls, ts+36347 /* "fcntl" */) != 0 { 75553 return -1 75554 } 75555 ap = va 75556 pArg = libc.VaUintptr(&ap) 75557 return (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 7*32 + 16 /* &.xOrig */))))(tls, fd, cmd, libc.VaList(bp, pArg)) 75558 } 75559 75560 // A wrapper around read(). 75561 func ts_read(tls *libc.TLS, fd int32, aBuf uintptr, nBuf size_t) int32 { /* test_syscall.c:316:12: */ 75562 if tsIsFailErrno(tls, ts+24593 /* "read" */) != 0 { 75563 return -1 75564 } 75565 return int32((*(*func(*libc.TLS, int32, uintptr, size_t) ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 8*32 + 16 /* &.xOrig */))))(tls, fd, aBuf, nBuf)) 75566 } 75567 75568 // A wrapper around pread(). 75569 func ts_pread(tls *libc.TLS, fd int32, aBuf uintptr, nBuf size_t, off off_t) int32 { /* test_syscall.c:326:12: */ 75570 if tsIsFailErrno(tls, ts+36353 /* "pread" */) != 0 { 75571 return -1 75572 } 75573 return int32((*(*func(*libc.TLS, int32, uintptr, size_t, off_t) ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 9*32 + 16 /* &.xOrig */))))(tls, fd, aBuf, nBuf, off)) 75574 } 75575 75576 // A wrapper around pread64(). 75577 func ts_pread64(tls *libc.TLS, fd int32, aBuf uintptr, nBuf size_t, off sqlite3_uint64) int32 { /* test_syscall.c:336:12: */ 75578 if tsIsFailErrno(tls, ts+36359 /* "pread64" */) != 0 { 75579 return -1 75580 } 75581 return int32((*(*func(*libc.TLS, int32, uintptr, size_t, sqlite3_uint64) ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 10*32 + 16 /* &.xOrig */))))(tls, fd, aBuf, nBuf, off)) 75582 } 75583 75584 // A wrapper around write(). 75585 func ts_write(tls *libc.TLS, fd int32, aBuf uintptr, nBuf size_t) int32 { /* test_syscall.c:346:12: */ 75586 if tsIsFailErrno(tls, ts+24598 /* "write" */) != 0 { 75587 if tsErrno(tls, ts+24598 /* "write" */) == EINTR { 75588 (*(*func(*libc.TLS, int32, uintptr, size_t) ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 11*32 + 16 /* &.xOrig */))))(tls, fd, aBuf, (nBuf / uint64(2))) 75589 } 75590 return -1 75591 } 75592 return int32((*(*func(*libc.TLS, int32, uintptr, size_t) ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 11*32 + 16 /* &.xOrig */))))(tls, fd, aBuf, nBuf)) 75593 } 75594 75595 // A wrapper around pwrite(). 75596 func ts_pwrite(tls *libc.TLS, fd int32, aBuf uintptr, nBuf size_t, off off_t) int32 { /* test_syscall.c:357:12: */ 75597 if tsIsFailErrno(tls, ts+36367 /* "pwrite" */) != 0 { 75598 return -1 75599 } 75600 return int32((*(*func(*libc.TLS, int32, uintptr, size_t, off_t) ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 12*32 + 16 /* &.xOrig */))))(tls, fd, aBuf, nBuf, off)) 75601 } 75602 75603 // A wrapper around pwrite64(). 75604 func ts_pwrite64(tls *libc.TLS, fd int32, aBuf uintptr, nBuf size_t, off sqlite3_uint64) int32 { /* test_syscall.c:367:12: */ 75605 if tsIsFailErrno(tls, ts+36374 /* "pwrite64" */) != 0 { 75606 return -1 75607 } 75608 return int32((*(*func(*libc.TLS, int32, uintptr, size_t, sqlite3_uint64) ssize_t)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 13*32 + 16 /* &.xOrig */))))(tls, fd, aBuf, nBuf, off)) 75609 } 75610 75611 // A wrapper around fchmod(). 75612 func ts_fchmod(tls *libc.TLS, fd int32, mode mode_t) int32 { /* test_syscall.c:377:12: */ 75613 if tsIsFail(tls) != 0 { 75614 return -1 75615 } 75616 return (*(*func(*libc.TLS, int32, mode_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 14*32 + 16 /* &.xOrig */))))(tls, fd, mode) 75617 } 75618 75619 // A wrapper around fallocate(). 75620 // 75621 // SQLite assumes that the fallocate() function is compatible with 75622 // posix_fallocate(). According to the Linux man page (2009-09-30): 75623 // 75624 // posix_fallocate() returns zero on success, or an error number on 75625 // failure. Note that errno is not set. 75626 func ts_fallocate(tls *libc.TLS, fd int32, off off_t, len off_t) int32 { /* test_syscall.c:393:12: */ 75627 if tsIsFail(tls) != 0 { 75628 return tsErrno(tls, ts+36390 /* "fallocate" */) 75629 } 75630 return (*(*func(*libc.TLS, int32, off_t, off_t) int32)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 15*32 + 16 /* &.xOrig */))))(tls, fd, off, len) 75631 } 75632 75633 func ts_mmap(tls *libc.TLS, pAddr uintptr, nByte size_t, prot int32, flags int32, fd int32, iOff off_t) uintptr { /* test_syscall.c:400:13: */ 75634 if tsIsFailErrno(tls, ts+28374 /* "mmap" */) != 0 { 75635 return libc.UintptrFromInt32(-1) 75636 } 75637 return (*(*func(*libc.TLS, uintptr, size_t, int32, int32, int32, off_t) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 16*32 + 16 /* &.xOrig */))))(tls, pAddr, nByte, prot, flags, fd, iOff) 75638 } 75639 75640 func ts_mremap(tls *libc.TLS, a uintptr, b size_t, c size_t, d int32, va uintptr) uintptr { /* test_syscall.c:414:13: */ 75641 bp := tls.Alloc(8) 75642 defer tls.Free(8) 75643 75644 var ap va_list 75645 _ = ap 75646 var pArg uintptr 75647 if tsIsFailErrno(tls, ts+36400 /* "mremap" */) != 0 { 75648 return libc.UintptrFromInt32(-1) 75649 } 75650 ap = va 75651 pArg = libc.VaUintptr(&ap) 75652 return (*(*func(*libc.TLS, uintptr, size_t, size_t, int32, uintptr) uintptr)(unsafe.Pointer((uintptr(unsafe.Pointer(&aSyscall)) + 17*32 + 16 /* &.xOrig */))))(tls, a, b, c, d, libc.VaList(bp, pArg)) 75653 } 75654 75655 func test_syscall_install(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_syscall.c:425:26: */ 75656 bp := tls.Alloc(20) 75657 defer tls.Free(20) 75658 75659 var pVfs uintptr 75660 // var nElem int32 at bp, 4 75661 75662 var i int32 75663 // var apElem uintptr at bp+8, 8 75664 75665 if objc != 3 { 75666 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+36407 /* "SYSCALL-LIST" */) 75667 return TCL_ERROR 75668 } 75669 if tcl.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &nElem */, bp+8 /* &apElem */) != 0 { 75670 return TCL_ERROR 75671 } 75672 pVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 75673 75674 for i = 0; i < *(*int32)(unsafe.Pointer(bp /* nElem */)); i++ { 75675 // var iCall int32 at bp+16, 4 75676 75677 var rc int32 = tcl.XTcl_GetIndexFromObjStruct(tls, interp, 75678 *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 8 /* apElem */)) + uintptr(i)*8)), uintptr(unsafe.Pointer(&aSyscall)), int32(unsafe.Sizeof(TestSyscallArray{})), ts+36420 /* "system-call" */, 0, bp+16 /* &iCall */) 75679 if rc != 0 { 75680 return rc 75681 } 75682 if aSyscall[*(*int32)(unsafe.Pointer(bp + 16 /* iCall */))].FxOrig == uintptr(0) { 75683 aSyscall[*(*int32)(unsafe.Pointer(bp + 16 /* iCall */))].FxOrig = (*(*func(*libc.TLS, uintptr, uintptr) sqlite3_syscall_ptr)(unsafe.Pointer((pVfs + 152 /* &.xGetSystemCall */))))(tls, pVfs, aSyscall[*(*int32)(unsafe.Pointer(bp + 16 /* iCall */))].FzName) 75684 (*(*func(*libc.TLS, uintptr, uintptr, sqlite3_syscall_ptr) int32)(unsafe.Pointer((pVfs + 144 /* &.xSetSystemCall */))))(tls, pVfs, aSyscall[*(*int32)(unsafe.Pointer(bp + 16 /* iCall */))].FzName, aSyscall[*(*int32)(unsafe.Pointer(bp + 16 /* iCall */))].FxTest) 75685 } 75686 aSyscall[*(*int32)(unsafe.Pointer(bp + 16 /* iCall */))].Fcustom_errno = aSyscall[*(*int32)(unsafe.Pointer(bp + 16 /* iCall */))].Fdefault_errno 75687 } 75688 75689 return TCL_OK 75690 } 75691 75692 func test_syscall_uninstall(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_syscall.c:461:26: */ 75693 var pVfs uintptr 75694 var i int32 75695 75696 if objc != 2 { 75697 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+489 /* "" */) 75698 return TCL_ERROR 75699 } 75700 75701 pVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 75702 for i = 0; aSyscall[i].FzName != 0; i++ { 75703 if aSyscall[i].FxOrig != 0 { 75704 (*(*func(*libc.TLS, uintptr, uintptr, sqlite3_syscall_ptr) int32)(unsafe.Pointer((pVfs + 144 /* &.xSetSystemCall */))))(tls, pVfs, aSyscall[i].FzName, uintptr(0)) 75705 aSyscall[i].FxOrig = uintptr(0) 75706 } 75707 } 75708 return TCL_OK 75709 } 75710 75711 func test_syscall_reset(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_syscall.c:485:26: */ 75712 bp := tls.Alloc(4) 75713 defer tls.Free(4) 75714 75715 var pVfs uintptr 75716 var i int32 75717 var rc int32 75718 75719 if (objc != 2) && (objc != 3) { 75720 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+489 /* "" */) 75721 return TCL_ERROR 75722 } 75723 75724 pVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 75725 if objc == 2 { 75726 rc = (*(*func(*libc.TLS, uintptr, uintptr, sqlite3_syscall_ptr) int32)(unsafe.Pointer((pVfs + 144 /* &.xSetSystemCall */))))(tls, pVfs, uintptr(0), uintptr(0)) 75727 for i = 0; aSyscall[i].FzName != 0; i++ { 75728 aSyscall[i].FxOrig = uintptr(0) 75729 } 75730 } else { 75731 // var nFunc int32 at bp, 4 75732 75733 var zFunc uintptr = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &nFunc */) 75734 rc = (*(*func(*libc.TLS, uintptr, uintptr, sqlite3_syscall_ptr) int32)(unsafe.Pointer((pVfs + 144 /* &.xSetSystemCall */))))(tls, pVfs, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), uintptr(0)) 75735 for i = 0; (rc == SQLITE_OK) && (aSyscall[i].FzName != 0); i++ { 75736 if libc.Xstrlen(tls, aSyscall[i].FzName) != size_t(*(*int32)(unsafe.Pointer(bp /* nFunc */))) { 75737 continue 75738 } 75739 if libc.Xmemcmp(tls, aSyscall[i].FzName, zFunc, uint64(*(*int32)(unsafe.Pointer(bp /* nFunc */)))) != 0 { 75740 continue 75741 } 75742 aSyscall[i].FxOrig = uintptr(0) 75743 } 75744 } 75745 if rc != SQLITE_OK { 75746 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 75747 return TCL_ERROR 75748 } 75749 75750 tcl.XTcl_ResetResult(tls, interp) 75751 return TCL_OK 75752 } 75753 75754 func test_syscall_exists(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_syscall.c:523:26: */ 75755 var pVfs uintptr 75756 var x sqlite3_syscall_ptr 75757 75758 if objc != 3 { 75759 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+489 /* "" */) 75760 return TCL_ERROR 75761 } 75762 75763 pVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 75764 x = (*(*func(*libc.TLS, uintptr, uintptr) sqlite3_syscall_ptr)(unsafe.Pointer((pVfs + 152 /* &.xGetSystemCall */))))(tls, pVfs, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)))) 75765 75766 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, (libc.Bool32((libc.Bool32(x != uintptr(0))) != 0)))) 75767 return TCL_OK 75768 } 75769 75770 func test_syscall_fault(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_syscall.c:544:26: */ 75771 bp := tls.Alloc(8) 75772 defer tls.Free(8) 75773 75774 *(*int32)(unsafe.Pointer(bp /* nCount */)) = 0 75775 *(*int32)(unsafe.Pointer(bp + 4 /* bPersist */)) = 0 75776 75777 if (objc != 2) && (objc != 4) { 75778 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+36432 /* "?COUNT PERSIST?" */) 75779 return TCL_ERROR 75780 } 75781 75782 if objc == 4 { 75783 if (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp /* &nCount */) != 0) || 75784 (tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+4 /* &bPersist */) != 0) { 75785 return TCL_ERROR 75786 } 75787 } 75788 75789 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, gSyscall.FnFail)) 75790 gSyscall.FnCount = *(*int32)(unsafe.Pointer(bp /* nCount */)) 75791 gSyscall.FbPersist = *(*int32)(unsafe.Pointer(bp + 4 /* bPersist */)) 75792 gSyscall.FnFail = 0 75793 return TCL_OK 75794 } 75795 75796 func test_syscall_errno(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_syscall.c:573:26: */ 75797 bp := tls.Alloc(204) 75798 defer tls.Free(204) 75799 75800 // var iCall int32 at bp, 4 75801 75802 // var iErrno int32 at bp+200, 4 75803 75804 var rc int32 75805 75806 *(*[12]Errno)(unsafe.Pointer(bp + 8 /* aErrno */)) = [12]Errno{ 75807 {Fz: ts + 36448 /* "EACCES" */, Fi: EACCES}, 75808 {Fz: ts + 36455 /* "EINTR" */, Fi: EINTR}, 75809 {Fz: ts + 36461 /* "EIO" */, Fi: EIO}, 75810 {Fz: ts + 36465 /* "EOVERFLOW" */, Fi: EOVERFLOW}, 75811 {Fz: ts + 36475 /* "ENOMEM" */, Fi: ENOMEM}, 75812 {Fz: ts + 36482 /* "EAGAIN" */, Fi: EAGAIN}, 75813 {Fz: ts + 36489 /* "ETIMEDOUT" */, Fi: ETIMEDOUT}, 75814 {Fz: ts + 36499 /* "EBUSY" */, Fi: EBUSY}, 75815 {Fz: ts + 36505 /* "EPERM" */, Fi: EPERM}, 75816 {Fz: ts + 36511 /* "EDEADLK" */, Fi: EDEADLK}, 75817 {Fz: ts + 36519 /* "ENOLCK" */, Fi: ENOLCK}, 75818 {}, 75819 } 75820 75821 if objc != 4 { 75822 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+36526 /* "SYSCALL ERRNO" */) 75823 return TCL_ERROR 75824 } 75825 75826 rc = tcl.XTcl_GetIndexFromObjStruct(tls, interp, 75827 *(*uintptr)(unsafe.Pointer(objv + 2*8)), uintptr(unsafe.Pointer(&aSyscall)), int32(unsafe.Sizeof(TestSyscallArray{})), ts+36420 /* "system-call" */, 0, bp /* &iCall */) 75828 if rc != TCL_OK { 75829 return rc 75830 } 75831 rc = tcl.XTcl_GetIndexFromObjStruct(tls, interp, 75832 *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+8 /* &aErrno[0] */, int32(unsafe.Sizeof(Errno{})), ts+36540 /* "errno" */, 0, bp+200 /* &iErrno */) 75833 if rc != TCL_OK { 75834 return rc 75835 } 75836 75837 aSyscall[*(*int32)(unsafe.Pointer(bp /* iCall */))].Fcustom_errno = (*Errno)(unsafe.Pointer(bp + 8 /* &aErrno */ + uintptr(*(*int32)(unsafe.Pointer(bp + 200 /* iErrno */)))*16)).Fi 75838 return TCL_OK 75839 } 75840 75841 type Errno = struct { 75842 Fz uintptr 75843 Fi int32 75844 _ [4]byte 75845 } /* test_syscall.c:583:3 */ 75846 75847 func test_syscall_list(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_syscall.c:619:26: */ 75848 var zSys uintptr 75849 var pVfs uintptr 75850 var pList uintptr 75851 75852 if objc != 2 { 75853 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+489 /* "" */) 75854 return TCL_ERROR 75855 } 75856 75857 pVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 75858 pList = tcl.XTcl_NewObj(tls) 75859 (*Tcl_Obj)(unsafe.Pointer(pList)).FrefCount++ 75860 for zSys = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer((pVfs + 160 /* &.xNextSystemCall */))))(tls, pVfs, uintptr(0)); zSys != uintptr(0); zSys = (*(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer((pVfs + 160 /* &.xNextSystemCall */))))(tls, pVfs, zSys) { 75861 tcl.XTcl_ListObjAppendElement(tls, interp, pList, tcl.XTcl_NewStringObj(tls, zSys, -1)) 75862 } 75863 75864 tcl.XTcl_SetObjResult(tls, interp, pList) 75865 for ok := true; ok; ok = 0 != 0 { 75866 var _objPtr uintptr = pList 75867 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 75868 tcl.XTclFreeObj(tls, _objPtr) 75869 } 75870 } 75871 return TCL_OK 75872 } 75873 75874 func test_syscall_defaultvfs(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_syscall.c:649:26: */ 75875 var pVfs uintptr 75876 75877 if objc != 2 { 75878 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+489 /* "" */) 75879 return TCL_ERROR 75880 } 75881 75882 pVfs = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 75883 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FzName, -1)) 75884 return TCL_OK 75885 } 75886 75887 func ts_getpagesize(tls *libc.TLS) int32 { /* test_syscall.c:667:12: */ 75888 return gSyscall.Fpgsz 75889 } 75890 75891 func test_syscall_pagesize(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_syscall.c:671:26: */ 75892 bp := tls.Alloc(20) 75893 defer tls.Free(20) 75894 75895 var pVfs uintptr = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 75896 // var pgsz int32 at bp+16, 4 75897 75898 if objc != 3 { 75899 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+36546 /* "PGSZ" */) 75900 return TCL_ERROR 75901 } 75902 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+16 /* &pgsz */) != 0 { 75903 return TCL_ERROR 75904 } 75905 75906 if *(*int32)(unsafe.Pointer(bp + 16 /* pgsz */)) < 0 { 75907 if gSyscall.Forig_getpagesize != 0 { 75908 (*(*func(*libc.TLS, uintptr, uintptr, sqlite3_syscall_ptr) int32)(unsafe.Pointer((pVfs + 144 /* &.xSetSystemCall */))))(tls, pVfs, ts+36551 /* "getpagesize" */, gSyscall.Forig_getpagesize) 75909 } 75910 } else { 75911 if (*(*int32)(unsafe.Pointer(bp + 16 /* pgsz */)) < 512) || ((*(*int32)(unsafe.Pointer(bp + 16 /* pgsz */)) & (*(*int32)(unsafe.Pointer(bp + 16 /* pgsz */)) - 1)) != 0) { 75912 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+36563 /* "pgsz out of rang..." */, 0)) 75913 return TCL_ERROR 75914 } 75915 gSyscall.Forig_getpagesize = (*(*func(*libc.TLS, uintptr, uintptr) sqlite3_syscall_ptr)(unsafe.Pointer((pVfs + 152 /* &.xGetSystemCall */))))(tls, pVfs, ts+36551 /* "getpagesize" */) 75916 gSyscall.Fpgsz = *(*int32)(unsafe.Pointer(bp + 16 /* pgsz */)) 75917 (*(*func(*libc.TLS, uintptr, uintptr, sqlite3_syscall_ptr) int32)(unsafe.Pointer((pVfs + 144 /* &.xSetSystemCall */))))(tls, 75918 pVfs, ts+36551 /* "getpagesize" */, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS) int32 }{ts_getpagesize}))) 75919 } 75920 75921 return TCL_OK 75922 } 75923 75924 func test_syscall(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_syscall.c:706:26: */ 75925 bp := tls.Alloc(180) 75926 defer tls.Free(180) 75927 75928 *(*[10]SyscallCmd)(unsafe.Pointer(bp + 16 /* aCmd */)) = [10]SyscallCmd{ 75929 {FzName: ts + 36581 /* "fault" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { 75930 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 75931 }{test_syscall_fault}))}, 75932 {FzName: ts + 36587 /* "install" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { 75933 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 75934 }{test_syscall_install}))}, 75935 {FzName: ts + 36595 /* "uninstall" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { 75936 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 75937 }{test_syscall_uninstall}))}, 75938 {FzName: ts + 7381 /* "reset" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { 75939 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 75940 }{test_syscall_reset}))}, 75941 {FzName: ts + 36540 /* "errno" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { 75942 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 75943 }{test_syscall_errno}))}, 75944 {FzName: ts + 13198 /* "exists" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { 75945 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 75946 }{test_syscall_exists}))}, 75947 {FzName: ts + 36605 /* "list" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { 75948 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 75949 }{test_syscall_list}))}, 75950 {FzName: ts + 36610 /* "defaultvfs" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { 75951 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 75952 }{test_syscall_defaultvfs}))}, 75953 {FzName: ts + 36621 /* "pagesize" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { 75954 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 75955 }{test_syscall_pagesize}))}, 75956 {}, 75957 } 75958 // var iCmd int32 at bp+176, 4 75959 75960 var rc int32 75961 var pVfs uintptr = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 75962 75963 if objc < 2 { 75964 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+32318 /* "SUB-COMMAND ..." */) 75965 return TCL_ERROR 75966 } 75967 if ((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FiVersion < 3) || ((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FxSetSystemCall == uintptr(0)) { 75968 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+36630 /* "VFS does not sup..." */, 0)) 75969 rc = TCL_ERROR 75970 } else { 75971 rc = tcl.XTcl_GetIndexFromObjStruct(tls, interp, 75972 *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+16 /* &aCmd[0] */, int32(unsafe.Sizeof(SyscallCmd{})), ts+1875 /* "sub-command" */, 0, bp+176 /* &iCmd */) 75973 } 75974 if rc != TCL_OK { 75975 return rc 75976 } 75977 return (*(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer((bp + 16 /* &aCmd */ + uintptr(*(*int32)(unsafe.Pointer(bp + 176 /* iCmd */)))*16 + 8 /* &.xCmd */))))(tls, clientData, interp, objc, objv) 75978 } 75979 75980 type SyscallCmd = struct { 75981 FzName uintptr 75982 FxCmd uintptr 75983 } /* test_syscall.c:712:3 */ 75984 75985 func SqlitetestSyscall_Init(tls *libc.TLS, interp uintptr) int32 { /* test_syscall.c:747:5: */ 75986 bp := tls.Alloc(16) 75987 defer tls.Free(16) 75988 75989 *(*[1]SyscallCmd)(unsafe.Pointer(bp /* aCmd */)) = [1]SyscallCmd{ 75990 {FzName: ts + 36666 /* "test_syscall" */, FxCmd: *(*uintptr)(unsafe.Pointer(&struct { 75991 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 75992 }{test_syscall}))}, 75993 } 75994 var i int32 75995 75996 for i = 0; uint64(i) < (uint64(unsafe.Sizeof([1]SyscallCmd{})) / uint64(unsafe.Sizeof(SyscallCmd{}))); i++ { 75997 tcl.XTcl_CreateObjCommand(tls, interp, (*SyscallCmd)(unsafe.Pointer(bp /* &aCmd */ +uintptr(i)*16)).FzName, (*SyscallCmd)(unsafe.Pointer(bp /* &aCmd */ +uintptr(i)*16)).FxCmd, uintptr(0), uintptr(0)) 75998 } 75999 return TCL_OK 76000 } 76001 76002 // This routine is the primary export of this file. 76003 // 76004 // Configure the interpreter passed as the first argument to have access 76005 // to the commands and linked variables that make up: 76006 // 76007 // * the [sqlite3] extension itself, 76008 // 76009 // * If SQLITE_TCLMD5 or SQLITE_TEST is defined, the Md5 commands, and 76010 // 76011 // * If SQLITE_TEST is set, the various test interfaces used by the Tcl 76012 // test suite. 76013 func sqlite3TestInit(tls *libc.TLS, interp uintptr) uintptr { /* test_tclsh.c:58:12: */ 76014 bp := tls.Alloc(80) 76015 defer tls.Free(80) 76016 76017 // var cmdInfo Tcl_CmdInfo at bp+16, 64 76018 76019 /* Since the primary use case for this binary is testing of SQLite, 76020 ** be sure to generate core files if we crash */ 76021 { 76022 // var x rlimit at bp, 16 76023 76024 libc.Xgetrlimit(tls, RLIMIT_CORE, bp /* &x */) 76025 (*rlimit)(unsafe.Pointer(bp /* &x */)).Frlim_cur = (*rlimit)(unsafe.Pointer(bp /* &x */)).Frlim_max 76026 libc.Xsetrlimit(tls, RLIMIT_CORE, bp /* &x */) 76027 76028 } 76029 76030 if tcl.XTcl_GetCommandInfo(tls, interp, ts+13949 /* "sqlite3" */, bp+16 /* &cmdInfo */) == 0 { 76031 Sqlite3_Init(tls, interp) 76032 } 76033 Md5_Init(tls, interp) 76034 Sqliteconfig_Init(tls, interp) 76035 Sqlitetest1_Init(tls, interp) 76036 Sqlitetest2_Init(tls, interp) 76037 Sqlitetest3_Init(tls, interp) 76038 Sqlitetest4_Init(tls, interp) 76039 Sqlitetest5_Init(tls, interp) 76040 Sqlitetest6_Init(tls, interp) 76041 Sqlitetest7_Init(tls, interp) 76042 Sqlitetest8_Init(tls, interp) 76043 Sqlitetest9_Init(tls, interp) 76044 Sqlitetestasync_Init(tls, interp) 76045 Sqlitetest_autoext_Init(tls, interp) 76046 Sqlitetest_blob_Init(tls, interp) 76047 Sqlitetest_demovfs_Init(tls, interp) 76048 Sqlitetest_func_Init(tls, interp) 76049 Sqlitetest_hexio_Init(tls, interp) 76050 Sqlitetest_init_Init(tls, interp) 76051 Sqlitetest_malloc_Init(tls, interp) 76052 Sqlitetest_mutex_Init(tls, interp) 76053 Sqlitetestschema_Init(tls, interp) 76054 Sqlitetesttclvar_Init(tls, interp) 76055 Sqlitetestfs_Init(tls, interp) 76056 SqlitetestThread_Init(tls, interp) 76057 SqlitetestOnefile_Init(tls) 76058 SqlitetestOsinst_Init(tls, interp) 76059 Sqlitetestbackup_Init(tls, interp) 76060 Sqlitetestintarray_Init(tls, interp) 76061 Sqlitetestvfs_Init(tls, interp) 76062 Sqlitetestrtree_Init(tls, interp) 76063 Sqlitequota_Init(tls, interp) 76064 Sqlitemultiplex_Init(tls, interp) 76065 SqliteSuperlock_Init(tls, interp) 76066 SqlitetestSyscall_Init(tls, interp) 76067 Fts5tcl_Init(tls, interp) 76068 SqliteRbu_Init(tls, interp) 76069 Sqlitetesttcl_Init(tls, interp) 76070 76071 TestExpert_Init(tls, interp) 76072 Sqlitetest_window_Init(tls, interp) 76073 Sqlitetestvdbecov_Init(tls, interp) 76074 76075 tcl.XTcl_CreateObjCommand(tls, 76076 interp, ts+36679 /* "load_testfixture..." */, *(*uintptr)(unsafe.Pointer(&struct { 76077 f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 76078 }{load_testfixture_extensions})), uintptr(0), uintptr(0)) 76079 return uintptr(0) 76080 } 76081 76082 // tclcmd: load_testfixture_extensions 76083 func load_testfixture_extensions(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_tclsh.c:185:26: */ 76084 var slave uintptr 76085 if objc != 2 { 76086 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+36707 /* "SLAVE" */) 76087 return TCL_ERROR 76088 } 76089 76090 slave = tcl.XTcl_GetSlave(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 76091 if !(slave != 0) { 76092 return TCL_ERROR 76093 } 76094 76095 sqlite3TestInit(tls, slave) 76096 return TCL_OK 76097 } 76098 76099 // end block for C++ 76100 76101 // Local Variables: 76102 // mode: c 76103 // c-basic-offset: 4 76104 // fill-column: 78 76105 // End: 76106 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 76107 // This file is part of the GNU C Library. 76108 // 76109 // The GNU C Library is free software; you can redistribute it and/or 76110 // modify it under the terms of the GNU Lesser General Public 76111 // License as published by the Free Software Foundation; either 76112 // version 2.1 of the License, or (at your option) any later version. 76113 // 76114 // The GNU C Library is distributed in the hope that it will be useful, 76115 // but WITHOUT ANY WARRANTY; without even the implied warranty of 76116 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 76117 // Lesser General Public License for more details. 76118 // 76119 // You should have received a copy of the GNU Lesser General Public 76120 // License along with the GNU C Library; if not, see 76121 // <http://www.gnu.org/licenses/>. 76122 76123 // ISO C99 Standard: 7.20 General utilities <stdlib.h> 76124 76125 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 76126 // This file is part of the GNU C Library. 76127 // 76128 // The GNU C Library is free software; you can redistribute it and/or 76129 // modify it under the terms of the GNU Lesser General Public 76130 // License as published by the Free Software Foundation; either 76131 // version 2.1 of the License, or (at your option) any later version. 76132 // 76133 // The GNU C Library is distributed in the hope that it will be useful, 76134 // but WITHOUT ANY WARRANTY; without even the implied warranty of 76135 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 76136 // Lesser General Public License for more details. 76137 // 76138 // You should have received a copy of the GNU Lesser General Public 76139 // License along with the GNU C Library; if not, see 76140 // <http://www.gnu.org/licenses/>. 76141 76142 // ISO C99 Standard: 7.21 String handling <string.h> 76143 76144 // Characters that make up the idxStr created by xBestIndex for xFilter. 76145 76146 type tclvar_vtab1 = struct { 76147 Fbase sqlite3_vtab 76148 Finterp uintptr 76149 } /* test_tclvar.c:58:9 */ 76150 76151 // end block for C++ 76152 76153 // Local Variables: 76154 // mode: c 76155 // c-basic-offset: 4 76156 // fill-column: 78 76157 // End: 76158 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 76159 // This file is part of the GNU C Library. 76160 // 76161 // The GNU C Library is free software; you can redistribute it and/or 76162 // modify it under the terms of the GNU Lesser General Public 76163 // License as published by the Free Software Foundation; either 76164 // version 2.1 of the License, or (at your option) any later version. 76165 // 76166 // The GNU C Library is distributed in the hope that it will be useful, 76167 // but WITHOUT ANY WARRANTY; without even the implied warranty of 76168 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 76169 // Lesser General Public License for more details. 76170 // 76171 // You should have received a copy of the GNU Lesser General Public 76172 // License along with the GNU C Library; if not, see 76173 // <http://www.gnu.org/licenses/>. 76174 76175 // ISO C99 Standard: 7.20 General utilities <stdlib.h> 76176 76177 // Copyright (C) 1991-2018 Free Software Foundation, Inc. 76178 // This file is part of the GNU C Library. 76179 // 76180 // The GNU C Library is free software; you can redistribute it and/or 76181 // modify it under the terms of the GNU Lesser General Public 76182 // License as published by the Free Software Foundation; either 76183 // version 2.1 of the License, or (at your option) any later version. 76184 // 76185 // The GNU C Library is distributed in the hope that it will be useful, 76186 // but WITHOUT ANY WARRANTY; without even the implied warranty of 76187 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 76188 // Lesser General Public License for more details. 76189 // 76190 // You should have received a copy of the GNU Lesser General Public 76191 // License along with the GNU C Library; if not, see 76192 // <http://www.gnu.org/licenses/>. 76193 76194 // ISO C99 Standard: 7.21 String handling <string.h> 76195 76196 // Characters that make up the idxStr created by xBestIndex for xFilter. 76197 76198 type tclvar_vtab = tclvar_vtab1 /* test_tclvar.c:58:28 */ 76199 type tclvar_cursor1 = struct { 76200 Fbase sqlite3_vtab_cursor 76201 FpList1 uintptr 76202 FpList2 uintptr 76203 Fi1 int32 76204 Fi2 int32 76205 } /* test_tclvar.c:59:9 */ 76206 76207 type tclvar_cursor = tclvar_cursor1 /* test_tclvar.c:59:30 */ 76208 76209 // Methods for the tclvar module 76210 func tclvarConnect(tls *libc.TLS, db uintptr, pAux uintptr, argc int32, argv uintptr, ppVtab uintptr, pzErr uintptr) int32 { /* test_tclvar.c:80:12: */ 76211 var pVtab uintptr 76212 pVtab = sqlite3.Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(tclvar_vtab{}))) 76213 if pVtab == uintptr(0) { 76214 return SQLITE_NOMEM 76215 } 76216 *(*uintptr)(unsafe.Pointer(ppVtab)) = (pVtab /* &.base */) 76217 (*tclvar_vtab)(unsafe.Pointer(pVtab)).Finterp = pAux 76218 sqlite3.Xsqlite3_declare_vtab(tls, db, uintptr(unsafe.Pointer(&zSchema))) 76219 return SQLITE_OK 76220 } 76221 76222 var zSchema = 76223 76224 // Base name 76225 // Array index 76226 // Value 76227 // base(index) name 76228 *(*[100]int8)(unsafe.Pointer(ts + 36713 /* "CREATE TABLE x( ..." */)) /* test_tclvar.c:88:21 */ 76229 76230 // Note that for this virtual table, the xCreate and xConnect 76231 // methods are identical. 76232 76233 func tclvarDisconnect(tls *libc.TLS, pVtab uintptr) int32 { /* test_tclvar.c:105:12: */ 76234 sqlite3.Xsqlite3_free(tls, pVtab) 76235 return SQLITE_OK 76236 } 76237 76238 // The xDisconnect and xDestroy methods are also the same 76239 76240 // Open a new tclvar cursor. 76241 func tclvarOpen(tls *libc.TLS, pVTab uintptr, ppCursor uintptr) int32 { /* test_tclvar.c:114:12: */ 76242 var pCur uintptr 76243 pCur = sqlite3.Xsqlite3MallocZero(tls, uint64(unsafe.Sizeof(tclvar_cursor{}))) 76244 *(*uintptr)(unsafe.Pointer(ppCursor)) = (pCur /* &.base */) 76245 return SQLITE_OK 76246 } 76247 76248 // Close a tclvar cursor. 76249 func tclvarClose(tls *libc.TLS, cur uintptr) int32 { /* test_tclvar.c:124:12: */ 76250 var pCur uintptr = cur 76251 if (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList1 != 0 { 76252 for ok := true; ok; ok = 0 != 0 { 76253 var _objPtr uintptr = (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList1 76254 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 76255 tcl.XTclFreeObj(tls, _objPtr) 76256 } 76257 } 76258 } 76259 if (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList2 != 0 { 76260 for ok1 := true; ok1; ok1 = 0 != 0 { 76261 var _objPtr uintptr = (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList2 76262 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 76263 tcl.XTclFreeObj(tls, _objPtr) 76264 } 76265 } 76266 } 76267 sqlite3.Xsqlite3_free(tls, pCur) 76268 return SQLITE_OK 76269 } 76270 76271 // Returns 1 if data is ready, or 0 if not. 76272 func next2(tls *libc.TLS, interp uintptr, pCur uintptr, pObj uintptr) int32 { /* test_tclvar.c:139:12: */ 76273 bp := tls.Alloc(4) 76274 defer tls.Free(4) 76275 76276 var p uintptr 76277 76278 if pObj != 0 { 76279 if !(int32((*tclvar_cursor)(unsafe.Pointer(pCur)).FpList2) != 0) { 76280 p = tcl.XTcl_NewStringObj(tls, ts+36813 /* "array names" */, -1) 76281 (*Tcl_Obj)(unsafe.Pointer(p)).FrefCount++ 76282 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), p, pObj) 76283 tcl.XTcl_EvalObjEx(tls, interp, p, TCL_EVAL_GLOBAL) 76284 for ok := true; ok; ok = 0 != 0 { 76285 var _objPtr uintptr = p 76286 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 76287 tcl.XTclFreeObj(tls, _objPtr) 76288 } 76289 } 76290 (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList2 = tcl.XTcl_GetObjResult(tls, interp) 76291 (*Tcl_Obj)(unsafe.Pointer((*tclvar_cursor)(unsafe.Pointer(pCur)).FpList2)).FrefCount++ 76292 76293 } else { 76294 *(*int32)(unsafe.Pointer(bp /* n */)) = 0 76295 (*tclvar_cursor)(unsafe.Pointer(pCur)).Fi2++ 76296 tcl.XTcl_ListObjLength(tls, uintptr(0), (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList2, bp /* &n */) 76297 if (*tclvar_cursor)(unsafe.Pointer(pCur)).Fi2 >= *(*int32)(unsafe.Pointer(bp /* n */)) { 76298 for ok1 := true; ok1; ok1 = 0 != 0 { 76299 var _objPtr uintptr = (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList2 76300 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 76301 tcl.XTclFreeObj(tls, _objPtr) 76302 } 76303 } 76304 (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList2 = uintptr(0) 76305 (*tclvar_cursor)(unsafe.Pointer(pCur)).Fi2 = 0 76306 return 0 76307 } 76308 } 76309 } 76310 76311 return 1 76312 } 76313 76314 func tclvarNext(tls *libc.TLS, cur uintptr) int32 { /* test_tclvar.c:168:12: */ 76315 bp := tls.Alloc(16) 76316 defer tls.Free(16) 76317 76318 // var pObj uintptr at bp+8, 8 76319 76320 *(*int32)(unsafe.Pointer(bp /* n */)) = 0 76321 var ok int32 = 0 76322 76323 var pCur uintptr = cur 76324 var interp uintptr = (*tclvar_vtab)(unsafe.Pointer((*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).Finterp 76325 76326 tcl.XTcl_ListObjLength(tls, uintptr(0), (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList1, bp /* &n */) 76327 for !(ok != 0) && ((*tclvar_cursor)(unsafe.Pointer(pCur)).Fi1 < *(*int32)(unsafe.Pointer(bp /* n */))) { 76328 tcl.XTcl_ListObjIndex(tls, uintptr(0), (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList1, (*tclvar_cursor)(unsafe.Pointer(pCur)).Fi1, bp+8 /* &pObj */) 76329 ok = next2(tls, interp, pCur, *(*uintptr)(unsafe.Pointer(bp + 8 /* pObj */))) 76330 if !(ok != 0) { 76331 (*tclvar_cursor)(unsafe.Pointer(pCur)).Fi1++ 76332 } 76333 } 76334 76335 return 0 76336 } 76337 76338 func tclvarFilter(tls *libc.TLS, pVtabCursor uintptr, idxNum int32, idxStr uintptr, argc int32, argv uintptr) int32 { /* test_tclvar.c:188:12: */ 76339 var pCur uintptr = pVtabCursor 76340 var interp uintptr = (*tclvar_vtab)(unsafe.Pointer((*sqlite3_vtab_cursor)(unsafe.Pointer(pVtabCursor)).FpVtab)).Finterp 76341 var p uintptr = tcl.XTcl_NewStringObj(tls, ts+36825 /* "tclvar_filter_cm..." */, -1) 76342 76343 var zEq uintptr = ts + 489 /* "" */ 76344 var zMatch uintptr = ts + 489 /* "" */ 76345 var zGlob uintptr = ts + 489 /* "" */ 76346 var zRegexp uintptr = ts + 489 /* "" */ 76347 var zLike uintptr = ts + 489 /* "" */ 76348 var i int32 76349 76350 for i = 0; *(*int8)(unsafe.Pointer(idxStr + uintptr(i))) != 0; i++ { 76351 switch int32(*(*int8)(unsafe.Pointer(idxStr + uintptr(i)))) { 76352 case 'e': 76353 zEq = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) 76354 break 76355 case 'm': 76356 zMatch = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) 76357 break 76358 case 'g': 76359 zGlob = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) 76360 break 76361 case 'r': 76362 zRegexp = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) 76363 break 76364 case 'l': 76365 zLike = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + uintptr(i)*8))) 76366 break 76367 default: 76368 76369 } 76370 } 76371 76372 (*Tcl_Obj)(unsafe.Pointer(p)).FrefCount++ 76373 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), p, tcl.XTcl_NewStringObj(tls, zEq, -1)) 76374 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), p, tcl.XTcl_NewStringObj(tls, zMatch, -1)) 76375 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), p, tcl.XTcl_NewStringObj(tls, zGlob, -1)) 76376 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), p, tcl.XTcl_NewStringObj(tls, zRegexp, -1)) 76377 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), p, tcl.XTcl_NewStringObj(tls, zLike, -1)) 76378 76379 tcl.XTcl_EvalObjEx(tls, interp, p, TCL_EVAL_GLOBAL) 76380 if (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList1 != 0 { 76381 for ok := true; ok; ok = 0 != 0 { 76382 var _objPtr uintptr = (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList1 76383 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 76384 tcl.XTclFreeObj(tls, _objPtr) 76385 } 76386 } 76387 } 76388 if (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList2 != 0 { 76389 for ok1 := true; ok1; ok1 = 0 != 0 { 76390 var _objPtr uintptr = (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList2 76391 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 76392 tcl.XTclFreeObj(tls, _objPtr) 76393 } 76394 } 76395 (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList2 = uintptr(0) 76396 } 76397 (*tclvar_cursor)(unsafe.Pointer(pCur)).Fi1 = 0 76398 (*tclvar_cursor)(unsafe.Pointer(pCur)).Fi2 = 0 76399 (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList1 = tcl.XTcl_GetObjResult(tls, interp) 76400 (*Tcl_Obj)(unsafe.Pointer((*tclvar_cursor)(unsafe.Pointer(pCur)).FpList1)).FrefCount++ 76401 76402 for ok2 := true; ok2; ok2 = 0 != 0 { 76403 var _objPtr uintptr = p 76404 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 76405 tcl.XTclFreeObj(tls, _objPtr) 76406 } 76407 } 76408 return tclvarNext(tls, pVtabCursor) 76409 } 76410 76411 func tclvarColumn(tls *libc.TLS, cur uintptr, ctx uintptr, i int32) int32 { /* test_tclvar.c:250:12: */ 76412 bp := tls.Alloc(32) 76413 defer tls.Free(32) 76414 76415 // var p1 uintptr at bp+16, 8 76416 76417 // var p2 uintptr at bp+24, 8 76418 76419 var z1 uintptr 76420 var z2 uintptr = ts + 489 /* "" */ 76421 var pCur uintptr = cur 76422 var interp uintptr = (*tclvar_vtab)(unsafe.Pointer((*sqlite3_vtab_cursor)(unsafe.Pointer(cur)).FpVtab)).Finterp 76423 76424 tcl.XTcl_ListObjIndex(tls, interp, (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList1, (*tclvar_cursor)(unsafe.Pointer(pCur)).Fi1, bp+16 /* &p1 */) 76425 tcl.XTcl_ListObjIndex(tls, interp, (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList2, (*tclvar_cursor)(unsafe.Pointer(pCur)).Fi2, bp+24 /* &p2 */) 76426 z1 = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* p1 */))) 76427 if *(*uintptr)(unsafe.Pointer(bp + 24 /* p2 */)) != 0 { 76428 z2 = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(bp + 24 /* p2 */))) 76429 } 76430 switch i { 76431 case 0: 76432 { 76433 sqlite3.Xsqlite3_result_text(tls, ctx, z1, -1, libc.UintptrFromInt32(-1)) 76434 break 76435 76436 } 76437 case 1: 76438 { 76439 sqlite3.Xsqlite3_result_text(tls, ctx, z2, -1, libc.UintptrFromInt32(-1)) 76440 break 76441 76442 } 76443 case 2: 76444 { 76445 var pVal uintptr = tcl.XTcl_GetVar2Ex(tls, interp, z1, func() uintptr { 76446 if *(*int8)(unsafe.Pointer(z2)) != 0 { 76447 return z2 76448 } 76449 return uintptr(0) 76450 }(), TCL_GLOBAL_ONLY) 76451 sqlite3.Xsqlite3_result_text(tls, ctx, tcl.XTcl_GetString(tls, pVal), -1, libc.UintptrFromInt32(-1)) 76452 break 76453 76454 } 76455 case 3: 76456 { 76457 var z3 uintptr 76458 if *(*uintptr)(unsafe.Pointer(bp + 24 /* p2 */)) != 0 { 76459 z3 = sqlite3.Xsqlite3_mprintf(tls, ts+36843 /* "%s(%s)" */, libc.VaList(bp, z1, z2)) 76460 sqlite3.Xsqlite3_result_text(tls, ctx, z3, -1, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sqlite3.Xsqlite3_free}))) 76461 } else { 76462 sqlite3.Xsqlite3_result_text(tls, ctx, z1, -1, libc.UintptrFromInt32(-1)) 76463 } 76464 break 76465 76466 } 76467 } 76468 return SQLITE_OK 76469 } 76470 76471 func tclvarRowid(tls *libc.TLS, cur uintptr, pRowid uintptr) int32 { /* test_tclvar.c:292:12: */ 76472 *(*sqlite_int64)(unsafe.Pointer(pRowid)) = int64(0) 76473 return SQLITE_OK 76474 } 76475 76476 func tclvarEof(tls *libc.TLS, cur uintptr) int32 { /* test_tclvar.c:297:12: */ 76477 var pCur uintptr = cur 76478 return func() int32 { 76479 if (*tclvar_cursor)(unsafe.Pointer(pCur)).FpList2 != 0 { 76480 return 0 76481 } 76482 return 1 76483 }() 76484 } 76485 76486 // If nul-terminated string zStr does not already contain the character 76487 // passed as the second argument, append it and return 0. Or, if there is 76488 // already an instance of x in zStr, do nothing return 1; 76489 // 76490 // There is guaranteed to be enough room in the buffer pointed to by zStr 76491 // for the new character and nul-terminator. 76492 func tclvarAddToIdxstr(tls *libc.TLS, zStr uintptr, x int8) int32 { /* test_tclvar.c:310:12: */ 76493 var i int32 76494 for i = 0; *(*int8)(unsafe.Pointer(zStr + uintptr(i))) != 0; i++ { 76495 if int32(*(*int8)(unsafe.Pointer(zStr + uintptr(i)))) == int32(x) { 76496 return 1 76497 } 76498 } 76499 *(*int8)(unsafe.Pointer(zStr + uintptr(i))) = x 76500 *(*int8)(unsafe.Pointer(zStr + uintptr((i + 1)))) = int8(0) 76501 return 0 76502 } 76503 76504 // Return true if variable $::tclvar_set_omit exists and is set to true. 76505 // False otherwise. 76506 func tclvarSetOmit(tls *libc.TLS, interp uintptr) int32 { /* test_tclvar.c:324:12: */ 76507 bp := tls.Alloc(4) 76508 defer tls.Free(4) 76509 76510 var rc int32 76511 *(*int32)(unsafe.Pointer(bp /* res */)) = 0 76512 var pRes uintptr 76513 rc = tcl.XTcl_Eval(tls, interp, 76514 ts+36850 /* "expr {[info exis..." */) 76515 if rc == TCL_OK { 76516 pRes = tcl.XTcl_GetObjResult(tls, interp) 76517 rc = tcl.XTcl_GetBooleanFromObj(tls, uintptr(0), pRes, bp /* &res */) 76518 } 76519 return (libc.Bool32((rc == TCL_OK) && (*(*int32)(unsafe.Pointer(bp /* res */)) != 0))) 76520 } 76521 76522 // The xBestIndex() method. This virtual table supports the following 76523 // operators: 76524 // 76525 // name = ? (omit flag clear) 76526 // name MATCH ? (omit flag set) 76527 // value GLOB ? (omit flag set iff $::tclvar_set_omit) 76528 // value REGEXP ? (omit flag set iff $::tclvar_set_omit) 76529 // value LIKE ? (omit flag set iff $::tclvar_set_omit) 76530 // 76531 // For each constraint present, the corresponding TCLVAR_XXX character is 76532 // appended to the idxStr value. 76533 func tclvarBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) int32 { /* test_tclvar.c:351:12: */ 76534 var pTab uintptr = tab 76535 var ii int32 76536 var zStr uintptr = sqlite3.Xsqlite3_malloc(tls, 32) 76537 var iStr int32 = 0 76538 76539 if zStr == uintptr(0) { 76540 return SQLITE_NOMEM 76541 } 76542 *(*int8)(unsafe.Pointer(zStr)) = int8(0) 76543 76544 for ii = 0; ii < (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint; ii++ { 76545 var pCons uintptr = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12) 76546 var pUsage uintptr 76547 76548 pUsage = ((*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(ii)*8) 76549 if (*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fusable != 0 { 76550 // name = ? 76551 if (int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == SQLITE_INDEX_CONSTRAINT_EQ) && ((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn == 0) { 76552 if 0 == tclvarAddToIdxstr(tls, zStr, int8('e')) { 76553 (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).FargvIndex = libc.PreIncInt32(&iStr, 1) 76554 (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).Fomit = uint8(0) 76555 } 76556 } 76557 76558 // name MATCH ? 76559 if (int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == SQLITE_INDEX_CONSTRAINT_MATCH) && ((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn == 0) { 76560 if 0 == tclvarAddToIdxstr(tls, zStr, int8('m')) { 76561 (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).FargvIndex = libc.PreIncInt32(&iStr, 1) 76562 (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).Fomit = uint8(1) 76563 } 76564 } 76565 76566 // value GLOB ? 76567 if (int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == SQLITE_INDEX_CONSTRAINT_GLOB) && ((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn == 2) { 76568 if 0 == tclvarAddToIdxstr(tls, zStr, int8('g')) { 76569 (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).FargvIndex = libc.PreIncInt32(&iStr, 1) 76570 (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).Fomit = uint8(tclvarSetOmit(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp)) 76571 } 76572 } 76573 76574 // value REGEXP ? 76575 if (int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == SQLITE_INDEX_CONSTRAINT_REGEXP) && ((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn == 2) { 76576 if 0 == tclvarAddToIdxstr(tls, zStr, int8('r')) { 76577 (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).FargvIndex = libc.PreIncInt32(&iStr, 1) 76578 (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).Fomit = uint8(tclvarSetOmit(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp)) 76579 } 76580 } 76581 76582 // value LIKE ? 76583 if (int32((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).Fop) == SQLITE_INDEX_CONSTRAINT_LIKE) && ((*sqlite3_index_constraint)(unsafe.Pointer(pCons)).FiColumn == 2) { 76584 if 0 == tclvarAddToIdxstr(tls, zStr, int8('l')) { 76585 (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).FargvIndex = libc.PreIncInt32(&iStr, 1) 76586 (*sqlite3_index_constraint_usage)(unsafe.Pointer(pUsage)).Fomit = uint8(tclvarSetOmit(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp)) 76587 } 76588 } 76589 } 76590 } 76591 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = zStr 76592 (*sqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FneedToFreeIdxStr = 1 76593 76594 return SQLITE_OK 76595 } 76596 76597 // Invoked for any UPDATE, INSERT, or DELETE against a tclvar table 76598 func tclvarUpdate(tls *libc.TLS, tab uintptr, argc int32, argv uintptr, pRowid uintptr) int32 { /* test_tclvar.c:416:12: */ 76599 var pTab uintptr = tab 76600 if argc == 1 { 76601 // A DELETE operation. The variable to be deleted is stored in argv[0] 76602 var zVar uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 76603 tcl.XTcl_UnsetVar2(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp, zVar, uintptr(0), TCL_GLOBAL_ONLY) 76604 return SQLITE_OK 76605 } 76606 if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_NULL { 76607 // An INSERT operation 76608 var zValue uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8))) 76609 var zName uintptr 76610 if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 5*8))) != SQLITE_TEXT { 76611 (*sqlite3_vtab)(unsafe.Pointer(tab)).FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+36911 /* "the 'fullname' c..." */, 0) 76612 return SQLITE_ERROR 76613 } 76614 zName = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 5*8))) 76615 if zValue != 0 { 76616 tcl.XTcl_SetVar2(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp, zName, uintptr(0), zValue, TCL_GLOBAL_ONLY) 76617 } else { 76618 tcl.XTcl_UnsetVar2(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp, zName, uintptr(0), TCL_GLOBAL_ONLY) 76619 } 76620 return SQLITE_OK 76621 } 76622 if (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv))) == SQLITE_TEXT) && 76623 (sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) == SQLITE_TEXT) { 76624 // An UPDATE operation 76625 var zOldName uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv))) 76626 var zNewName uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8))) 76627 var zValue uintptr = sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(argv + 4*8))) 76628 76629 if (libc.Xstrcmp(tls, zOldName, zNewName) != 0) || (zValue == uintptr(0)) { 76630 tcl.XTcl_UnsetVar2(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp, zOldName, uintptr(0), TCL_GLOBAL_ONLY) 76631 } 76632 if zValue != uintptr(0) { 76633 tcl.XTcl_SetVar2(tls, (*tclvar_vtab)(unsafe.Pointer(pTab)).Finterp, zNewName, uintptr(0), zValue, TCL_GLOBAL_ONLY) 76634 } 76635 return SQLITE_OK 76636 } 76637 (*sqlite3_vtab)(unsafe.Pointer(tab)).FzErrMsg = sqlite3.Xsqlite3_mprintf(tls, ts+36946 /* "prohibited TCL v..." */, 0) 76638 return SQLITE_ERROR 76639 } 76640 76641 // A virtual table module that provides read-only access to a 76642 // Tcl global variable namespace. 76643 var tclvarModule = sqlite3_module{ // iVersion 76644 FxCreate: 0, 76645 FxConnect: 0, 76646 FxBestIndex: 0, 76647 FxDisconnect: 0, 76648 FxDestroy: 0, 76649 FxOpen: 0, // xOpen - open a cursor 76650 FxClose: 0, // xClose - close a cursor 76651 FxFilter: 0, // xFilter - configure scan constraints 76652 FxNext: 0, // xNext - advance a cursor 76653 FxEof: 0, // xEof - check for end of scan 76654 FxColumn: 0, // xColumn - read data 76655 FxRowid: 0, // xRowid - read data 76656 FxUpdate: 0, // xRename 76657 } /* test_tclvar.c:469:23 */ 76658 76659 // Register the echo virtual table module. 76660 func register_tclvar_module(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_tclvar.c:500:26: */ 76661 bp := tls.Alloc(8) 76662 defer tls.Free(8) 76663 76664 var rc int32 = TCL_OK 76665 // var db uintptr at bp, 8 76666 76667 if objc != 2 { 76668 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 76669 return TCL_ERROR 76670 } 76671 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 76672 return TCL_ERROR 76673 } 76674 sqlite3.Xsqlite3_create_module(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+29192 /* "tclvar" */, uintptr(unsafe.Pointer(&tclvarModule)), interp) 76675 rc = tcl.XTcl_Eval(tls, interp, 76676 76677 ts+36977 /* "proc like {patte..." */) 76678 return rc 76679 } 76680 76681 // Register commands with the TCL interpreter. 76682 func Sqlitetesttclvar_Init(tls *libc.TLS, interp uintptr) int32 { /* test_tclvar.c:546:5: */ 76683 var i int32 76684 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aObjCmd13)) / uint64(unsafe.Sizeof(struct { 76685 FzName uintptr 76686 FxProc uintptr 76687 FclientData uintptr 76688 }{}))); i++ { 76689 tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd13[i].FzName, 76690 aObjCmd13[i].FxProc, aObjCmd13[i].FclientData, uintptr(0)) 76691 } 76692 return TCL_OK 76693 } 76694 76695 var aObjCmd13 = [1]struct { 76696 FzName uintptr 76697 FxProc uintptr 76698 FclientData uintptr 76699 }{ 76700 {FzName: ts + 37513 /* "register_tclvar_..." */, FxProc: 0}, 76701 } /* test_tclvar.c:552:5 */ 76702 76703 // Define some macros helping to catch buffer overflows. 76704 76705 // One of these is allocated for each thread created by [sqlthread spawn]. 76706 type SqlThread1 = struct { 76707 Fparent Tcl_ThreadId 76708 Finterp uintptr 76709 FzScript uintptr 76710 FzVarname uintptr 76711 } /* test_thread.c:36:9 */ 76712 76713 // Define some macros helping to catch buffer overflows. 76714 76715 // One of these is allocated for each thread created by [sqlthread spawn]. 76716 type SqlThread = SqlThread1 /* test_thread.c:36:26 */ 76717 76718 // A custom Tcl_Event type used by this module. When the event is 76719 // handled, script zScript is evaluated in interpreter interp. If 76720 // the evaluation throws an exception (returns TCL_ERROR), then the 76721 // error is handled by Tcl_BackgroundError(). If no error occurs, 76722 // the result is simply discarded. 76723 type EvalEvent1 = struct { 76724 Fbase Tcl_Event 76725 FzScript uintptr 76726 Finterp uintptr 76727 } /* test_thread.c:51:9 */ 76728 76729 // A custom Tcl_Event type used by this module. When the event is 76730 // handled, script zScript is evaluated in interpreter interp. If 76731 // the evaluation throws an exception (returns TCL_ERROR), then the 76732 // error is handled by Tcl_BackgroundError(). If no error occurs, 76733 // the result is simply discarded. 76734 type EvalEvent = EvalEvent1 /* test_thread.c:51:26 */ 76735 76736 // Handler for events of type EvalEvent. 76737 func tclScriptEvent(tls *libc.TLS, evPtr uintptr, flags int32) int32 { /* test_thread.c:79:26: */ 76738 var rc int32 76739 var p uintptr = evPtr 76740 rc = tcl.XTcl_Eval(tls, (*EvalEvent)(unsafe.Pointer(p)).Finterp, (*EvalEvent)(unsafe.Pointer(p)).FzScript) 76741 if rc != TCL_OK { 76742 tcl.XTcl_BackgroundError(tls, (*EvalEvent)(unsafe.Pointer(p)).Finterp) 76743 } 76744 _ = flags 76745 return 1 76746 } 76747 76748 // Register an EvalEvent to evaluate the script pScript in the 76749 // parent interpreter/thread of SqlThread p. 76750 func postToParent(tls *libc.TLS, p uintptr, pScript uintptr) { /* test_thread.c:94:13: */ 76751 bp := tls.Alloc(4) 76752 defer tls.Free(4) 76753 76754 var pEvent uintptr 76755 var zMsg uintptr 76756 // var nMsg int32 at bp, 4 76757 76758 zMsg = tcl.XTcl_GetStringFromObj(tls, pScript, bp /* &nMsg */) 76759 pEvent = tcl.XTcl_Alloc(tls, (uint32((uint64(unsafe.Sizeof(EvalEvent{})) + uint64(*(*int32)(unsafe.Pointer(bp /* nMsg */)))) + uint64(1)))) 76760 (*EvalEvent)(unsafe.Pointer(pEvent)).Fbase.FnextPtr = uintptr(0) 76761 (*EvalEvent)(unsafe.Pointer(pEvent)).Fbase.Fproc = *(*uintptr)(unsafe.Pointer(&struct { 76762 f func(*libc.TLS, uintptr, int32) int32 76763 }{tclScriptEvent})) 76764 (*EvalEvent)(unsafe.Pointer(pEvent)).FzScript = (pEvent + 1*32) 76765 libc.Xmemcpy(tls, (*EvalEvent)(unsafe.Pointer(pEvent)).FzScript, zMsg, (uint64(*(*int32)(unsafe.Pointer(bp /* nMsg */)) + 1))) 76766 (*EvalEvent)(unsafe.Pointer(pEvent)).Finterp = (*SqlThread)(unsafe.Pointer(p)).Finterp 76767 76768 tcl.XTcl_ThreadQueueEvent(tls, (*SqlThread)(unsafe.Pointer(p)).Fparent, pEvent, TCL_QUEUE_TAIL) 76769 tcl.XTcl_ThreadAlert(tls, (*SqlThread)(unsafe.Pointer(p)).Fparent) 76770 } 76771 76772 // The main function for threads created with [sqlthread spawn]. 76773 func tclScriptThread(tls *libc.TLS, pSqlThread ClientData) { /* test_thread.c:114:29: */ 76774 var interp uintptr 76775 var pRes uintptr 76776 var pList uintptr 76777 var rc int32 76778 var p uintptr = pSqlThread 76779 76780 interp = tcl.XTcl_CreateInterp(tls) 76781 tcl.XTcl_CreateObjCommand(tls, interp, ts+37536 /* "clock_seconds" */, *(*uintptr)(unsafe.Pointer(&struct { 76782 f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 76783 }{clock_seconds_proc})), uintptr(0), uintptr(0)) 76784 tcl.XTcl_CreateObjCommand(tls, interp, ts+37550 /* "sqlthread" */, *(*uintptr)(unsafe.Pointer(&struct { 76785 f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 76786 }{sqlthread_proc})), pSqlThread, uintptr(0)) 76787 tcl.XTcl_CreateObjCommand(tls, interp, ts+37560 /* "sqlite3_blocking..." */, *(*uintptr)(unsafe.Pointer(&struct { 76788 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 76789 }{blocking_step_proc})), uintptr(0), uintptr(0)) 76790 tcl.XTcl_CreateObjCommand(tls, interp, 76791 ts+37582 /* "sqlite3_blocking..." */, *(*uintptr)(unsafe.Pointer(&struct { 76792 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 76793 }{blocking_prepare_v2_proc})), uintptr(1), uintptr(0)) 76794 tcl.XTcl_CreateObjCommand(tls, interp, 76795 ts+37610 /* "sqlite3_nonblock..." */, *(*uintptr)(unsafe.Pointer(&struct { 76796 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 76797 }{blocking_prepare_v2_proc})), uintptr(0), uintptr(0)) 76798 Sqlitetest1_Init(tls, interp) 76799 Sqlitetest_mutex_Init(tls, interp) 76800 Sqlite3_Init(tls, interp) 76801 76802 rc = tcl.XTcl_Eval(tls, interp, (*SqlThread)(unsafe.Pointer(p)).FzScript) 76803 pRes = tcl.XTcl_GetObjResult(tls, interp) 76804 pList = tcl.XTcl_NewObj(tls) 76805 (*Tcl_Obj)(unsafe.Pointer(pList)).FrefCount++ 76806 (*Tcl_Obj)(unsafe.Pointer(pRes)).FrefCount++ 76807 76808 if rc != TCL_OK { 76809 tcl.XTcl_ListObjAppendElement(tls, interp, pList, tcl.XTcl_NewStringObj(tls, ts+10311 /* "error" */, -1)) 76810 tcl.XTcl_ListObjAppendElement(tls, interp, pList, pRes) 76811 postToParent(tls, p, pList) 76812 for ok := true; ok; ok = 0 != 0 { 76813 var _objPtr uintptr = pList 76814 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 76815 tcl.XTclFreeObj(tls, _objPtr) 76816 } 76817 } 76818 pList = tcl.XTcl_NewObj(tls) 76819 } 76820 76821 tcl.XTcl_ListObjAppendElement(tls, interp, pList, tcl.XTcl_NewStringObj(tls, ts+37641 /* "set" */, -1)) 76822 tcl.XTcl_ListObjAppendElement(tls, interp, pList, tcl.XTcl_NewStringObj(tls, (*SqlThread)(unsafe.Pointer(p)).FzVarname, -1)) 76823 tcl.XTcl_ListObjAppendElement(tls, interp, pList, pRes) 76824 postToParent(tls, p, pList) 76825 76826 tcl.XTcl_Free(tls, p) 76827 for ok1 := true; ok1; ok1 = 0 != 0 { 76828 var _objPtr uintptr = pList 76829 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 76830 tcl.XTclFreeObj(tls, _objPtr) 76831 } 76832 } 76833 for ok2 := true; ok2; ok2 = 0 != 0 { 76834 var _objPtr uintptr = pRes 76835 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 76836 tcl.XTclFreeObj(tls, _objPtr) 76837 } 76838 } 76839 tcl.XTcl_DeleteInterp(tls, interp) 76840 for tcl.XTcl_DoOneEvent(tls, ((libc.CplInt32((int32(1) << 1)))|(int32(1)<<1))) != 0 { 76841 } 76842 tcl.XTcl_ExitThread(tls, 0) 76843 76844 } 76845 76846 // sqlthread spawn VARNAME SCRIPT 76847 // 76848 // Spawn a new thread with its own Tcl interpreter and run the 76849 // specified SCRIPT(s) in it. The thread terminates after running 76850 // the script. The result of the script is stored in the variable 76851 // VARNAME. 76852 // 76853 // The caller can wait for the script to terminate using [vwait VARNAME]. 76854 func sqlthread_spawn(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_thread.c:174:26: */ 76855 bp := tls.Alloc(32) 76856 defer tls.Free(32) 76857 76858 // var x Tcl_ThreadId at bp+24, 8 76859 76860 var pNew uintptr 76861 var rc int32 76862 // var nVarname int32 at bp+16, 4 76863 76864 var zVarname uintptr 76865 // var nScript int32 at bp+20, 4 76866 76867 var zScript uintptr 76868 76869 // Parameters for thread creation 76870 var nStack int32 = 0 76871 var flags int32 = 0000 76872 76873 _ = clientData 76874 _ = objc 76875 76876 zVarname = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+16 /* &nVarname */) 76877 zScript = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+20 /* &nScript */) 76878 76879 pNew = tcl.XTcl_Alloc(tls, (uint32(((uint64(unsafe.Sizeof(SqlThread{})) + uint64(*(*int32)(unsafe.Pointer(bp + 16 /* nVarname */)))) + uint64(*(*int32)(unsafe.Pointer(bp + 20 /* nScript */)))) + uint64(2)))) 76880 (*SqlThread)(unsafe.Pointer(pNew)).FzVarname = (pNew + 1*32) 76881 (*SqlThread)(unsafe.Pointer(pNew)).FzScript = ((*SqlThread)(unsafe.Pointer(pNew)).FzVarname + uintptr((*(*int32)(unsafe.Pointer(bp + 16 /* nVarname */)) + 1))) 76882 libc.Xmemcpy(tls, (*SqlThread)(unsafe.Pointer(pNew)).FzVarname, zVarname, (uint64(*(*int32)(unsafe.Pointer(bp + 16 /* nVarname */)) + 1))) 76883 libc.Xmemcpy(tls, (*SqlThread)(unsafe.Pointer(pNew)).FzScript, zScript, (uint64(*(*int32)(unsafe.Pointer(bp + 20 /* nScript */)) + 1))) 76884 (*SqlThread)(unsafe.Pointer(pNew)).Fparent = tcl.XTcl_GetCurrentThread(tls) 76885 (*SqlThread)(unsafe.Pointer(pNew)).Finterp = interp 76886 76887 rc = tcl.XTcl_CreateThread(tls, bp+24 /* &x */, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, ClientData) }{tclScriptThread})), pNew, nStack, flags) 76888 if rc != TCL_OK { 76889 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+37645 /* "Error in Tcl_Cre..." */, 0)) 76890 tcl.XTcl_Free(tls, pNew) 76891 return TCL_ERROR 76892 } 76893 76894 return TCL_OK 76895 } 76896 76897 // sqlthread parent SCRIPT 76898 // 76899 // This can be called by spawned threads only. It sends the specified 76900 // script back to the parent thread for execution. The result of 76901 // evaluating the SCRIPT is returned. The parent thread must enter 76902 // the event loop for this to work - otherwise the caller will 76903 // block indefinitely. 76904 // 76905 // NOTE: At the moment, this doesn't work. FIXME. 76906 func sqlthread_parent(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_thread.c:227:26: */ 76907 bp := tls.Alloc(20) 76908 defer tls.Free(20) 76909 76910 var pEvent uintptr 76911 var zMsg uintptr 76912 // var nMsg int32 at bp+16, 4 76913 76914 var p uintptr = clientData 76915 76916 _ = objc 76917 76918 if p == uintptr(0) { 76919 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+37673 /* "no parent thread" */, 0)) 76920 return TCL_ERROR 76921 } 76922 76923 zMsg = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+16 /* &nMsg */) 76924 pEvent = tcl.XTcl_Alloc(tls, (uint32((uint64(unsafe.Sizeof(EvalEvent{})) + uint64(*(*int32)(unsafe.Pointer(bp + 16 /* nMsg */)))) + uint64(1)))) 76925 (*EvalEvent)(unsafe.Pointer(pEvent)).Fbase.FnextPtr = uintptr(0) 76926 (*EvalEvent)(unsafe.Pointer(pEvent)).Fbase.Fproc = *(*uintptr)(unsafe.Pointer(&struct { 76927 f func(*libc.TLS, uintptr, int32) int32 76928 }{tclScriptEvent})) 76929 (*EvalEvent)(unsafe.Pointer(pEvent)).FzScript = (pEvent + 1*32) 76930 libc.Xmemcpy(tls, (*EvalEvent)(unsafe.Pointer(pEvent)).FzScript, zMsg, (uint64(*(*int32)(unsafe.Pointer(bp + 16 /* nMsg */)) + 1))) 76931 (*EvalEvent)(unsafe.Pointer(pEvent)).Finterp = (*SqlThread)(unsafe.Pointer(p)).Finterp 76932 tcl.XTcl_ThreadQueueEvent(tls, (*SqlThread)(unsafe.Pointer(p)).Fparent, pEvent, TCL_QUEUE_TAIL) 76933 tcl.XTcl_ThreadAlert(tls, (*SqlThread)(unsafe.Pointer(p)).Fparent) 76934 76935 return TCL_OK 76936 } 76937 76938 func xBusy(tls *libc.TLS, pArg uintptr, nBusy int32) int32 { /* test_thread.c:259:12: */ 76939 _ = pArg 76940 _ = nBusy 76941 sqlite3.Xsqlite3_sleep(tls, 50) 76942 return 1 // Try again... 76943 } 76944 76945 // sqlthread open 76946 // 76947 // Open a database handle and return the string representation of 76948 // the pointer value. 76949 func sqlthread_open(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_thread.c:272:26: */ 76950 bp := tls.Alloc(124) 76951 defer tls.Free(124) 76952 76953 var zFilename uintptr 76954 // var db uintptr at bp+16, 8 76955 76956 // var zBuf [100]int8 at bp+24, 100 76957 76958 _ = clientData 76959 _ = objc 76960 76961 zFilename = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 76962 sqlite3.Xsqlite3_open(tls, zFilename, bp+16 /* &db */) 76963 Md5_Register(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), uintptr(0), uintptr(0)) 76964 sqlite3.Xsqlite3_busy_handler(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), *(*uintptr)(unsafe.Pointer(&struct { 76965 f func(*libc.TLS, uintptr, int32) int32 76966 }{xBusy})), uintptr(0)) 76967 76968 if sqlite3TestMakePointerStr(tls, interp, bp+24 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */))) != 0 { 76969 return TCL_ERROR 76970 } 76971 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, bp+24 /* &zBuf[0] */, 0)) 76972 76973 return TCL_OK 76974 } 76975 76976 // sqlthread open 76977 // 76978 // Return the current thread-id (Tcl_GetCurrentThread()) cast to 76979 // an integer. 76980 func sqlthread_id(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_thread.c:306:26: */ 76981 var id Tcl_ThreadId = tcl.XTcl_GetCurrentThread(tls) 76982 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, int32(id))) 76983 _ = clientData 76984 _ = objc 76985 _ = objv 76986 return TCL_OK 76987 } 76988 76989 // Dispatch routine for the sub-commands of [sqlthread]. 76990 func sqlthread_proc(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_thread.c:324:26: */ 76991 bp := tls.Alloc(164) 76992 defer tls.Free(164) 76993 76994 *(*[5]struct { 76995 FzName uintptr 76996 FxProc uintptr 76997 FnArg int32 76998 _ [4]byte 76999 FzUsage uintptr 77000 })(unsafe.Pointer(bp /* aSub */)) = [5]struct { 77001 FzName uintptr 77002 FxProc uintptr 77003 FnArg int32 77004 _ [4]byte 77005 FzUsage uintptr 77006 }{ 77007 {FzName: ts + 37690 /* "parent" */, FxProc: *(*uintptr)(unsafe.Pointer(&struct { 77008 f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 77009 }{sqlthread_parent})), FnArg: 1, FzUsage: ts + 11585 /* "SCRIPT" */}, 77010 {FzName: ts + 37697 /* "spawn" */, FxProc: *(*uintptr)(unsafe.Pointer(&struct { 77011 f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 77012 }{sqlthread_spawn})), FnArg: 2, FzUsage: ts + 37703 /* "VARNAME SCRIPT" */}, 77013 {FzName: ts + 36307 /* "open" */, FxProc: *(*uintptr)(unsafe.Pointer(&struct { 77014 f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 77015 }{sqlthread_open})), FnArg: 1, FzUsage: ts + 37718 /* "DBNAME" */}, 77016 {FzName: ts + 37725 /* "id" */, FxProc: *(*uintptr)(unsafe.Pointer(&struct { 77017 f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 77018 }{sqlthread_id})), FzUsage: ts + 489 /* "" */}, 77019 {}, 77020 } 77021 var pSub uintptr 77022 var rc int32 77023 // var iIndex int32 at bp+160, 4 77024 77025 if objc < 2 { 77026 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+2384 /* "SUB-COMMAND" */) 77027 return TCL_ERROR 77028 } 77029 77030 rc = tcl.XTcl_GetIndexFromObjStruct(tls, 77031 interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp /* &aSub[0] */, int32(unsafe.Sizeof(struct { 77032 FzName uintptr 77033 FxProc uintptr 77034 FnArg int32 77035 _ [4]byte 77036 FzUsage uintptr 77037 }{})), ts+1875 /* "sub-command" */, 0, bp+160 /* &iIndex */) 77038 if rc != TCL_OK { 77039 return rc 77040 } 77041 pSub = (bp /* &aSub */ + uintptr(*(*int32)(unsafe.Pointer(bp + 160 /* iIndex */)))*32) 77042 77043 if objc < ((*struct { 77044 FzName uintptr 77045 FxProc uintptr 77046 FnArg int32 77047 _ [4]byte 77048 FzUsage uintptr 77049 })(unsafe.Pointer(pSub)).FnArg + 2) { 77050 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, (*struct { 77051 FzName uintptr 77052 FxProc uintptr 77053 FnArg int32 77054 _ [4]byte 77055 FzUsage uintptr 77056 })(unsafe.Pointer(pSub)).FzUsage) 77057 return TCL_ERROR 77058 } 77059 77060 return (*(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer((pSub + 8 /* &.xProc */))))(tls, clientData, interp, objc, objv) 77061 } 77062 77063 /* 77064 ** The [clock_seconds] command. This is more or less the same as the 77065 ** regular tcl [clock seconds], except that it is available in testfixture 77066 ** when linked against both Tcl 8.4 and 8.5. Because [clock seconds] is 77067 ** implemented as a script in Tcl 8.5, it is not usually available to 77068 ** testfixture. 77069 */ 77070 func clock_seconds_proc(tls *libc.TLS, clientData ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_thread.c:372:26: */ 77071 bp := tls.Alloc(16) 77072 defer tls.Free(16) 77073 77074 // var now Tcl_Time at bp, 16 77075 77076 tcl.XTcl_GetTime(tls, bp /* &now */) 77077 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, int32((*Tcl_Time)(unsafe.Pointer(bp /* &now */)).Fsec))) 77078 _ = clientData 77079 _ = objc 77080 _ = objv 77081 return TCL_OK 77082 } 77083 77084 // A pointer to an instance of this structure is passed as the user-context 77085 // pointer when registering for an unlock-notify callback. 77086 type UnlockNotification1 = struct { 77087 Ffired int32 77088 _ [4]byte 77089 Fcond pthread_cond_t 77090 Fmutex pthread_mutex_t 77091 } /* test_thread.c:410:9 */ 77092 77093 // A pointer to an instance of this structure is passed as the user-context 77094 // pointer when registering for an unlock-notify callback. 77095 type UnlockNotification = UnlockNotification1 /* test_thread.c:410:35 */ 77096 77097 // This function is an unlock-notify callback registered with SQLite. 77098 func unlock_notify_cb(tls *libc.TLS, apArg uintptr, nArg int32) { /* test_thread.c:420:13: */ 77099 var i int32 77100 for i = 0; i < nArg; i++ { 77101 var p uintptr = *(*uintptr)(unsafe.Pointer(apArg + uintptr(i)*8)) 77102 libc2.Xpthread_mutex_lock(tls, (p + 56 /* &.mutex */)) 77103 (*UnlockNotification)(unsafe.Pointer(p)).Ffired = 1 77104 libc2.Xpthread_cond_signal(tls, (p + 8 /* &.cond */)) 77105 libc2.Xpthread_mutex_unlock(tls, (p + 56 /* &.mutex */)) 77106 } 77107 } 77108 77109 // This function assumes that an SQLite API call (either sqlite3_prepare_v2() 77110 // or sqlite3_step()) has just returned SQLITE_LOCKED. The argument is the 77111 // associated database connection. 77112 // 77113 // This function calls sqlite3_unlock_notify() to register for an 77114 // unlock-notify callback, then blocks until that callback is delivered 77115 // and returns SQLITE_OK. The caller should then retry the failed operation. 77116 // 77117 // Or, if sqlite3_unlock_notify() indicates that to block would deadlock 77118 // the system, then this function returns SQLITE_LOCKED immediately. In 77119 // this case the caller should not retry the operation and should roll 77120 // back the current transaction (if any). 77121 func wait_for_unlock_notify(tls *libc.TLS, db uintptr) int32 { /* test_thread.c:445:12: */ 77122 bp := tls.Alloc(96) 77123 defer tls.Free(96) 77124 77125 var rc int32 77126 // var un UnlockNotification at bp, 96 77127 77128 // Initialize the UnlockNotification structure. 77129 (*UnlockNotification)(unsafe.Pointer(bp /* &un */)).Ffired = 0 77130 libc2.Xpthread_mutex_init(tls, (bp /* &un */ + 56 /* &.mutex */), uintptr(0)) 77131 libc2.Xpthread_cond_init(tls, (bp /* &un */ + 8 /* &.cond */), uintptr(0)) 77132 77133 // Register for an unlock-notify callback. 77134 rc = sqlite3.Xsqlite3_unlock_notify(tls, db, *(*uintptr)(unsafe.Pointer(&struct { 77135 f func(*libc.TLS, uintptr, int32) 77136 }{unlock_notify_cb})), bp /* &un */) 77137 77138 // The call to sqlite3_unlock_notify() always returns either SQLITE_LOCKED 77139 // or SQLITE_OK. 77140 // 77141 // If SQLITE_LOCKED was returned, then the system is deadlocked. In this 77142 // case this function needs to return SQLITE_LOCKED to the caller so 77143 // that the current transaction can be rolled back. Otherwise, block 77144 // until the unlock-notify callback is invoked, then return SQLITE_OK. 77145 if rc == SQLITE_OK { 77146 libc2.Xpthread_mutex_lock(tls, (bp /* &un */ + 56 /* &.mutex */)) 77147 if !((*UnlockNotification)(unsafe.Pointer(bp /* &un */)).Ffired != 0) { 77148 libc2.Xpthread_cond_wait(tls, (bp /* &un */ + 8 /* &.cond */), (bp /* &un */ + 56 /* &.mutex */)) 77149 } 77150 libc2.Xpthread_mutex_unlock(tls, (bp /* &un */ + 56 /* &.mutex */)) 77151 } 77152 77153 // Destroy the mutex and condition variables. 77154 libc2.Xpthread_cond_destroy(tls, (bp /* &un */ + 8 /* &.cond */)) 77155 libc2.Xpthread_mutex_destroy(tls, (bp /* &un */ + 56 /* &.mutex */)) 77156 77157 return rc 77158 } 77159 77160 // This function is a wrapper around the SQLite function sqlite3_step(). 77161 // It functions in the same way as step(), except that if a required 77162 // shared-cache lock cannot be obtained, this function may block waiting for 77163 // the lock to become available. In this scenario the normal API step() 77164 // function always returns SQLITE_LOCKED. 77165 // 77166 // If this function returns SQLITE_LOCKED, the caller should rollback 77167 // the current transaction (if any) and try again later. Otherwise, the 77168 // system may become deadlocked. 77169 func sqlite3_blocking_step(tls *libc.TLS, pStmt uintptr) int32 { /* test_thread.c:492:5: */ 77170 var rc int32 77171 for SQLITE_LOCKED == (libc.AssignInt32(&rc, sqlite3.Xsqlite3_step(tls, pStmt))) { 77172 rc = wait_for_unlock_notify(tls, sqlite3.Xsqlite3_db_handle(tls, pStmt)) 77173 if rc != SQLITE_OK { 77174 break 77175 } 77176 sqlite3.Xsqlite3_reset(tls, pStmt) 77177 } 77178 return rc 77179 } 77180 77181 // This function is a wrapper around the SQLite function sqlite3_prepare_v2(). 77182 // It functions in the same way as prepare_v2(), except that if a required 77183 // shared-cache lock cannot be obtained, this function may block waiting for 77184 // the lock to become available. In this scenario the normal API prepare_v2() 77185 // function always returns SQLITE_LOCKED. 77186 // 77187 // If this function returns SQLITE_LOCKED, the caller should rollback 77188 // the current transaction (if any) and try again later. Otherwise, the 77189 // system may become deadlocked. 77190 func sqlite3_blocking_prepare_v2(tls *libc.TLS, db uintptr, zSql uintptr, nSql int32, ppStmt uintptr, pz uintptr) int32 { /* test_thread.c:513:5: */ 77191 var rc int32 77192 for SQLITE_LOCKED == (libc.AssignInt32(&rc, sqlite3.Xsqlite3_prepare_v2(tls, db, zSql, nSql, ppStmt, pz))) { 77193 rc = wait_for_unlock_notify(tls, db) 77194 if rc != SQLITE_OK { 77195 break 77196 } 77197 } 77198 return rc 77199 } 77200 77201 // END_SQLITE_BLOCKING_STEP 77202 77203 // Usage: sqlite3_blocking_step STMT 77204 // 77205 // Advance the statement to the next row. 77206 func blocking_step_proc(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_thread.c:534:26: */ 77207 var pStmt uintptr 77208 var rc int32 77209 77210 if objc != 2 { 77211 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+16629 /* "STMT" */) 77212 return TCL_ERROR 77213 } 77214 77215 pStmt = sqlite3TestTextToPtr(tls, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8)))) 77216 rc = sqlite3_blocking_step(tls, pStmt) 77217 77218 tcl.XTcl_SetResult(tls, interp, sqlite3.Xsqlite3ErrName(tls, rc), uintptr(0)) 77219 return TCL_OK 77220 } 77221 77222 // Usage: sqlite3_blocking_prepare_v2 DB sql bytes ?tailvar? 77223 // Usage: sqlite3_nonblocking_prepare_v2 DB sql bytes ?tailvar? 77224 func blocking_prepare_v2_proc(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_thread.c:560:26: */ 77225 bp := tls.Alloc(162) 77226 defer tls.Free(162) 77227 77228 // var db uintptr at bp+80, 8 77229 77230 var zSql uintptr 77231 // var bytes int32 at bp+88, 4 77232 77233 *(*uintptr)(unsafe.Pointer(bp + 104 /* zTail */)) = uintptr(0) 77234 *(*uintptr)(unsafe.Pointer(bp + 96 /* pStmt */)) = uintptr(0) 77235 // var zBuf [50]int8 at bp+112, 50 77236 77237 var rc int32 77238 var isBlocking int32 = libc.BoolInt32(!(clientData == uintptr(0))) 77239 77240 if (objc != 5) && (objc != 4) { 77241 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+14631, /* "wrong # args: sh..." */ 77242 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv))), ts+16675 /* " DB sql bytes ta..." */, 0)) 77243 return TCL_ERROR 77244 } 77245 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+80 /* &db */) != 0 { 77246 return TCL_ERROR 77247 } 77248 zSql = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 77249 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+88 /* &bytes */) != 0 { 77250 return TCL_ERROR 77251 } 77252 77253 if isBlocking != 0 { 77254 rc = sqlite3_blocking_prepare_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */)), zSql, *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)), bp+96 /* &pStmt */, bp+104 /* &zTail */) 77255 } else { 77256 rc = sqlite3.Xsqlite3_prepare_v2(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */)), zSql, *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)), bp+96 /* &pStmt */, bp+104 /* &zTail */) 77257 } 77258 77259 if (*(*uintptr)(unsafe.Pointer(bp + 104 /* zTail */)) != 0) && (objc >= 5) { 77260 if *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) >= 0 { 77261 *(*int32)(unsafe.Pointer(bp + 88 /* bytes */)) = (int32(int64(*(*int32)(unsafe.Pointer(bp + 88 /* bytes */))) - ((int64(*(*uintptr)(unsafe.Pointer(bp + 104 /* zTail */))) - int64(zSql)) / 1))) 77262 } 77263 tcl.XTcl_ObjSetVar2(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), uintptr(0), tcl.XTcl_NewStringObj(tls, *(*uintptr)(unsafe.Pointer(bp + 104 /* zTail */)), *(*int32)(unsafe.Pointer(bp + 88 /* bytes */))), 0) 77264 } 77265 if rc != SQLITE_OK { 77266 77267 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([50]int8{})), bp+112 /* &zBuf[0] */, ts+37728 /* "%s " */, libc.VaList(bp+32, sqlite3.Xsqlite3ErrName(tls, rc))) 77268 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+40, bp+112 /* &zBuf[0] */, sqlite3.Xsqlite3_errmsg(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* db */))), 0)) 77269 return TCL_ERROR 77270 } 77271 77272 if *(*uintptr)(unsafe.Pointer(bp + 96 /* pStmt */)) != 0 { 77273 if sqlite3TestMakePointerStr(tls, interp, bp+112 /* &zBuf[0] */, *(*uintptr)(unsafe.Pointer(bp + 96 /* pStmt */))) != 0 { 77274 return TCL_ERROR 77275 } 77276 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+64, bp+112 /* &zBuf[0] */, 0)) 77277 } 77278 return TCL_OK 77279 } 77280 77281 // 77282 // End of implementation of [sqlite3_blocking_step]. 77283 // 77284 77285 // Register commands with the TCL interpreter. 77286 func SqlitetestThread_Init(tls *libc.TLS, interp uintptr) int32 { /* test_thread.c:619:5: */ 77287 tcl.XTcl_CreateObjCommand(tls, interp, ts+37550 /* "sqlthread" */, *(*uintptr)(unsafe.Pointer(&struct { 77288 f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 77289 }{sqlthread_proc})), uintptr(0), uintptr(0)) 77290 tcl.XTcl_CreateObjCommand(tls, interp, ts+37536 /* "clock_seconds" */, *(*uintptr)(unsafe.Pointer(&struct { 77291 f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 77292 }{clock_seconds_proc})), uintptr(0), uintptr(0)) 77293 tcl.XTcl_CreateObjCommand(tls, interp, ts+37560 /* "sqlite3_blocking..." */, *(*uintptr)(unsafe.Pointer(&struct { 77294 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 77295 }{blocking_step_proc})), uintptr(0), uintptr(0)) 77296 tcl.XTcl_CreateObjCommand(tls, interp, 77297 ts+37582 /* "sqlite3_blocking..." */, *(*uintptr)(unsafe.Pointer(&struct { 77298 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 77299 }{blocking_prepare_v2_proc})), uintptr(1), uintptr(0)) 77300 tcl.XTcl_CreateObjCommand(tls, interp, 77301 ts+37610 /* "sqlite3_nonblock..." */, *(*uintptr)(unsafe.Pointer(&struct { 77302 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 77303 }{blocking_prepare_v2_proc})), uintptr(0), uintptr(0)) 77304 return TCL_OK 77305 } 77306 77307 // end block for C++ 77308 77309 // Local Variables: 77310 // mode: c 77311 // c-basic-offset: 4 77312 // fill-column: 78 77313 // End: 77314 77315 func Sqlitetestvdbecov_Init(tls *libc.TLS, interp uintptr) int32 { /* test_vdbecov.c:113:5: */ 77316 return TCL_OK 77317 } 77318 77319 // end block for C++ 77320 77321 // Local Variables: 77322 // mode: c 77323 // c-basic-offset: 4 77324 // fill-column: 78 77325 // End: 77326 77327 type Testvfs1 = struct { 77328 FzName uintptr 77329 FpParent uintptr 77330 FpVfs uintptr 77331 Finterp uintptr 77332 FpScript uintptr 77333 FpBuffer uintptr 77334 FisNoshm int32 77335 FisFullshm int32 77336 Fmask int32 77337 Fioerr_err TestFaultInject 77338 Ffull_err TestFaultInject 77339 Fcantopen_err TestFaultInject 77340 FiDevchar int32 77341 FiSectorsize int32 77342 } /* test_vfs.c:37:9 */ 77343 77344 // end block for C++ 77345 77346 // Local Variables: 77347 // mode: c 77348 // c-basic-offset: 4 77349 // fill-column: 78 77350 // End: 77351 77352 type Testvfs = Testvfs1 /* test_vfs.c:37:24 */ 77353 type TestvfsBuffer1 = struct { 77354 FzFile uintptr 77355 Fpgsz int32 77356 _ [4]byte 77357 FaPage [1024]uintptr 77358 FpFile uintptr 77359 FpNext uintptr 77360 } /* test_vfs.c:37:9 */ 77361 77362 type TestvfsBuffer = TestvfsBuffer1 /* test_vfs.c:39:30 */ 77363 type TestvfsFile1 = struct { 77364 Fbase sqlite3_file 77365 FpFd uintptr 77366 } /* test_vfs.c:40:9 */ 77367 77368 type TestvfsFile = TestvfsFile1 /* test_vfs.c:40:28 */ 77369 type TestvfsFd1 = struct { 77370 FpVfs uintptr 77371 FzFilename uintptr 77372 FpReal uintptr 77373 FpShmId uintptr 77374 FpShm uintptr 77375 Fexcllock u322 77376 Fsharedlock u322 77377 FpNext uintptr 77378 } /* test_vfs.c:37:9 */ 77379 77380 type TestvfsFd = TestvfsFd1 /* test_vfs.c:41:26 */ 77381 77382 type TestFaultInject1 = struct { 77383 FiCnt int32 77384 FeFault int32 77385 FnFail int32 77386 } /* test_vfs.c:37:9 */ 77387 77388 type TestFaultInject = TestFaultInject1 /* test_vfs.c:69:32 */ 77389 77390 var tvfs_io_methods = sqlite3_io_methods{ 77391 FiVersion: 3, // iVersion 77392 FxClose: 0, // xClose 77393 FxRead: 0, // xRead 77394 FxWrite: 0, // xWrite 77395 FxTruncate: 0, // xTruncate 77396 FxSync: 0, // xSync 77397 FxFileSize: 0, // xFileSize 77398 FxLock: 0, // xLock 77399 FxUnlock: 0, // xUnlock 77400 FxCheckReservedLock: 0, // xCheckReservedLock 77401 FxFileControl: 0, // xFileControl 77402 FxSectorSize: 0, // xSectorSize 77403 FxDeviceCharacteristics: 0, // xDeviceCharacteristics 77404 FxShmMap: 0, // xShmMap 77405 FxShmLock: 0, // xShmLock 77406 FxShmBarrier: 0, // xShmBarrier 77407 FxShmUnmap: 0, // xShmUnmap 77408 FxFetch: 0, 77409 FxUnfetch: 0, 77410 } /* test_vfs.c:204:27 */ 77411 77412 func tvfsResultCode(tls *libc.TLS, p uintptr, pRc uintptr) int32 { /* test_vfs.c:226:12: */ 77413 bp := tls.Alloc(144) 77414 defer tls.Free(144) 77415 77416 *(*[9]errcode)(unsafe.Pointer(bp /* aCode */)) = [9]errcode{ 77417 {FzCode: ts + 1988 /* "SQLITE_OK" */}, 77418 {FeCode: SQLITE_ERROR, FzCode: ts + 1975 /* "SQLITE_ERROR" */}, 77419 {FeCode: SQLITE_IOERR, FzCode: ts + 37732 /* "SQLITE_IOERR" */}, 77420 {FeCode: SQLITE_LOCKED, FzCode: ts + 37745 /* "SQLITE_LOCKED" */}, 77421 {FeCode: SQLITE_BUSY, FzCode: ts + 37759 /* "SQLITE_BUSY" */}, 77422 {FeCode: SQLITE_READONLY, FzCode: ts + 37771 /* "SQLITE_READONLY" */}, 77423 {FeCode: (SQLITE_READONLY | (int32(5) << 8)), FzCode: ts + 37787 /* "SQLITE_READONLY_..." */}, 77424 {FeCode: SQLITE_NOTFOUND, FzCode: ts + 37812 /* "SQLITE_NOTFOUND" */}, 77425 {FeCode: -1, FzCode: ts + 37828 /* "SQLITE_OMIT" */}, 77426 } 77427 var z uintptr 77428 var i int32 77429 77430 z = tcl.XTcl_GetStringResult(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp) 77431 for i = 0; i < (int32(uint64(unsafe.Sizeof([9]errcode{})) / uint64(unsafe.Sizeof(errcode{})))); i++ { 77432 if 0 == libc.Xstrcmp(tls, z, (*errcode)(unsafe.Pointer(bp /* &aCode */ +uintptr(i)*16)).FzCode) { 77433 *(*int32)(unsafe.Pointer(pRc)) = (*errcode)(unsafe.Pointer(bp /* &aCode */ + uintptr(i)*16)).FeCode 77434 return 1 77435 } 77436 } 77437 77438 return 0 77439 } 77440 77441 type errcode = struct { 77442 FeCode int32 77443 _ [4]byte 77444 FzCode uintptr 77445 } /* test_vfs.c:227:3 */ 77446 77447 func tvfsInjectFault(tls *libc.TLS, p uintptr) int32 { /* test_vfs.c:256:12: */ 77448 var ret int32 = 0 77449 if (*TestFaultInject)(unsafe.Pointer(p)).FeFault != 0 { 77450 (*TestFaultInject)(unsafe.Pointer(p)).FiCnt-- 77451 if ((*TestFaultInject)(unsafe.Pointer(p)).FiCnt == 0) || (((*TestFaultInject)(unsafe.Pointer(p)).FiCnt < 0) && ((*TestFaultInject)(unsafe.Pointer(p)).FeFault == FAULT_INJECT_PERSISTENT)) { 77452 ret = 1 77453 (*TestFaultInject)(unsafe.Pointer(p)).FnFail++ 77454 } 77455 } 77456 return ret 77457 } 77458 77459 func tvfsInjectIoerr(tls *libc.TLS, p uintptr) int32 { /* test_vfs.c:269:12: */ 77460 return tvfsInjectFault(tls, (p + 60 /* &.ioerr_err */)) 77461 } 77462 77463 func tvfsInjectFullerr(tls *libc.TLS, p uintptr) int32 { /* test_vfs.c:273:12: */ 77464 return tvfsInjectFault(tls, (p + 72 /* &.full_err */)) 77465 } 77466 77467 func tvfsInjectCantopenerr(tls *libc.TLS, p uintptr) int32 { /* test_vfs.c:276:12: */ 77468 return tvfsInjectFault(tls, (p + 84 /* &.cantopen_err */)) 77469 } 77470 77471 func tvfsExecTcl(tls *libc.TLS, p uintptr, zMethod uintptr, arg1 uintptr, arg2 uintptr, arg3 uintptr, arg4 uintptr) { /* test_vfs.c:281:13: */ 77472 var rc int32 // Return code from Tcl_EvalObj() 77473 var pEval uintptr 77474 77475 pEval = tcl.XTcl_DuplicateObj(tls, (*Testvfs)(unsafe.Pointer(p)).FpScript) 77476 (*Tcl_Obj)(unsafe.Pointer((*Testvfs)(unsafe.Pointer(p)).FpScript)).FrefCount++ 77477 tcl.XTcl_ListObjAppendElement(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp, pEval, tcl.XTcl_NewStringObj(tls, zMethod, -1)) 77478 if arg1 != 0 { 77479 tcl.XTcl_ListObjAppendElement(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp, pEval, arg1) 77480 } 77481 if arg2 != 0 { 77482 tcl.XTcl_ListObjAppendElement(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp, pEval, arg2) 77483 } 77484 if arg3 != 0 { 77485 tcl.XTcl_ListObjAppendElement(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp, pEval, arg3) 77486 } 77487 if arg4 != 0 { 77488 tcl.XTcl_ListObjAppendElement(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp, pEval, arg4) 77489 } 77490 77491 rc = tcl.XTcl_EvalObjEx(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp, pEval, TCL_EVAL_GLOBAL) 77492 if rc != TCL_OK { 77493 tcl.XTcl_BackgroundError(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp) 77494 tcl.XTcl_ResetResult(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp) 77495 } 77496 } 77497 77498 // Close an tvfs-file. 77499 func tvfsClose(tls *libc.TLS, pFile uintptr) int32 { /* test_vfs.c:317:12: */ 77500 var pTestfile uintptr = pFile 77501 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pTestfile)).FpFd 77502 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData 77503 77504 if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_CLOSE_MASK) != 0) { 77505 tvfsExecTcl(tls, p, ts+34830, /* "xClose" */ 77506 tcl.XTcl_NewStringObj(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, -1), (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId, uintptr(0), uintptr(0)) 77507 } 77508 77509 if (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId != 0 { 77510 for ok := true; ok; ok = 0 != 0 { 77511 var _objPtr uintptr = (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId 77512 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 77513 tcl.XTclFreeObj(tls, _objPtr) 77514 } 77515 } 77516 (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId = uintptr(0) 77517 } 77518 if (*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods != 0 { 77519 tcl.XTcl_Free(tls, (*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods) 77520 } 77521 sqlite3.Xsqlite3OsClose(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal) 77522 tcl.XTcl_Free(tls, pFd) 77523 (*TestvfsFile)(unsafe.Pointer(pTestfile)).FpFd = uintptr(0) 77524 return SQLITE_OK 77525 } 77526 77527 // Read data from an tvfs-file. 77528 func tvfsRead(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test_vfs.c:344:12: */ 77529 bp := tls.Alloc(4) 77530 defer tls.Free(4) 77531 77532 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK 77533 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd 77534 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData 77535 if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_READ_MASK) != 0) { 77536 tvfsExecTcl(tls, p, ts+34837, /* "xRead" */ 77537 tcl.XTcl_NewStringObj(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, -1), (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId, uintptr(0), uintptr(0)) 77538 tvfsResultCode(tls, p, bp /* &rc */) 77539 } 77540 if ((*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_READ_MASK) != 0)) && (tvfsInjectIoerr(tls, p) != 0) { 77541 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_IOERR 77542 } 77543 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 77544 *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3.Xsqlite3OsRead(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal, zBuf, iAmt, iOfst) 77545 } 77546 return *(*int32)(unsafe.Pointer(bp /* rc */)) 77547 } 77548 77549 // Write data to an tvfs-file. 77550 func tvfsWrite(tls *libc.TLS, pFile uintptr, zBuf uintptr, iAmt int32, iOfst sqlite_int64) int32 { /* test_vfs.c:371:12: */ 77551 bp := tls.Alloc(4) 77552 defer tls.Free(4) 77553 77554 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK 77555 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd 77556 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData 77557 77558 if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_WRITE_MASK) != 0) { 77559 tvfsExecTcl(tls, p, ts+34843, /* "xWrite" */ 77560 tcl.XTcl_NewStringObj(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, -1), (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId, 77561 tcl.XTcl_NewWideIntObj(tls, iOfst), tcl.XTcl_NewIntObj(tls, iAmt)) 77562 tvfsResultCode(tls, p, bp /* &rc */) 77563 if *(*int32)(unsafe.Pointer(bp /* rc */)) < 0 { 77564 return SQLITE_OK 77565 } 77566 } 77567 77568 if (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (tvfsInjectFullerr(tls, p) != 0) { 77569 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_FULL 77570 } 77571 if ((*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_WRITE_MASK) != 0)) && (tvfsInjectIoerr(tls, p) != 0) { 77572 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_IOERR 77573 } 77574 77575 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 77576 *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3.Xsqlite3OsWrite(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal, zBuf, iAmt, iOfst) 77577 } 77578 return *(*int32)(unsafe.Pointer(bp /* rc */)) 77579 } 77580 77581 // Truncate an tvfs-file. 77582 func tvfsTruncate(tls *libc.TLS, pFile uintptr, size sqlite_int64) int32 { /* test_vfs.c:406:12: */ 77583 bp := tls.Alloc(4) 77584 defer tls.Free(4) 77585 77586 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK 77587 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd 77588 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData 77589 77590 if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_TRUNCATE_MASK) != 0) { 77591 tvfsExecTcl(tls, p, ts+34850, /* "xTruncate" */ 77592 tcl.XTcl_NewStringObj(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, -1), (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId, uintptr(0), uintptr(0)) 77593 tvfsResultCode(tls, p, bp /* &rc */) 77594 } 77595 77596 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 77597 *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3.Xsqlite3OsTruncate(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal, size) 77598 } 77599 return *(*int32)(unsafe.Pointer(bp /* rc */)) 77600 } 77601 77602 // Sync an tvfs-file. 77603 func tvfsSync(tls *libc.TLS, pFile uintptr, flags int32) int32 { /* test_vfs.c:427:12: */ 77604 bp := tls.Alloc(4) 77605 defer tls.Free(4) 77606 77607 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK 77608 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd 77609 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData 77610 77611 if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_SYNC_MASK) != 0) { 77612 var zFlags uintptr = uintptr(0) 77613 77614 switch flags { 77615 case SQLITE_SYNC_NORMAL: 77616 zFlags = ts + 16080 /* "normal" */ 77617 break 77618 fallthrough 77619 case SQLITE_SYNC_FULL: 77620 zFlags = ts + 17941 /* "full" */ 77621 break 77622 fallthrough 77623 case (SQLITE_SYNC_NORMAL | SQLITE_SYNC_DATAONLY): 77624 zFlags = ts + 37840 /* "normal|dataonly" */ 77625 break 77626 fallthrough 77627 case (SQLITE_SYNC_FULL | SQLITE_SYNC_DATAONLY): 77628 zFlags = ts + 37856 /* "full|dataonly" */ 77629 break 77630 fallthrough 77631 default: 77632 77633 } 77634 77635 tvfsExecTcl(tls, p, ts+27316, /* "xSync" */ 77636 tcl.XTcl_NewStringObj(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, -1), (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId, 77637 tcl.XTcl_NewStringObj(tls, zFlags, -1), uintptr(0)) 77638 tvfsResultCode(tls, p, bp /* &rc */) 77639 } 77640 77641 if (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (tvfsInjectFullerr(tls, p) != 0) { 77642 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_FULL 77643 } 77644 77645 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 77646 *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3.Xsqlite3OsSync(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal, flags) 77647 } 77648 77649 return *(*int32)(unsafe.Pointer(bp /* rc */)) 77650 } 77651 77652 // Return the current file-size of an tvfs-file. 77653 func tvfsFileSize(tls *libc.TLS, pFile uintptr, pSize uintptr) int32 { /* test_vfs.c:471:12: */ 77654 var p uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd 77655 return sqlite3.Xsqlite3OsFileSize(tls, (*TestvfsFd)(unsafe.Pointer(p)).FpReal, pSize) 77656 } 77657 77658 // Lock an tvfs-file. 77659 func tvfsLock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_vfs.c:479:12: */ 77660 bp := tls.Alloc(38) 77661 defer tls.Free(38) 77662 77663 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd 77664 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData 77665 if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_LOCK_MASK) != 0) { 77666 // var zLock [30]int8 at bp+8, 30 77667 77668 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+8 /* &zLock[0] */, ts+1238 /* "%d" */, libc.VaList(bp, eLock)) 77669 tvfsExecTcl(tls, p, ts+34870 /* "xLock" */, tcl.XTcl_NewStringObj(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, -1), 77670 tcl.XTcl_NewStringObj(tls, bp+8 /* &zLock[0] */, -1), uintptr(0), uintptr(0)) 77671 } 77672 return sqlite3.Xsqlite3OsLock(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal, eLock) 77673 } 77674 77675 // Unlock an tvfs-file. 77676 func tvfsUnlock(tls *libc.TLS, pFile uintptr, eLock int32) int32 { /* test_vfs.c:494:12: */ 77677 bp := tls.Alloc(38) 77678 defer tls.Free(38) 77679 77680 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd 77681 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData 77682 if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_UNLOCK_MASK) != 0) { 77683 // var zLock [30]int8 at bp+8, 30 77684 77685 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([30]int8{})), bp+8 /* &zLock[0] */, ts+1238 /* "%d" */, libc.VaList(bp, eLock)) 77686 tvfsExecTcl(tls, p, ts+34876 /* "xUnlock" */, tcl.XTcl_NewStringObj(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, -1), 77687 tcl.XTcl_NewStringObj(tls, bp+8 /* &zLock[0] */, -1), uintptr(0), uintptr(0)) 77688 } 77689 if (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_WRITE_MASK) != 0) && (tvfsInjectIoerr(tls, p) != 0) { 77690 return (SQLITE_IOERR | (int32(8) << 8)) 77691 } 77692 return sqlite3.Xsqlite3OsUnlock(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal, eLock) 77693 } 77694 77695 // Check if another file-handle holds a RESERVED lock on an tvfs-file. 77696 func tvfsCheckReservedLock(tls *libc.TLS, pFile uintptr, pResOut uintptr) int32 { /* test_vfs.c:512:12: */ 77697 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd 77698 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData 77699 if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_CKLOCK_MASK) != 0) { 77700 tvfsExecTcl(tls, p, ts+37870 /* "xCheckReservedLo..." */, tcl.XTcl_NewStringObj(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, -1), 77701 uintptr(0), uintptr(0), uintptr(0)) 77702 } 77703 return sqlite3.Xsqlite3OsCheckReservedLock(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal, pResOut) 77704 } 77705 77706 // File control method. For custom operations on an tvfs-file. 77707 func tvfsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) int32 { /* test_vfs.c:525:12: */ 77708 bp := tls.Alloc(68) 77709 defer tls.Free(68) 77710 77711 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd 77712 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData 77713 if op == SQLITE_FCNTL_PRAGMA { 77714 var argv uintptr = pArg 77715 if sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+10311 /* "error" */) == 0 { 77716 var rc int32 = SQLITE_ERROR 77717 if *(*uintptr)(unsafe.Pointer(argv + 2*8)) != 0 { 77718 var z uintptr = *(*uintptr)(unsafe.Pointer(argv + 2*8)) 77719 var x int32 = libc.Xatoi(tls, z) 77720 if x != 0 { 77721 rc = x 77722 for (int32(sqlite3.Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z)))]) & 0x04) != 0 { 77723 z++ 77724 } 77725 for (int32(sqlite3.Xsqlite3CtypeMap[uint8(*(*int8)(unsafe.Pointer(z)))]) & 0x01) != 0 { 77726 z++ 77727 } 77728 } 77729 if *(*int8)(unsafe.Pointer(z)) != 0 { 77730 *(*uintptr)(unsafe.Pointer(argv)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp, z)) 77731 } 77732 } 77733 return rc 77734 } 77735 if sqlite3.Xsqlite3_stricmp(tls, *(*uintptr)(unsafe.Pointer(argv + 1*8)), ts+4665 /* "filename" */) == 0 { 77736 *(*uintptr)(unsafe.Pointer(argv)) = sqlite3.Xsqlite3_mprintf(tls, ts /* "%s" */, libc.VaList(bp+8, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename)) 77737 return SQLITE_OK 77738 } 77739 } 77740 if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_FCNTL_MASK) != 0) { 77741 *(*[3]Fcntl)(unsafe.Pointer(bp + 16 /* aF */)) = [3]Fcntl{ 77742 {FiFnctl: SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, FzFnctl: ts + 37889 /* "BEGIN_ATOMIC_WRI..." */}, 77743 {FiFnctl: SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, FzFnctl: ts + 37908 /* "COMMIT_ATOMIC_WR..." */}, 77744 {FiFnctl: SQLITE_FCNTL_ZIPVFS, FzFnctl: ts + 37928 /* "ZIPVFS" */}, 77745 } 77746 var i int32 77747 for i = 0; uint64(i) < (uint64(unsafe.Sizeof([3]Fcntl{})) / uint64(unsafe.Sizeof(Fcntl{}))); i++ { 77748 if op == (*Fcntl)(unsafe.Pointer(bp+16 /* &aF */ +uintptr(i)*16)).FiFnctl { 77749 break 77750 } 77751 } 77752 if uint64(i) < (uint64(unsafe.Sizeof([3]Fcntl{})) / uint64(unsafe.Sizeof(Fcntl{}))) { 77753 *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) = 0 77754 tvfsExecTcl(tls, p, ts+34898, /* "xFileControl" */ 77755 tcl.XTcl_NewStringObj(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, -1), 77756 tcl.XTcl_NewStringObj(tls, (*Fcntl)(unsafe.Pointer(bp+16 /* &aF */ +uintptr(i)*16)).FzFnctl, -1), 77757 uintptr(0), uintptr(0)) 77758 tvfsResultCode(tls, p, bp+64 /* &rc */) 77759 if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) != 0 { 77760 return func() int32 { 77761 if *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) < 0 { 77762 return SQLITE_OK 77763 } 77764 return *(*int32)(unsafe.Pointer(bp + 64 /* rc */)) 77765 }() 77766 } 77767 } 77768 } 77769 return sqlite3.Xsqlite3OsFileControl(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal, op, pArg) 77770 } 77771 77772 type Fcntl = struct { 77773 FiFnctl int32 77774 _ [4]byte 77775 FzFnctl uintptr 77776 } /* test_vfs.c:550:5 */ 77777 77778 // Return the sector-size in bytes for an tvfs-file. 77779 func tvfsSectorSize(tls *libc.TLS, pFile uintptr) int32 { /* test_vfs.c:579:12: */ 77780 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd 77781 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData 77782 if (*Testvfs)(unsafe.Pointer(p)).FiSectorsize >= 0 { 77783 return (*Testvfs)(unsafe.Pointer(p)).FiSectorsize 77784 } 77785 return sqlite3.Xsqlite3OsSectorSize(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal) 77786 } 77787 77788 // Return the device characteristic flags supported by an tvfs-file. 77789 func tvfsDeviceCharacteristics(tls *libc.TLS, pFile uintptr) int32 { /* test_vfs.c:591:12: */ 77790 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd 77791 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData 77792 if (*Testvfs)(unsafe.Pointer(p)).FiDevchar >= 0 { 77793 return (*Testvfs)(unsafe.Pointer(p)).FiDevchar 77794 } 77795 return sqlite3.Xsqlite3OsDeviceCharacteristics(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal) 77796 } 77797 77798 // Open an tvfs file handle. 77799 func tvfsOpen(tls *libc.TLS, pVfs uintptr, zName uintptr, pFile uintptr, flags int32, pOutFlags uintptr) int32 { /* test_vfs.c:603:12: */ 77800 bp := tls.Alloc(4) 77801 defer tls.Free(4) 77802 77803 // var rc int32 at bp, 4 77804 77805 var pTestfile uintptr = pFile 77806 var pFd uintptr 77807 var pId uintptr = uintptr(0) 77808 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData 77809 77810 pFd = tcl.XTcl_Alloc(tls, (uint32(uint64(unsafe.Sizeof(TestvfsFd{})) + uint64((*sqlite3_vfs)(unsafe.Pointer(((*Testvfs)(unsafe.Pointer((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FpParent))).FszOsFile)))) 77811 libc.Xmemset(tls, pFd, 0, (uint64(unsafe.Sizeof(TestvfsFd{})) + uint64((*sqlite3_vfs)(unsafe.Pointer(((*Testvfs)(unsafe.Pointer((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FpParent))).FszOsFile))) 77812 (*TestvfsFd)(unsafe.Pointer(pFd)).FpShm = uintptr(0) 77813 (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId = uintptr(0) 77814 (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename = zName 77815 (*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs = pVfs 77816 (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal = (pFd + 1*56) 77817 libc.Xmemset(tls, pTestfile, 0, uint64(unsafe.Sizeof(TestvfsFile{}))) 77818 (*TestvfsFile)(unsafe.Pointer(pTestfile)).FpFd = pFd 77819 77820 // Evaluate the Tcl script: 77821 // 77822 // SCRIPT xOpen FILENAME KEY-VALUE-ARGS 77823 // 77824 // If the script returns an SQLite error code other than SQLITE_OK, an 77825 // error is returned to the caller. If it returns SQLITE_OK, the new 77826 // connection is named "anon". Otherwise, the value returned by the 77827 // script is used as the connection name. 77828 tcl.XTcl_ResetResult(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp) 77829 if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_OPEN_MASK) != 0) { 77830 var pArg uintptr = tcl.XTcl_NewObj(tls) 77831 (*Tcl_Obj)(unsafe.Pointer(pArg)).FrefCount++ 77832 if (flags & SQLITE_OPEN_MAIN_DB) != 0 { 77833 var z uintptr = (zName + uintptr((libc.Xstrlen(tls, zName) + uint64(1)))) 77834 for *(*int8)(unsafe.Pointer(z)) != 0 { 77835 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pArg, tcl.XTcl_NewStringObj(tls, z, -1)) 77836 z += (uintptr(libc.Xstrlen(tls, z) + uint64(1))) 77837 tcl.XTcl_ListObjAppendElement(tls, uintptr(0), pArg, tcl.XTcl_NewStringObj(tls, z, -1)) 77838 z += (uintptr(libc.Xstrlen(tls, z) + uint64(1))) 77839 } 77840 } 77841 tvfsExecTcl(tls, p, ts+26888 /* "xOpen" */, tcl.XTcl_NewStringObj(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, -1), pArg, uintptr(0), uintptr(0)) 77842 for ok := true; ok; ok = 0 != 0 { 77843 var _objPtr uintptr = pArg 77844 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 77845 tcl.XTclFreeObj(tls, _objPtr) 77846 } 77847 } 77848 if tvfsResultCode(tls, p, bp /* &rc */) != 0 { 77849 if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { 77850 return *(*int32)(unsafe.Pointer(bp /* rc */)) 77851 } 77852 } else { 77853 pId = tcl.XTcl_GetObjResult(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp) 77854 } 77855 } 77856 77857 if (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_OPEN_MASK) != 0) && (tvfsInjectIoerr(tls, p) != 0) { 77858 return SQLITE_IOERR 77859 } 77860 if tvfsInjectCantopenerr(tls, p) != 0 { 77861 return SQLITE_CANTOPEN 77862 } 77863 if tvfsInjectFullerr(tls, p) != 0 { 77864 return SQLITE_FULL 77865 } 77866 77867 if !(pId != 0) { 77868 pId = tcl.XTcl_NewStringObj(tls, ts+37935 /* "anon" */, -1) 77869 } 77870 (*Tcl_Obj)(unsafe.Pointer(pId)).FrefCount++ 77871 (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId = pId 77872 tcl.XTcl_ResetResult(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp) 77873 77874 *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3.Xsqlite3OsOpen(tls, (*Testvfs)(unsafe.Pointer((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FpParent, zName, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal, flags, pOutFlags) 77875 if (*sqlite3_file)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpReal)).FpMethods != 0 { 77876 var pMethods uintptr 77877 var nByte int32 77878 77879 if (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FiVersion > 1 { 77880 nByte = int32(unsafe.Sizeof(sqlite3_io_methods{})) 77881 } else { 77882 nByte = int32((uintptr(0) + 104 /* &.xShmMap */)) 77883 } 77884 77885 pMethods = tcl.XTcl_Alloc(tls, uint32(nByte)) 77886 libc.Xmemcpy(tls, pMethods, uintptr(unsafe.Pointer(&tvfs_io_methods)), uint64(nByte)) 77887 (*sqlite3_io_methods)(unsafe.Pointer(pMethods)).FiVersion = (*sqlite3_io_methods1)(unsafe.Pointer((*sqlite3_file)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpReal)).FpMethods)).FiVersion 77888 if (*sqlite3_io_methods)(unsafe.Pointer(pMethods)).FiVersion > (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FiVersion { 77889 (*sqlite3_io_methods)(unsafe.Pointer(pMethods)).FiVersion = (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FiVersion 77890 } 77891 if ((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FiVersion > 1) && ((*Testvfs)(unsafe.Pointer(((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData))).FisNoshm != 0) { 77892 (*sqlite3_io_methods)(unsafe.Pointer(pMethods)).FxShmUnmap = uintptr(0) 77893 (*sqlite3_io_methods)(unsafe.Pointer(pMethods)).FxShmLock = uintptr(0) 77894 (*sqlite3_io_methods)(unsafe.Pointer(pMethods)).FxShmBarrier = uintptr(0) 77895 (*sqlite3_io_methods)(unsafe.Pointer(pMethods)).FxShmMap = uintptr(0) 77896 } 77897 (*sqlite3_file)(unsafe.Pointer(pFile)).FpMethods = pMethods 77898 } 77899 77900 return *(*int32)(unsafe.Pointer(bp /* rc */)) 77901 } 77902 77903 // Delete the file located at zPath. If the dirSync argument is true, 77904 // ensure the file-system modifications are synced to disk before 77905 // returning. 77906 func tvfsDelete(tls *libc.TLS, pVfs uintptr, zPath uintptr, dirSync int32) int32 { /* test_vfs.c:702:12: */ 77907 bp := tls.Alloc(4) 77908 defer tls.Free(4) 77909 77910 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK 77911 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData 77912 77913 if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_DELETE_MASK) != 0) { 77914 tvfsExecTcl(tls, p, ts+34935, /* "xDelete" */ 77915 tcl.XTcl_NewStringObj(tls, zPath, -1), tcl.XTcl_NewIntObj(tls, dirSync), uintptr(0), uintptr(0)) 77916 tvfsResultCode(tls, p, bp /* &rc */) 77917 } 77918 if *(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK { 77919 *(*int32)(unsafe.Pointer(bp /* rc */)) = sqlite3.Xsqlite3OsDelete(tls, (*Testvfs)(unsafe.Pointer((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FpParent, zPath, dirSync) 77920 } 77921 return *(*int32)(unsafe.Pointer(bp /* rc */)) 77922 } 77923 77924 // Test for access permissions. Return true if the requested permission 77925 // is available, or false otherwise. 77926 func tvfsAccess(tls *libc.TLS, pVfs uintptr, zPath uintptr, flags int32, pResOut uintptr) int32 { /* test_vfs.c:722:12: */ 77927 bp := tls.Alloc(4) 77928 defer tls.Free(4) 77929 77930 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData 77931 if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_ACCESS_MASK) != 0) { 77932 // var rc int32 at bp, 4 77933 77934 var zArg uintptr = uintptr(0) 77935 if flags == SQLITE_ACCESS_EXISTS { 77936 zArg = ts + 37940 /* "SQLITE_ACCESS_EX..." */ 77937 } 77938 if flags == SQLITE_ACCESS_READWRITE { 77939 zArg = ts + 37961 /* "SQLITE_ACCESS_RE..." */ 77940 } 77941 if flags == SQLITE_ACCESS_READ { 77942 zArg = ts + 37985 /* "SQLITE_ACCESS_RE..." */ 77943 } 77944 tvfsExecTcl(tls, p, ts+34943, /* "xAccess" */ 77945 tcl.XTcl_NewStringObj(tls, zPath, -1), tcl.XTcl_NewStringObj(tls, zArg, -1), uintptr(0), uintptr(0)) 77946 if tvfsResultCode(tls, p, bp /* &rc */) != 0 { 77947 if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { 77948 return *(*int32)(unsafe.Pointer(bp /* rc */)) 77949 } 77950 } else { 77951 var interp uintptr = (*Testvfs)(unsafe.Pointer(p)).Finterp 77952 if TCL_OK == tcl.XTcl_GetBooleanFromObj(tls, uintptr(0), tcl.XTcl_GetObjResult(tls, interp), pResOut) { 77953 return SQLITE_OK 77954 } 77955 } 77956 } 77957 return sqlite3.Xsqlite3OsAccess(tls, (*Testvfs)(unsafe.Pointer((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FpParent, zPath, flags, pResOut) 77958 } 77959 77960 // Populate buffer zOut with the full canonical pathname corresponding 77961 // to the pathname in zPath. zOut is guaranteed to point to a buffer 77962 // of at least (DEVSYM_MAX_PATHNAME+1) bytes. 77963 func tvfsFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zOut uintptr) int32 { /* test_vfs.c:755:12: */ 77964 bp := tls.Alloc(4) 77965 defer tls.Free(4) 77966 77967 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData 77968 if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_FULLPATHNAME_MASK) != 0) { 77969 // var rc int32 at bp, 4 77970 77971 tvfsExecTcl(tls, p, ts+34951 /* "xFullPathname" */, tcl.XTcl_NewStringObj(tls, zPath, -1), uintptr(0), uintptr(0), uintptr(0)) 77972 if tvfsResultCode(tls, p, bp /* &rc */) != 0 { 77973 if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { 77974 return *(*int32)(unsafe.Pointer(bp /* rc */)) 77975 } 77976 } 77977 } 77978 return sqlite3.Xsqlite3OsFullPathname(tls, (*Testvfs)(unsafe.Pointer((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FpParent, zPath, nOut, zOut) 77979 } 77980 77981 // Populate the buffer pointed to by zBufOut with nByte bytes of 77982 // random data. 77983 func tvfsRandomness(tls *libc.TLS, pVfs uintptr, nByte int32, zBufOut uintptr) int32 { /* test_vfs.c:808:12: */ 77984 return sqlite3.Xsqlite3OsRandomness(tls, (*Testvfs)(unsafe.Pointer((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FpParent, nByte, zBufOut) 77985 } 77986 77987 // Sleep for nMicro microseconds. Return the number of microseconds 77988 // actually slept. 77989 func tvfsSleep(tls *libc.TLS, pVfs uintptr, nMicro int32) int32 { /* test_vfs.c:816:12: */ 77990 return sqlite3.Xsqlite3OsSleep(tls, (*Testvfs)(unsafe.Pointer((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FpParent, nMicro) 77991 } 77992 77993 // Return the current time as a Julian Day number in *pTimeOut. 77994 func tvfsCurrentTime(tls *libc.TLS, pVfs uintptr, pTimeOut uintptr) int32 { /* test_vfs.c:823:12: */ 77995 return (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(((*Testvfs)(unsafe.Pointer((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FpParent + 120 /* &.xCurrentTime */))))(tls, (*Testvfs)(unsafe.Pointer((*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData)).FpParent, pTimeOut) 77996 } 77997 77998 func tvfsShmOpen(tls *libc.TLS, pFile uintptr) int32 { /* test_vfs.c:827:12: */ 77999 bp := tls.Alloc(4) 78000 defer tls.Free(4) 78001 78002 var p uintptr 78003 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK // Return code 78004 var pBuffer uintptr // Buffer to open connection to 78005 var pFd uintptr // The testvfs file structure 78006 78007 pFd = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd 78008 p = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData 78009 78010 // Evaluate the Tcl script: 78011 // 78012 // SCRIPT xShmOpen FILENAME 78013 tcl.XTcl_ResetResult(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp) 78014 if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_SHMOPEN_MASK) != 0) { 78015 tvfsExecTcl(tls, p, ts+38004 /* "xShmOpen" */, tcl.XTcl_NewStringObj(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, -1), uintptr(0), uintptr(0), uintptr(0)) 78016 if tvfsResultCode(tls, p, bp /* &rc */) != 0 { 78017 if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { 78018 return *(*int32)(unsafe.Pointer(bp /* rc */)) 78019 } 78020 } 78021 } 78022 78023 if (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_SHMOPEN_MASK) != 0) && (tvfsInjectIoerr(tls, p) != 0) { 78024 return SQLITE_IOERR 78025 } 78026 78027 // Search for a TestvfsBuffer. Create a new one if required. 78028 for pBuffer = (*Testvfs)(unsafe.Pointer(p)).FpBuffer; pBuffer != 0; pBuffer = (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).FpNext { 78029 if 0 == libc.Xstrcmp(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).FzFile) { 78030 break 78031 } 78032 } 78033 if !(pBuffer != 0) { 78034 var szName int32 = int32(libc.Xstrlen(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename)) 78035 var nByte int32 = (int32((uint64(unsafe.Sizeof(TestvfsBuffer{})) + uint64(szName)) + uint64(1))) 78036 pBuffer = tcl.XTcl_Alloc(tls, uint32(nByte)) 78037 libc.Xmemset(tls, pBuffer, 0, uint64(nByte)) 78038 (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).FzFile = (pBuffer + 1*8224) 78039 libc.Xmemcpy(tls, (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).FzFile, (*TestvfsFd)(unsafe.Pointer(pFd)).FzFilename, (uint64(szName + 1))) 78040 (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).FpNext = (*Testvfs)(unsafe.Pointer(p)).FpBuffer 78041 (*Testvfs)(unsafe.Pointer(p)).FpBuffer = pBuffer 78042 } 78043 78044 // Connect the TestvfsBuffer to the new TestvfsShm handle and return. 78045 (*TestvfsFd)(unsafe.Pointer(pFd)).FpNext = (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).FpFile 78046 (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).FpFile = pFd 78047 (*TestvfsFd)(unsafe.Pointer(pFd)).FpShm = pBuffer 78048 return *(*int32)(unsafe.Pointer(bp /* rc */)) 78049 } 78050 78051 func tvfsAllocPage(tls *libc.TLS, p uintptr, iPage int32, pgsz int32) { /* test_vfs.c:877:13: */ 78052 78053 if *(*uintptr)(unsafe.Pointer((p + 16 /* &.aPage */) + uintptr(iPage)*8)) == uintptr(0) { 78054 *(*uintptr)(unsafe.Pointer((p + 16 /* &.aPage */) + uintptr(iPage)*8)) = tcl.XTcl_Alloc(tls, uint32(pgsz)) 78055 libc.Xmemset(tls, *(*uintptr)(unsafe.Pointer((p + 16 /* &.aPage */) + uintptr(iPage)*8)), 0, uint64(pgsz)) 78056 (*TestvfsBuffer)(unsafe.Pointer(p)).Fpgsz = pgsz 78057 } 78058 } 78059 78060 func tvfsShmMap(tls *libc.TLS, pFile uintptr, iPage int32, pgsz int32, isWrite int32, pp uintptr) int32 { /* test_vfs.c:886:12: */ 78061 bp := tls.Alloc(4) 78062 defer tls.Free(4) 78063 78064 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK 78065 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd 78066 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData 78067 78068 if (*Testvfs)(unsafe.Pointer(p)).FisFullshm != 0 { 78069 var pReal uintptr = (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal 78070 return (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pReal)).FpMethods + 104 /* &.xShmMap */))))(tls, pReal, iPage, pgsz, isWrite, libc.AtomicLoadUintptr(&pp)) 78071 } 78072 78073 if uintptr(0) == (*TestvfsFd)(unsafe.Pointer(pFd)).FpShm { 78074 *(*int32)(unsafe.Pointer(bp /* rc */)) = tvfsShmOpen(tls, pFile) 78075 if *(*int32)(unsafe.Pointer(bp /* rc */)) != SQLITE_OK { 78076 return *(*int32)(unsafe.Pointer(bp /* rc */)) 78077 } 78078 } 78079 78080 if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_SHMMAP_MASK) != 0) { 78081 var pArg uintptr = tcl.XTcl_NewObj(tls) 78082 (*Tcl_Obj)(unsafe.Pointer(pArg)).FrefCount++ 78083 tcl.XTcl_ListObjAppendElement(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp, pArg, tcl.XTcl_NewIntObj(tls, iPage)) 78084 tcl.XTcl_ListObjAppendElement(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp, pArg, tcl.XTcl_NewIntObj(tls, pgsz)) 78085 tcl.XTcl_ListObjAppendElement(tls, (*Testvfs)(unsafe.Pointer(p)).Finterp, pArg, tcl.XTcl_NewIntObj(tls, isWrite)) 78086 tvfsExecTcl(tls, p, ts+35028, /* "xShmMap" */ 78087 tcl.XTcl_NewStringObj(tls, (*TestvfsBuffer)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpShm)).FzFile, -1), (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId, pArg, uintptr(0)) 78088 tvfsResultCode(tls, p, bp /* &rc */) 78089 for ok := true; ok; ok = 0 != 0 { 78090 var _objPtr uintptr = pArg 78091 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 78092 tcl.XTclFreeObj(tls, _objPtr) 78093 } 78094 } 78095 } 78096 if ((*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_SHMMAP_MASK) != 0)) && (tvfsInjectIoerr(tls, p) != 0) { 78097 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_IOERR 78098 } 78099 78100 if ((*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) && (isWrite != 0)) && !(int32(*(*uintptr)(unsafe.Pointer(((*TestvfsFd)(unsafe.Pointer(pFd)).FpShm + 16 /* &.aPage */) + uintptr(iPage)*8))) != 0) { 78101 tvfsAllocPage(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpShm, iPage, pgsz) 78102 } 78103 if (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_OK) || (*(*int32)(unsafe.Pointer(bp /* rc */)) == SQLITE_READONLY) { 78104 *(*uintptr)(unsafe.Pointer(libc.AtomicLoadUintptr(&pp))) = *(*uintptr)(unsafe.Pointer(((*TestvfsFd)(unsafe.Pointer(pFd)).FpShm + 16 /* &.aPage */) + uintptr(iPage)*8)) 78105 } 78106 78107 return *(*int32)(unsafe.Pointer(bp /* rc */)) 78108 } 78109 78110 func tvfsShmLock(tls *libc.TLS, pFile uintptr, ofst int32, n int32, flags int32) int32 { /* test_vfs.c:936:12: */ 78111 bp := tls.Alloc(100) 78112 defer tls.Free(100) 78113 78114 *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = SQLITE_OK 78115 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd 78116 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData 78117 var nLock int32 78118 // var zLock [80]int8 at bp+16, 80 78119 78120 if (*Testvfs)(unsafe.Pointer(p)).FisFullshm != 0 { 78121 var pReal uintptr = (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal 78122 return (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pReal)).FpMethods + 112 /* &.xShmLock */))))(tls, pReal, ofst, n, flags) 78123 } 78124 78125 if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_SHMLOCK_MASK) != 0) { 78126 sqlite3.Xsqlite3_snprintf(tls, int32(unsafe.Sizeof([80]int8{})), bp+16 /* &zLock[0] */, ts+17476 /* "%d %d" */, libc.VaList(bp, ofst, n)) 78127 nLock = int32(libc.Xstrlen(tls, bp+16 /* &zLock[0] */)) 78128 if (flags & SQLITE_SHM_LOCK) != 0 { 78129 libc.Xstrcpy(tls, (bp + 16 /* &zLock */ + uintptr(nLock)), ts+38013 /* " lock" */) 78130 } else { 78131 libc.Xstrcpy(tls, (bp + 16 /* &zLock */ + uintptr(nLock)), ts+38019 /* " unlock" */) 78132 } 78133 nLock = nLock + (int32(libc.Xstrlen(tls, (bp + 16 /* &zLock */ + uintptr(nLock))))) 78134 if (flags & SQLITE_SHM_SHARED) != 0 { 78135 libc.Xstrcpy(tls, (bp + 16 /* &zLock */ + uintptr(nLock)), ts+38027 /* " shared" */) 78136 } else { 78137 libc.Xstrcpy(tls, (bp + 16 /* &zLock */ + uintptr(nLock)), ts+38035 /* " exclusive" */) 78138 } 78139 tvfsExecTcl(tls, p, ts+35007, /* "xShmLock" */ 78140 tcl.XTcl_NewStringObj(tls, (*TestvfsBuffer)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpShm)).FzFile, -1), (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId, 78141 tcl.XTcl_NewStringObj(tls, bp+16 /* &zLock[0] */, -1), uintptr(0)) 78142 tvfsResultCode(tls, p, bp+96 /* &rc */) 78143 } 78144 78145 if ((*(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == SQLITE_OK) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_SHMLOCK_MASK) != 0)) && (tvfsInjectIoerr(tls, p) != 0) { 78146 *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = SQLITE_IOERR 78147 } 78148 78149 if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == SQLITE_OK { 78150 var isLock int32 = (flags & SQLITE_SHM_LOCK) 78151 var isExcl int32 = (flags & SQLITE_SHM_EXCLUSIVE) 78152 var mask u322 = (u322(((int32(1) << n) - 1) << ofst)) 78153 if isLock != 0 { 78154 var p2 uintptr 78155 for p2 = (*TestvfsBuffer)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpShm)).FpFile; p2 != 0; p2 = (*TestvfsFd)(unsafe.Pointer(p2)).FpNext { 78156 if p2 == pFd { 78157 continue 78158 } 78159 if (((*TestvfsFd)(unsafe.Pointer(p2)).Fexcllock & mask) != 0) || ((isExcl != 0) && (((*TestvfsFd)(unsafe.Pointer(p2)).Fsharedlock & mask) != 0)) { 78160 *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) = SQLITE_BUSY 78161 break 78162 } 78163 } 78164 if *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) == SQLITE_OK { 78165 if isExcl != 0 { 78166 *(*u322)(unsafe.Pointer(pFd + 40 /* &.excllock */)) |= (mask) 78167 } 78168 if !(isExcl != 0) { 78169 *(*u322)(unsafe.Pointer(pFd + 44 /* &.sharedlock */)) |= (mask) 78170 } 78171 } 78172 } else { 78173 if isExcl != 0 { 78174 *(*u322)(unsafe.Pointer(pFd + 40 /* &.excllock */)) &= (^mask) 78175 } 78176 if !(isExcl != 0) { 78177 *(*u322)(unsafe.Pointer(pFd + 44 /* &.sharedlock */)) &= (^mask) 78178 } 78179 } 78180 } 78181 78182 return *(*int32)(unsafe.Pointer(bp + 96 /* rc */)) 78183 } 78184 78185 func tvfsShmBarrier(tls *libc.TLS, pFile uintptr) { /* test_vfs.c:1004:13: */ 78186 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd 78187 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData 78188 78189 if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_SHMBARRIER_MASK) != 0) { 78190 var z uintptr 78191 if (*TestvfsFd)(unsafe.Pointer(pFd)).FpShm != 0 { 78192 z = (*TestvfsBuffer)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpShm)).FzFile 78193 } else { 78194 z = ts + 489 /* "" */ 78195 } 78196 tvfsExecTcl(tls, p, ts+35016 /* "xShmBarrier" */, tcl.XTcl_NewStringObj(tls, z, -1), (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId, uintptr(0), uintptr(0)) 78197 } 78198 78199 if (*Testvfs)(unsafe.Pointer(p)).FisFullshm != 0 { 78200 var pReal uintptr = (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal 78201 (*(*func(*libc.TLS, uintptr))(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pReal)).FpMethods + 120 /* &.xShmBarrier */))))(tls, pReal) 78202 return 78203 } 78204 } 78205 78206 func tvfsShmUnmap(tls *libc.TLS, pFile uintptr, deleteFlag int32) int32 { /* test_vfs.c:1020:12: */ 78207 bp := tls.Alloc(4) 78208 defer tls.Free(4) 78209 78210 *(*int32)(unsafe.Pointer(bp /* rc */)) = SQLITE_OK 78211 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd 78212 var p uintptr = (*sqlite3_vfs)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpVfs)).FpAppData 78213 var pBuffer uintptr = (*TestvfsFd)(unsafe.Pointer(pFd)).FpShm 78214 var ppFd uintptr 78215 78216 if (*Testvfs)(unsafe.Pointer(p)).FisFullshm != 0 { 78217 var pReal uintptr = (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal 78218 return (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(pReal)).FpMethods + 128 /* &.xShmUnmap */))))(tls, pReal, deleteFlag) 78219 } 78220 78221 if !(pBuffer != 0) { 78222 return SQLITE_OK 78223 } 78224 78225 if ((*Testvfs)(unsafe.Pointer(p)).FpScript != 0) && (((*Testvfs)(unsafe.Pointer(p)).Fmask & TESTVFS_SHMCLOSE_MASK) != 0) { 78226 tvfsExecTcl(tls, p, ts+34997, /* "xShmUnmap" */ 78227 tcl.XTcl_NewStringObj(tls, (*TestvfsBuffer)(unsafe.Pointer((*TestvfsFd)(unsafe.Pointer(pFd)).FpShm)).FzFile, -1), (*TestvfsFd)(unsafe.Pointer(pFd)).FpShmId, uintptr(0), uintptr(0)) 78228 tvfsResultCode(tls, p, bp /* &rc */) 78229 } 78230 78231 for ppFd = (pBuffer + 8208 /* &.pFile */); *(*uintptr)(unsafe.Pointer(ppFd)) != pFd; ppFd = (*(*uintptr)(unsafe.Pointer(ppFd)) + 48 /* &.pNext */) { 78232 } 78233 78234 *(*uintptr)(unsafe.Pointer(ppFd)) = (*TestvfsFd)(unsafe.Pointer(pFd)).FpNext 78235 (*TestvfsFd)(unsafe.Pointer(pFd)).FpNext = uintptr(0) 78236 78237 if (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).FpFile == uintptr(0) { 78238 var i int32 78239 var pp uintptr 78240 for pp = (p + 40 /* &.pBuffer */); *(*uintptr)(unsafe.Pointer(pp)) != pBuffer; pp = (*(*uintptr)(unsafe.Pointer(pp)) + 8216 /* &.pNext */) { 78241 } 78242 *(*uintptr)(unsafe.Pointer(pp)) = (*TestvfsBuffer)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(pp)))).FpNext 78243 for i = 0; *(*uintptr)(unsafe.Pointer((pBuffer + 16 /* &.aPage */) + uintptr(i)*8)) != 0; i++ { 78244 tcl.XTcl_Free(tls, *(*uintptr)(unsafe.Pointer((pBuffer + 16 /* &.aPage */) + uintptr(i)*8))) 78245 } 78246 tcl.XTcl_Free(tls, pBuffer) 78247 } 78248 (*TestvfsFd)(unsafe.Pointer(pFd)).FpShm = uintptr(0) 78249 78250 return *(*int32)(unsafe.Pointer(bp /* rc */)) 78251 } 78252 78253 func tvfsFetch(tls *libc.TLS, pFile uintptr, iOfst sqlite3_int64, iAmt int32, pp uintptr) int32 { /* test_vfs.c:1065:12: */ 78254 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd 78255 return sqlite3.Xsqlite3OsFetch(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal, iOfst, iAmt, pp) 78256 } 78257 78258 func tvfsUnfetch(tls *libc.TLS, pFile uintptr, iOfst sqlite3_int64, p uintptr) int32 { /* test_vfs.c:1075:12: */ 78259 var pFd uintptr = (*TestvfsFile)(unsafe.Pointer(pFile)).FpFd 78260 return sqlite3.Xsqlite3OsUnfetch(tls, (*TestvfsFd)(unsafe.Pointer(pFd)).FpReal, iOfst, p) 78261 } 78262 78263 func testvfs_obj_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_vfs.c:1080:26: */ 78264 bp := tls.Alloc(568) 78265 defer tls.Free(568) 78266 78267 var p uintptr = cd 78268 *(*[10]TestvfsSubcmd)(unsafe.Pointer(bp + 96 /* aSubcmd */)) = [10]TestvfsSubcmd{ 78269 {FzName: ts + 38046 /* "shm" */}, 78270 {FzName: ts + 38050 /* "delete" */, FeCmd: uint32(1) /* CMD_DELETE */}, 78271 {FzName: ts + 38057 /* "filter" */, FeCmd: uint32(2) /* CMD_FILTER */}, 78272 {FzName: ts + 38064 /* "ioerr" */, FeCmd: uint32(3) /* CMD_IOERR */}, 78273 {FzName: ts + 38070 /* "fullerr" */, FeCmd: uint32(7) /* CMD_FULLERR */}, 78274 {FzName: ts + 38078 /* "cantopenerr" */, FeCmd: uint32(8) /* CMD_CANTOPENERR */}, 78275 {FzName: ts + 38090 /* "script" */, FeCmd: uint32(4) /* CMD_SCRIPT */}, 78276 {FzName: ts + 38097 /* "devchar" */, FeCmd: uint32(5) /* CMD_DEVCHAR */}, 78277 {FzName: ts + 38105 /* "sectorsize" */, FeCmd: uint32(6) /* CMD_SECTORSIZE */}, 78278 {}, 78279 } 78280 // var i int32 at bp+256, 4 78281 78282 if objc < 2 { 78283 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1860 /* "SUBCOMMAND ..." */) 78284 return TCL_ERROR 78285 } 78286 if tcl.XTcl_GetIndexFromObjStruct(tls, 78287 interp, *(*uintptr)(unsafe.Pointer(objv + 1*8)), bp+96 /* &aSubcmd[0] */, int32(unsafe.Sizeof(TestvfsSubcmd{})), ts+38116 /* "subcommand" */, 0, bp+256 /* &i */) != 0 { 78288 return TCL_ERROR 78289 } 78290 tcl.XTcl_ResetResult(tls, interp) 78291 78292 switch (*TestvfsSubcmd)(unsafe.Pointer(bp + 96 /* &aSubcmd */ + uintptr(*(*int32)(unsafe.Pointer(bp + 256 /* i */)))*16)).FeCmd { 78293 case uint32(0) /* CMD_SHM */ : 78294 { 78295 var pObj uintptr 78296 var rc int32 78297 var pBuffer uintptr 78298 var zName uintptr 78299 if (objc != 3) && (objc != 4) { 78300 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+38127 /* "FILE ?VALUE?" */) 78301 return TCL_ERROR 78302 } 78303 zName = tcl.XTcl_Alloc(tls, uint32((*sqlite3_vfs)(unsafe.Pointer((*Testvfs)(unsafe.Pointer(p)).FpParent)).FmxPathname)) 78304 rc = (*(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(((*Testvfs)(unsafe.Pointer(p)).FpParent + 64 /* &.xFullPathname */))))(tls, 78305 (*Testvfs)(unsafe.Pointer(p)).FpParent, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), 78306 (*sqlite3_vfs)(unsafe.Pointer((*Testvfs)(unsafe.Pointer(p)).FpParent)).FmxPathname, zName) 78307 if rc != SQLITE_OK { 78308 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+38140, /* "failed to get fu..." */ 78309 tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), 0)) 78310 tcl.XTcl_Free(tls, zName) 78311 return TCL_ERROR 78312 } 78313 for pBuffer = (*Testvfs)(unsafe.Pointer(p)).FpBuffer; pBuffer != 0; pBuffer = (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).FpNext { 78314 if 0 == libc.Xstrcmp(tls, (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).FzFile, zName) { 78315 break 78316 } 78317 } 78318 tcl.XTcl_Free(tls, zName) 78319 if !(pBuffer != 0) { 78320 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+24, ts+38166 /* "no such file: " */, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), 0)) 78321 return TCL_ERROR 78322 } 78323 if objc == 4 { 78324 // var n int32 at bp+260, 4 78325 78326 var a uintptr = tcl.XTcl_GetByteArrayFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+260 /* &n */) 78327 var pgsz int32 = (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).Fpgsz 78328 if pgsz == 0 { 78329 pgsz = 65536 78330 } 78331 for *(*int32)(unsafe.Pointer(bp + 256 /* i */)) = 0; (*(*int32)(unsafe.Pointer(bp + 256 /* i */)) * pgsz) < *(*int32)(unsafe.Pointer(bp + 260 /* n */)); *(*int32)(unsafe.Pointer(bp + 256 /* i */))++ { 78332 var nByte int32 = pgsz 78333 tvfsAllocPage(tls, pBuffer, *(*int32)(unsafe.Pointer(bp + 256 /* i */)), pgsz) 78334 if (*(*int32)(unsafe.Pointer(bp + 260 /* n */)) - (*(*int32)(unsafe.Pointer(bp + 256 /* i */)) * pgsz)) < pgsz { 78335 nByte = *(*int32)(unsafe.Pointer(bp + 260 /* n */)) 78336 } 78337 libc.Xmemcpy(tls, *(*uintptr)(unsafe.Pointer((pBuffer + 16 /* &.aPage */) + uintptr(*(*int32)(unsafe.Pointer(bp + 256 /* i */)))*8)), (a + uintptr((*(*int32)(unsafe.Pointer(bp + 256 /* i */)) * pgsz))), uint64(nByte)) 78338 } 78339 } 78340 78341 pObj = tcl.XTcl_NewObj(tls) 78342 for *(*int32)(unsafe.Pointer(bp + 256 /* i */)) = 0; *(*uintptr)(unsafe.Pointer((pBuffer + 16 /* &.aPage */) + uintptr(*(*int32)(unsafe.Pointer(bp + 256 /* i */)))*8)) != 0; *(*int32)(unsafe.Pointer(bp + 256 /* i */))++ { 78343 var pgsz int32 = (*TestvfsBuffer)(unsafe.Pointer(pBuffer)).Fpgsz 78344 if pgsz == 0 { 78345 pgsz = 65536 78346 } 78347 tcl.XTcl_AppendObjToObj(tls, pObj, tcl.XTcl_NewByteArrayObj(tls, *(*uintptr)(unsafe.Pointer((pBuffer + 16 /* &.aPage */) + uintptr(*(*int32)(unsafe.Pointer(bp + 256 /* i */)))*8)), pgsz)) 78348 } 78349 tcl.XTcl_SetObjResult(tls, interp, pObj) 78350 break 78351 78352 } 78353 78354 // TESTVFS filter METHOD-LIST 78355 // 78356 // Activate special processing for those methods contained in the list 78357 case uint32(2) /* CMD_FILTER */ : 78358 { 78359 *(*uintptr)(unsafe.Pointer(bp + 272 /* apElem */)) = uintptr(0) 78360 *(*int32)(unsafe.Pointer(bp + 264 /* nElem */)) = 0 78361 var mask int32 = 0 78362 if objc != 3 { 78363 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+31755 /* "LIST" */) 78364 return TCL_ERROR 78365 } 78366 if tcl.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+264 /* &nElem */, bp+272 /* &apElem */) != 0 { 78367 return TCL_ERROR 78368 } 78369 tcl.XTcl_ResetResult(tls, interp) 78370 for *(*int32)(unsafe.Pointer(bp + 256 /* i */)) = 0; *(*int32)(unsafe.Pointer(bp + 256 /* i */)) < *(*int32)(unsafe.Pointer(bp + 264 /* nElem */)); *(*int32)(unsafe.Pointer(bp + 256 /* i */))++ { 78371 var iMethod int32 78372 var zElem uintptr = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 272 /* apElem */)) + uintptr(*(*int32)(unsafe.Pointer(bp + 256 /* i */)))*8))) 78373 for iMethod = 0; iMethod < (int32(uint64(unsafe.Sizeof(vfsmethod)) / uint64(unsafe.Sizeof(VfsMethod{})))); iMethod++ { 78374 if libc.Xstrcmp(tls, zElem, vfsmethod[iMethod].FzName) == 0 { 78375 mask = mask | (vfsmethod[iMethod].Fmask) 78376 break 78377 } 78378 } 78379 if iMethod == (int32(uint64(unsafe.Sizeof(vfsmethod)) / uint64(unsafe.Sizeof(VfsMethod{})))) { 78380 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+48, ts+38181 /* "unknown method: " */, zElem, 0)) 78381 return TCL_ERROR 78382 } 78383 } 78384 (*Testvfs)(unsafe.Pointer(p)).Fmask = mask 78385 break 78386 78387 } 78388 78389 // TESTVFS script ?SCRIPT? 78390 // 78391 // Query or set the script to be run when filtered VFS events 78392 // occur. 78393 case uint32(4) /* CMD_SCRIPT */ : 78394 { 78395 if objc == 3 { 78396 // var nByte int32 at bp+280, 4 78397 78398 if (*Testvfs)(unsafe.Pointer(p)).FpScript != 0 { 78399 for ok := true; ok; ok = 0 != 0 { 78400 var _objPtr uintptr = (*Testvfs)(unsafe.Pointer(p)).FpScript 78401 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 78402 tcl.XTclFreeObj(tls, _objPtr) 78403 } 78404 } 78405 (*Testvfs)(unsafe.Pointer(p)).FpScript = uintptr(0) 78406 } 78407 tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+280 /* &nByte */) 78408 if *(*int32)(unsafe.Pointer(bp + 280 /* nByte */)) > 0 { 78409 (*Testvfs)(unsafe.Pointer(p)).FpScript = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 78410 (*Tcl_Obj)(unsafe.Pointer((*Testvfs)(unsafe.Pointer(p)).FpScript)).FrefCount++ 78411 } 78412 } else if objc != 2 { 78413 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+12940 /* "?SCRIPT?" */) 78414 return TCL_ERROR 78415 } 78416 78417 tcl.XTcl_ResetResult(tls, interp) 78418 if (*Testvfs)(unsafe.Pointer(p)).FpScript != 0 { 78419 tcl.XTcl_SetObjResult(tls, interp, (*Testvfs)(unsafe.Pointer(p)).FpScript) 78420 } 78421 78422 break 78423 78424 } 78425 78426 // TESTVFS ioerr ?IFAIL PERSIST? 78427 // 78428 // Where IFAIL is an integer and PERSIST is boolean. 78429 case uint32(8) /* CMD_CANTOPENERR */ : 78430 fallthrough 78431 case uint32(3) /* CMD_IOERR */ : 78432 fallthrough 78433 case uint32(7) /* CMD_FULLERR */ : 78434 { 78435 var pTest uintptr = uintptr(0) 78436 var iRet int32 78437 78438 switch (*TestvfsSubcmd)(unsafe.Pointer(bp + 96 /* &aSubcmd */ + uintptr(*(*int32)(unsafe.Pointer(bp + 256 /* i */)))*16)).FeCmd { 78439 case uint32(3) /* CMD_IOERR */ : 78440 pTest = (p + 60 /* &.ioerr_err */) 78441 break 78442 case uint32(7) /* CMD_FULLERR */ : 78443 pTest = (p + 72 /* &.full_err */) 78444 break 78445 case uint32(8) /* CMD_CANTOPENERR */ : 78446 pTest = (p + 84 /* &.cantopen_err */) 78447 break 78448 default: 78449 } 78450 iRet = (*TestFaultInject)(unsafe.Pointer(pTest)).FnFail 78451 (*TestFaultInject)(unsafe.Pointer(pTest)).FnFail = 0 78452 (*TestFaultInject)(unsafe.Pointer(pTest)).FeFault = 0 78453 (*TestFaultInject)(unsafe.Pointer(pTest)).FiCnt = 0 78454 78455 if objc == 4 { 78456 // var iCnt int32 at bp+284, 4 78457 78458 // var iPersist int32 at bp+288, 4 78459 78460 if (TCL_OK != tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+284 /* &iCnt */)) || 78461 (TCL_OK != tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+288 /* &iPersist */)) { 78462 return TCL_ERROR 78463 } 78464 (*TestFaultInject)(unsafe.Pointer(pTest)).FeFault = func() int32 { 78465 if *(*int32)(unsafe.Pointer(bp + 288 /* iPersist */)) != 0 { 78466 return FAULT_INJECT_PERSISTENT 78467 } 78468 return FAULT_INJECT_TRANSIENT 78469 }() 78470 (*TestFaultInject)(unsafe.Pointer(pTest)).FiCnt = *(*int32)(unsafe.Pointer(bp + 284 /* iCnt */)) 78471 } else if objc != 2 { 78472 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+38198 /* "?CNT PERSIST?" */) 78473 return TCL_ERROR 78474 } 78475 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, iRet)) 78476 break 78477 78478 } 78479 78480 case uint32(1) /* CMD_DELETE */ : 78481 { 78482 tcl.XTcl_DeleteCommand(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv)))) 78483 break 78484 78485 } 78486 78487 case uint32(5) /* CMD_DEVCHAR */ : 78488 { 78489 *(*[16]DeviceFlag)(unsafe.Pointer(bp + 304 /* aFlag */)) = [16]DeviceFlag{ 78490 {FzName: ts + 38212 /* "default" */, FiValue: -1}, 78491 {FzName: ts + 25870 /* "atomic" */, FiValue: SQLITE_IOCAP_ATOMIC}, 78492 {FzName: ts + 25877 /* "atomic512" */, FiValue: SQLITE_IOCAP_ATOMIC512}, 78493 {FzName: ts + 25887 /* "atomic1k" */, FiValue: SQLITE_IOCAP_ATOMIC1K}, 78494 {FzName: ts + 25896 /* "atomic2k" */, FiValue: SQLITE_IOCAP_ATOMIC2K}, 78495 {FzName: ts + 25905 /* "atomic4k" */, FiValue: SQLITE_IOCAP_ATOMIC4K}, 78496 {FzName: ts + 25914 /* "atomic8k" */, FiValue: SQLITE_IOCAP_ATOMIC8K}, 78497 {FzName: ts + 25923 /* "atomic16k" */, FiValue: SQLITE_IOCAP_ATOMIC16K}, 78498 {FzName: ts + 25933 /* "atomic32k" */, FiValue: SQLITE_IOCAP_ATOMIC32K}, 78499 {FzName: ts + 25943 /* "atomic64k" */, FiValue: SQLITE_IOCAP_ATOMIC64K}, 78500 {FzName: ts + 25953 /* "sequential" */, FiValue: SQLITE_IOCAP_SEQUENTIAL}, 78501 {FzName: ts + 25964 /* "safe_append" */, FiValue: SQLITE_IOCAP_SAFE_APPEND}, 78502 {FzName: ts + 38220 /* "undeletable_when..." */, FiValue: SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN}, 78503 {FzName: ts + 25976 /* "powersafe_overwr..." */, FiValue: SQLITE_IOCAP_POWERSAFE_OVERWRITE}, 78504 {FzName: ts + 38242 /* "immutable" */, FiValue: SQLITE_IOCAP_IMMUTABLE}, 78505 {}, 78506 } 78507 var pRet uintptr 78508 var iFlag int32 78509 78510 if objc > 3 { 78511 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+38252 /* "?ATTR-LIST?" */) 78512 return TCL_ERROR 78513 } 78514 if objc == 3 { 78515 var j int32 78516 var iNew int32 = 0 78517 *(*uintptr)(unsafe.Pointer(bp + 296 /* flags */)) = uintptr(0) 78518 *(*int32)(unsafe.Pointer(bp + 292 /* nFlags */)) = 0 78519 78520 if tcl.XTcl_ListObjGetElements(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+292 /* &nFlags */, bp+296 /* &flags */) != 0 { 78521 return TCL_ERROR 78522 } 78523 78524 for j = 0; j < *(*int32)(unsafe.Pointer(bp + 292 /* nFlags */)); j++ { 78525 *(*int32)(unsafe.Pointer(bp + 560 /* idx */)) = 0 78526 if tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 296 /* flags */)) + uintptr(j)*8)), bp+304, /* &aFlag[0] */ 78527 int32(unsafe.Sizeof(DeviceFlag{})), ts+17196 /* "flag" */, 0, bp+560 /* &idx */) != 0 { 78528 return TCL_ERROR 78529 } 78530 if ((*DeviceFlag)(unsafe.Pointer(bp+304 /* &aFlag */ +uintptr(*(*int32)(unsafe.Pointer(bp + 560 /* idx */)))*16)).FiValue < 0) && (*(*int32)(unsafe.Pointer(bp + 292 /* nFlags */)) > 1) { 78531 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp+72, ts+38264 /* "bad flags: " */, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))), 0)) 78532 return TCL_ERROR 78533 } 78534 iNew = iNew | ((*DeviceFlag)(unsafe.Pointer(bp + 304 /* &aFlag */ + uintptr(*(*int32)(unsafe.Pointer(bp + 560 /* idx */)))*16)).FiValue) 78535 } 78536 78537 (*Testvfs)(unsafe.Pointer(p)).FiDevchar = (iNew | 0x10000000) 78538 } 78539 78540 pRet = tcl.XTcl_NewObj(tls) 78541 for iFlag = 0; uint64(iFlag) < (uint64(unsafe.Sizeof([16]DeviceFlag{})) / uint64(unsafe.Sizeof(DeviceFlag{}))); iFlag++ { 78542 if ((*Testvfs)(unsafe.Pointer(p)).FiDevchar & (*DeviceFlag)(unsafe.Pointer(bp+304 /* &aFlag */ +uintptr(iFlag)*16)).FiValue) != 0 { 78543 tcl.XTcl_ListObjAppendElement(tls, 78544 interp, pRet, tcl.XTcl_NewStringObj(tls, (*DeviceFlag)(unsafe.Pointer(bp+304 /* &aFlag */ +uintptr(iFlag)*16)).FzName, -1)) 78545 } 78546 } 78547 tcl.XTcl_SetObjResult(tls, interp, pRet) 78548 78549 break 78550 78551 } 78552 78553 case uint32(6) /* CMD_SECTORSIZE */ : 78554 { 78555 if objc > 3 { 78556 tcl.XTcl_WrongNumArgs(tls, interp, 2, objv, ts+38276 /* "?VALUE?" */) 78557 return TCL_ERROR 78558 } 78559 if objc == 3 { 78560 *(*int32)(unsafe.Pointer(bp + 564 /* iNew */)) = 0 78561 if tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 2*8)), bp+564 /* &iNew */) != 0 { 78562 return TCL_ERROR 78563 } 78564 (*Testvfs)(unsafe.Pointer(p)).FiSectorsize = *(*int32)(unsafe.Pointer(bp + 564 /* iNew */)) 78565 } 78566 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, (*Testvfs)(unsafe.Pointer(p)).FiSectorsize)) 78567 break 78568 78569 } 78570 } 78571 78572 return TCL_OK 78573 } 78574 78575 type TestvfsSubcmd = struct { 78576 FzName uintptr 78577 FeCmd uint32 78578 _ [4]byte 78579 } /* test_vfs.c:1092:3 */ 78580 78581 type VfsMethod = struct { 78582 FzName uintptr 78583 Fmask int32 78584 _ [4]byte 78585 } /* test_vfs.c:1179:14 */ 78586 78587 var vfsmethod = [18]VfsMethod{ 78588 {FzName: ts + 38004 /* "xShmOpen" */, Fmask: TESTVFS_SHMOPEN_MASK}, 78589 {FzName: ts + 35007 /* "xShmLock" */, Fmask: TESTVFS_SHMLOCK_MASK}, 78590 {FzName: ts + 35016 /* "xShmBarrier" */, Fmask: TESTVFS_SHMBARRIER_MASK}, 78591 {FzName: ts + 34997 /* "xShmUnmap" */, Fmask: TESTVFS_SHMCLOSE_MASK}, 78592 {FzName: ts + 35028 /* "xShmMap" */, Fmask: TESTVFS_SHMMAP_MASK}, 78593 {FzName: ts + 27316 /* "xSync" */, Fmask: TESTVFS_SYNC_MASK}, 78594 {FzName: ts + 34935 /* "xDelete" */, Fmask: TESTVFS_DELETE_MASK}, 78595 {FzName: ts + 34843 /* "xWrite" */, Fmask: TESTVFS_WRITE_MASK}, 78596 {FzName: ts + 34837 /* "xRead" */, Fmask: TESTVFS_READ_MASK}, 78597 {FzName: ts + 34850 /* "xTruncate" */, Fmask: TESTVFS_TRUNCATE_MASK}, 78598 {FzName: ts + 26888 /* "xOpen" */, Fmask: TESTVFS_OPEN_MASK}, 78599 {FzName: ts + 34830 /* "xClose" */, Fmask: TESTVFS_CLOSE_MASK}, 78600 {FzName: ts + 34943 /* "xAccess" */, Fmask: TESTVFS_ACCESS_MASK}, 78601 {FzName: ts + 34951 /* "xFullPathname" */, Fmask: TESTVFS_FULLPATHNAME_MASK}, 78602 {FzName: ts + 34876 /* "xUnlock" */, Fmask: TESTVFS_UNLOCK_MASK}, 78603 {FzName: ts + 34870 /* "xLock" */, Fmask: TESTVFS_LOCK_MASK}, 78604 {FzName: ts + 37870 /* "xCheckReservedLo..." */, Fmask: TESTVFS_CKLOCK_MASK}, 78605 {FzName: ts + 34898 /* "xFileControl" */, Fmask: TESTVFS_FCNTL_MASK}, 78606 } /* test_vfs.c:1182:9 */ 78607 78608 func testvfs_obj_del(tls *libc.TLS, cd ClientData) { /* test_vfs.c:1393:27: */ 78609 var p uintptr = cd 78610 if (*Testvfs)(unsafe.Pointer(p)).FpScript != 0 { 78611 for ok := true; ok; ok = 0 != 0 { 78612 var _objPtr uintptr = (*Testvfs)(unsafe.Pointer(p)).FpScript 78613 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 78614 tcl.XTclFreeObj(tls, _objPtr) 78615 } 78616 } 78617 } 78618 sqlite3.Xsqlite3_vfs_unregister(tls, (*Testvfs)(unsafe.Pointer(p)).FpVfs) 78619 libc.Xmemset(tls, (*Testvfs)(unsafe.Pointer(p)).FpVfs, 0, uint64(unsafe.Sizeof(sqlite3_vfs{}))) 78620 tcl.XTcl_Free(tls, (*Testvfs)(unsafe.Pointer(p)).FpVfs) 78621 libc.Xmemset(tls, p, 0, uint64(unsafe.Sizeof(Testvfs{}))) 78622 tcl.XTcl_Free(tls, p) 78623 } 78624 78625 // Usage: testvfs VFSNAME ?SWITCHES? 78626 // 78627 // Switches are: 78628 // 78629 // -noshm BOOLEAN (True to omit shm methods. Default false) 78630 // -default BOOLEAN (True to make the vfs default. Default false) 78631 // 78632 // This command creates two things when it is invoked: an SQLite VFS, and 78633 // a Tcl command. Both are named VFSNAME. The VFS is installed. It is not 78634 // installed as the default VFS. 78635 // 78636 // The VFS passes all file I/O calls through to the underlying VFS. 78637 // 78638 // Whenever the xShmMap method of the VFS 78639 // is invoked, the SCRIPT is executed as follows: 78640 // 78641 // SCRIPT xShmMap FILENAME ID 78642 // 78643 // The value returned by the invocation of SCRIPT above is interpreted as 78644 // an SQLite error code and returned to SQLite. Either a symbolic 78645 // "SQLITE_OK" or numeric "0" value may be returned. 78646 // 78647 // The contents of the shared-memory buffer associated with a given file 78648 // may be read and set using the following command: 78649 // 78650 // VFSNAME shm FILENAME ?NEWVALUE? 78651 // 78652 // When the xShmLock method is invoked by SQLite, the following script is 78653 // run: 78654 // 78655 // SCRIPT xShmLock FILENAME ID LOCK 78656 // 78657 // where LOCK is of the form "OFFSET NBYTE lock/unlock shared/exclusive" 78658 func testvfs_cmd(tls *libc.TLS, cd ClientData, interp uintptr, objc int32, objv uintptr) int32 { /* test_vfs.c:1438:26: */ 78659 bp := tls.Alloc(28) 78660 defer tls.Free(28) 78661 78662 var p uintptr // New object 78663 var pVfs uintptr // New VFS 78664 var zVfs uintptr 78665 var nByte int32 // Bytes of space to allocate at p 78666 78667 var i int32 78668 // var isNoshm int32 at bp+4, 4 78669 // True if -noshm is passed 78670 // var isFullshm int32 at bp+24, 4 78671 // True if -fullshm is passed 78672 // var isDefault int32 at bp+8, 4 78673 // True if -default is passed 78674 // var szOsFile int32 at bp+12, 4 78675 // Value passed to -szosfile 78676 // var mxPathname int32 at bp+16, 4 78677 // Value passed to -mxpathname 78678 // var iVersion int32 at bp+20, 4 78679 78680 // var nSwitch int32 at bp, 4 78681 78682 var zSwitch uintptr 78683 *(*int32)(unsafe.Pointer(bp + 4 /* isNoshm */)) = 0 78684 *(*int32)(unsafe.Pointer(bp + 24 /* isFullshm */)) = 0 78685 *(*int32)(unsafe.Pointer(bp + 8 /* isDefault */)) = 0 78686 *(*int32)(unsafe.Pointer(bp + 12 /* szOsFile */)) = 0 78687 *(*int32)(unsafe.Pointer(bp + 16 /* mxPathname */)) = -1 78688 *(*int32)(unsafe.Pointer(bp + 20 /* iVersion */)) = 3 // Value passed to -iversion 78689 78690 if !((objc < 2) || (0 != (objc % 2))) { 78691 goto __1 78692 } 78693 goto bad_args 78694 __1: 78695 ; 78696 i = 2 78697 __2: 78698 if !(i < objc) { 78699 goto __4 78700 } 78701 zSwitch = tcl.XTcl_GetStringFromObj(tls, *(*uintptr)(unsafe.Pointer(objv + uintptr(i)*8)), bp /* &nSwitch */) 78702 78703 if !((*(*int32)(unsafe.Pointer(bp /* nSwitch */)) > 2) && (0 == libc.Xstrncmp(tls, ts+38284 /* "-noshm" */, zSwitch, uint64(*(*int32)(unsafe.Pointer(bp /* nSwitch */)))))) { 78704 goto __5 78705 } 78706 if !(tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)), bp+4 /* &isNoshm */) != 0) { 78707 goto __7 78708 } 78709 return TCL_ERROR 78710 __7: 78711 ; 78712 if !(*(*int32)(unsafe.Pointer(bp + 4 /* isNoshm */)) != 0) { 78713 goto __8 78714 } 78715 *(*int32)(unsafe.Pointer(bp + 24 /* isFullshm */)) = 0 78716 __8: 78717 ; 78718 goto __6 78719 __5: 78720 if !((*(*int32)(unsafe.Pointer(bp /* nSwitch */)) > 2) && (0 == libc.Xstrncmp(tls, ts+26246 /* "-default" */, zSwitch, uint64(*(*int32)(unsafe.Pointer(bp /* nSwitch */)))))) { 78721 goto __9 78722 } 78723 if !(tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)), bp+8 /* &isDefault */) != 0) { 78724 goto __11 78725 } 78726 return TCL_ERROR 78727 __11: 78728 ; 78729 goto __10 78730 __9: 78731 if !((*(*int32)(unsafe.Pointer(bp /* nSwitch */)) > 2) && (0 == libc.Xstrncmp(tls, ts+38291 /* "-szosfile" */, zSwitch, uint64(*(*int32)(unsafe.Pointer(bp /* nSwitch */)))))) { 78732 goto __12 78733 } 78734 if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)), bp+12 /* &szOsFile */) != 0) { 78735 goto __14 78736 } 78737 return TCL_ERROR 78738 __14: 78739 ; 78740 goto __13 78741 __12: 78742 if !((*(*int32)(unsafe.Pointer(bp /* nSwitch */)) > 2) && (0 == libc.Xstrncmp(tls, ts+38301 /* "-mxpathname" */, zSwitch, uint64(*(*int32)(unsafe.Pointer(bp /* nSwitch */)))))) { 78743 goto __15 78744 } 78745 if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)), bp+16 /* &mxPathname */) != 0) { 78746 goto __17 78747 } 78748 return TCL_ERROR 78749 __17: 78750 ; 78751 goto __16 78752 __15: 78753 if !((*(*int32)(unsafe.Pointer(bp /* nSwitch */)) > 2) && (0 == libc.Xstrncmp(tls, ts+38313 /* "-iversion" */, zSwitch, uint64(*(*int32)(unsafe.Pointer(bp /* nSwitch */)))))) { 78754 goto __18 78755 } 78756 if !(tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)), bp+20 /* &iVersion */) != 0) { 78757 goto __20 78758 } 78759 return TCL_ERROR 78760 __20: 78761 ; 78762 goto __19 78763 __18: 78764 if !((*(*int32)(unsafe.Pointer(bp /* nSwitch */)) > 2) && (0 == libc.Xstrncmp(tls, ts+38323 /* "-fullshm" */, zSwitch, uint64(*(*int32)(unsafe.Pointer(bp /* nSwitch */)))))) { 78765 goto __21 78766 } 78767 if !(tcl.XTcl_GetBooleanFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + uintptr((i+1))*8)), bp+24 /* &isFullshm */) != 0) { 78768 goto __23 78769 } 78770 return TCL_ERROR 78771 __23: 78772 ; 78773 if !(*(*int32)(unsafe.Pointer(bp + 24 /* isFullshm */)) != 0) { 78774 goto __24 78775 } 78776 *(*int32)(unsafe.Pointer(bp + 4 /* isNoshm */)) = 0 78777 __24: 78778 ; 78779 goto __22 78780 __21: 78781 goto bad_args 78782 __22: 78783 ; 78784 __19: 78785 ; 78786 __16: 78787 ; 78788 __13: 78789 ; 78790 __10: 78791 ; 78792 __6: 78793 ; 78794 goto __3 78795 __3: 78796 i = i + (2) 78797 goto __2 78798 goto __4 78799 __4: 78800 ; 78801 78802 if !(uint64(*(*int32)(unsafe.Pointer(bp + 12 /* szOsFile */))) < uint64(unsafe.Sizeof(TestvfsFile{}))) { 78803 goto __25 78804 } 78805 *(*int32)(unsafe.Pointer(bp + 12 /* szOsFile */)) = int32(unsafe.Sizeof(TestvfsFile{})) 78806 __25: 78807 ; 78808 78809 zVfs = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))) 78810 nByte = (int32((uint64(unsafe.Sizeof(Testvfs{})) + uint64(int32(libc.Xstrlen(tls, zVfs)))) + uint64(1))) 78811 p = tcl.XTcl_Alloc(tls, uint32(nByte)) 78812 libc.Xmemset(tls, p, 0, uint64(nByte)) 78813 (*Testvfs)(unsafe.Pointer(p)).FiDevchar = -1 78814 (*Testvfs)(unsafe.Pointer(p)).FiSectorsize = -1 78815 78816 // Create the new object command before querying SQLite for a default VFS 78817 // to use for 'real' IO operations. This is because creating the new VFS 78818 // may delete an existing [testvfs] VFS of the same name. If such a VFS 78819 // is currently the default, the new [testvfs] may end up calling the 78820 // methods of a deleted object. 78821 tcl.XTcl_CreateObjCommand(tls, interp, zVfs, *(*uintptr)(unsafe.Pointer(&struct { 78822 f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 78823 }{testvfs_obj_cmd})), p, *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, ClientData) }{testvfs_obj_del}))) 78824 (*Testvfs)(unsafe.Pointer(p)).FpParent = sqlite3.Xsqlite3_vfs_find(tls, uintptr(0)) 78825 (*Testvfs)(unsafe.Pointer(p)).Finterp = interp 78826 78827 (*Testvfs)(unsafe.Pointer(p)).FzName = (p + 1*104) 78828 libc.Xmemcpy(tls, (*Testvfs)(unsafe.Pointer(p)).FzName, zVfs, (libc.Xstrlen(tls, zVfs) + uint64(1))) 78829 78830 pVfs = tcl.XTcl_Alloc(tls, uint32(unsafe.Sizeof(sqlite3_vfs{}))) 78831 libc.Xmemcpy(tls, pVfs, uintptr(unsafe.Pointer(&tvfs_vfs)), uint64(unsafe.Sizeof(sqlite3_vfs{}))) 78832 (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FpAppData = p 78833 (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FiVersion = *(*int32)(unsafe.Pointer(bp + 20 /* iVersion */)) 78834 (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FzName = (*Testvfs)(unsafe.Pointer(p)).FzName 78835 (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname = (*sqlite3_vfs)(unsafe.Pointer((*Testvfs)(unsafe.Pointer(p)).FpParent)).FmxPathname 78836 if !((*(*int32)(unsafe.Pointer(bp + 16 /* mxPathname */)) >= 0) && (*(*int32)(unsafe.Pointer(bp + 16 /* mxPathname */)) < (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname)) { 78837 goto __26 78838 } 78839 (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FmxPathname = *(*int32)(unsafe.Pointer(bp + 16 /* mxPathname */)) 78840 __26: 78841 ; 78842 (*sqlite3_vfs)(unsafe.Pointer(pVfs)).FszOsFile = *(*int32)(unsafe.Pointer(bp + 12 /* szOsFile */)) 78843 (*Testvfs)(unsafe.Pointer(p)).FpVfs = pVfs 78844 (*Testvfs)(unsafe.Pointer(p)).FisNoshm = *(*int32)(unsafe.Pointer(bp + 4 /* isNoshm */)) 78845 (*Testvfs)(unsafe.Pointer(p)).FisFullshm = *(*int32)(unsafe.Pointer(bp + 24 /* isFullshm */)) 78846 (*Testvfs)(unsafe.Pointer(p)).Fmask = TESTVFS_ALL_MASK 78847 78848 sqlite3.Xsqlite3_vfs_register(tls, pVfs, *(*int32)(unsafe.Pointer(bp + 8 /* isDefault */))) 78849 78850 return TCL_OK 78851 78852 bad_args: 78853 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+38332 /* "VFSNAME ?-noshm ..." */) 78854 return TCL_ERROR 78855 } 78856 78857 var tvfs_vfs = sqlite3_vfs{ 78858 FiVersion: 3, // pAppData 78859 FxOpen: 0, // xOpen 78860 FxDelete: 0, // xDelete 78861 FxAccess: 0, // xAccess 78862 FxFullPathname: 0, // xDlClose 78863 FxRandomness: 0, // xRandomness 78864 FxSleep: 0, // xSleep 78865 FxCurrentTime: 0, // xNextSystemCall 78866 } /* test_vfs.c:1444:22 */ 78867 78868 // tclcmd: vfs_shmlock DB DBNAME (shared|exclusive) (lock|unlock) OFFSET N 78869 func test_vfs_shmlock(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_vfs.c:1586:26: */ 78870 bp := tls.Alloc(88) 78871 defer tls.Free(88) 78872 78873 *(*[3]uintptr)(unsafe.Pointer(bp + 8 /* azArg1 */)) = [3]uintptr{ts + 38436 /* "shared" */, ts + 13660 /* "exclusive" */, uintptr(0)} 78874 *(*[3]uintptr)(unsafe.Pointer(bp + 40 /* azArg2 */)) = [3]uintptr{ts + 38443 /* "lock" */, ts + 38448 /* "unlock" */, uintptr(0)} 78875 *(*uintptr)(unsafe.Pointer(bp /* db */)) = uintptr(0) 78876 var rc int32 = SQLITE_OK 78877 var zDbname uintptr = uintptr(0) 78878 *(*int32)(unsafe.Pointer(bp + 32 /* iArg1 */)) = 0 78879 *(*int32)(unsafe.Pointer(bp + 64 /* iArg2 */)) = 0 78880 *(*int32)(unsafe.Pointer(bp + 68 /* iOffset */)) = 0 78881 *(*int32)(unsafe.Pointer(bp + 72 /* n */)) = 0 78882 // var pFd uintptr at bp+80, 8 78883 78884 if objc != 7 { 78885 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, 78886 ts+38455 /* "DB DBNAME (share..." */) 78887 return TCL_ERROR 78888 } 78889 78890 zDbname = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 78891 if ((((getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0) || 78892 (tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+8 /* &azArg1[0] */, int32(unsafe.Sizeof(uintptr(0))), ts+38507 /* "ARG" */, 0, bp+32 /* &iArg1 */) != 0)) || 78893 (tcl.XTcl_GetIndexFromObjStruct(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+40 /* &azArg2[0] */, int32(unsafe.Sizeof(uintptr(0))), ts+38507 /* "ARG" */, 0, bp+64 /* &iArg2 */) != 0)) || 78894 (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 5*8)), bp+68 /* &iOffset */) != 0)) || 78895 (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 6*8)), bp+72 /* &n */) != 0) { 78896 return TCL_ERROR 78897 } 78898 78899 sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zDbname, SQLITE_FCNTL_FILE_POINTER, bp+80 /* &pFd */) 78900 if *(*uintptr)(unsafe.Pointer(bp + 80 /* pFd */)) == uintptr(0) { 78901 return TCL_ERROR 78902 } 78903 rc = (*(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 80 /* pFd */)))).FpMethods + 112 /* &.xShmLock */))))(tls, *(*uintptr)(unsafe.Pointer(bp + 80 /* pFd */)), *(*int32)(unsafe.Pointer(bp + 68 /* iOffset */)), *(*int32)(unsafe.Pointer(bp + 72 /* n */)), 78904 ((func() int32 { 78905 if *(*int32)(unsafe.Pointer(bp + 32 /* iArg1 */)) == 0 { 78906 return SQLITE_SHM_SHARED 78907 } 78908 return SQLITE_SHM_EXCLUSIVE 78909 }()) | 78910 (func() int32 { 78911 if *(*int32)(unsafe.Pointer(bp + 64 /* iArg2 */)) == 0 { 78912 return SQLITE_SHM_LOCK 78913 } 78914 return SQLITE_SHM_UNLOCK 78915 }()))) 78916 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 78917 return TCL_OK 78918 } 78919 78920 func test_vfs_set_readmark(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_vfs.c:1632:26: */ 78921 bp := tls.Alloc(48) 78922 defer tls.Free(48) 78923 78924 *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)) = uintptr(0) 78925 var rc int32 = SQLITE_OK 78926 var zDbname uintptr = uintptr(0) 78927 *(*int32)(unsafe.Pointer(bp + 24 /* iSlot */)) = 0 78928 *(*int32)(unsafe.Pointer(bp + 28 /* iVal */)) = -1 78929 // var pFd uintptr at bp+32, 8 78930 78931 *(*uintptr)(unsafe.Pointer(bp + 40 /* pShm */)) = uintptr(0) 78932 var aShm uintptr 78933 var iOff int32 78934 78935 if (objc != 4) && (objc != 5) { 78936 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+38511 /* "DB DBNAME SLOT ?..." */) 78937 return TCL_ERROR 78938 } 78939 78940 zDbname = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 78941 if ((getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp+16 /* &db */) != 0) || 78942 (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 3*8)), bp+24 /* &iSlot */) != 0)) || 78943 ((objc == 5) && (tcl.XTcl_GetIntFromObj(tls, interp, *(*uintptr)(unsafe.Pointer(objv + 4*8)), bp+28 /* &iVal */) != 0)) { 78944 return TCL_ERROR 78945 } 78946 78947 sqlite3.Xsqlite3_file_control(tls, *(*uintptr)(unsafe.Pointer(bp + 16 /* db */)), zDbname, SQLITE_FCNTL_FILE_POINTER, bp+32 /* &pFd */) 78948 if *(*uintptr)(unsafe.Pointer(bp + 32 /* pFd */)) == uintptr(0) { 78949 return TCL_ERROR 78950 } 78951 rc = (*(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(((*sqlite3_file)(unsafe.Pointer(*(*uintptr)(unsafe.Pointer(bp + 32 /* pFd */)))).FpMethods + 104 /* &.xShmMap */))))(tls, *(*uintptr)(unsafe.Pointer(bp + 32 /* pFd */)), 0, (32 * 1024), 0, bp+40 /* &pShm */) 78952 if rc != SQLITE_OK { 78953 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 78954 return TCL_ERROR 78955 } 78956 if libc.AtomicLoadPUintptr(bp+40 /* pShm */) == uintptr(0) { 78957 tcl.XTcl_AppendResult(tls, interp, libc.VaList(bp, ts+38534 /* "*-shm is not yet..." */, 0)) 78958 return TCL_ERROR 78959 } 78960 aShm = libc.AtomicLoadPUintptr(bp + 40 /* pShm */) 78961 iOff = (((12 * 2) + 1) + *(*int32)(unsafe.Pointer(bp + 24 /* iSlot */))) 78962 78963 if objc == 5 { 78964 *(*u322)(unsafe.Pointer(aShm + uintptr(iOff)*4)) = u322(*(*int32)(unsafe.Pointer(bp + 28 /* iVal */))) 78965 } 78966 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewIntObj(tls, int32(*(*u322)(unsafe.Pointer(aShm + uintptr(iOff)*4))))) 78967 78968 return TCL_OK 78969 } 78970 78971 func Sqlitetestvfs_Init(tls *libc.TLS, interp uintptr) int32 { /* test_vfs.c:1685:5: */ 78972 tcl.XTcl_CreateObjCommand(tls, interp, ts+38558 /* "testvfs" */, *(*uintptr)(unsafe.Pointer(&struct { 78973 f func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32 78974 }{testvfs_cmd})), uintptr(0), uintptr(0)) 78975 tcl.XTcl_CreateObjCommand(tls, interp, ts+38566 /* "vfs_shmlock" */, *(*uintptr)(unsafe.Pointer(&struct { 78976 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 78977 }{test_vfs_shmlock})), uintptr(0), uintptr(0)) 78978 tcl.XTcl_CreateObjCommand(tls, interp, ts+38578 /* "vfs_set_readmark" */, *(*uintptr)(unsafe.Pointer(&struct { 78979 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 78980 }{test_vfs_set_readmark})), uintptr(0), uintptr(0)) 78981 return TCL_OK 78982 } 78983 78984 // 2015 November 30 78985 // 78986 // The author disclaims copyright to this source code. In place of 78987 // a legal notice, here is a blessing: 78988 // 78989 // May you do good and not evil. 78990 // May you find forgiveness for yourself and forgive others. 78991 // May you share freely, never taking more than you give. 78992 // 78993 // 78994 // This file contains code to implement most of the opendir() family of 78995 // POSIX functions on Win32 using the MSVCRT. 78996 78997 type TestWindow1 = struct { 78998 FxStep uintptr 78999 FxFinal uintptr 79000 FxValue uintptr 79001 FxInverse uintptr 79002 Finterp uintptr 79003 } /* test_window.c:24:9 */ 79004 79005 type TestWindow = TestWindow1 /* test_window.c:24:27 */ 79006 79007 type TestWindowCtx1 = struct{ FpVal uintptr } /* test_window.c:33:9 */ 79008 79009 type TestWindowCtx = TestWindowCtx1 /* test_window.c:33:30 */ 79010 79011 func doTestWindowStep(tls *libc.TLS, bInverse int32, ctx uintptr, nArg int32, apArg uintptr) { /* test_window.c:38:13: */ 79012 var i int32 79013 var p uintptr = sqlite3.Xsqlite3_user_data(tls, ctx) 79014 var pEval uintptr = tcl.XTcl_DuplicateObj(tls, func() uintptr { 79015 if bInverse != 0 { 79016 return (*TestWindow)(unsafe.Pointer(p)).FxInverse 79017 } 79018 return (*TestWindow)(unsafe.Pointer(p)).FxStep 79019 }()) 79020 var pCtx uintptr = sqlite3.Xsqlite3_aggregate_context(tls, ctx, int32(unsafe.Sizeof(TestWindowCtx{}))) 79021 79022 (*Tcl_Obj)(unsafe.Pointer(pEval)).FrefCount++ 79023 if pCtx != 0 { 79024 var zResult uintptr 79025 var rc int32 79026 if (*TestWindowCtx)(unsafe.Pointer(pCtx)).FpVal != 0 { 79027 tcl.XTcl_ListObjAppendElement(tls, (*TestWindow)(unsafe.Pointer(p)).Finterp, pEval, tcl.XTcl_DuplicateObj(tls, (*TestWindowCtx)(unsafe.Pointer(pCtx)).FpVal)) 79028 } else { 79029 tcl.XTcl_ListObjAppendElement(tls, (*TestWindow)(unsafe.Pointer(p)).Finterp, pEval, tcl.XTcl_NewStringObj(tls, ts+489 /* "" */, -1)) 79030 } 79031 for i = 0; i < nArg; i++ { 79032 var pArg uintptr 79033 pArg = tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3_value_text(tls, *(*uintptr)(unsafe.Pointer(apArg + uintptr(i)*8))), -1) 79034 tcl.XTcl_ListObjAppendElement(tls, (*TestWindow)(unsafe.Pointer(p)).Finterp, pEval, pArg) 79035 } 79036 rc = tcl.XTcl_EvalObjEx(tls, (*TestWindow)(unsafe.Pointer(p)).Finterp, pEval, TCL_EVAL_GLOBAL) 79037 if rc != TCL_OK { 79038 zResult = tcl.XTcl_GetStringResult(tls, (*TestWindow)(unsafe.Pointer(p)).Finterp) 79039 sqlite3.Xsqlite3_result_error(tls, ctx, zResult, -1) 79040 } else { 79041 if (*TestWindowCtx)(unsafe.Pointer(pCtx)).FpVal != 0 { 79042 for ok := true; ok; ok = 0 != 0 { 79043 var _objPtr uintptr = (*TestWindowCtx)(unsafe.Pointer(pCtx)).FpVal 79044 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 79045 tcl.XTclFreeObj(tls, _objPtr) 79046 } 79047 } 79048 } 79049 (*TestWindowCtx)(unsafe.Pointer(pCtx)).FpVal = tcl.XTcl_DuplicateObj(tls, tcl.XTcl_GetObjResult(tls, (*TestWindow)(unsafe.Pointer(p)).Finterp)) 79050 (*Tcl_Obj)(unsafe.Pointer((*TestWindowCtx)(unsafe.Pointer(pCtx)).FpVal)).FrefCount++ 79051 } 79052 } 79053 for ok1 := true; ok1; ok1 = 0 != 0 { 79054 var _objPtr uintptr = pEval 79055 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 79056 tcl.XTclFreeObj(tls, _objPtr) 79057 } 79058 } 79059 } 79060 79061 func doTestWindowFinalize(tls *libc.TLS, bValue int32, ctx uintptr) { /* test_window.c:76:13: */ 79062 var p uintptr = sqlite3.Xsqlite3_user_data(tls, ctx) 79063 var pEval uintptr = tcl.XTcl_DuplicateObj(tls, func() uintptr { 79064 if bValue != 0 { 79065 return (*TestWindow)(unsafe.Pointer(p)).FxValue 79066 } 79067 return (*TestWindow)(unsafe.Pointer(p)).FxFinal 79068 }()) 79069 var pCtx uintptr = sqlite3.Xsqlite3_aggregate_context(tls, ctx, int32(unsafe.Sizeof(TestWindowCtx{}))) 79070 79071 (*Tcl_Obj)(unsafe.Pointer(pEval)).FrefCount++ 79072 if pCtx != 0 { 79073 var zResult uintptr 79074 var rc int32 79075 if (*TestWindowCtx)(unsafe.Pointer(pCtx)).FpVal != 0 { 79076 tcl.XTcl_ListObjAppendElement(tls, (*TestWindow)(unsafe.Pointer(p)).Finterp, pEval, tcl.XTcl_DuplicateObj(tls, (*TestWindowCtx)(unsafe.Pointer(pCtx)).FpVal)) 79077 } else { 79078 tcl.XTcl_ListObjAppendElement(tls, (*TestWindow)(unsafe.Pointer(p)).Finterp, pEval, tcl.XTcl_NewStringObj(tls, ts+489 /* "" */, -1)) 79079 } 79080 79081 rc = tcl.XTcl_EvalObjEx(tls, (*TestWindow)(unsafe.Pointer(p)).Finterp, pEval, TCL_EVAL_GLOBAL) 79082 zResult = tcl.XTcl_GetStringResult(tls, (*TestWindow)(unsafe.Pointer(p)).Finterp) 79083 if rc != TCL_OK { 79084 sqlite3.Xsqlite3_result_error(tls, ctx, zResult, -1) 79085 } else { 79086 sqlite3.Xsqlite3_result_text(tls, ctx, zResult, -1, libc.UintptrFromInt32(-1)) 79087 } 79088 79089 if bValue == 0 { 79090 if (*TestWindowCtx)(unsafe.Pointer(pCtx)).FpVal != 0 { 79091 for ok := true; ok; ok = 0 != 0 { 79092 var _objPtr uintptr = (*TestWindowCtx)(unsafe.Pointer(pCtx)).FpVal 79093 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 79094 tcl.XTclFreeObj(tls, _objPtr) 79095 } 79096 } 79097 } 79098 (*TestWindowCtx)(unsafe.Pointer(pCtx)).FpVal = uintptr(0) 79099 } 79100 } 79101 for ok1 := true; ok1; ok1 = 0 != 0 { 79102 var _objPtr uintptr = pEval 79103 if libc.PostDecInt32(&(*Tcl_Obj)(unsafe.Pointer((_objPtr))).FrefCount, 1) <= 1 { 79104 tcl.XTclFreeObj(tls, _objPtr) 79105 } 79106 } 79107 } 79108 79109 func testWindowStep(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { /* test_window.c:107:13: */ 79110 doTestWindowStep(tls, 0, ctx, nArg, apArg) 79111 } 79112 79113 func testWindowInverse(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { /* test_window.c:114:13: */ 79114 doTestWindowStep(tls, 1, ctx, nArg, apArg) 79115 } 79116 79117 func testWindowFinal(tls *libc.TLS, ctx uintptr) { /* test_window.c:122:13: */ 79118 doTestWindowFinalize(tls, 0, ctx) 79119 } 79120 79121 func testWindowValue(tls *libc.TLS, ctx uintptr) { /* test_window.c:125:13: */ 79122 doTestWindowFinalize(tls, 1, ctx) 79123 } 79124 79125 func testWindowDestroy(tls *libc.TLS, pCtx uintptr) { /* test_window.c:129:13: */ 79126 tcl.XTcl_Free(tls, pCtx) 79127 } 79128 79129 // Usage: sqlite3_create_window_function DB NAME XSTEP XFINAL XVALUE XINVERSE 79130 func test_create_window(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_window.c:136:26: */ 79131 bp := tls.Alloc(8) 79132 defer tls.Free(8) 79133 79134 var pNew uintptr 79135 // var db uintptr at bp, 8 79136 79137 var zName uintptr 79138 var rc int32 79139 79140 if objc != 7 { 79141 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+38595 /* "DB NAME XSTEP XF..." */) 79142 return TCL_ERROR 79143 } 79144 79145 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 79146 return TCL_ERROR 79147 } 79148 zName = tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 2*8))) 79149 pNew = tcl.XTcl_Alloc(tls, uint32(unsafe.Sizeof(TestWindow{}))) 79150 libc.Xmemset(tls, pNew, 0, uint64(unsafe.Sizeof(TestWindow{}))) 79151 (*TestWindow)(unsafe.Pointer(pNew)).FxStep = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + 3*8))) 79152 (*TestWindow)(unsafe.Pointer(pNew)).FxFinal = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + 4*8))) 79153 (*TestWindow)(unsafe.Pointer(pNew)).FxValue = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + 5*8))) 79154 (*TestWindow)(unsafe.Pointer(pNew)).FxInverse = tcl.XTcl_DuplicateObj(tls, *(*uintptr)(unsafe.Pointer(objv + 6*8))) 79155 (*TestWindow)(unsafe.Pointer(pNew)).Finterp = interp 79156 79157 (*Tcl_Obj)(unsafe.Pointer((*TestWindow)(unsafe.Pointer(pNew)).FxStep)).FrefCount++ 79158 (*Tcl_Obj)(unsafe.Pointer((*TestWindow)(unsafe.Pointer(pNew)).FxFinal)).FrefCount++ 79159 (*Tcl_Obj)(unsafe.Pointer((*TestWindow)(unsafe.Pointer(pNew)).FxValue)).FrefCount++ 79160 (*Tcl_Obj)(unsafe.Pointer((*TestWindow)(unsafe.Pointer(pNew)).FxInverse)).FrefCount++ 79161 79162 rc = sqlite3.Xsqlite3_create_window_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), zName, -1, SQLITE_UTF8, pNew, 79163 *(*uintptr)(unsafe.Pointer(&struct { 79164 f func(*libc.TLS, uintptr, int32, uintptr) 79165 }{testWindowStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testWindowFinal})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testWindowValue})), *(*uintptr)(unsafe.Pointer(&struct { 79166 f func(*libc.TLS, uintptr, int32, uintptr) 79167 }{testWindowInverse})), 79168 *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testWindowDestroy}))) 79169 if rc != SQLITE_OK { 79170 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 79171 return TCL_ERROR 79172 } 79173 79174 return TCL_OK 79175 } 79176 79177 func test_create_window_misuse(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_window.c:179:26: */ 79178 bp := tls.Alloc(8) 79179 defer tls.Free(8) 79180 79181 // var db uintptr at bp, 8 79182 79183 var rc int32 79184 79185 if !(objc != 2) { 79186 goto __1 79187 } 79188 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 79189 return TCL_ERROR 79190 __1: 79191 ; 79192 if !(getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0) { 79193 goto __2 79194 } 79195 return TCL_ERROR 79196 __2: 79197 ; 79198 79199 rc = sqlite3.Xsqlite3_create_window_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+38632 /* "fff" */, -1, SQLITE_UTF8, uintptr(0), 79200 uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testWindowFinal})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testWindowValue})), *(*uintptr)(unsafe.Pointer(&struct { 79201 f func(*libc.TLS, uintptr, int32, uintptr) 79202 }{testWindowInverse})), 79203 uintptr(0)) 79204 if !(rc != SQLITE_MISUSE) { 79205 goto __3 79206 } 79207 goto error 79208 __3: 79209 ; 79210 rc = sqlite3.Xsqlite3_create_window_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+38632 /* "fff" */, -1, SQLITE_UTF8, uintptr(0), 79211 *(*uintptr)(unsafe.Pointer(&struct { 79212 f func(*libc.TLS, uintptr, int32, uintptr) 79213 }{testWindowStep})), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testWindowValue})), *(*uintptr)(unsafe.Pointer(&struct { 79214 f func(*libc.TLS, uintptr, int32, uintptr) 79215 }{testWindowInverse})), 79216 uintptr(0)) 79217 if !(rc != SQLITE_MISUSE) { 79218 goto __4 79219 } 79220 goto error 79221 __4: 79222 ; 79223 rc = sqlite3.Xsqlite3_create_window_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+38632 /* "fff" */, -1, SQLITE_UTF8, uintptr(0), 79224 *(*uintptr)(unsafe.Pointer(&struct { 79225 f func(*libc.TLS, uintptr, int32, uintptr) 79226 }{testWindowStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testWindowFinal})), uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 79227 f func(*libc.TLS, uintptr, int32, uintptr) 79228 }{testWindowInverse})), 79229 uintptr(0)) 79230 if !(rc != SQLITE_MISUSE) { 79231 goto __5 79232 } 79233 goto error 79234 __5: 79235 ; 79236 rc = sqlite3.Xsqlite3_create_window_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+38632 /* "fff" */, -1, SQLITE_UTF8, uintptr(0), 79237 *(*uintptr)(unsafe.Pointer(&struct { 79238 f func(*libc.TLS, uintptr, int32, uintptr) 79239 }{testWindowStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testWindowFinal})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{testWindowValue})), uintptr(0), 79240 uintptr(0)) 79241 if !(rc != SQLITE_MISUSE) { 79242 goto __6 79243 } 79244 goto error 79245 __6: 79246 ; 79247 79248 return TCL_OK 79249 79250 error: 79251 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, ts+38636 /* "misuse test erro..." */, -1)) 79252 return TCL_ERROR 79253 } 79254 79255 // xStep for sumint(). 79256 func sumintStep(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { /* test_window.c:225:13: */ 79257 var pInt uintptr 79258 79259 if sqlite3.Xsqlite3_value_type(tls, *(*uintptr)(unsafe.Pointer(apArg))) != SQLITE_INTEGER { 79260 sqlite3.Xsqlite3_result_error(tls, ctx, ts+38654 /* "invalid argument" */, -1) 79261 return 79262 } 79263 pInt = sqlite3.Xsqlite3_aggregate_context(tls, ctx, int32(unsafe.Sizeof(sqlite3_int64(0)))) 79264 if pInt != 0 { 79265 *(*sqlite3_int64)(unsafe.Pointer(pInt)) += (sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apArg)))) 79266 } 79267 } 79268 79269 // xInverse for sumint(). 79270 func sumintInverse(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) { /* test_window.c:246:13: */ 79271 var pInt uintptr 79272 pInt = sqlite3.Xsqlite3_aggregate_context(tls, ctx, int32(unsafe.Sizeof(sqlite3_int64(0)))) 79273 *(*sqlite3_int64)(unsafe.Pointer(pInt)) -= (sqlite3.Xsqlite3_value_int64(tls, *(*uintptr)(unsafe.Pointer(apArg)))) 79274 } 79275 79276 // xFinal for sumint(). 79277 func sumintFinal(tls *libc.TLS, ctx uintptr) { /* test_window.c:259:13: */ 79278 var res sqlite3_int64 = int64(0) 79279 var pInt uintptr 79280 pInt = sqlite3.Xsqlite3_aggregate_context(tls, ctx, 0) 79281 if pInt != 0 { 79282 res = *(*sqlite3_int64)(unsafe.Pointer(pInt)) 79283 } 79284 sqlite3.Xsqlite3_result_int64(tls, ctx, res) 79285 } 79286 79287 // xValue for sumint(). 79288 func sumintValue(tls *libc.TLS, ctx uintptr) { /* test_window.c:270:13: */ 79289 var res sqlite3_int64 = int64(0) 79290 var pInt uintptr 79291 pInt = sqlite3.Xsqlite3_aggregate_context(tls, ctx, 0) 79292 if pInt != 0 { 79293 res = *(*sqlite3_int64)(unsafe.Pointer(pInt)) 79294 } 79295 sqlite3.Xsqlite3_result_int64(tls, ctx, res) 79296 } 79297 79298 func test_create_sumint(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_window.c:278:26: */ 79299 bp := tls.Alloc(8) 79300 defer tls.Free(8) 79301 79302 // var db uintptr at bp, 8 79303 79304 var rc int32 79305 79306 if objc != 2 { 79307 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 79308 return TCL_ERROR 79309 } 79310 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 79311 return TCL_ERROR 79312 } 79313 79314 rc = sqlite3.Xsqlite3_create_window_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+38671 /* "sumint" */, 1, SQLITE_UTF8, uintptr(0), 79315 *(*uintptr)(unsafe.Pointer(&struct { 79316 f func(*libc.TLS, uintptr, int32, uintptr) 79317 }{sumintStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sumintFinal})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sumintValue})), *(*uintptr)(unsafe.Pointer(&struct { 79318 f func(*libc.TLS, uintptr, int32, uintptr) 79319 }{sumintInverse})), 79320 uintptr(0)) 79321 79322 if rc != SQLITE_OK { 79323 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 79324 return TCL_ERROR 79325 } 79326 return TCL_OK 79327 } 79328 79329 func test_override_sum(tls *libc.TLS, clientData uintptr, interp uintptr, objc int32, objv uintptr) int32 { /* test_window.c:305:26: */ 79330 bp := tls.Alloc(8) 79331 defer tls.Free(8) 79332 79333 // var db uintptr at bp, 8 79334 79335 var rc int32 79336 79337 if objc != 2 { 79338 tcl.XTcl_WrongNumArgs(tls, interp, 1, objv, ts+1911 /* "DB" */) 79339 return TCL_ERROR 79340 } 79341 if getDbPointer(tls, interp, tcl.XTcl_GetString(tls, *(*uintptr)(unsafe.Pointer(objv + 1*8))), bp /* &db */) != 0 { 79342 return TCL_ERROR 79343 } 79344 79345 rc = sqlite3.Xsqlite3_create_function(tls, *(*uintptr)(unsafe.Pointer(bp /* db */)), ts+38678 /* "sum" */, -1, SQLITE_UTF8, uintptr(0), 79346 uintptr(0), *(*uintptr)(unsafe.Pointer(&struct { 79347 f func(*libc.TLS, uintptr, int32, uintptr) 79348 }{sumintStep})), *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{sumintFinal}))) 79349 79350 if rc != SQLITE_OK { 79351 tcl.XTcl_SetObjResult(tls, interp, tcl.XTcl_NewStringObj(tls, sqlite3.Xsqlite3ErrName(tls, rc), -1)) 79352 return TCL_ERROR 79353 } 79354 return TCL_OK 79355 } 79356 79357 func Sqlitetest_window_Init(tls *libc.TLS, interp uintptr) int32 { /* test_window.c:331:5: */ 79358 var i int32 79359 for i = 0; uint64(i) < (uint64(unsafe.Sizeof(aObjCmd14)) / uint64(unsafe.Sizeof(struct { 79360 FzName uintptr 79361 FxProc uintptr 79362 FclientData int32 79363 _ [4]byte 79364 }{}))); i++ { 79365 var c ClientData = uintptr(intptr_t(aObjCmd14[i].FclientData)) 79366 tcl.XTcl_CreateObjCommand(tls, interp, aObjCmd14[i].FzName, aObjCmd14[i].FxProc, c, uintptr(0)) 79367 } 79368 return TCL_OK 79369 } 79370 79371 var aObjCmd14 = [4]struct { 79372 FzName uintptr 79373 FxProc uintptr 79374 FclientData int32 79375 _ [4]byte 79376 }{ 79377 {FzName: ts + 38682 /* "sqlite3_create_w..." */, FxProc: 0}, 79378 {FzName: ts + 38713 /* "test_create_wind..." */, FxProc: 0}, 79379 {FzName: ts + 38748 /* "test_create_sumi..." */, FxProc: 0}, 79380 {FzName: ts + 38767 /* "test_override_su..." */, FxProc: 0}, 79381 } /* test_window.c:336:5 */ 79382 79383 // 2008 September 1 79384 // 79385 // The author disclaims copyright to this source code. In place of 79386 // a legal notice, here is a blessing: 79387 // 79388 // May you do good and not evil. 79389 // May you find forgiveness for yourself and forgive others. 79390 // May you share freely, never taking more than you give. 79391 // 79392 // 79393 // 79394 // The code in this file contains sample implementations of the 79395 // sqlite3_wsd_init() and sqlite3_wsd_find() functions required if the 79396 // SQLITE_OMIT_WSD symbol is defined at build time. 79397 79398 func init() { 79399 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CrashFileVtab)) + 8 /* .xClose */)) = cfClose // test6.c:577:3: 79400 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CrashFileVtab)) + 16 /* .xRead */)) = cfRead // test6.c:578:3: 79401 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CrashFileVtab)) + 24 /* .xWrite */)) = cfWrite // test6.c:579:3: 79402 *(*func(*libc.TLS, uintptr, sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CrashFileVtab)) + 32 /* .xTruncate */)) = cfTruncate // test6.c:580:3: 79403 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CrashFileVtab)) + 40 /* .xSync */)) = cfSync // test6.c:581:3: 79404 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CrashFileVtab)) + 48 /* .xFileSize */)) = cfFileSize // test6.c:582:3: 79405 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CrashFileVtab)) + 56 /* .xLock */)) = cfLock // test6.c:583:3: 79406 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CrashFileVtab)) + 64 /* .xUnlock */)) = cfUnlock // test6.c:584:3: 79407 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CrashFileVtab)) + 72 /* .xCheckReservedLock */)) = cfCheckReservedLock // test6.c:585:3: 79408 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CrashFileVtab)) + 80 /* .xFileControl */)) = cfFileControl // test6.c:586:3: 79409 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CrashFileVtab)) + 88 /* .xSectorSize */)) = cfSectorSize // test6.c:587:3: 79410 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CrashFileVtab)) + 96 /* .xDeviceCharacteristics */)) = cfDeviceCharacteristics // test6.c:588:3: 79411 *(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CrashFileVtab)) + 104 /* .xShmMap */)) = cfShmMap // test6.c:589:3: 79412 *(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CrashFileVtab)) + 112 /* .xShmLock */)) = cfShmLock // test6.c:590:3: 79413 *(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&CrashFileVtab)) + 120 /* .xShmBarrier */)) = cfShmBarrier // test6.c:591:3: 79414 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CrashFileVtab)) + 128 /* .xShmUnmap */)) = cfShmUnmap // test6.c:592:3: 79415 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModule)) + 8 /* .xCreate */)) = csvtabCreate // csv.c:874:3: 79416 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModule)) + 16 /* .xConnect */)) = csvtabConnect // csv.c:875:3: 79417 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModule)) + 24 /* .xBestIndex */)) = csvtabBestIndex // csv.c:876:3: 79418 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModule)) + 32 /* .xDisconnect */)) = csvtabDisconnect // csv.c:877:3: 79419 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModule)) + 40 /* .xDestroy */)) = csvtabDisconnect // csv.c:878:3: 79420 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModule)) + 48 /* .xOpen */)) = csvtabOpen // csv.c:879:3: 79421 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModule)) + 56 /* .xClose */)) = csvtabClose // csv.c:880:3: 79422 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModule)) + 64 /* .xFilter */)) = csvtabFilter // csv.c:881:3: 79423 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModule)) + 72 /* .xNext */)) = csvtabNext // csv.c:882:3: 79424 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModule)) + 80 /* .xEof */)) = csvtabEof // csv.c:883:3: 79425 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModule)) + 88 /* .xColumn */)) = csvtabColumn // csv.c:884:3: 79426 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModule)) + 96 /* .xRowid */)) = csvtabRowid // csv.c:885:3: 79427 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModuleFauxWrite)) + 8 /* .xCreate */)) = csvtabCreate // csv.c:906:3: 79428 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModuleFauxWrite)) + 16 /* .xConnect */)) = csvtabConnect // csv.c:907:3: 79429 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModuleFauxWrite)) + 24 /* .xBestIndex */)) = csvtabBestIndex // csv.c:908:3: 79430 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModuleFauxWrite)) + 32 /* .xDisconnect */)) = csvtabDisconnect // csv.c:909:3: 79431 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModuleFauxWrite)) + 40 /* .xDestroy */)) = csvtabDisconnect // csv.c:910:3: 79432 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModuleFauxWrite)) + 48 /* .xOpen */)) = csvtabOpen // csv.c:911:3: 79433 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModuleFauxWrite)) + 56 /* .xClose */)) = csvtabClose // csv.c:912:3: 79434 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModuleFauxWrite)) + 64 /* .xFilter */)) = csvtabFilter // csv.c:913:3: 79435 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModuleFauxWrite)) + 72 /* .xNext */)) = csvtabNext // csv.c:914:3: 79436 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModuleFauxWrite)) + 80 /* .xEof */)) = csvtabEof // csv.c:915:3: 79437 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModuleFauxWrite)) + 88 /* .xColumn */)) = csvtabColumn // csv.c:916:3: 79438 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModuleFauxWrite)) + 96 /* .xRowid */)) = csvtabRowid // csv.c:917:3: 79439 *(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&CsvModuleFauxWrite)) + 104 /* .xUpdate */)) = csvtabUpdate // csv.c:918:3: 79440 *(*func(*libc.TLS, ClientData, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&IncrblobChannelType)) + 16 /* .closeProc */)) = incrblobClose // tclsqlite.c:372:3: 79441 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&IncrblobChannelType)) + 24 /* .inputProc */)) = incrblobInput // tclsqlite.c:373:3: 79442 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&IncrblobChannelType)) + 32 /* .outputProc */)) = incrblobOutput // tclsqlite.c:374:3: 79443 *(*func(*libc.TLS, ClientData, int64, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&IncrblobChannelType)) + 40 /* .seekProc */)) = incrblobSeek // tclsqlite.c:375:3: 79444 *(*func(*libc.TLS, ClientData, int32))(unsafe.Pointer(uintptr(unsafe.Pointer(&IncrblobChannelType)) + 64 /* .watchProc */)) = incrblobWatch // tclsqlite.c:378:3: 79445 *(*func(*libc.TLS, ClientData, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&IncrblobChannelType)) + 72 /* .getHandleProc */)) = incrblobHandle // tclsqlite.c:379:3: 79446 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd)) + 8 /* .xProc */)) = f5tCreateTokenizer // fts5_tcl.c:1125:42: 79447 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd)) + 32 /* .xProc */)) = f5tTokenizerReturn // fts5_tcl.c:1126:42: 79448 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd)) + 56 /* .xProc */)) = f5tTokenize // fts5_tcl.c:1127:42: 79449 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd)) + 80 /* .xProc */)) = f5tCreateFunction // fts5_tcl.c:1128:42: 79450 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd)) + 104 /* .xProc */)) = f5tMayBeCorrupt // fts5_tcl.c:1129:42: 79451 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd)) + 128 /* .xProc */)) = f5tTokenHash // fts5_tcl.c:1130:42: 79452 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd)) + 152 /* .xProc */)) = f5tRegisterMatchinfo // fts5_tcl.c:1131:42: 79453 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd)) + 176 /* .xProc */)) = f5tRegisterTok // fts5_tcl.c:1132:45: 79454 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 8 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79455 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79456 }{db_enter})) // test1.c:8229:41: 79457 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 24 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79458 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79459 }{db_leave})) // test1.c:8230:41: 79460 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 40 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79461 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79462 }{sqlite3_mprintf_int})) // test1.c:8231:41: 79463 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 56 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79464 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79465 }{sqlite3_mprintf_int64})) // test1.c:8232:41: 79466 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 72 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79467 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79468 }{sqlite3_mprintf_long})) // test1.c:8233:41: 79469 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 88 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79470 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79471 }{sqlite3_mprintf_str})) // test1.c:8234:41: 79472 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 104 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79473 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79474 }{sqlite3_snprintf_str})) // test1.c:8235:41: 79475 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 120 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79476 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79477 }{sqlite3_mprintf_stronly})) // test1.c:8236:41: 79478 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 136 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79479 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79480 }{sqlite3_mprintf_double})) // test1.c:8237:41: 79481 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 152 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79482 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79483 }{sqlite3_mprintf_scaled})) // test1.c:8238:41: 79484 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 168 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79485 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79486 }{sqlite3_mprintf_hexdouble})) // test1.c:8239:39: 79487 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 184 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79488 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79489 }{test_mprintf_z})) // test1.c:8240:41: 79490 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 200 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79491 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79492 }{test_mprintf_n})) // test1.c:8241:41: 79493 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 216 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79494 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79495 }{test_snprintf_int})) // test1.c:8242:41: 79496 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 232 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79497 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79498 }{test_last_rowid})) // test1.c:8243:41: 79499 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 248 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79500 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79501 }{test_exec_printf})) // test1.c:8244:41: 79502 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 264 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79503 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79504 }{test_exec_hex})) // test1.c:8245:41: 79505 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 280 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79506 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79507 }{test_exec})) // test1.c:8246:41: 79508 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 296 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79509 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79510 }{test_exec_nr})) // test1.c:8247:41: 79511 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 312 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79512 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79513 }{test_get_table_printf})) // test1.c:8249:41: 79514 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 328 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79515 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79516 }{sqlite_test_close})) // test1.c:8251:41: 79517 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 344 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79518 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79519 }{sqlite_test_close_v2})) // test1.c:8252:41: 79520 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 360 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79521 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79522 }{test_create_function})) // test1.c:8253:41: 79523 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 376 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79524 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79525 }{test_create_aggregate})) // test1.c:8254:41: 79526 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 392 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79527 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79528 }{test_drop_modules})) // test1.c:8255:41: 79529 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 408 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79530 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79531 }{test_register_func})) // test1.c:8256:41: 79532 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 424 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79533 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79534 }{sqlite_abort})) // test1.c:8257:41: 79535 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 440 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79536 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79537 }{test_bind})) // test1.c:8258:41: 79538 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 456 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79539 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79540 }{test_breakpoint})) // test1.c:8259:41: 79541 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 472 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79542 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79543 }{test_key})) // test1.c:8260:41: 79544 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 488 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79545 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79546 }{test_rekey})) // test1.c:8261:41: 79547 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 504 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79548 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79549 }{sqlite_set_magic})) // test1.c:8262:41: 79550 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 520 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79551 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79552 }{test_interrupt})) // test1.c:8263:41: 79553 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 536 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79554 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79555 }{delete_function})) // test1.c:8264:41: 79556 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 552 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79557 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79558 }{delete_collation})) // test1.c:8265:41: 79559 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 568 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79560 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79561 }{get_autocommit})) // test1.c:8266:41: 79562 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 584 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79563 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79564 }{test_busy_timeout})) // test1.c:8267:41: 79565 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 600 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79566 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79567 }{test_printf})) // test1.c:8268:41: 79568 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 616 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79569 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79570 }{test_io_trace})) // test1.c:8269:39: 79571 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd1)) + 632 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79572 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79573 }{clang_sanitize_address})) // test1.c:8270:41: 79574 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 8 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79575 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79576 }{pager_open})) // test2.c:708:34: 79577 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 24 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79578 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79579 }{pager_close})) // test2.c:709:34: 79580 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 40 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79581 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79582 }{pager_commit})) // test2.c:710:34: 79583 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 56 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79584 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79585 }{pager_rollback})) // test2.c:711:34: 79586 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 72 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79587 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79588 }{pager_stmt_begin})) // test2.c:712:34: 79589 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 88 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79590 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79591 }{pager_stmt_commit})) // test2.c:713:34: 79592 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 104 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79593 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79594 }{pager_stmt_rollback})) // test2.c:714:34: 79595 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 120 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79596 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79597 }{pager_stats})) // test2.c:715:34: 79598 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 136 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79599 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79600 }{pager_pagecount})) // test2.c:716:34: 79601 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 152 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79602 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79603 }{page_get})) // test2.c:717:34: 79604 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 168 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79605 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79606 }{page_lookup})) // test2.c:718:34: 79607 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 184 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79608 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79609 }{page_unref})) // test2.c:719:34: 79610 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 200 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79611 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79612 }{page_read})) // test2.c:720:34: 79613 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 216 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79614 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79615 }{page_write})) // test2.c:721:34: 79616 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 232 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79617 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79618 }{page_number})) // test2.c:722:34: 79619 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 248 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79620 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79621 }{pager_truncate})) // test2.c:723:34: 79622 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 264 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79623 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79624 }{fake_big_file})) // test2.c:725:34: 79625 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 280 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79626 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79627 }{testBitvecBuiltinTest})) // test2.c:727:34: 79628 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 296 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79629 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79630 }{testPendingByte})) // test2.c:728:45: 79631 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd2)) + 312 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79632 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79633 }{faultInstallCmd})) // test2.c:729:45: 79634 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd3)) + 8 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79635 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79636 }{btree_open})) // test3.c:666:36: 79637 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd3)) + 24 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79638 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79639 }{btree_close})) // test3.c:667:36: 79640 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd3)) + 40 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79641 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79642 }{btree_begin_transaction})) // test3.c:668:36: 79643 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd3)) + 56 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79644 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79645 }{btree_pager_stats})) // test3.c:669:36: 79646 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd3)) + 72 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79647 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79648 }{btree_cursor})) // test3.c:670:36: 79649 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd3)) + 88 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79650 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79651 }{btree_close_cursor})) // test3.c:671:36: 79652 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd3)) + 104 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79653 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79654 }{btree_next})) // test3.c:672:36: 79655 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd3)) + 120 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79656 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79657 }{btree_eof})) // test3.c:673:36: 79658 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd3)) + 136 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79659 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79660 }{btree_payload_size})) // test3.c:674:36: 79661 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd3)) + 152 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79662 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79663 }{btree_first})) // test3.c:675:36: 79664 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd3)) + 168 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79665 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79666 }{btree_varint_test})) // test3.c:676:36: 79667 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd3)) + 184 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79668 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79669 }{btree_from_db})) // test3.c:677:36: 79670 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd3)) + 200 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79671 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79672 }{btree_ismemdb})) // test3.c:678:36: 79673 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd3)) + 216 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79674 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79675 }{btree_set_cache_size})) // test3.c:679:36: 79676 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd4)) + 8 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79677 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79678 }{tcl_thread_create})) // test4.c:701:29: 79679 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd4)) + 24 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79680 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79681 }{tcl_thread_wait})) // test4.c:702:29: 79682 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd4)) + 40 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79683 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79684 }{tcl_thread_halt})) // test4.c:703:29: 79685 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd4)) + 56 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79686 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79687 }{tcl_thread_argc})) // test4.c:704:29: 79688 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd4)) + 72 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79689 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79690 }{tcl_thread_argv})) // test4.c:705:29: 79691 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd4)) + 88 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79692 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79693 }{tcl_thread_colname})) // test4.c:706:29: 79694 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd4)) + 104 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79695 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79696 }{tcl_thread_result})) // test4.c:707:29: 79697 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd4)) + 120 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79698 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79699 }{tcl_thread_error})) // test4.c:708:29: 79700 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd4)) + 136 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79701 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79702 }{tcl_thread_compile})) // test4.c:709:29: 79703 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd4)) + 152 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79704 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79705 }{tcl_thread_step})) // test4.c:710:29: 79706 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd4)) + 168 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79707 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79708 }{tcl_thread_finalize})) // test4.c:711:29: 79709 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd4)) + 184 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79710 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79711 }{tcl_thread_swap})) // test4.c:712:29: 79712 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd4)) + 200 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79713 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79714 }{tcl_thread_db_get})) // test4.c:713:29: 79715 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd4)) + 216 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79716 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79717 }{tcl_thread_db_put})) // test4.c:714:29: 79718 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd4)) + 232 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79719 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79720 }{tcl_thread_stmt_get})) // test4.c:715:29: 79721 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd5)) + 8 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79722 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79723 }{binarize})) // test5.c:210:34: 79724 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd5)) + 24 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79725 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79726 }{test_value_overhead})) // test5.c:211:34: 79727 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd5)) + 40 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79728 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79729 }{test_translate})) // test5.c:212:34: 79730 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd5)) + 56 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79731 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79732 }{test_translate_selftest})) // test5.c:213:34: 79733 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd6)) + 8 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79734 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79735 }{tcl_client_create})) // test7.c:695:29: 79736 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd6)) + 24 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79737 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79738 }{tcl_client_wait})) // test7.c:696:29: 79739 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd6)) + 40 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79740 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79741 }{tcl_client_halt})) // test7.c:697:29: 79742 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd6)) + 56 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79743 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79744 }{tcl_client_argc})) // test7.c:698:29: 79745 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd6)) + 72 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79746 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79747 }{tcl_client_argv})) // test7.c:699:29: 79748 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd6)) + 88 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79749 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79750 }{tcl_client_colname})) // test7.c:700:29: 79751 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd6)) + 104 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79752 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79753 }{tcl_client_result})) // test7.c:701:29: 79754 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd6)) + 120 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79755 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79756 }{tcl_client_error})) // test7.c:702:29: 79757 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd6)) + 136 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79758 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79759 }{tcl_client_compile})) // test7.c:703:29: 79760 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd6)) + 152 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79761 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79762 }{tcl_client_step})) // test7.c:704:29: 79763 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd6)) + 168 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79764 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79765 }{tcl_client_reset})) // test7.c:705:29: 79766 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd6)) + 184 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79767 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79768 }{tcl_client_finalize})) // test7.c:706:29: 79769 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd6)) + 200 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79770 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79771 }{tcl_client_swap})) // test7.c:707:29: 79772 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd7)) + 8 /* .xProc */)) = test_multiplex_initialize // test_multiplex.c:1311:39: 79773 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd7)) + 24 /* .xProc */)) = test_multiplex_shutdown // test_multiplex.c:1312:37: 79774 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd7)) + 40 /* .xProc */)) = test_multiplex_control // test_multiplex.c:1313:36: 79775 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd8)) + 8 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79776 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79777 }{test_shutdown})) // test_mutex.c:485:34: 79778 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd8)) + 24 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79779 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79780 }{test_initialize})) // test_mutex.c:486:34: 79781 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd8)) + 40 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79782 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79783 }{test_config})) // test_mutex.c:487:34: 79784 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd8)) + 56 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79785 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79786 }{test_enter_static_mutex})) // test_mutex.c:489:34: 79787 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd8)) + 72 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79788 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79789 }{test_leave_static_mutex})) // test_mutex.c:490:34: 79790 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd8)) + 88 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79791 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79792 }{test_enter_db_mutex})) // test_mutex.c:492:34: 79793 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd8)) + 104 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79794 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79795 }{test_leave_db_mutex})) // test_mutex.c:493:34: 79796 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd8)) + 120 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79797 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79798 }{test_alloc_mutex})) // test_mutex.c:495:34: 79799 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd8)) + 136 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79800 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79801 }{test_install_mutex_counters})) // test_mutex.c:496:34: 79802 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd8)) + 152 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79803 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79804 }{test_read_mutex_counters})) // test_mutex.c:497:34: 79805 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd8)) + 168 /* .xProc */)) = *(*uintptr)(unsafe.Pointer(&struct { 79806 f func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32 79807 }{test_clear_mutex_counters})) // test_mutex.c:498:34: 79808 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 8 /* .xProc */)) = test_quota_initialize // test_quota.c:1949:38: 79809 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 24 /* .xProc */)) = test_quota_shutdown // test_quota.c:1950:38: 79810 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 40 /* .xProc */)) = test_quota_set // test_quota.c:1951:38: 79811 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 56 /* .xProc */)) = test_quota_file // test_quota.c:1952:38: 79812 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 72 /* .xProc */)) = test_quota_dump // test_quota.c:1953:38: 79813 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 88 /* .xProc */)) = test_quota_fopen // test_quota.c:1954:38: 79814 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 104 /* .xProc */)) = test_quota_fread // test_quota.c:1955:38: 79815 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 120 /* .xProc */)) = test_quota_fwrite // test_quota.c:1956:38: 79816 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 136 /* .xProc */)) = test_quota_fclose // test_quota.c:1957:38: 79817 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 152 /* .xProc */)) = test_quota_fflush // test_quota.c:1958:38: 79818 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 168 /* .xProc */)) = test_quota_fseek // test_quota.c:1959:38: 79819 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 184 /* .xProc */)) = test_quota_rewind // test_quota.c:1960:38: 79820 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 200 /* .xProc */)) = test_quota_ftell // test_quota.c:1961:38: 79821 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 216 /* .xProc */)) = test_quota_ftruncate // test_quota.c:1962:38: 79822 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 232 /* .xProc */)) = test_quota_file_size // test_quota.c:1963:38: 79823 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 248 /* .xProc */)) = test_quota_file_truesize // test_quota.c:1964:38: 79824 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 264 /* .xProc */)) = test_quota_file_mtime // test_quota.c:1965:38: 79825 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 280 /* .xProc */)) = test_quota_remove // test_quota.c:1966:38: 79826 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 296 /* .xProc */)) = test_quota_glob // test_quota.c:1967:38: 79827 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 312 /* .xProc */)) = test_quota_file_available // test_quota.c:1968:38: 79828 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aCmd9)) + 328 /* .xProc */)) = test_quota_ferror // test_quota.c:1969:38: 79829 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 8 /* .pInit */)) = sqlite3_amatch_init // test1.c:7526:32: 79830 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 24 /* .pInit */)) = sqlite3_appendvfs_init // test1.c:7527:32: 79831 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 40 /* .pInit */)) = sqlite3_carray_init // test1.c:7528:32: 79832 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 56 /* .pInit */)) = sqlite3_closure_init // test1.c:7529:32: 79833 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 72 /* .pInit */)) = sqlite3_csv_init // test1.c:7530:32: 79834 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 88 /* .pInit */)) = sqlite3_decimal_init // test1.c:7531:32: 79835 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 104 /* .pInit */)) = sqlite3_eval_init // test1.c:7532:32: 79836 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 120 /* .pInit */)) = sqlite3_explain_init // test1.c:7533:32: 79837 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 136 /* .pInit */)) = sqlite3_fileio_init // test1.c:7534:32: 79838 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 152 /* .pInit */)) = sqlite3_fuzzer_init // test1.c:7535:32: 79839 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 168 /* .pInit */)) = sqlite3_ieee_init // test1.c:7536:32: 79840 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 184 /* .pInit */)) = sqlite3_nextchar_init // test1.c:7537:32: 79841 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 200 /* .pInit */)) = sqlite3_percentile_init // test1.c:7538:32: 79842 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 216 /* .pInit */)) = sqlite3_prefixes_init // test1.c:7540:32: 79843 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 232 /* .pInit */)) = sqlite3_regexp_init // test1.c:7542:32: 79844 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 248 /* .pInit */)) = sqlite3_remember_init // test1.c:7543:32: 79845 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 264 /* .pInit */)) = sqlite3_series_init // test1.c:7544:32: 79846 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 280 /* .pInit */)) = sqlite3_spellfix_init // test1.c:7545:32: 79847 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 296 /* .pInit */)) = sqlite3_totype_init // test1.c:7546:32: 79848 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 312 /* .pInit */)) = sqlite3_unionvtab_init // test1.c:7547:32: 79849 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 328 /* .pInit */)) = sqlite3_wholenumber_init // test1.c:7548:32: 79850 *(*func(*libc.TLS, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aExtension)) + 344 /* .pInit */)) = sqlite3_zipfile_init // test1.c:7550:32: 79851 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc)) + 16 /* .xFunc */)) = decimalFunc // decimal.c:607:29: 79852 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc)) + 40 /* .xFunc */)) = decimalCmpFunc // decimal.c:608:29: 79853 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc)) + 64 /* .xFunc */)) = decimalAddFunc // decimal.c:609:29: 79854 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc)) + 88 /* .xFunc */)) = decimalSubFunc // decimal.c:610:29: 79855 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc)) + 112 /* .xFunc */)) = decimalMulFunc // decimal.c:611:29: 79856 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc1)) + 16 /* .xFunc */)) = ieee754func // ieee754.c:270:36: 79857 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc1)) + 40 /* .xFunc */)) = ieee754func // ieee754.c:271:36: 79858 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc1)) + 64 /* .xFunc */)) = ieee754func // ieee754.c:272:36: 79859 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc1)) + 88 /* .xFunc */)) = ieee754func // ieee754.c:273:36: 79860 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc1)) + 112 /* .xFunc */)) = ieee754func_to_blob // ieee754.c:274:36: 79861 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFunc1)) + 136 /* .xFunc */)) = ieee754func_from_blob // ieee754.c:275:36: 79862 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 16 /* .xFunc */)) = randStr // test_func.c:675:48: 79863 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 40 /* .xFunc */)) = test_destructor // test_func.c:676:48: 79864 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 64 /* .xFunc */)) = test_destructor16 // test_func.c:678:48: 79865 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 88 /* .xFunc */)) = testHexToUtf16be // test_func.c:679:48: 79866 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 112 /* .xFunc */)) = testHexToUtf16le // test_func.c:680:48: 79867 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 136 /* .xFunc */)) = testHexToUtf8 // test_func.c:682:48: 79868 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 160 /* .xFunc */)) = test_destructor_count // test_func.c:683:48: 79869 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 184 /* .xFunc */)) = test_auxdata // test_func.c:684:48: 79870 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 208 /* .xFunc */)) = test_error // test_func.c:685:48: 79871 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 232 /* .xFunc */)) = test_error // test_func.c:686:48: 79872 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 256 /* .xFunc */)) = test_eval // test_func.c:687:48: 79873 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 280 /* .xFunc */)) = test_isolation // test_func.c:688:48: 79874 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 304 /* .xFunc */)) = counterFunc // test_func.c:689:48: 79875 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 328 /* .xFunc */)) = real2hex // test_func.c:690:48: 79876 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 352 /* .xFunc */)) = test_decode // test_func.c:691:48: 79877 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 376 /* .xFunc */)) = test_extract // test_func.c:692:48: 79878 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 400 /* .xFunc */)) = test_zeroblob // test_func.c:693:62: 79879 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 424 /* .xFunc */)) = test_getsubtype // test_func.c:694:48: 79880 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 448 /* .xFunc */)) = test_setsubtype // test_func.c:695:48: 79881 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&aFuncs)) + 472 /* .xFunc */)) = test_frombind // test_func.c:696:48: 79882 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd)) + 8 /* .xProc */)) = test_sqlite3rbu // test_rbu.c:370:21: 79883 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd)) + 24 /* .xProc */)) = test_sqlite3rbu_vacuum // test_rbu.c:371:28: 79884 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd)) + 40 /* .xProc */)) = test_sqlite3rbu_create_vfs // test_rbu.c:372:32: 79885 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd)) + 56 /* .xProc */)) = test_sqlite3rbu_destroy_vfs // test_rbu.c:373:33: 79886 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd)) + 72 /* .xProc */)) = test_sqlite3rbu_internal_test // test_rbu.c:374:35: 79887 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 8 /* .xProc */)) = test_sqlite3_db_config // test1.c:8277:41: 79888 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 32 /* .xProc */)) = test_sqlite3_txn_state // test1.c:8278:41: 79889 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 56 /* .xProc */)) = test_bad_behavior // test1.c:8279:41: 79890 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 64 /* .clientData */)) = uintptr(unsafe.Pointer(&iZero)) // test1.c:8279:61: 79891 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 80 /* .xProc */)) = test_register_dbstat_vtab // test1.c:8280:41: 79892 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 104 /* .xProc */)) = get_sqlite_pointer // test1.c:8281:41: 79893 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 128 /* .xProc */)) = test_intarray_addr // test1.c:8282:41: 79894 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 152 /* .xProc */)) = test_int64array_addr // test1.c:8283:41: 79895 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 176 /* .xProc */)) = test_doublearray_addr // test1.c:8284:41: 79896 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 200 /* .xProc */)) = test_textarray_addr // test1.c:8285:41: 79897 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 224 /* .xProc */)) = test_bind_int // test1.c:8286:41: 79898 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 248 /* .xProc */)) = test_bind_zeroblob // test1.c:8287:41: 79899 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 272 /* .xProc */)) = test_bind_zeroblob64 // test1.c:8288:41: 79900 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 296 /* .xProc */)) = test_bind_int64 // test1.c:8289:41: 79901 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 320 /* .xProc */)) = test_bind_double // test1.c:8290:41: 79902 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 344 /* .xProc */)) = test_bind_null // test1.c:8291:41: 79903 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 368 /* .xProc */)) = test_bind_text // test1.c:8292:41: 79904 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 392 /* .xProc */)) = test_bind_text16 // test1.c:8293:41: 79905 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 416 /* .xProc */)) = test_bind_blob // test1.c:8294:41: 79906 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 440 /* .xProc */)) = test_carray_bind // test1.c:8296:41: 79907 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 464 /* .xProc */)) = test_bind_parameter_count // test1.c:8298:41: 79908 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 488 /* .xProc */)) = test_bind_parameter_name // test1.c:8299:41: 79909 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 512 /* .xProc */)) = test_bind_parameter_index // test1.c:8300:41: 79910 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 536 /* .xProc */)) = test_clear_bindings // test1.c:8301:41: 79911 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 560 /* .xProc */)) = test_sleep // test1.c:8302:41: 79912 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 584 /* .xProc */)) = test_errcode // test1.c:8303:41: 79913 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 608 /* .xProc */)) = test_ex_errcode // test1.c:8304:41: 79914 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 632 /* .xProc */)) = test_errmsg // test1.c:8305:41: 79915 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 656 /* .xProc */)) = test_errmsg16 // test1.c:8306:41: 79916 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 680 /* .xProc */)) = test_open // test1.c:8307:41: 79917 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 704 /* .xProc */)) = test_open16 // test1.c:8308:41: 79918 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 728 /* .xProc */)) = test_open_v2 // test1.c:8309:41: 79919 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 752 /* .xProc */)) = test_complete16 // test1.c:8310:41: 79920 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 776 /* .xProc */)) = test_normalize // test1.c:8311:41: 79921 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 800 /* .xProc */)) = test_prepare // test1.c:8313:41: 79922 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 824 /* .xProc */)) = test_prepare16 // test1.c:8314:41: 79923 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 848 /* .xProc */)) = test_prepare_v2 // test1.c:8315:41: 79924 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 872 /* .xProc */)) = test_prepare_v3 // test1.c:8316:41: 79925 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 896 /* .xProc */)) = test_prepare_tkt3134 // test1.c:8317:41: 79926 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 920 /* .xProc */)) = test_prepare16_v2 // test1.c:8318:41: 79927 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 944 /* .xProc */)) = test_finalize // test1.c:8319:41: 79928 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 968 /* .xProc */)) = test_stmt_status // test1.c:8320:41: 79929 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 992 /* .xProc */)) = test_reset // test1.c:8321:41: 79930 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1016 /* .xProc */)) = test_expired // test1.c:8322:41: 79931 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1040 /* .xProc */)) = test_transfer_bind // test1.c:8323:41: 79932 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1064 /* .xProc */)) = test_changes // test1.c:8324:41: 79933 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1088 /* .xProc */)) = test_step // test1.c:8325:41: 79934 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1112 /* .xProc */)) = test_sql // test1.c:8326:41: 79935 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1136 /* .xProc */)) = test_ex_sql // test1.c:8327:41: 79936 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1160 /* .xProc */)) = test_next_stmt // test1.c:8331:41: 79937 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1184 /* .xProc */)) = test_stmt_readonly // test1.c:8332:41: 79938 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1208 /* .xProc */)) = test_stmt_isexplain // test1.c:8333:41: 79939 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1232 /* .xProc */)) = test_stmt_busy // test1.c:8334:41: 79940 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1256 /* .xProc */)) = uses_stmt_journal // test1.c:8335:41: 79941 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1280 /* .xProc */)) = test_release_memory // test1.c:8337:41: 79942 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1304 /* .xProc */)) = test_db_release_memory // test1.c:8338:41: 79943 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1328 /* .xProc */)) = test_db_cacheflush // test1.c:8339:41: 79944 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1352 /* .xProc */)) = test_system_errno // test1.c:8340:41: 79945 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1376 /* .xProc */)) = test_db_filename // test1.c:8341:41: 79946 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1400 /* .xProc */)) = test_db_readonly // test1.c:8342:41: 79947 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1424 /* .xProc */)) = test_soft_heap_limit // test1.c:8343:41: 79948 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1448 /* .xProc */)) = test_soft_heap_limit // test1.c:8344:41: 79949 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1472 /* .xProc */)) = test_hard_heap_limit // test1.c:8345:41: 79950 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1496 /* .xProc */)) = test_thread_cleanup // test1.c:8346:41: 79951 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1520 /* .xProc */)) = test_pager_refcounts // test1.c:8347:41: 79952 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1544 /* .xProc */)) = test_load_extension // test1.c:8349:41: 79953 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1568 /* .xProc */)) = test_enable_load // test1.c:8350:41: 79954 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1592 /* .xProc */)) = test_extended_result_codes // test1.c:8351:41: 79955 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1616 /* .xProc */)) = test_limit // test1.c:8352:41: 79956 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1640 /* .xProc */)) = test_dbconfig_maindbname_icecube // test1.c:8353:41: 79957 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1664 /* .xProc */)) = save_prng_state // test1.c:8355:41: 79958 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1688 /* .xProc */)) = restore_prng_state // test1.c:8356:41: 79959 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1712 /* .xProc */)) = reset_prng_state // test1.c:8357:41: 79960 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1736 /* .xProc */)) = prng_seed // test1.c:8358:41: 79961 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1760 /* .xProc */)) = extra_schema_checks // test1.c:8359:41: 79962 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1784 /* .xProc */)) = database_never_corrupt // test1.c:8360:41: 79963 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1808 /* .xProc */)) = database_may_be_corrupt // test1.c:8361:41: 79964 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1832 /* .xProc */)) = optimization_control // test1.c:8362:41: 79965 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1856 /* .xProc */)) = runAsObjProc // test1.c:8371:41: 79966 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1880 /* .xProc */)) = test_column_count // test1.c:8374:41: 79967 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1904 /* .xProc */)) = test_data_count // test1.c:8375:41: 79968 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1928 /* .xProc */)) = test_column_type // test1.c:8376:41: 79969 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1952 /* .xProc */)) = test_column_blob // test1.c:8377:41: 79970 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 1976 /* .xProc */)) = test_column_double // test1.c:8378:41: 79971 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2000 /* .xProc */)) = test_column_int64 // test1.c:8379:41: 79972 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2024 /* .xProc */)) = test_stmt_utf8 // test1.c:8380:33: 79973 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2032 /* .clientData */)) = *(*uintptr)(unsafe.Pointer(&struct { 79974 f func(*libc.TLS, uintptr, int32) uintptr 79975 }{sqlite3.Xsqlite3_column_text})) // test1.c:8380:50: 79976 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2048 /* .xProc */)) = test_stmt_utf8 // test1.c:8381:33: 79977 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2056 /* .clientData */)) = *(*uintptr)(unsafe.Pointer(&struct { 79978 f func(*libc.TLS, uintptr, int32) uintptr 79979 }{sqlite3.Xsqlite3_column_name})) // test1.c:8381:50: 79980 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2072 /* .xProc */)) = test_stmt_int // test1.c:8382:33: 79981 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2080 /* .clientData */)) = *(*uintptr)(unsafe.Pointer(&struct { 79982 f func(*libc.TLS, uintptr, int32) int32 79983 }{sqlite3.Xsqlite3_column_int})) // test1.c:8382:50: 79984 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2096 /* .xProc */)) = test_stmt_int // test1.c:8383:33: 79985 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2104 /* .clientData */)) = *(*uintptr)(unsafe.Pointer(&struct { 79986 f func(*libc.TLS, uintptr, int32) int32 79987 }{sqlite3.Xsqlite3_column_bytes})) // test1.c:8383:50: 79988 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2120 /* .xProc */)) = test_stmt_utf8 // test1.c:8385:34: 79989 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2128 /* .clientData */)) = *(*uintptr)(unsafe.Pointer(&struct { 79990 f func(*libc.TLS, uintptr, int32) uintptr 79991 }{sqlite3.Xsqlite3_column_decltype})) // test1.c:8385:49: 79992 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2144 /* .xProc */)) = test_stmt_utf8 // test1.c:8388:34: 79993 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2152 /* .clientData */)) = *(*uintptr)(unsafe.Pointer(&struct { 79994 f func(*libc.TLS, uintptr, int32) uintptr 79995 }{sqlite3.Xsqlite3_column_database_name})) // test1.c:8388:49: 79996 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2168 /* .xProc */)) = test_stmt_utf8 // test1.c:8389:31: 79997 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2176 /* .clientData */)) = *(*uintptr)(unsafe.Pointer(&struct { 79998 f func(*libc.TLS, uintptr, int32) uintptr 79999 }{sqlite3.Xsqlite3_column_table_name})) // test1.c:8389:46: 80000 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2192 /* .xProc */)) = test_stmt_utf8 // test1.c:8390:32: 80001 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2200 /* .clientData */)) = *(*uintptr)(unsafe.Pointer(&struct { 80002 f func(*libc.TLS, uintptr, int32) uintptr 80003 }{sqlite3.Xsqlite3_column_origin_name})) // test1.c:8390:47: 80004 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2216 /* .xProc */)) = test_stmt_int // test1.c:8394:34: 80005 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2224 /* .clientData */)) = *(*uintptr)(unsafe.Pointer(&struct { 80006 f func(*libc.TLS, uintptr, int32) int32 80007 }{sqlite3.Xsqlite3_column_bytes16})) // test1.c:8394:49: 80008 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2240 /* .xProc */)) = test_stmt_utf16 // test1.c:8395:34: 80009 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2248 /* .clientData */)) = *(*uintptr)(unsafe.Pointer(&struct { 80010 f func(*libc.TLS, uintptr, int32) uintptr 80011 }{sqlite3.Xsqlite3_column_text16})) // test1.c:8395:51: 80012 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2264 /* .xProc */)) = test_stmt_utf16 // test1.c:8396:34: 80013 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2272 /* .clientData */)) = *(*uintptr)(unsafe.Pointer(&struct { 80014 f func(*libc.TLS, uintptr, int32) uintptr 80015 }{sqlite3.Xsqlite3_column_name16})) // test1.c:8396:51: 80016 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2288 /* .xProc */)) = add_alignment_test_collations // test1.c:8397:41: 80017 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2312 /* .xProc */)) = test_stmt_utf16 // test1.c:8399:36: 80018 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2320 /* .clientData */)) = *(*uintptr)(unsafe.Pointer(&struct { 80019 f func(*libc.TLS, uintptr, int32) uintptr 80020 }{sqlite3.Xsqlite3_column_decltype16})) // test1.c:8399:52: 80021 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2336 /* .xProc */)) = test_stmt_utf16 // test1.c:8403:3: 80022 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2344 /* .clientData */)) = *(*uintptr)(unsafe.Pointer(&struct { 80023 f func(*libc.TLS, uintptr, int32) uintptr 80024 }{sqlite3.Xsqlite3_column_database_name16})) // test1.c:8403:20: 80025 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2360 /* .xProc */)) = test_stmt_utf16 // test1.c:8404:33: 80026 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2368 /* .clientData */)) = *(*uintptr)(unsafe.Pointer(&struct { 80027 f func(*libc.TLS, uintptr, int32) uintptr 80028 }{sqlite3.Xsqlite3_column_table_name16})) // test1.c:8404:50: 80029 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2384 /* .xProc */)) = test_stmt_utf16 // test1.c:8405:34: 80030 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2392 /* .clientData */)) = *(*uintptr)(unsafe.Pointer(&struct { 80031 f func(*libc.TLS, uintptr, int32) uintptr 80032 }{sqlite3.Xsqlite3_column_origin_name16})) // test1.c:8405:51: 80033 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2408 /* .xProc */)) = test_create_collation_v2 // test1.c:8408:39: 80034 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2432 /* .xProc */)) = test_global_recover // test1.c:8409:38: 80035 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2456 /* .xProc */)) = working_64bit_int // test1.c:8410:38: 80036 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2480 /* .xProc */)) = vfs_unlink_test // test1.c:8411:38: 80037 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2504 /* .xProc */)) = vfs_initfail_test // test1.c:8412:38: 80038 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2528 /* .xProc */)) = vfs_unregister_all // test1.c:8413:38: 80039 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2552 /* .xProc */)) = vfs_reregister_all // test1.c:8414:38: 80040 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2576 /* .xProc */)) = file_control_test // test1.c:8415:38: 80041 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2600 /* .xProc */)) = file_control_lasterrno_test // test1.c:8416:39: 80042 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2624 /* .xProc */)) = file_control_lockproxy_test // test1.c:8417:39: 80043 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2648 /* .xProc */)) = file_control_chunksize_test // test1.c:8418:39: 80044 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2672 /* .xProc */)) = file_control_sizehint_test // test1.c:8419:39: 80045 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2696 /* .xProc */)) = file_control_data_version // test1.c:8420:39: 80046 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2720 /* .xProc */)) = file_control_persist_wal // test1.c:8426:39: 80047 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2744 /* .xProc */)) = file_control_powersafe_overwrite // test1.c:8427:43: 80048 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2768 /* .xProc */)) = file_control_vfsname // test1.c:8428:39: 80049 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2792 /* .xProc */)) = file_control_reservebytes // test1.c:8429:39: 80050 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2816 /* .xProc */)) = file_control_tempfilename // test1.c:8430:39: 80051 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2840 /* .xProc */)) = vfs_list // test1.c:8431:38: 80052 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2864 /* .xProc */)) = test_create_function_v2 // test1.c:8432:38: 80053 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2888 /* .xProc */)) = test_collate // test1.c:8436:35: 80054 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2912 /* .xProc */)) = test_collate_needed // test1.c:8437:35: 80055 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2936 /* .xProc */)) = test_function // test1.c:8438:35: 80056 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2960 /* .xProc */)) = test_utf16bin_collate // test1.c:8439:40: 80057 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 2984 /* .xProc */)) = test_errstr // test1.c:8441:35: 80058 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3008 /* .xProc */)) = tcl_variable_type // test1.c:8442:35: 80059 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3032 /* .xProc */)) = test_enable_shared // test1.c:8444:39: 80060 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3056 /* .xProc */)) = sqlite3BtreeSharedCacheReport // test1.c:8445:39: 80061 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3080 /* .xProc */)) = test_libversion_number // test1.c:8447:37: 80062 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3104 /* .xProc */)) = test_table_column_metadata // test1.c:8448:41: 80063 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3128 /* .xProc */)) = test_blob_reopen // test1.c:8450:31: 80064 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3152 /* .xProc */)) = test_pcache_stats // test1.c:8452:30: 80065 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3176 /* .xProc */)) = test_unlock_notify // test1.c:8454:33: 80066 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3200 /* .xProc */)) = test_wal_checkpoint // test1.c:8456:36: 80067 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3224 /* .xProc */)) = test_wal_checkpoint_v2 // test1.c:8457:36: 80068 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3248 /* .xProc */)) = test_wal_autocheckpoint // test1.c:8458:37: 80069 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3272 /* .xProc */)) = test_sqlite3_log // test1.c:8459:36: 80070 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3296 /* .xProc */)) = test_print_eqp // test1.c:8461:36: 80071 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3320 /* .xProc */)) = test_test_control // test1.c:8463:32: 80072 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3344 /* .xProc */)) = test_getrusage // test1.c:8465:21: 80073 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3368 /* .xProc */)) = tclLoadStaticExtensionCmd // test1.c:8467:33: 80074 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3392 /* .xProc */)) = sorter_test_fakeheap // test1.c:8468:32: 80075 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3416 /* .xProc */)) = sorter_test_sort4_helper // test1.c:8469:36: 80076 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3440 /* .xProc */)) = vfsCurrentTimeInt64 // test1.c:8483:44: 80077 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3464 /* .xProc */)) = test_snapshot_get // test1.c:8485:32: 80078 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3488 /* .xProc */)) = test_snapshot_open // test1.c:8486:33: 80079 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3512 /* .xProc */)) = test_snapshot_free // test1.c:8487:33: 80080 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3536 /* .xProc */)) = test_snapshot_cmp // test1.c:8488:32: 80081 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3560 /* .xProc */)) = test_snapshot_recover // test1.c:8489:36: 80082 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3584 /* .xProc */)) = test_snapshot_get_blob // test1.c:8490:37: 80083 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3608 /* .xProc */)) = test_snapshot_open_blob // test1.c:8491:38: 80084 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3632 /* .xProc */)) = test_snapshot_cmp_blob // test1.c:8492:37: 80085 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3656 /* .xProc */)) = test_delete_database // test1.c:8494:35: 80086 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3680 /* .xProc */)) = test_atomic_batch_write // test1.c:8495:35: 80087 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3704 /* .xProc */)) = test_mmap_warm // test1.c:8496:35: 80088 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3728 /* .xProc */)) = test_config_sorterref // test1.c:8497:36: 80089 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3752 /* .xProc */)) = test_decode_hexdb // test1.c:8498:36: 80090 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3776 /* .xProc */)) = test_write_db // test1.c:8499:36: 80091 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3800 /* .xProc */)) = test_register_cksumvfs // test1.c:8500:37: 80092 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd1)) + 3824 /* .xProc */)) = test_unregister_cksumvfs // test1.c:8501:39: 80093 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd10)) + 8 /* .xProc */)) = test_intarray_create // test_intarray.c:381:35: 80094 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd10)) + 32 /* .xProc */)) = test_intarray_bind // test_intarray.c:382:33: 80095 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 8 /* .xProc */)) = test_malloc // test_malloc.c:1473:38: 80096 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 32 /* .xProc */)) = test_realloc // test_malloc.c:1474:38: 80097 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 56 /* .xProc */)) = test_free // test_malloc.c:1475:38: 80098 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 80 /* .xProc */)) = test_memset // test_malloc.c:1476:38: 80099 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 104 /* .xProc */)) = test_memget // test_malloc.c:1477:38: 80100 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 128 /* .xProc */)) = test_memory_used // test_malloc.c:1478:38: 80101 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 152 /* .xProc */)) = test_memory_highwater // test_malloc.c:1479:38: 80102 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 176 /* .xProc */)) = test_memdebug_backtrace // test_malloc.c:1480:38: 80103 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 200 /* .xProc */)) = test_memdebug_dump // test_malloc.c:1481:38: 80104 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 224 /* .xProc */)) = test_memdebug_fail // test_malloc.c:1482:38: 80105 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 248 /* .xProc */)) = test_memdebug_pending // test_malloc.c:1483:38: 80106 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 272 /* .xProc */)) = test_memdebug_settitle // test_malloc.c:1484:38: 80107 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 296 /* .xProc */)) = test_memdebug_malloc_count // test_malloc.c:1485:41: 80108 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 320 /* .xProc */)) = test_memdebug_log // test_malloc.c:1486:38: 80109 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 344 /* .xProc */)) = test_config_pagecache // test_malloc.c:1487:38: 80110 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 368 /* .xProc */)) = test_alt_pcache // test_malloc.c:1488:38: 80111 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 392 /* .xProc */)) = test_status // test_malloc.c:1489:38: 80112 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 416 /* .xProc */)) = test_db_status // test_malloc.c:1490:38: 80113 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 440 /* .xProc */)) = test_install_malloc_faultsim // test_malloc.c:1491:38: 80114 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 464 /* .xProc */)) = test_config_heap // test_malloc.c:1492:38: 80115 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 488 /* .xProc */)) = test_config_heap_size // test_malloc.c:1493:38: 80116 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 512 /* .xProc */)) = test_config_memstatus // test_malloc.c:1494:38: 80117 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 536 /* .xProc */)) = test_config_lookaside // test_malloc.c:1495:38: 80118 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 560 /* .xProc */)) = test_config_error // test_malloc.c:1496:38: 80119 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 584 /* .xProc */)) = test_config_uri // test_malloc.c:1497:38: 80120 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 608 /* .xProc */)) = test_config_cis // test_malloc.c:1498:38: 80121 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 632 /* .xProc */)) = test_config_pmasz // test_malloc.c:1499:38: 80122 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 656 /* .xProc */)) = test_db_config_lookaside // test_malloc.c:1500:38: 80123 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 680 /* .xProc */)) = test_dump_memsys3 // test_malloc.c:1501:38: 80124 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 704 /* .xProc */)) = test_dump_memsys3 // test_malloc.c:1502:38: 80125 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 728 /* .xProc */)) = test_install_memsys3 // test_malloc.c:1503:38: 80126 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd11)) + 752 /* .xProc */)) = test_vfs_oom_test // test_malloc.c:1504:41: 80127 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd12)) + 8 /* .xProc */)) = register_schema_module // test_schema.c:336:34: 80128 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd13)) + 8 /* .xProc */)) = register_tclvar_module // test_tclvar.c:553:36: 80129 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd14)) + 8 /* .xProc */)) = test_create_window // test_window.c:337:42: 80130 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd14)) + 32 /* .xProc */)) = test_create_window_misuse // test_window.c:338:46: 80131 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd14)) + 56 /* .xProc */)) = test_create_sumint // test_window.c:339:30: 80132 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd14)) + 80 /* .xProc */)) = test_override_sum // test_window.c:340:29: 80133 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd2)) + 8 /* .xProc */)) = register_echo_module // test8.c:1434:38: 80134 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd2)) + 32 /* .xProc */)) = declare_vtab // test8.c:1435:38: 80135 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd3)) + 8 /* .xProc */)) = c_misuse_test // test9.c:194:28: 80136 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd3)) + 32 /* .xProc */)) = c_realloc_test // test9.c:195:28: 80137 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd3)) + 56 /* .xProc */)) = c_collation_test // test9.c:196:28: 80138 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd4)) + 8 /* .xProc */)) = register_tcl_module // test_bestindex.c:611:33: 80139 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd5)) + 8 /* .xProc */)) = test_blob_open // test_blob.c:318:40: 80140 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd5)) + 24 /* .xProc */)) = test_blob_close // test_blob.c:319:40: 80141 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd5)) + 40 /* .xProc */)) = test_blob_bytes // test_blob.c:320:40: 80142 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd5)) + 56 /* .xProc */)) = test_blob_read // test_blob.c:321:40: 80143 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd5)) + 72 /* .xProc */)) = test_blob_write // test_blob.c:322:40: 80144 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd6)) + 8 /* .xProc */)) = register_fs_module // test_fs.c:908:32: 80145 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd7)) + 8 /* .xProc */)) = autoinstall_test_funcs // test_func.c:938:41: 80146 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd7)) + 24 /* .xProc */)) = abuse_create_function // test_func.c:939:41: 80147 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd7)) + 40 /* .xProc */)) = install_fts3_rank_function // test_func.c:940:41: 80148 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd8)) + 8 /* .xProc */)) = hexio_read // test_hexio.c:451:40: 80149 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd8)) + 24 /* .xProc */)) = hexio_write // test_hexio.c:452:40: 80150 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd8)) + 40 /* .xProc */)) = hexio_get_int // test_hexio.c:453:40: 80151 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd8)) + 56 /* .xProc */)) = hexio_render_int16 // test_hexio.c:454:40: 80152 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd8)) + 72 /* .xProc */)) = hexio_render_int32 // test_hexio.c:455:40: 80153 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd8)) + 88 /* .xProc */)) = utf8_to_utf8 // test_hexio.c:456:40: 80154 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd8)) + 104 /* .xProc */)) = read_fts3varint // test_hexio.c:457:40: 80155 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd8)) + 120 /* .xProc */)) = make_fts3record // test_hexio.c:458:40: 80156 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd9)) + 8 /* .xProc */)) = init_wrapper_install // test_init.c:283:32: 80157 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd9)) + 24 /* .xProc */)) = init_wrapper_query // test_init.c:284:32: 80158 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd9)) + 40 /* .xProc */)) = init_wrapper_uninstall // test_init.c:285:32: 80159 *(*func(*libc.TLS, ClientData, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&aObjCmd9)) + 56 /* .xProc */)) = init_wrapper_clear // test_init.c:286:32: 80160 *(*sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 8 /* .xTest */)) = *(*uintptr)(unsafe.Pointer(&struct { 80161 f func(*libc.TLS, uintptr, int32, int32) int32 80162 }{ts_open})) // test_syscall.c:134:27: 80163 *(*sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 40 /* .xTest */)) = *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, int32) int32 }{ts_close})) // test_syscall.c:135:27: 80164 *(*sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 72 /* .xTest */)) = *(*uintptr)(unsafe.Pointer(&struct { 80165 f func(*libc.TLS, uintptr, int32) int32 80166 }{ts_access})) // test_syscall.c:136:27: 80167 *(*sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 104 /* .xTest */)) = *(*uintptr)(unsafe.Pointer(&struct { 80168 f func(*libc.TLS, uintptr, size_t) uintptr 80169 }{ts_getcwd})) // test_syscall.c:137:27: 80170 *(*sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 136 /* .xTest */)) = *(*uintptr)(unsafe.Pointer(&struct { 80171 f func(*libc.TLS, uintptr, uintptr) int32 80172 }{ts_stat})) // test_syscall.c:138:27: 80173 *(*sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 168 /* .xTest */)) = *(*uintptr)(unsafe.Pointer(&struct { 80174 f func(*libc.TLS, int32, uintptr) int32 80175 }{ts_fstat})) // test_syscall.c:139:27: 80176 *(*sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 200 /* .xTest */)) = *(*uintptr)(unsafe.Pointer(&struct { 80177 f func(*libc.TLS, int32, off_t) int32 80178 }{ts_ftruncate})) // test_syscall.c:140:27: 80179 *(*sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 232 /* .xTest */)) = *(*uintptr)(unsafe.Pointer(&struct { 80180 f func(*libc.TLS, int32, int32, uintptr) int32 80181 }{ts_fcntl})) // test_syscall.c:141:27: 80182 *(*sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 264 /* .xTest */)) = *(*uintptr)(unsafe.Pointer(&struct { 80183 f func(*libc.TLS, int32, uintptr, size_t) int32 80184 }{ts_read})) // test_syscall.c:142:27: 80185 *(*sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 296 /* .xTest */)) = *(*uintptr)(unsafe.Pointer(&struct { 80186 f func(*libc.TLS, int32, uintptr, size_t, off_t) int32 80187 }{ts_pread})) // test_syscall.c:143:27: 80188 *(*sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 328 /* .xTest */)) = *(*uintptr)(unsafe.Pointer(&struct { 80189 f func(*libc.TLS, int32, uintptr, size_t, sqlite3_uint64) int32 80190 }{ts_pread64})) // test_syscall.c:144:27: 80191 *(*sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 360 /* .xTest */)) = *(*uintptr)(unsafe.Pointer(&struct { 80192 f func(*libc.TLS, int32, uintptr, size_t) int32 80193 }{ts_write})) // test_syscall.c:145:27: 80194 *(*sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 392 /* .xTest */)) = *(*uintptr)(unsafe.Pointer(&struct { 80195 f func(*libc.TLS, int32, uintptr, size_t, off_t) int32 80196 }{ts_pwrite})) // test_syscall.c:146:27: 80197 *(*sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 424 /* .xTest */)) = *(*uintptr)(unsafe.Pointer(&struct { 80198 f func(*libc.TLS, int32, uintptr, size_t, sqlite3_uint64) int32 80199 }{ts_pwrite64})) // test_syscall.c:147:27: 80200 *(*sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 456 /* .xTest */)) = *(*uintptr)(unsafe.Pointer(&struct { 80201 f func(*libc.TLS, int32, mode_t) int32 80202 }{ts_fchmod})) // test_syscall.c:148:27: 80203 *(*sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 488 /* .xTest */)) = *(*uintptr)(unsafe.Pointer(&struct { 80204 f func(*libc.TLS, int32, off_t, off_t) int32 80205 }{ts_fallocate})) // test_syscall.c:149:27: 80206 *(*sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 520 /* .xTest */)) = *(*uintptr)(unsafe.Pointer(&struct { 80207 f func(*libc.TLS, uintptr, size_t, int32, int32, int32, off_t) uintptr 80208 }{ts_mmap})) // test_syscall.c:150:27: 80209 *(*sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&aSyscall)) + 552 /* .xTest */)) = *(*uintptr)(unsafe.Pointer(&struct { 80210 f func(*libc.TLS, uintptr, size_t, size_t, int32, uintptr) uintptr 80211 }{ts_mremap})) // test_syscall.c:151:27: 80212 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&amatchModule)) + 8 /* .xCreate */)) = amatchConnect // amatch.c:1456:3: 80213 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&amatchModule)) + 16 /* .xConnect */)) = amatchConnect // amatch.c:1457:3: 80214 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&amatchModule)) + 24 /* .xBestIndex */)) = amatchBestIndex // amatch.c:1458:3: 80215 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&amatchModule)) + 32 /* .xDisconnect */)) = amatchDisconnect // amatch.c:1459:3: 80216 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&amatchModule)) + 40 /* .xDestroy */)) = amatchDisconnect // amatch.c:1460:3: 80217 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&amatchModule)) + 48 /* .xOpen */)) = amatchOpen // amatch.c:1461:3: 80218 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&amatchModule)) + 56 /* .xClose */)) = amatchClose // amatch.c:1462:3: 80219 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&amatchModule)) + 64 /* .xFilter */)) = amatchFilter // amatch.c:1463:3: 80220 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&amatchModule)) + 72 /* .xNext */)) = amatchNext // amatch.c:1464:3: 80221 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&amatchModule)) + 80 /* .xEof */)) = amatchEof // amatch.c:1465:3: 80222 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&amatchModule)) + 88 /* .xColumn */)) = amatchColumn // amatch.c:1466:3: 80223 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&amatchModule)) + 96 /* .xRowid */)) = amatchRowid // amatch.c:1467:3: 80224 *(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&amatchModule)) + 104 /* .xUpdate */)) = amatchUpdate // amatch.c:1468:3: 80225 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_io_methods)) + 8 /* .xClose */)) = apndClose // appendvfs.c:204:3: 80226 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_io_methods)) + 16 /* .xRead */)) = apndRead // appendvfs.c:205:3: 80227 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_io_methods)) + 24 /* .xWrite */)) = apndWrite // appendvfs.c:206:3: 80228 *(*func(*libc.TLS, uintptr, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_io_methods)) + 32 /* .xTruncate */)) = apndTruncate // appendvfs.c:207:3: 80229 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_io_methods)) + 40 /* .xSync */)) = apndSync // appendvfs.c:208:3: 80230 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_io_methods)) + 48 /* .xFileSize */)) = apndFileSize // appendvfs.c:209:3: 80231 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_io_methods)) + 56 /* .xLock */)) = apndLock // appendvfs.c:210:3: 80232 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_io_methods)) + 64 /* .xUnlock */)) = apndUnlock // appendvfs.c:211:3: 80233 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_io_methods)) + 72 /* .xCheckReservedLock */)) = apndCheckReservedLock // appendvfs.c:212:3: 80234 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_io_methods)) + 80 /* .xFileControl */)) = apndFileControl // appendvfs.c:213:3: 80235 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_io_methods)) + 88 /* .xSectorSize */)) = apndSectorSize // appendvfs.c:214:3: 80236 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_io_methods)) + 96 /* .xDeviceCharacteristics */)) = apndDeviceCharacteristics // appendvfs.c:215:3: 80237 *(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_io_methods)) + 104 /* .xShmMap */)) = apndShmMap // appendvfs.c:216:3: 80238 *(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_io_methods)) + 112 /* .xShmLock */)) = apndShmLock // appendvfs.c:217:3: 80239 *(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_io_methods)) + 120 /* .xShmBarrier */)) = apndShmBarrier // appendvfs.c:218:3: 80240 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_io_methods)) + 128 /* .xShmUnmap */)) = apndShmUnmap // appendvfs.c:219:3: 80241 *(*func(*libc.TLS, uintptr, sqlite3_int64, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_io_methods)) + 136 /* .xFetch */)) = apndFetch // appendvfs.c:220:3: 80242 *(*func(*libc.TLS, uintptr, sqlite3_int64, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_io_methods)) + 144 /* .xUnfetch */)) = apndUnfetch // appendvfs.c:221:3: 80243 *(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_vfs)) + 40 /* .xOpen */)) = apndOpen // appendvfs.c:184:3: 80244 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_vfs)) + 48 /* .xDelete */)) = apndDelete // appendvfs.c:185:3: 80245 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_vfs)) + 56 /* .xAccess */)) = apndAccess // appendvfs.c:186:3: 80246 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_vfs)) + 64 /* .xFullPathname */)) = apndFullPathname // appendvfs.c:187:3: 80247 *(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_vfs)) + 72 /* .xDlOpen */)) = apndDlOpen // appendvfs.c:188:3: 80248 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_vfs)) + 80 /* .xDlError */)) = apndDlError // appendvfs.c:189:3: 80249 *(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_vfs)) + 88 /* .xDlSym */)) = apndDlSym // appendvfs.c:190:3: 80250 *(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_vfs)) + 96 /* .xDlClose */)) = apndDlClose // appendvfs.c:191:3: 80251 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_vfs)) + 104 /* .xRandomness */)) = apndRandomness // appendvfs.c:192:3: 80252 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_vfs)) + 112 /* .xSleep */)) = apndSleep // appendvfs.c:193:3: 80253 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_vfs)) + 120 /* .xCurrentTime */)) = apndCurrentTime // appendvfs.c:194:3: 80254 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_vfs)) + 128 /* .xGetLastError */)) = apndGetLastError // appendvfs.c:195:3: 80255 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_vfs)) + 136 /* .xCurrentTimeInt64 */)) = apndCurrentTimeInt64 // appendvfs.c:196:3: 80256 *(*func(*libc.TLS, uintptr, uintptr, sqlite3_syscall_ptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_vfs)) + 144 /* .xSetSystemCall */)) = apndSetSystemCall // appendvfs.c:197:3: 80257 *(*func(*libc.TLS, uintptr, uintptr) sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_vfs)) + 152 /* .xGetSystemCall */)) = apndGetSystemCall // appendvfs.c:198:3: 80258 *(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&apnd_vfs)) + 160 /* .xNextSystemCall */)) = apndNextSystemCall // appendvfs.c:199:3: 80259 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&carrayModule)) + 16 /* .xConnect */)) = carrayConnect // carray.c:368:3: 80260 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&carrayModule)) + 24 /* .xBestIndex */)) = carrayBestIndex // carray.c:369:3: 80261 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&carrayModule)) + 32 /* .xDisconnect */)) = carrayDisconnect // carray.c:370:3: 80262 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&carrayModule)) + 48 /* .xOpen */)) = carrayOpen // carray.c:372:3: 80263 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&carrayModule)) + 56 /* .xClose */)) = carrayClose // carray.c:373:3: 80264 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&carrayModule)) + 64 /* .xFilter */)) = carrayFilter // carray.c:374:3: 80265 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&carrayModule)) + 72 /* .xNext */)) = carrayNext // carray.c:375:3: 80266 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&carrayModule)) + 80 /* .xEof */)) = carrayEof // carray.c:376:3: 80267 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&carrayModule)) + 88 /* .xColumn */)) = carrayColumn // carray.c:377:3: 80268 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&carrayModule)) + 96 /* .xRowid */)) = carrayRowid // carray.c:378:3: 80269 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_io_methods)) + 8 /* .xClose */)) = cksmClose // cksumvfs.c:274:3: 80270 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_io_methods)) + 16 /* .xRead */)) = cksmRead // cksumvfs.c:275:3: 80271 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_io_methods)) + 24 /* .xWrite */)) = cksmWrite // cksumvfs.c:276:3: 80272 *(*func(*libc.TLS, uintptr, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_io_methods)) + 32 /* .xTruncate */)) = cksmTruncate // cksumvfs.c:277:3: 80273 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_io_methods)) + 40 /* .xSync */)) = cksmSync // cksumvfs.c:278:3: 80274 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_io_methods)) + 48 /* .xFileSize */)) = cksmFileSize // cksumvfs.c:279:3: 80275 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_io_methods)) + 56 /* .xLock */)) = cksmLock // cksumvfs.c:280:3: 80276 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_io_methods)) + 64 /* .xUnlock */)) = cksmUnlock // cksumvfs.c:281:3: 80277 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_io_methods)) + 72 /* .xCheckReservedLock */)) = cksmCheckReservedLock // cksumvfs.c:282:3: 80278 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_io_methods)) + 80 /* .xFileControl */)) = cksmFileControl // cksumvfs.c:283:3: 80279 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_io_methods)) + 88 /* .xSectorSize */)) = cksmSectorSize // cksumvfs.c:284:3: 80280 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_io_methods)) + 96 /* .xDeviceCharacteristics */)) = cksmDeviceCharacteristics // cksumvfs.c:285:3: 80281 *(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_io_methods)) + 104 /* .xShmMap */)) = cksmShmMap // cksumvfs.c:286:3: 80282 *(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_io_methods)) + 112 /* .xShmLock */)) = cksmShmLock // cksumvfs.c:287:3: 80283 *(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_io_methods)) + 120 /* .xShmBarrier */)) = cksmShmBarrier // cksumvfs.c:288:3: 80284 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_io_methods)) + 128 /* .xShmUnmap */)) = cksmShmUnmap // cksumvfs.c:289:3: 80285 *(*func(*libc.TLS, uintptr, sqlite3_int64, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_io_methods)) + 136 /* .xFetch */)) = cksmFetch // cksumvfs.c:290:3: 80286 *(*func(*libc.TLS, uintptr, sqlite3_int64, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_io_methods)) + 144 /* .xUnfetch */)) = cksmUnfetch // cksumvfs.c:291:3: 80287 *(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_vfs)) + 40 /* .xOpen */)) = cksmOpen // cksumvfs.c:254:3: 80288 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_vfs)) + 48 /* .xDelete */)) = cksmDelete // cksumvfs.c:255:3: 80289 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_vfs)) + 56 /* .xAccess */)) = cksmAccess // cksumvfs.c:256:3: 80290 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_vfs)) + 64 /* .xFullPathname */)) = cksmFullPathname // cksumvfs.c:257:3: 80291 *(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_vfs)) + 72 /* .xDlOpen */)) = cksmDlOpen // cksumvfs.c:258:3: 80292 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_vfs)) + 80 /* .xDlError */)) = cksmDlError // cksumvfs.c:259:3: 80293 *(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_vfs)) + 88 /* .xDlSym */)) = cksmDlSym // cksumvfs.c:260:3: 80294 *(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_vfs)) + 96 /* .xDlClose */)) = cksmDlClose // cksumvfs.c:261:3: 80295 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_vfs)) + 104 /* .xRandomness */)) = cksmRandomness // cksumvfs.c:262:3: 80296 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_vfs)) + 112 /* .xSleep */)) = cksmSleep // cksumvfs.c:263:3: 80297 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_vfs)) + 120 /* .xCurrentTime */)) = cksmCurrentTime // cksumvfs.c:264:3: 80298 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_vfs)) + 128 /* .xGetLastError */)) = cksmGetLastError // cksumvfs.c:265:3: 80299 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_vfs)) + 136 /* .xCurrentTimeInt64 */)) = cksmCurrentTimeInt64 // cksumvfs.c:266:3: 80300 *(*func(*libc.TLS, uintptr, uintptr, sqlite3_syscall_ptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_vfs)) + 144 /* .xSetSystemCall */)) = cksmSetSystemCall // cksumvfs.c:267:3: 80301 *(*func(*libc.TLS, uintptr, uintptr) sqlite3_syscall_ptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_vfs)) + 152 /* .xGetSystemCall */)) = cksmGetSystemCall // cksumvfs.c:268:3: 80302 *(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&cksm_vfs)) + 160 /* .xNextSystemCall */)) = cksmNextSystemCall // cksumvfs.c:269:3: 80303 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&closureModule)) + 8 /* .xCreate */)) = closureConnect // closure.c:920:3: 80304 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&closureModule)) + 16 /* .xConnect */)) = closureConnect // closure.c:921:3: 80305 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&closureModule)) + 24 /* .xBestIndex */)) = closureBestIndex // closure.c:922:3: 80306 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&closureModule)) + 32 /* .xDisconnect */)) = closureDisconnect // closure.c:923:3: 80307 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&closureModule)) + 40 /* .xDestroy */)) = closureDisconnect // closure.c:924:3: 80308 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&closureModule)) + 48 /* .xOpen */)) = closureOpen // closure.c:925:3: 80309 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&closureModule)) + 56 /* .xClose */)) = closureClose // closure.c:926:3: 80310 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&closureModule)) + 64 /* .xFilter */)) = closureFilter // closure.c:927:3: 80311 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&closureModule)) + 72 /* .xNext */)) = closureNext // closure.c:928:3: 80312 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&closureModule)) + 80 /* .xEof */)) = closureEof // closure.c:929:3: 80313 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&closureModule)) + 88 /* .xColumn */)) = closureColumn // closure.c:930:3: 80314 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&closureModule)) + 96 /* .xRowid */)) = closureRowid // closure.c:931:3: 80315 *(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&crashVfs)) + 40 /* .xOpen */)) = cfOpen // test6.c:857:5: 80316 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&crashVfs)) + 48 /* .xDelete */)) = cfDelete // test6.c:858:5: 80317 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&crashVfs)) + 56 /* .xAccess */)) = cfAccess // test6.c:859:5: 80318 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&crashVfs)) + 64 /* .xFullPathname */)) = cfFullPathname // test6.c:860:5: 80319 *(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&crashVfs)) + 72 /* .xDlOpen */)) = cfDlOpen // test6.c:861:5: 80320 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&crashVfs)) + 80 /* .xDlError */)) = cfDlError // test6.c:862:5: 80321 *(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&crashVfs)) + 88 /* .xDlSym */)) = cfDlSym // test6.c:863:5: 80322 *(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&crashVfs)) + 96 /* .xDlClose */)) = cfDlClose // test6.c:864:5: 80323 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&crashVfs)) + 104 /* .xRandomness */)) = cfRandomness // test6.c:865:5: 80324 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&crashVfs)) + 112 /* .xSleep */)) = cfSleep // test6.c:866:5: 80325 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&crashVfs)) + 120 /* .xCurrentTime */)) = cfCurrentTime // test6.c:867:5: 80326 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&crashVfs)) + 128 /* .xGetLastError */)) = cfGetLastError // test6.c:868:5: 80327 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_io_methods)) + 8 /* .xClose */)) = devsymClose // test_devsym.c:229:3: 80328 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_io_methods)) + 16 /* .xRead */)) = devsymRead // test_devsym.c:230:3: 80329 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_io_methods)) + 24 /* .xWrite */)) = devsymWrite // test_devsym.c:231:3: 80330 *(*func(*libc.TLS, uintptr, sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_io_methods)) + 32 /* .xTruncate */)) = devsymTruncate // test_devsym.c:232:3: 80331 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_io_methods)) + 40 /* .xSync */)) = devsymSync // test_devsym.c:233:3: 80332 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_io_methods)) + 48 /* .xFileSize */)) = devsymFileSize // test_devsym.c:234:3: 80333 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_io_methods)) + 56 /* .xLock */)) = devsymLock // test_devsym.c:235:3: 80334 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_io_methods)) + 64 /* .xUnlock */)) = devsymUnlock // test_devsym.c:236:3: 80335 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_io_methods)) + 72 /* .xCheckReservedLock */)) = devsymCheckReservedLock // test_devsym.c:237:3: 80336 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_io_methods)) + 80 /* .xFileControl */)) = devsymFileControl // test_devsym.c:238:3: 80337 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_io_methods)) + 88 /* .xSectorSize */)) = devsymSectorSize // test_devsym.c:239:3: 80338 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_io_methods)) + 96 /* .xDeviceCharacteristics */)) = devsymDeviceCharacteristics // test_devsym.c:240:3: 80339 *(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_io_methods)) + 104 /* .xShmMap */)) = devsymShmMap // test_devsym.c:241:3: 80340 *(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_io_methods)) + 112 /* .xShmLock */)) = devsymShmLock // test_devsym.c:242:3: 80341 *(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_io_methods)) + 120 /* .xShmBarrier */)) = devsymShmBarrier // test_devsym.c:243:3: 80342 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_io_methods)) + 128 /* .xShmUnmap */)) = devsymShmUnmap // test_devsym.c:244:3: 80343 *(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_vfs)) + 40 /* .xOpen */)) = devsymOpen // test_devsym.c:428:3: 80344 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_vfs)) + 48 /* .xDelete */)) = devsymDelete // test_devsym.c:429:3: 80345 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_vfs)) + 56 /* .xAccess */)) = devsymAccess // test_devsym.c:430:3: 80346 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_vfs)) + 64 /* .xFullPathname */)) = devsymFullPathname // test_devsym.c:431:3: 80347 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_vfs)) + 104 /* .xRandomness */)) = devsymRandomness // test_devsym.c:443:3: 80348 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_vfs)) + 112 /* .xSleep */)) = devsymSleep // test_devsym.c:444:3: 80349 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&devsym_vfs)) + 120 /* .xCurrentTime */)) = devsymCurrentTime // test_devsym.c:445:3: 80350 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 8 /* .xCreate */)) = echoCreate // test8.c:1301:3: 80351 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 16 /* .xConnect */)) = echoConnect // test8.c:1302:3: 80352 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 24 /* .xBestIndex */)) = echoBestIndex // test8.c:1303:3: 80353 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 32 /* .xDisconnect */)) = echoDisconnect // test8.c:1304:3: 80354 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 40 /* .xDestroy */)) = echoDestroy // test8.c:1305:3: 80355 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 48 /* .xOpen */)) = echoOpen // test8.c:1306:3: 80356 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 56 /* .xClose */)) = echoClose // test8.c:1307:3: 80357 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 64 /* .xFilter */)) = echoFilter // test8.c:1308:3: 80358 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 72 /* .xNext */)) = echoNext // test8.c:1309:3: 80359 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 80 /* .xEof */)) = echoEof // test8.c:1310:3: 80360 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 88 /* .xColumn */)) = echoColumn // test8.c:1311:3: 80361 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 96 /* .xRowid */)) = echoRowid // test8.c:1312:3: 80362 *(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 104 /* .xUpdate */)) = echoUpdate // test8.c:1313:3: 80363 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 112 /* .xBegin */)) = echoBegin // test8.c:1314:3: 80364 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 120 /* .xSync */)) = echoSync // test8.c:1315:3: 80365 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 128 /* .xCommit */)) = echoCommit // test8.c:1316:3: 80366 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 136 /* .xRollback */)) = echoRollback // test8.c:1317:3: 80367 *(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 144 /* .xFindFunction */)) = echoFindFunction // test8.c:1318:3: 80368 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModule)) + 152 /* .xRename */)) = echoRename // test8.c:1319:3: 80369 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 8 /* .xCreate */)) = echoCreate // test8.c:1324:3: 80370 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 16 /* .xConnect */)) = echoConnect // test8.c:1325:3: 80371 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 24 /* .xBestIndex */)) = echoBestIndex // test8.c:1326:3: 80372 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 32 /* .xDisconnect */)) = echoDisconnect // test8.c:1327:3: 80373 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 40 /* .xDestroy */)) = echoDestroy // test8.c:1328:3: 80374 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 48 /* .xOpen */)) = echoOpen // test8.c:1329:3: 80375 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 56 /* .xClose */)) = echoClose // test8.c:1330:3: 80376 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 64 /* .xFilter */)) = echoFilter // test8.c:1331:3: 80377 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 72 /* .xNext */)) = echoNext // test8.c:1332:3: 80378 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 80 /* .xEof */)) = echoEof // test8.c:1333:3: 80379 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 88 /* .xColumn */)) = echoColumn // test8.c:1334:3: 80380 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 96 /* .xRowid */)) = echoRowid // test8.c:1335:3: 80381 *(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 104 /* .xUpdate */)) = echoUpdate // test8.c:1336:3: 80382 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 112 /* .xBegin */)) = echoBegin // test8.c:1337:3: 80383 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 120 /* .xSync */)) = echoSync // test8.c:1338:3: 80384 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 128 /* .xCommit */)) = echoCommit // test8.c:1339:3: 80385 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 136 /* .xRollback */)) = echoRollback // test8.c:1340:3: 80386 *(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 144 /* .xFindFunction */)) = echoFindFunction // test8.c:1341:3: 80387 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 152 /* .xRename */)) = echoRename // test8.c:1342:3: 80388 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 160 /* .xSavepoint */)) = echoSavepoint // test8.c:1343:3: 80389 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 168 /* .xRelease */)) = echoRelease // test8.c:1344:3: 80390 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&echoModuleV2)) + 176 /* .xRollbackTo */)) = echoRollbackTo // test8.c:1345:3: 80391 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&expertModule)) + 8 /* .xCreate */)) = expertConnect // sqlite3expert.c:625:5: 80392 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&expertModule)) + 16 /* .xConnect */)) = expertConnect // sqlite3expert.c:626:5: 80393 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&expertModule)) + 24 /* .xBestIndex */)) = expertBestIndex // sqlite3expert.c:627:5: 80394 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&expertModule)) + 32 /* .xDisconnect */)) = expertDisconnect // sqlite3expert.c:628:5: 80395 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&expertModule)) + 40 /* .xDestroy */)) = expertDisconnect // sqlite3expert.c:629:5: 80396 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&expertModule)) + 48 /* .xOpen */)) = expertOpen // sqlite3expert.c:630:5: 80397 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&expertModule)) + 56 /* .xClose */)) = expertClose // sqlite3expert.c:631:5: 80398 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&expertModule)) + 64 /* .xFilter */)) = expertFilter // sqlite3expert.c:632:5: 80399 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&expertModule)) + 72 /* .xNext */)) = expertNext // sqlite3expert.c:633:5: 80400 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&expertModule)) + 80 /* .xEof */)) = expertEof // sqlite3expert.c:634:5: 80401 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&expertModule)) + 88 /* .xColumn */)) = expertColumn // sqlite3expert.c:635:5: 80402 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&expertModule)) + 96 /* .xRowid */)) = expertRowid // sqlite3expert.c:636:5: 80403 *(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&expertModule)) + 104 /* .xUpdate */)) = expertUpdate // sqlite3expert.c:637:5: 80404 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&explainModule)) + 16 /* .xConnect */)) = explainConnect // explain.c:274:3: 80405 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&explainModule)) + 24 /* .xBestIndex */)) = explainBestIndex // explain.c:275:3: 80406 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&explainModule)) + 32 /* .xDisconnect */)) = explainDisconnect // explain.c:276:3: 80407 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&explainModule)) + 48 /* .xOpen */)) = explainOpen // explain.c:278:3: 80408 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&explainModule)) + 56 /* .xClose */)) = explainClose // explain.c:279:3: 80409 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&explainModule)) + 64 /* .xFilter */)) = explainFilter // explain.c:280:3: 80410 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&explainModule)) + 72 /* .xNext */)) = explainNext // explain.c:281:3: 80411 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&explainModule)) + 80 /* .xEof */)) = explainEof // explain.c:282:3: 80412 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&explainModule)) + 88 /* .xColumn */)) = explainColumn // explain.c:283:3: 80413 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&explainModule)) + 96 /* .xRowid */)) = explainRowid // explain.c:284:3: 80414 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsModule)) + 8 /* .xCreate */)) = fsConnect // test_fs.c:800:3: 80415 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsModule)) + 16 /* .xConnect */)) = fsConnect // test_fs.c:801:3: 80416 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsModule)) + 24 /* .xBestIndex */)) = fsBestIndex // test_fs.c:802:3: 80417 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsModule)) + 32 /* .xDisconnect */)) = fsDisconnect // test_fs.c:803:3: 80418 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsModule)) + 40 /* .xDestroy */)) = fsDisconnect // test_fs.c:804:3: 80419 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsModule)) + 48 /* .xOpen */)) = fsOpen // test_fs.c:805:3: 80420 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsModule)) + 56 /* .xClose */)) = fsClose // test_fs.c:806:3: 80421 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsModule)) + 64 /* .xFilter */)) = fsFilter // test_fs.c:807:3: 80422 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsModule)) + 72 /* .xNext */)) = fsNext // test_fs.c:808:3: 80423 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsModule)) + 80 /* .xEof */)) = fsEof // test_fs.c:809:3: 80424 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsModule)) + 88 /* .xColumn */)) = fsColumn // test_fs.c:810:3: 80425 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsModule)) + 96 /* .xRowid */)) = fsRowid // test_fs.c:811:3: 80426 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_io_methods)) + 8 /* .xClose */)) = fsClose1 // test_onefile.c:210:3: 80427 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_io_methods)) + 16 /* .xRead */)) = fsRead // test_onefile.c:211:3: 80428 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_io_methods)) + 24 /* .xWrite */)) = fsWrite // test_onefile.c:212:3: 80429 *(*func(*libc.TLS, uintptr, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_io_methods)) + 32 /* .xTruncate */)) = fsTruncate // test_onefile.c:213:3: 80430 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_io_methods)) + 40 /* .xSync */)) = fsSync // test_onefile.c:214:3: 80431 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_io_methods)) + 48 /* .xFileSize */)) = fsFileSize // test_onefile.c:215:3: 80432 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_io_methods)) + 56 /* .xLock */)) = fsLock // test_onefile.c:216:3: 80433 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_io_methods)) + 64 /* .xUnlock */)) = fsUnlock // test_onefile.c:217:3: 80434 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_io_methods)) + 72 /* .xCheckReservedLock */)) = fsCheckReservedLock // test_onefile.c:218:3: 80435 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_io_methods)) + 80 /* .xFileControl */)) = fsFileControl // test_onefile.c:219:3: 80436 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_io_methods)) + 88 /* .xSectorSize */)) = fsSectorSize // test_onefile.c:220:3: 80437 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_io_methods)) + 96 /* .xDeviceCharacteristics */)) = fsDeviceCharacteristics // test_onefile.c:221:3: 80438 *(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_vfs)) + 40 /* .xOpen */)) = fsOpen1 // test_onefile.c:191:5: 80439 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_vfs)) + 48 /* .xDelete */)) = fsDelete // test_onefile.c:192:5: 80440 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_vfs)) + 56 /* .xAccess */)) = fsAccess // test_onefile.c:193:5: 80441 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_vfs)) + 64 /* .xFullPathname */)) = fsFullPathname // test_onefile.c:194:5: 80442 *(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_vfs)) + 72 /* .xDlOpen */)) = fsDlOpen // test_onefile.c:195:5: 80443 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_vfs)) + 80 /* .xDlError */)) = fsDlError // test_onefile.c:196:5: 80444 *(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_vfs)) + 88 /* .xDlSym */)) = fsDlSym // test_onefile.c:197:5: 80445 *(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_vfs)) + 96 /* .xDlClose */)) = fsDlClose // test_onefile.c:198:5: 80446 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_vfs)) + 104 /* .xRandomness */)) = fsRandomness // test_onefile.c:199:5: 80447 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_vfs)) + 112 /* .xSleep */)) = fsSleep // test_onefile.c:200:5: 80448 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fs_vfs)) + 120 /* .xCurrentTime */)) = fsCurrentTime // test_onefile.c:201:5: 80449 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule)) + 8 /* .xCreate */)) = fsdirConnect1 // test_fs.c:823:3: 80450 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule)) + 16 /* .xConnect */)) = fsdirConnect1 // test_fs.c:824:3: 80451 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule)) + 24 /* .xBestIndex */)) = fsdirBestIndex1 // test_fs.c:825:3: 80452 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule)) + 32 /* .xDisconnect */)) = fsdirDisconnect1 // test_fs.c:826:3: 80453 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule)) + 40 /* .xDestroy */)) = fsdirDisconnect1 // test_fs.c:827:3: 80454 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule)) + 48 /* .xOpen */)) = fsdirOpen1 // test_fs.c:828:3: 80455 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule)) + 56 /* .xClose */)) = fsdirClose1 // test_fs.c:829:3: 80456 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule)) + 64 /* .xFilter */)) = fsdirFilter1 // test_fs.c:830:3: 80457 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule)) + 72 /* .xNext */)) = fsdirNext1 // test_fs.c:831:3: 80458 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule)) + 80 /* .xEof */)) = fsdirEof1 // test_fs.c:832:3: 80459 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule)) + 88 /* .xColumn */)) = fsdirColumn1 // test_fs.c:833:3: 80460 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule)) + 96 /* .xRowid */)) = fsdirRowid1 // test_fs.c:834:3: 80461 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule1)) + 16 /* .xConnect */)) = fsdirConnect // fileio.c:942:5: 80462 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule1)) + 24 /* .xBestIndex */)) = fsdirBestIndex // fileio.c:943:5: 80463 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule1)) + 32 /* .xDisconnect */)) = fsdirDisconnect // fileio.c:944:5: 80464 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule1)) + 48 /* .xOpen */)) = fsdirOpen // fileio.c:946:5: 80465 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule1)) + 56 /* .xClose */)) = fsdirClose // fileio.c:947:5: 80466 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule1)) + 64 /* .xFilter */)) = fsdirFilter // fileio.c:948:5: 80467 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule1)) + 72 /* .xNext */)) = fsdirNext // fileio.c:949:5: 80468 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule1)) + 80 /* .xEof */)) = fsdirEof // fileio.c:950:5: 80469 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule1)) + 88 /* .xColumn */)) = fsdirColumn // fileio.c:951:5: 80470 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fsdirModule1)) + 96 /* .xRowid */)) = fsdirRowid // fileio.c:952:5: 80471 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fstreeModule)) + 8 /* .xCreate */)) = fstreeConnect // test_fs.c:846:3: 80472 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fstreeModule)) + 16 /* .xConnect */)) = fstreeConnect // test_fs.c:847:3: 80473 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fstreeModule)) + 24 /* .xBestIndex */)) = fstreeBestIndex // test_fs.c:848:3: 80474 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fstreeModule)) + 32 /* .xDisconnect */)) = fstreeDisconnect // test_fs.c:849:3: 80475 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fstreeModule)) + 40 /* .xDestroy */)) = fstreeDisconnect // test_fs.c:850:3: 80476 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fstreeModule)) + 48 /* .xOpen */)) = fstreeOpen // test_fs.c:851:3: 80477 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fstreeModule)) + 56 /* .xClose */)) = fstreeClose // test_fs.c:852:3: 80478 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fstreeModule)) + 64 /* .xFilter */)) = fstreeFilter // test_fs.c:853:3: 80479 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fstreeModule)) + 72 /* .xNext */)) = fstreeNext // test_fs.c:854:3: 80480 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fstreeModule)) + 80 /* .xEof */)) = fstreeEof // test_fs.c:855:3: 80481 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fstreeModule)) + 88 /* .xColumn */)) = fstreeColumn // test_fs.c:856:3: 80482 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fstreeModule)) + 96 /* .xRowid */)) = fstreeRowid // test_fs.c:857:3: 80483 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5tok_module)) + 8 /* .xCreate */)) = fts5tokConnectMethod // fts5_test_tok.c:453:6: 80484 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5tok_module)) + 16 /* .xConnect */)) = fts5tokConnectMethod // fts5_test_tok.c:454:6: 80485 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5tok_module)) + 24 /* .xBestIndex */)) = fts5tokBestIndexMethod // fts5_test_tok.c:455:6: 80486 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5tok_module)) + 32 /* .xDisconnect */)) = fts5tokDisconnectMethod // fts5_test_tok.c:456:6: 80487 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5tok_module)) + 40 /* .xDestroy */)) = fts5tokDisconnectMethod // fts5_test_tok.c:457:6: 80488 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5tok_module)) + 48 /* .xOpen */)) = fts5tokOpenMethod // fts5_test_tok.c:458:6: 80489 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5tok_module)) + 56 /* .xClose */)) = fts5tokCloseMethod // fts5_test_tok.c:459:6: 80490 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5tok_module)) + 64 /* .xFilter */)) = fts5tokFilterMethod // fts5_test_tok.c:460:6: 80491 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5tok_module)) + 72 /* .xNext */)) = fts5tokNextMethod // fts5_test_tok.c:461:6: 80492 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5tok_module)) + 80 /* .xEof */)) = fts5tokEofMethod // fts5_test_tok.c:462:6: 80493 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5tok_module)) + 88 /* .xColumn */)) = fts5tokColumnMethod // fts5_test_tok.c:463:6: 80494 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fts5tok_module)) + 96 /* .xRowid */)) = fts5tokRowidMethod // fts5_test_tok.c:464:6: 80495 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fuzzerModule)) + 8 /* .xCreate */)) = fuzzerConnect // fuzzer.c:1149:3: 80496 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fuzzerModule)) + 16 /* .xConnect */)) = fuzzerConnect // fuzzer.c:1150:3: 80497 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fuzzerModule)) + 24 /* .xBestIndex */)) = fuzzerBestIndex // fuzzer.c:1151:3: 80498 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fuzzerModule)) + 32 /* .xDisconnect */)) = fuzzerDisconnect // fuzzer.c:1152:3: 80499 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fuzzerModule)) + 40 /* .xDestroy */)) = fuzzerDisconnect // fuzzer.c:1153:3: 80500 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fuzzerModule)) + 48 /* .xOpen */)) = fuzzerOpen // fuzzer.c:1154:3: 80501 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fuzzerModule)) + 56 /* .xClose */)) = fuzzerClose // fuzzer.c:1155:3: 80502 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fuzzerModule)) + 64 /* .xFilter */)) = fuzzerFilter // fuzzer.c:1156:3: 80503 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fuzzerModule)) + 72 /* .xNext */)) = fuzzerNext // fuzzer.c:1157:3: 80504 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fuzzerModule)) + 80 /* .xEof */)) = fuzzerEof // fuzzer.c:1158:3: 80505 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fuzzerModule)) + 88 /* .xColumn */)) = fuzzerColumn // fuzzer.c:1159:3: 80506 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&fuzzerModule)) + 96 /* .xRowid */)) = fuzzerRowid // fuzzer.c:1160:3: 80507 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&intarrayModule)) + 8 /* .xCreate */)) = intarrayCreate // test_intarray.c:189:3: 80508 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&intarrayModule)) + 16 /* .xConnect */)) = intarrayCreate // test_intarray.c:190:3: 80509 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&intarrayModule)) + 24 /* .xBestIndex */)) = intarrayBestIndex // test_intarray.c:191:3: 80510 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&intarrayModule)) + 32 /* .xDisconnect */)) = intarrayDestroy // test_intarray.c:192:3: 80511 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&intarrayModule)) + 40 /* .xDestroy */)) = intarrayDestroy // test_intarray.c:193:3: 80512 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&intarrayModule)) + 48 /* .xOpen */)) = intarrayOpen // test_intarray.c:194:3: 80513 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&intarrayModule)) + 56 /* .xClose */)) = intarrayClose // test_intarray.c:195:3: 80514 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&intarrayModule)) + 64 /* .xFilter */)) = intarrayFilter // test_intarray.c:196:3: 80515 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&intarrayModule)) + 72 /* .xNext */)) = intarrayNext // test_intarray.c:197:3: 80516 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&intarrayModule)) + 80 /* .xEof */)) = intarrayEof // test_intarray.c:198:3: 80517 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&intarrayModule)) + 88 /* .xColumn */)) = intarrayColumn // test_intarray.c:199:3: 80518 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&intarrayModule)) + 96 /* .xRowid */)) = intarrayRowid // test_intarray.c:200:3: 80519 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_io_methods)) + 8 /* .xClose */)) = jtClose // test_journal.c:189:3: 80520 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_io_methods)) + 16 /* .xRead */)) = jtRead // test_journal.c:190:3: 80521 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_io_methods)) + 24 /* .xWrite */)) = jtWrite // test_journal.c:191:3: 80522 *(*func(*libc.TLS, uintptr, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_io_methods)) + 32 /* .xTruncate */)) = jtTruncate // test_journal.c:192:3: 80523 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_io_methods)) + 40 /* .xSync */)) = jtSync // test_journal.c:193:3: 80524 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_io_methods)) + 48 /* .xFileSize */)) = jtFileSize // test_journal.c:194:3: 80525 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_io_methods)) + 56 /* .xLock */)) = jtLock // test_journal.c:195:3: 80526 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_io_methods)) + 64 /* .xUnlock */)) = jtUnlock // test_journal.c:196:3: 80527 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_io_methods)) + 72 /* .xCheckReservedLock */)) = jtCheckReservedLock // test_journal.c:197:3: 80528 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_io_methods)) + 80 /* .xFileControl */)) = jtFileControl // test_journal.c:198:3: 80529 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_io_methods)) + 88 /* .xSectorSize */)) = jtSectorSize // test_journal.c:199:3: 80530 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_io_methods)) + 96 /* .xDeviceCharacteristics */)) = jtDeviceCharacteristics // test_journal.c:200:3: 80531 *(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_vfs)) + 40 /* .xOpen */)) = jtOpen // test_journal.c:172:3: 80532 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_vfs)) + 48 /* .xDelete */)) = jtDelete // test_journal.c:173:3: 80533 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_vfs)) + 56 /* .xAccess */)) = jtAccess // test_journal.c:174:3: 80534 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_vfs)) + 64 /* .xFullPathname */)) = jtFullPathname // test_journal.c:175:3: 80535 *(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_vfs)) + 72 /* .xDlOpen */)) = jtDlOpen // test_journal.c:176:3: 80536 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_vfs)) + 80 /* .xDlError */)) = jtDlError // test_journal.c:177:3: 80537 *(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_vfs)) + 88 /* .xDlSym */)) = jtDlSym // test_journal.c:178:3: 80538 *(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_vfs)) + 96 /* .xDlClose */)) = jtDlClose // test_journal.c:179:3: 80539 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_vfs)) + 104 /* .xRandomness */)) = jtRandomness // test_journal.c:180:3: 80540 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_vfs)) + 112 /* .xSleep */)) = jtSleep // test_journal.c:181:3: 80541 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_vfs)) + 120 /* .xCurrentTime */)) = jtCurrentTime // test_journal.c:182:3: 80542 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_vfs)) + 128 /* .xGetLastError */)) = jtGetLastError // test_journal.c:183:3: 80543 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&jt_vfs)) + 136 /* .xCurrentTimeInt64 */)) = jtCurrentTimeInt64 // test_journal.c:184:3: 80544 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&prefixesModule)) + 16 /* .xConnect */)) = prefixesConnect // prefixes.c:230:21: 80545 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&prefixesModule)) + 24 /* .xBestIndex */)) = prefixesBestIndex // prefixes.c:231:21: 80546 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&prefixesModule)) + 32 /* .xDisconnect */)) = prefixesDisconnect // prefixes.c:232:21: 80547 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&prefixesModule)) + 48 /* .xOpen */)) = prefixesOpen // prefixes.c:234:21: 80548 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&prefixesModule)) + 56 /* .xClose */)) = prefixesClose // prefixes.c:235:21: 80549 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&prefixesModule)) + 64 /* .xFilter */)) = prefixesFilter // prefixes.c:236:21: 80550 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&prefixesModule)) + 72 /* .xNext */)) = prefixesNext // prefixes.c:237:21: 80551 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&prefixesModule)) + 80 /* .xEof */)) = prefixesEof // prefixes.c:238:21: 80552 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&prefixesModule)) + 88 /* .xColumn */)) = prefixesColumn // prefixes.c:239:21: 80553 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&prefixesModule)) + 96 /* .xRowid */)) = prefixesRowid // prefixes.c:240:21: 80554 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&pzNeededCollation)) + 0)) = uintptr(unsafe.Pointer(&zNeededCollation)) // test1.c:3130:34: 80555 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&schemaModule)) + 8 /* .xCreate */)) = schemaCreate // test_schema.c:276:3: 80556 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&schemaModule)) + 16 /* .xConnect */)) = schemaCreate // test_schema.c:277:3: 80557 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&schemaModule)) + 24 /* .xBestIndex */)) = schemaBestIndex // test_schema.c:278:3: 80558 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&schemaModule)) + 32 /* .xDisconnect */)) = schemaDestroy // test_schema.c:279:3: 80559 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&schemaModule)) + 40 /* .xDestroy */)) = schemaDestroy // test_schema.c:280:3: 80560 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&schemaModule)) + 48 /* .xOpen */)) = schemaOpen // test_schema.c:281:3: 80561 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&schemaModule)) + 56 /* .xClose */)) = schemaClose // test_schema.c:282:3: 80562 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&schemaModule)) + 64 /* .xFilter */)) = schemaFilter // test_schema.c:283:3: 80563 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&schemaModule)) + 72 /* .xNext */)) = schemaNext // test_schema.c:284:3: 80564 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&schemaModule)) + 80 /* .xEof */)) = schemaEof // test_schema.c:285:3: 80565 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&schemaModule)) + 88 /* .xColumn */)) = schemaColumn // test_schema.c:286:3: 80566 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&schemaModule)) + 96 /* .xRowid */)) = schemaRowid // test_schema.c:287:3: 80567 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&seriesModule)) + 16 /* .xConnect */)) = seriesConnect // series.c:400:3: 80568 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&seriesModule)) + 24 /* .xBestIndex */)) = seriesBestIndex // series.c:401:3: 80569 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&seriesModule)) + 32 /* .xDisconnect */)) = seriesDisconnect // series.c:402:3: 80570 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&seriesModule)) + 48 /* .xOpen */)) = seriesOpen // series.c:404:3: 80571 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&seriesModule)) + 56 /* .xClose */)) = seriesClose // series.c:405:3: 80572 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&seriesModule)) + 64 /* .xFilter */)) = seriesFilter // series.c:406:3: 80573 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&seriesModule)) + 72 /* .xNext */)) = seriesNext // series.c:407:3: 80574 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&seriesModule)) + 80 /* .xEof */)) = seriesEof // series.c:408:3: 80575 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&seriesModule)) + 88 /* .xColumn */)) = seriesColumn // series.c:409:3: 80576 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&seriesModule)) + 96 /* .xRowid */)) = seriesRowid // series.c:410:3: 80577 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&spellfix1Module)) + 8 /* .xCreate */)) = spellfix1Create // spellfix.c:2993:3: 80578 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&spellfix1Module)) + 16 /* .xConnect */)) = spellfix1Connect // spellfix.c:2994:3: 80579 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&spellfix1Module)) + 24 /* .xBestIndex */)) = spellfix1BestIndex // spellfix.c:2995:3: 80580 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&spellfix1Module)) + 32 /* .xDisconnect */)) = spellfix1Disconnect // spellfix.c:2996:3: 80581 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&spellfix1Module)) + 40 /* .xDestroy */)) = spellfix1Destroy // spellfix.c:2997:3: 80582 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&spellfix1Module)) + 48 /* .xOpen */)) = spellfix1Open // spellfix.c:2998:3: 80583 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&spellfix1Module)) + 56 /* .xClose */)) = spellfix1Close // spellfix.c:2999:3: 80584 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&spellfix1Module)) + 64 /* .xFilter */)) = spellfix1Filter // spellfix.c:3000:3: 80585 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&spellfix1Module)) + 72 /* .xNext */)) = spellfix1Next // spellfix.c:3001:3: 80586 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&spellfix1Module)) + 80 /* .xEof */)) = spellfix1Eof // spellfix.c:3002:3: 80587 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&spellfix1Module)) + 88 /* .xColumn */)) = spellfix1Column // spellfix.c:3003:3: 80588 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&spellfix1Module)) + 96 /* .xRowid */)) = spellfix1Rowid // spellfix.c:3004:3: 80589 *(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&spellfix1Module)) + 104 /* .xUpdate */)) = spellfix1Update // spellfix.c:3005:3: 80590 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&spellfix1Module)) + 152 /* .xRename */)) = spellfix1Rename // spellfix.c:3011:3: 80591 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclModule)) + 8 /* .xCreate */)) = tclConnect // test_bestindex.c:551:3: 80592 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclModule)) + 16 /* .xConnect */)) = tclConnect // test_bestindex.c:552:3: 80593 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclModule)) + 24 /* .xBestIndex */)) = tclBestIndex // test_bestindex.c:553:3: 80594 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclModule)) + 32 /* .xDisconnect */)) = tclDisconnect // test_bestindex.c:554:3: 80595 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclModule)) + 40 /* .xDestroy */)) = tclDisconnect // test_bestindex.c:555:3: 80596 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclModule)) + 48 /* .xOpen */)) = tclOpen // test_bestindex.c:556:3: 80597 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclModule)) + 56 /* .xClose */)) = tclClose // test_bestindex.c:557:3: 80598 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclModule)) + 64 /* .xFilter */)) = tclFilter // test_bestindex.c:558:3: 80599 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclModule)) + 72 /* .xNext */)) = tclNext // test_bestindex.c:559:3: 80600 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclModule)) + 80 /* .xEof */)) = tclEof // test_bestindex.c:560:3: 80601 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclModule)) + 88 /* .xColumn */)) = tclColumn // test_bestindex.c:561:3: 80602 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclModule)) + 96 /* .xRowid */)) = tclRowid // test_bestindex.c:562:3: 80603 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclvarModule)) + 8 /* .xCreate */)) = tclvarConnect // test_tclvar.c:471:3: 80604 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclvarModule)) + 16 /* .xConnect */)) = tclvarConnect // test_tclvar.c:472:3: 80605 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclvarModule)) + 24 /* .xBestIndex */)) = tclvarBestIndex // test_tclvar.c:473:3: 80606 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclvarModule)) + 32 /* .xDisconnect */)) = tclvarDisconnect // test_tclvar.c:474:3: 80607 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclvarModule)) + 40 /* .xDestroy */)) = tclvarDisconnect // test_tclvar.c:475:3: 80608 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclvarModule)) + 48 /* .xOpen */)) = tclvarOpen // test_tclvar.c:476:3: 80609 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclvarModule)) + 56 /* .xClose */)) = tclvarClose // test_tclvar.c:477:3: 80610 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclvarModule)) + 64 /* .xFilter */)) = tclvarFilter // test_tclvar.c:478:3: 80611 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclvarModule)) + 72 /* .xNext */)) = tclvarNext // test_tclvar.c:479:3: 80612 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclvarModule)) + 80 /* .xEof */)) = tclvarEof // test_tclvar.c:480:3: 80613 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclvarModule)) + 88 /* .xColumn */)) = tclvarColumn // test_tclvar.c:481:3: 80614 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclvarModule)) + 96 /* .xRowid */)) = tclvarRowid // test_tclvar.c:482:3: 80615 *(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tclvarModule)) + 104 /* .xUpdate */)) = tclvarUpdate // test_tclvar.c:483:3: 80616 *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&testPcache)) + 8 /* .pArg */)) = uintptr(unsafe.Pointer(&testpcacheGlobal)) // test_pcache.c:435:5: 80617 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&testPcache)) + 16 /* .xInit */)) = testpcacheInit // test_pcache.c:436:5: 80618 *(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&testPcache)) + 24 /* .xShutdown */)) = testpcacheShutdown // test_pcache.c:437:5: 80619 *(*func(*libc.TLS, int32, int32, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&testPcache)) + 32 /* .xCreate */)) = testpcacheCreate // test_pcache.c:438:5: 80620 *(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(uintptr(unsafe.Pointer(&testPcache)) + 40 /* .xCachesize */)) = testpcacheCachesize // test_pcache.c:439:5: 80621 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&testPcache)) + 48 /* .xPagecount */)) = testpcachePagecount // test_pcache.c:440:5: 80622 *(*func(*libc.TLS, uintptr, uint32, int32) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&testPcache)) + 56 /* .xFetch */)) = testpcacheFetch // test_pcache.c:441:5: 80623 *(*func(*libc.TLS, uintptr, uintptr, int32))(unsafe.Pointer(uintptr(unsafe.Pointer(&testPcache)) + 64 /* .xUnpin */)) = testpcacheUnpin // test_pcache.c:442:5: 80624 *(*func(*libc.TLS, uintptr, uintptr, uint32, uint32))(unsafe.Pointer(uintptr(unsafe.Pointer(&testPcache)) + 72 /* .xRekey */)) = testpcacheRekey // test_pcache.c:443:5: 80625 *(*func(*libc.TLS, uintptr, uint32))(unsafe.Pointer(uintptr(unsafe.Pointer(&testPcache)) + 80 /* .xTruncate */)) = testpcacheTruncate // test_pcache.c:444:5: 80626 *(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&testPcache)) + 88 /* .xDestroy */)) = testpcacheDestroy // test_pcache.c:445:5: 80627 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tmp_io_methods)) + 8 /* .xClose */)) = tmpClose // test_onefile.c:231:3: 80628 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tmp_io_methods)) + 16 /* .xRead */)) = tmpRead // test_onefile.c:232:3: 80629 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tmp_io_methods)) + 24 /* .xWrite */)) = tmpWrite // test_onefile.c:233:3: 80630 *(*func(*libc.TLS, uintptr, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tmp_io_methods)) + 32 /* .xTruncate */)) = tmpTruncate // test_onefile.c:234:3: 80631 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tmp_io_methods)) + 40 /* .xSync */)) = tmpSync // test_onefile.c:235:3: 80632 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tmp_io_methods)) + 48 /* .xFileSize */)) = tmpFileSize // test_onefile.c:236:3: 80633 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tmp_io_methods)) + 56 /* .xLock */)) = tmpLock // test_onefile.c:237:3: 80634 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tmp_io_methods)) + 64 /* .xUnlock */)) = tmpUnlock // test_onefile.c:238:3: 80635 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tmp_io_methods)) + 72 /* .xCheckReservedLock */)) = tmpCheckReservedLock // test_onefile.c:239:3: 80636 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tmp_io_methods)) + 80 /* .xFileControl */)) = tmpFileControl // test_onefile.c:240:3: 80637 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tmp_io_methods)) + 88 /* .xSectorSize */)) = tmpSectorSize // test_onefile.c:241:3: 80638 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tmp_io_methods)) + 96 /* .xDeviceCharacteristics */)) = tmpDeviceCharacteristics // test_onefile.c:242:3: 80639 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_io_methods)) + 8 /* .xClose */)) = tvfsClose // test_vfs.c:206:3: 80640 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_io_methods)) + 16 /* .xRead */)) = tvfsRead // test_vfs.c:207:3: 80641 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_io_methods)) + 24 /* .xWrite */)) = tvfsWrite // test_vfs.c:208:3: 80642 *(*func(*libc.TLS, uintptr, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_io_methods)) + 32 /* .xTruncate */)) = tvfsTruncate // test_vfs.c:209:3: 80643 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_io_methods)) + 40 /* .xSync */)) = tvfsSync // test_vfs.c:210:3: 80644 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_io_methods)) + 48 /* .xFileSize */)) = tvfsFileSize // test_vfs.c:211:3: 80645 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_io_methods)) + 56 /* .xLock */)) = tvfsLock // test_vfs.c:212:3: 80646 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_io_methods)) + 64 /* .xUnlock */)) = tvfsUnlock // test_vfs.c:213:3: 80647 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_io_methods)) + 72 /* .xCheckReservedLock */)) = tvfsCheckReservedLock // test_vfs.c:214:3: 80648 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_io_methods)) + 80 /* .xFileControl */)) = tvfsFileControl // test_vfs.c:215:3: 80649 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_io_methods)) + 88 /* .xSectorSize */)) = tvfsSectorSize // test_vfs.c:216:3: 80650 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_io_methods)) + 96 /* .xDeviceCharacteristics */)) = tvfsDeviceCharacteristics // test_vfs.c:217:3: 80651 *(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_io_methods)) + 104 /* .xShmMap */)) = tvfsShmMap // test_vfs.c:218:3: 80652 *(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_io_methods)) + 112 /* .xShmLock */)) = tvfsShmLock // test_vfs.c:219:3: 80653 *(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_io_methods)) + 120 /* .xShmBarrier */)) = tvfsShmBarrier // test_vfs.c:220:3: 80654 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_io_methods)) + 128 /* .xShmUnmap */)) = tvfsShmUnmap // test_vfs.c:221:3: 80655 *(*func(*libc.TLS, uintptr, sqlite3_int64, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_io_methods)) + 136 /* .xFetch */)) = tvfsFetch // test_vfs.c:222:3: 80656 *(*func(*libc.TLS, uintptr, sqlite3_int64, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_io_methods)) + 144 /* .xUnfetch */)) = tvfsUnfetch // test_vfs.c:223:3: 80657 *(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_vfs)) + 40 /* .xOpen */)) = tvfsOpen // test_vfs.c:1451:5: 80658 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_vfs)) + 48 /* .xDelete */)) = tvfsDelete // test_vfs.c:1452:5: 80659 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_vfs)) + 56 /* .xAccess */)) = tvfsAccess // test_vfs.c:1453:5: 80660 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_vfs)) + 64 /* .xFullPathname */)) = tvfsFullPathname // test_vfs.c:1454:5: 80661 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_vfs)) + 104 /* .xRandomness */)) = tvfsRandomness // test_vfs.c:1466:5: 80662 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_vfs)) + 112 /* .xSleep */)) = tvfsSleep // test_vfs.c:1467:5: 80663 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&tvfs_vfs)) + 120 /* .xCurrentTime */)) = tvfsCurrentTime // test_vfs.c:1468:5: 80664 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&unionModule)) + 8 /* .xCreate */)) = unionConnect // unionvtab.c:1332:5: 80665 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&unionModule)) + 16 /* .xConnect */)) = unionConnect // unionvtab.c:1333:5: 80666 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&unionModule)) + 24 /* .xBestIndex */)) = unionBestIndex // unionvtab.c:1334:5: 80667 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&unionModule)) + 32 /* .xDisconnect */)) = unionDisconnect // unionvtab.c:1335:5: 80668 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&unionModule)) + 40 /* .xDestroy */)) = unionDisconnect // unionvtab.c:1336:5: 80669 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&unionModule)) + 48 /* .xOpen */)) = unionOpen // unionvtab.c:1337:5: 80670 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&unionModule)) + 56 /* .xClose */)) = unionClose // unionvtab.c:1338:5: 80671 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&unionModule)) + 64 /* .xFilter */)) = unionFilter // unionvtab.c:1339:5: 80672 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&unionModule)) + 72 /* .xNext */)) = unionNext // unionvtab.c:1340:5: 80673 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&unionModule)) + 80 /* .xEof */)) = unionEof // unionvtab.c:1341:5: 80674 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&unionModule)) + 88 /* .xColumn */)) = unionColumn // unionvtab.c:1342:5: 80675 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&unionModule)) + 96 /* .xRowid */)) = unionRowid // unionvtab.c:1343:5: 80676 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_io_methods)) + 8 /* .xClose */)) = vfslogClose // test_osinst.c:204:3: 80677 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_io_methods)) + 16 /* .xRead */)) = vfslogRead // test_osinst.c:205:3: 80678 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_io_methods)) + 24 /* .xWrite */)) = vfslogWrite // test_osinst.c:206:3: 80679 *(*func(*libc.TLS, uintptr, sqlite3_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_io_methods)) + 32 /* .xTruncate */)) = vfslogTruncate // test_osinst.c:207:3: 80680 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_io_methods)) + 40 /* .xSync */)) = vfslogSync // test_osinst.c:208:3: 80681 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_io_methods)) + 48 /* .xFileSize */)) = vfslogFileSize // test_osinst.c:209:3: 80682 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_io_methods)) + 56 /* .xLock */)) = vfslogLock // test_osinst.c:210:3: 80683 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_io_methods)) + 64 /* .xUnlock */)) = vfslogUnlock // test_osinst.c:211:3: 80684 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_io_methods)) + 72 /* .xCheckReservedLock */)) = vfslogCheckReservedLock // test_osinst.c:212:3: 80685 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_io_methods)) + 80 /* .xFileControl */)) = vfslogFileControl // test_osinst.c:213:3: 80686 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_io_methods)) + 88 /* .xSectorSize */)) = vfslogSectorSize // test_osinst.c:214:3: 80687 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_io_methods)) + 96 /* .xDeviceCharacteristics */)) = vfslogDeviceCharacteristics // test_osinst.c:215:3: 80688 *(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_io_methods)) + 104 /* .xShmMap */)) = vfslogShmMap // test_osinst.c:216:3: 80689 *(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_io_methods)) + 112 /* .xShmLock */)) = vfslogShmLock // test_osinst.c:217:3: 80690 *(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_io_methods)) + 120 /* .xShmBarrier */)) = vfslogShmBarrier // test_osinst.c:218:3: 80691 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_io_methods)) + 128 /* .xShmUnmap */)) = vfslogShmUnmap // test_osinst.c:219:3: 80692 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_module)) + 8 /* .xCreate */)) = vlogConnect // test_osinst.c:1074:5: 80693 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_module)) + 16 /* .xConnect */)) = vlogConnect // test_osinst.c:1075:5: 80694 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_module)) + 24 /* .xBestIndex */)) = vlogBestIndex // test_osinst.c:1076:5: 80695 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_module)) + 32 /* .xDisconnect */)) = vlogDisconnect // test_osinst.c:1077:5: 80696 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_module)) + 40 /* .xDestroy */)) = vlogDisconnect // test_osinst.c:1078:5: 80697 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_module)) + 48 /* .xOpen */)) = vlogOpen // test_osinst.c:1079:5: 80698 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_module)) + 56 /* .xClose */)) = vlogClose // test_osinst.c:1080:5: 80699 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_module)) + 64 /* .xFilter */)) = vlogFilter // test_osinst.c:1081:5: 80700 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_module)) + 72 /* .xNext */)) = vlogNext // test_osinst.c:1082:5: 80701 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_module)) + 80 /* .xEof */)) = vlogEof // test_osinst.c:1083:5: 80702 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_module)) + 88 /* .xColumn */)) = vlogColumn // test_osinst.c:1084:5: 80703 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_module)) + 96 /* .xRowid */)) = vlogRowid // test_osinst.c:1085:5: 80704 *(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_vfs)) + 40 /* .xOpen */)) = vfslogOpen // test_osinst.c:187:3: 80705 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_vfs)) + 48 /* .xDelete */)) = vfslogDelete // test_osinst.c:188:3: 80706 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_vfs)) + 56 /* .xAccess */)) = vfslogAccess // test_osinst.c:189:3: 80707 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_vfs)) + 64 /* .xFullPathname */)) = vfslogFullPathname // test_osinst.c:190:3: 80708 *(*func(*libc.TLS, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_vfs)) + 72 /* .xDlOpen */)) = vfslogDlOpen // test_osinst.c:191:3: 80709 *(*func(*libc.TLS, uintptr, int32, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_vfs)) + 80 /* .xDlError */)) = vfslogDlError // test_osinst.c:192:3: 80710 *(*func(*libc.TLS, uintptr, uintptr, uintptr) uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_vfs)) + 88 /* .xDlSym */)) = vfslogDlSym // test_osinst.c:193:3: 80711 *(*func(*libc.TLS, uintptr, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_vfs)) + 96 /* .xDlClose */)) = vfslogDlClose // test_osinst.c:194:3: 80712 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_vfs)) + 104 /* .xRandomness */)) = vfslogRandomness // test_osinst.c:195:3: 80713 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_vfs)) + 112 /* .xSleep */)) = vfslogSleep // test_osinst.c:196:3: 80714 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_vfs)) + 120 /* .xCurrentTime */)) = vfslogCurrentTime // test_osinst.c:197:3: 80715 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_vfs)) + 128 /* .xGetLastError */)) = vfslogGetLastError // test_osinst.c:198:3: 80716 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&vfslog_vfs)) + 136 /* .xCurrentTimeInt64 */)) = vfslogCurrentTimeInt64 // test_osinst.c:199:3: 80717 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&wholenumberModule)) + 8 /* .xCreate */)) = wholenumberConnect // wholenumber.c:238:3: 80718 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&wholenumberModule)) + 16 /* .xConnect */)) = wholenumberConnect // wholenumber.c:239:3: 80719 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&wholenumberModule)) + 24 /* .xBestIndex */)) = wholenumberBestIndex // wholenumber.c:240:3: 80720 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&wholenumberModule)) + 32 /* .xDisconnect */)) = wholenumberDisconnect // wholenumber.c:241:3: 80721 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&wholenumberModule)) + 40 /* .xDestroy */)) = wholenumberDisconnect // wholenumber.c:242:3: 80722 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&wholenumberModule)) + 48 /* .xOpen */)) = wholenumberOpen // wholenumber.c:243:3: 80723 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&wholenumberModule)) + 56 /* .xClose */)) = wholenumberClose // wholenumber.c:244:3: 80724 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&wholenumberModule)) + 64 /* .xFilter */)) = wholenumberFilter // wholenumber.c:245:3: 80725 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&wholenumberModule)) + 72 /* .xNext */)) = wholenumberNext // wholenumber.c:246:3: 80726 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&wholenumberModule)) + 80 /* .xEof */)) = wholenumberEof // wholenumber.c:247:3: 80727 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&wholenumberModule)) + 88 /* .xColumn */)) = wholenumberColumn // wholenumber.c:248:3: 80728 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&wholenumberModule)) + 96 /* .xRowid */)) = wholenumberRowid // wholenumber.c:249:3: 80729 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_io_methods)) + 8 /* .xClose */)) = devsymClose // test_devsym.c:393:3: 80730 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_io_methods)) + 16 /* .xRead */)) = devsymRead // test_devsym.c:394:3: 80731 *(*func(*libc.TLS, uintptr, uintptr, int32, sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_io_methods)) + 24 /* .xWrite */)) = writecrashWrite // test_devsym.c:395:3: 80732 *(*func(*libc.TLS, uintptr, sqlite_int64) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_io_methods)) + 32 /* .xTruncate */)) = devsymTruncate // test_devsym.c:396:3: 80733 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_io_methods)) + 40 /* .xSync */)) = devsymSync // test_devsym.c:397:3: 80734 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_io_methods)) + 48 /* .xFileSize */)) = devsymFileSize // test_devsym.c:398:3: 80735 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_io_methods)) + 56 /* .xLock */)) = devsymLock // test_devsym.c:399:3: 80736 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_io_methods)) + 64 /* .xUnlock */)) = devsymUnlock // test_devsym.c:400:3: 80737 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_io_methods)) + 72 /* .xCheckReservedLock */)) = devsymCheckReservedLock // test_devsym.c:401:3: 80738 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_io_methods)) + 80 /* .xFileControl */)) = devsymFileControl // test_devsym.c:402:3: 80739 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_io_methods)) + 88 /* .xSectorSize */)) = writecrashSectorSize // test_devsym.c:403:3: 80740 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_io_methods)) + 96 /* .xDeviceCharacteristics */)) = writecrashDeviceCharacteristics // test_devsym.c:404:3: 80741 *(*func(*libc.TLS, uintptr, int32, int32, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_io_methods)) + 104 /* .xShmMap */)) = devsymShmMap // test_devsym.c:405:3: 80742 *(*func(*libc.TLS, uintptr, int32, int32, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_io_methods)) + 112 /* .xShmLock */)) = devsymShmLock // test_devsym.c:406:3: 80743 *(*func(*libc.TLS, uintptr))(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_io_methods)) + 120 /* .xShmBarrier */)) = devsymShmBarrier // test_devsym.c:407:3: 80744 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_io_methods)) + 128 /* .xShmUnmap */)) = devsymShmUnmap // test_devsym.c:408:3: 80745 *(*func(*libc.TLS, uintptr, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_vfs)) + 40 /* .xOpen */)) = writecrashOpen // test_devsym.c:457:3: 80746 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_vfs)) + 48 /* .xDelete */)) = devsymDelete // test_devsym.c:458:3: 80747 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_vfs)) + 56 /* .xAccess */)) = devsymAccess // test_devsym.c:459:3: 80748 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_vfs)) + 64 /* .xFullPathname */)) = devsymFullPathname // test_devsym.c:460:3: 80749 *(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_vfs)) + 104 /* .xRandomness */)) = devsymRandomness // test_devsym.c:472:3: 80750 *(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_vfs)) + 112 /* .xSleep */)) = devsymSleep // test_devsym.c:473:3: 80751 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&writecrash_vfs)) + 120 /* .xCurrentTime */)) = devsymCurrentTime // test_devsym.c:474:3: 80752 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&zipfileModule)) + 8 /* .xCreate */)) = zipfileConnect // zipfile.c:2145:5: 80753 *(*func(*libc.TLS, uintptr, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&zipfileModule)) + 16 /* .xConnect */)) = zipfileConnect // zipfile.c:2146:5: 80754 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&zipfileModule)) + 24 /* .xBestIndex */)) = zipfileBestIndex // zipfile.c:2147:5: 80755 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&zipfileModule)) + 32 /* .xDisconnect */)) = zipfileDisconnect // zipfile.c:2148:5: 80756 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&zipfileModule)) + 40 /* .xDestroy */)) = zipfileDisconnect // zipfile.c:2149:5: 80757 *(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&zipfileModule)) + 48 /* .xOpen */)) = zipfileOpen // zipfile.c:2150:5: 80758 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&zipfileModule)) + 56 /* .xClose */)) = zipfileClose // zipfile.c:2151:5: 80759 *(*func(*libc.TLS, uintptr, int32, uintptr, int32, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&zipfileModule)) + 64 /* .xFilter */)) = zipfileFilter // zipfile.c:2152:5: 80760 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&zipfileModule)) + 72 /* .xNext */)) = zipfileNext // zipfile.c:2153:5: 80761 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&zipfileModule)) + 80 /* .xEof */)) = zipfileEof // zipfile.c:2154:5: 80762 *(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&zipfileModule)) + 88 /* .xColumn */)) = zipfileColumn // zipfile.c:2155:5: 80763 *(*func(*libc.TLS, uintptr, int32, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&zipfileModule)) + 104 /* .xUpdate */)) = zipfileUpdate // zipfile.c:2157:5: 80764 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&zipfileModule)) + 112 /* .xBegin */)) = zipfileBegin // zipfile.c:2158:5: 80765 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&zipfileModule)) + 128 /* .xCommit */)) = zipfileCommit // zipfile.c:2160:5: 80766 *(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&zipfileModule)) + 136 /* .xRollback */)) = zipfileRollback // zipfile.c:2161:5: 80767 *(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(uintptr(unsafe.Pointer(&zipfileModule)) + 144 /* .xFindFunction */)) = zipfileFindFunction // zipfile.c:2162:5: 80768 } 80769 80770 var ts1 = "%s\x00internal error!\x00SELECT * FROM main.%Q WHERE sample()\x00expert\x00PRAGMA table_xinfo=%Q\x00main\x00, \x00%Q\x00 COLLATE %Q\x00 COLLATE %s\x00 DESC\x00PRAGMA index_list=%Q\x00PRAGMA index_xInfo=%Q\x00%s_idx_%08x\x00CREATE INDEX '%q' ON %Q(%s)\x00CREATE INDEX %s ON %s(%s)\x00EXPLAIN QUERY PLAN %s\x00 USING INDEX \x00 USING COVERING INDEX \x00%s\n\x00%s;\n\x00SELECT 'CREATE TEMP' || substr(sql, 7) FROM sqlite_schema WHERE tbl_name = %Q AND type IN ('table', 'trigger') ORDER BY type;\x00ALTER TABLE temp.%Q RENAME TO %Q\x00INSERT INTO %Q VALUES(\x00%s?\x00\x00)\x00UPDATE %Q SET \x00%s%Q=?\x00DELETE FROM %Q\x00t592690916721053953805701627921227776\x00DROP TABLE t592690916721053953805701627921227776\x00SELECT type, name, sql, 1 FROM sqlite_schema WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%%' UNION ALL SELECT type, name, sql, 2 FROM sqlite_schema WHERE type = 'trigger' AND tbl_name IN(SELECT name FROM sqlite_schema WHERE type = 'view') ORDER BY 4, 1\x00CREATE TABLE x(\x00%s%Q COLLATE %s\x00CREATE VIRTUAL TABLE %Q USING expert(%Q)\x00SELECT max(i.seqno) FROM sqlite_schema AS s, pragma_index_list(s.name) AS l, pragma_index_info(l.name) AS i WHERE s.type = 'table'\x00%sx.%Q IS rem(%d, x.%Q) COLLATE %s\x00%s%d\x00SELECT %s FROM %Q x ORDER BY %s\x00SELECT %s FROM temp.t592690916721053953805701627921227776 x ORDER BY %s\x00%d\x00 %d\x00DROP TABLE IF EXISTS temp.t592690916721053953805701627921227776\x00CREATE TABLE temp.t592690916721053953805701627921227776 AS SELECT * FROM %Q\x00SELECT s.rowid, s.name, l.name FROM sqlite_schema AS s, pragma_index_list(s.name) AS l WHERE s.type = 'table'\x00SELECT name, coll FROM pragma_index_xinfo(?) WHERE key\x00INSERT INTO sqlite_stat1 VALUES(?, ?, ?)\x00ANALYZE; PRAGMA writable_schema=1\x00rem\x00sample\x00ANALYZE sqlite_schema\x00:memory:\x00SELECT sql FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%' AND sql NOT LIKE 'CREATE VIRTUAL %%'\x00%s;%s%s\n\x00 -- stat1: \x00no such handle: \x00sql\x00TABLE\x00analyze\x00count\x00report\x00STMT EREPORT\x00destroy\x00SUBCOMMAND ...\x00sub-command\x00indexes\x00plan\x00candidates\x00DB\x00sqlite3expert%d\x00out of memory\x00sqlite3_expert_new\x00SQLITE_DONE\x00SQLITE_ERROR\x00SQLITE_OK\x00SELECT fts5(?1)\x00error: \x00fts5_api_ptr\x00f5t_2_%lld\x00xColumnCount\x00xRowCount\x00xColumnTotalSize\x00COL\x00xTokenize\x00TEXT SCRIPT\x00xPhraseCount\x00xPhraseSize\x00PHRASE\x00xInstCount\x00xInst\x00IDX\x00xRowid\x00xColumnText\x00xColumnSize\x00xQueryPhrase\x00PHRASE SCRIPT\x00xSetAuxdata\x00VALUE\x00xGetAuxdata\x00CLEAR\x00xSetAuxdataInt\x00INTEGER\x00xGetAuxdataInt\x00xPhraseForeach\x00IPHRASE COLVAR OFFVAR SCRIPT\x00xPhraseColumnForeach\x00IPHRASE COLVAR SCRIPT\x00SUB-COMMAND\x00f5t_%lld\x00bytearray\x00boolean\x00double\x00wideInt\x00int\x00DB NAME SCRIPT\x00?-subst? DB NAME TEXT\x00-subst\x00unrecognized option: \x00no such tokenizer: \x00error in tokenizer.xCreate()\x00error in tokenizer.xTokenize()\x00document\x00aux\x00query\x00prefixquery\x00invalid\x00-colocated\x00sqlite3_fts5_token may only be used by tokenizer callback\x00?-colocated? TEXT START END\x00error in fts5_api.xCreateTokenizer()\x00?BOOLEAN?\x00NSLOT TOKEN\x00sqlite3_fts5_create_tokenizer\x00sqlite3_fts5_token\x00sqlite3_fts5_tokenize\x00sqlite3_fts5_create_function\x00sqlite3_fts5_may_be_corrupt\x00sqlite3_fts5_token_hash\x00sqlite3_fts5_register_matchinfo\x00sqlite3_fts5_register_fts5tokenize\x00unrecognized matchinfo flag: %c\x00pcx\x00matchinfo\x00CREATE TABLE x(input HIDDEN, token, start, end, position)\x00fts5tokenize\x00apndvfs\x00Start-Of-SQLite3-\x00apnd(%lld)/%z\x00SQLite format 3\x00%s: cost must be between 1 and %d\x00%s: maximum string length is %d\x00%s: iLang must be between 0 and %d\x00?\x00SELECT * FROM %Q.%Q\x00%s: %s\x00%s: %s has %d columns, expected 4\x00vocabulary_table\x00vocabulary_word\x00vocabulary_language\x00edit_distances\x00unrecognized argument: [%s]\n\x00no edit_distances table specified\x00CREATE TABLE x(word,distance,language,command HIDDEN,nword HIDDEN)\x000123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ^abcdefghijklmnopqrstuvwxyz~\x00SELECT \"%w\" FROM \"%w\"\x00 WHERE \"%w\">=?1 AND \"%w\"=?2 ORDER BY 1\x00SELECT \"%w\" FROM \"%w\" WHERE \"%w\">=?1 ORDER BY 1\x00*\x00DELETE from %s is not allowed\x00UPDATE of %s is not allowed\x00INSERT INTO %s allowed for column [command] only\x00approximate_match\x00int32\x00int64\x00char*\x00CREATE TABLE x(value,pointer hidden,count hidden,ctype hidden)\x00carray-bind\x00carray\x00unknown datatype: %Q\x00inttoptr\x00cksmvfs\x00ZV-\x00checksum fault offset %lld of \"%s\"\x00checksum_verification\x00enable%\x00yes\x00on\x00page_size\x00cksm/%z\x00verify_checksum\x00tablename\x00idcolumn\x00parentcolumn\x00CREATE TABLE x(id,depth,root HIDDEN,tablename HIDDEN,idcolumn HIDDEN,parentcolumn HIDDEN)\x00SELECT \"%w\".\"%w\" FROM \"%w\" WHERE \"%w\".\"%w\"=?1\x00transitive_closure\x00rb\x00cannot open '%s' for reading\x00line %d: unescaped %c character\x00line %d: unterminated %c-quoted field\n\x00more than one '%s' parameter\x00true\x00no\x00off\x00false\x00header\x00more than one 'header' parameter\x00testflags\x00columns\x00more than one 'columns' parameter\x00column= value must be positive\x00bad parameter: '%s'\x00must specify either filename= or data= but not both\x00%sc%d TEXT\x00,\x00%s\"%w\" TEXT\x00bad schema: '%s' - %s\x00filename\x00data\x00schema\x00csv\x00csv_wr\x00decimal_sum\x00decimal\x00decimal_cmp\x00decimal_add\x00decimal_sub\x00decimal_mul\x00 \x00eval\x00CREATE TABLE x(addr,opcode,p1,p2,p3,p4,p5,comment,sql HIDDEN)\x00EXPLAIN %s\x00explain\x00wb\x00wrong number of arguments to function writefile()\x00failed to create symlink: %s\x00failed to create directory: %s\x00failed to write file: %s\x00CREATE TABLE x(name,mode,mtime,data,path HIDDEN,dir HIDDEN)\x00cannot read directory: %s\x00%s/%s\x00cannot stat file: %s\x00table function fsdir requires an argument\x00table function fsdir requires a non-NULL argument\x00fsdir\x00readfile\x00writefile\x00lsmode\x00%s: ruleset must be between 0 and %d\x00%s: wrong number of CREATE VIRTUAL TABLE arguments\x00CREATE TABLE x(word,distance,ruleset)\x00fuzzer\x00ieee754(%lld,%d)\x00ieee754\x00ieee754_mantissa\x00ieee754_exponent\x00ieee754_to_blob\x00ieee754_from_blob\x00BEGIN; SELECT * FROM %s%q%ssqlite_schema\x00'\x00'.\x00PRAGMA %s%q%spage_size\x00sqlite3_mmap_warm_cache: Warmed up %d pages of %s\x00END\x00AND (%s)\x00collate \"%w\"\x00SELECT %s FROM %s WHERE %s>=(?1 || ?2) %s AND %s<=(?1 || char(1114111)) %s %s ORDER BY 1 %s ASC LIMIT 1\x00next_char\x00NULL\x00is\x00not\x00in(\x00in(select\x00in(with\x00?,?,?\x002nd argument to percentile() is not a number between 0.0 and 100.0\x002nd argument to percentile() is not the same for all input rows\x001st argument to percentile() is not numeric\x00Inf input to percentile()\x00percentile\x00CREATE TABLE prefixes(prefix TEXT, original_string TEXT HIDDEN)\x00prefixes\x00prefix_length\x00unknown \\ escape\x00afnrtv\\()*.+?[$^{|}]\x00\a\f\n\r\t\v\x00unmatched '('\x00'*' without operand\x00'+' without operand\x00'?' without operand\x00'{m,n}' without operand\x00unmatched '{'\x00n less than m in '{m,n}'\x00both m and n are zero in '{m,n}'\x00POSIX character classes not supported\x00unclosed '['\x00unrecognized character\x00regexp\x00remember\x00CREATE TABLE x(value,start hidden,stop hidden,step hidden)\x00generate_series() requires SQLite 3.8.12 or later\x00generate_series\x00.ABCDHLRMY9 ?\x00non-ASCII input to editdist()\x00NULL input to editdist()\x00SELECT iLang, cFrom, cTo, iCost FROM \"%w\" WHERE iLang>=0 ORDER BY iLang\x00editdist3\x00DROP TABLE IF EXISTS \"%w\".\"%w_vocab\"\x00CREATE TABLE x(word,rank,distance,langid, score, matchlen, phonehash HIDDEN, top HIDDEN, scope HIDDEN, srchcnt HIDDEN, soundslike HIDDEN, command HIDDEN)\x00CREATE TABLE IF NOT EXISTS \"%w\".\"%w_vocab\"(\n id INTEGER PRIMARY KEY,\n rank INT,\n langid INT,\n word TEXT,\n k1 TEXT,\n k2 TEXT\n);\n\x00CREATE INDEX IF NOT EXISTS \"%w\".\"%w_vocab_index_langid_k2\" ON \"%w_vocab\"(langid,k2);\x00edit_cost_table=\x00bad argument to spellfix1(): \"%s\"\x00SELECT id, word, rank, coalesce(k1,word) FROM \"%w\".\"%w_vocab\" WHERE langid=%d AND k2>=?1 AND k2<?2\x00SELECT word, rank, NULL, langid, id FROM \"%w\".\"%w_vocab\"%s\x00 WHERE rowid=?\x00ROLLBACK\x00IGNORE\x00ABORT\x00REPLACE\x00DELETE FROM \"%w\".\"%w_vocab\" WHERE id=%lld\x00NOT NULL constraint failed: %s.word\x00reset\x00null\x00unknown value for %s.command: \"%w\"\x00INSERT INTO \"%w\".\"%w_vocab\"(rank,langid,word,k1,k2) VALUES(%d,%d,%Q,nullif(%Q,%Q),%Q)\x00INSERT OR %s INTO \"%w\".\"%w_vocab\"(id,rank,langid,word,k1,k2) VALUES(%lld,%d,%d,%Q,nullif(%Q,%Q),%Q)\x00UPDATE OR %s \"%w\".\"%w_vocab\" SET id=%lld, rank=%d, langid=%d, word=%Q, k1=nullif(%Q,%Q), k2=%Q WHERE id=%lld\x00ALTER TABLE \"%w\".\"%w_vocab\" RENAME TO \"%w_vocab\"\x00spellfix1_translit\x00spellfix1_editdist\x00spellfix1_phonehash\x00spellfix1_scriptcode\x00spellfix1\x00922337203685477580\x00tointeger\x00toreal\x00sql error: %s\x00_rowid_\x00integer\x00no such rowid table: %s%s%s\x00.\x00SELECT group_concat(quote(name) || '.' || quote(type)) FROM pragma_table_info(?, ?)\x00source table schema mismatch\x00swarmvtab: no such SQL parameter: %s\x00maxopen\x00swarmvtab: illegal maxopen value\x00missing\x00swarmvtab: duplicate \"missing\" option\x00SELECT \"%w\"(?%s)\x00,?\x00openclose\x00swarmvtab: duplicate \"openclose\" option\x00SELECT \"%w\"(?,?%s)\x00swarmvtab: unrecognized option: %s\x00SELECT \"%w\"(?)\x00swarmvtab: parse error: %s\x00swarmvtab\x00unionvtab\x00temp\x00%s tables must be created in TEMP schema\x00wrong number of arguments for %s\x00SELECT * FROM (%z) ORDER BY 3\x00rowid range mismatch error\x00no source tables configured\x00SELECT 'CREATE TABLE xyz(' || group_concat(quote(name) || ' ' || type, ', ') || ')',max((cid+1) * (type='INTEGER' COLLATE nocase AND pk=1))-1 FROM pragma_table_info(%Q, ?)\x00SELECT rowid, * FROM %Q %s %lld\x00WHERE _rowid_ <=\x00-- \x00%z%sSELECT rowid, * FROM %s%q%s%Q\x00 UNION ALL \x00%z WHERE rowid=%lld\x00WHERE\x00%z WHERE rowid>=%lld\x00AND\x00%z %s rowid<=%lld\x00CREATE TABLE x(value)\x00wholenumber\x00CREATE TABLE y(name PRIMARY KEY,mode,mtime,sz,rawdata,data,method,z HIDDEN) WITHOUT ROWID;\x00zipfile\x00zipfile constructor requires one argument\x00error in fread()\x00error in fwrite()\x00failed to read CDS at offset %lld\x00%.*s\x00failed to read LFH at offset %d\x001.2.11\x00inflateInit2() failed (%d)\x00inflate() failed (%d)\x00zipfile: deflate() error\x00cannot find end of central directory record\x00zipfile() function requires an argument\x00cannot open file: %s\x00-rwxrwxrwx\x00zipfile: mode does not match data\x00zipfile: parse error in mode: %s\x00zipfile: missing filename\x00ab+\x00zipfile: failed to open file %s for writing\x00sz must be NULL\x00rawdata must be NULL\x00unknown compression method: %d\x00%s/\x00duplicate name: \"%s\"\x00{\"version-made-by\" : %u, \"version-to-extract\" : %u, \"flags\" : %u, \"compression\" : %u, \"time\" : %u, \"date\" : %u, \"crc32\" : %u, \"compressed-size\" : %u, \"uncompressed-size\" : %u, \"file-name-length\" : %u, \"extra-field-length\" : %u, \"file-comment-length\" : %u, \"disk-number-start\" : %u, \"internal-attr\" : %u, \"external-attr\" : %u, \"offset\" : %u }\x00zipfile_cds\x00wrong number of arguments to function zipfile()\x00first argument to zipfile() must be non-NULL\x00illegal method value: %d\x00non-directory name must not end with /\x00rbu_delta\x00step\x00close\x00create_rbu_delta\x00savestate\x00dbMain_eval\x00SQL\x00bp_progress\x00db\x00RBU\x00state\x00progress\x00close_no_error\x00temp_size_limit\x00LIMIT\x00temp_size\x00dbRbu_eval\x00METHOD\x00method\x00 - \x00oal\x00move\x00checkpoint\x00done\x00error\x00NAME TARGET-DB RBU-DB ?STATE-DB?\x00NAME TARGET-DB ?STATE-DB?\x00?-default? NAME PARENT\x00NAME\x00sqlite3rbu_db(0, 0)!=0\x00sqlite3rbu\x00sqlite3rbu_vacuum\x00sqlite3rbu_create_vfs\x00sqlite3rbu_destroy_vfs\x00sqlite3rbu_internal_test\x00incrblob\x00incrblob_%d\x00%lld\x00sqlite_unlock_notify_arg\x00sqlite_unlock_notify_argcount\x00DELETE\x00INSERT\x00UPDATE\x00SQLITE_COPY\x00SQLITE_CREATE_INDEX\x00SQLITE_CREATE_TABLE\x00SQLITE_CREATE_TEMP_INDEX\x00SQLITE_CREATE_TEMP_TABLE\x00SQLITE_CREATE_TEMP_TRIGGER\x00SQLITE_CREATE_TEMP_VIEW\x00SQLITE_CREATE_TRIGGER\x00SQLITE_CREATE_VIEW\x00SQLITE_DELETE\x00SQLITE_DROP_INDEX\x00SQLITE_DROP_TABLE\x00SQLITE_DROP_TEMP_INDEX\x00SQLITE_DROP_TEMP_TABLE\x00SQLITE_DROP_TEMP_TRIGGER\x00SQLITE_DROP_TEMP_VIEW\x00SQLITE_DROP_TRIGGER\x00SQLITE_DROP_VIEW\x00SQLITE_INSERT\x00SQLITE_PRAGMA\x00SQLITE_READ\x00SQLITE_SELECT\x00SQLITE_TRANSACTION\x00SQLITE_UPDATE\x00SQLITE_ATTACH\x00SQLITE_DETACH\x00SQLITE_ALTER_TABLE\x00SQLITE_REINDEX\x00SQLITE_ANALYZE\x00SQLITE_CREATE_VTABLE\x00SQLITE_DROP_VTABLE\x00SQLITE_FUNCTION\x00SQLITE_SAVEPOINT\x00SQLITE_RECURSIVE\x00????\x00SQLITE_DENY\x00SQLITE_IGNORE\x00RELEASE _tcl_transaction\x00COMMIT\x00ROLLBACK TO _tcl_transaction ; RELEASE _tcl_transaction\x00option\x00?CALLBACK?\x00?DATABASE? FILENAME\x00cannot open target database: \x00backup failed: \x00CALLBACK\x00cache option ?arg?\x00flush\x00size\x00size n\x00cannot convert \"\x00\" to integer\x00bad option \"\x00\": must be flush or size\x00NAME SCRIPT\x00SCRIPT\x00?OPTION? ?BOOLEAN?\x00unknown config option: \"\x00\"\x00CONFLICT-ALGORITHM TABLE FILENAME ?SEPARATOR? ?NULLINDICATOR?\x00\t\x00Error: non-null separator required for copy\x00rollback\x00abort\x00fail\x00ignore\x00replace\x00Error: \"\x00\", conflict-algorithm must be one of: rollback, abort, fail, ignore, or replace\x00SELECT * FROM '%q'\x00Error: no such table: \x00Error: \x00Error: can't malloc()\x00INSERT OR %q INTO '%q' VALUES(?\x00Error: cannot open file: \x00BEGIN\x00Error: %s line %d: expected %d columns of data but found %d\x00, failed while processing line: \x00?DATABASE? VALUE\x00-maxsize\x00-readonly\x00unknown option: \x00unable to set MEMDB content\x00extension loading is turned off at compile-time\x00-withoutnulls\x00unknown option: \"\x00?OPTIONS? SQL ?ARRAY-NAME? ?SCRIPT?\x00NAME ?SWITCHES? SCRIPT\x00-argcount\x00option requires an argument: \x00number of arguments must be non-negative\x00-deterministic\x00-directonly\x00-innocuous\x00-returntype\x00real\x00text\x00blob\x00any\x00type\x00\": must be -argcount, -deterministic, -directonly, -innocuous, or -returntype\x00?-readonly? ?DB? TABLE COLUMN ROWID\x00NULLVALUE\x00N CALLBACK\x00KEY\x00cannot open source database: \x00restore failed: \x00restore failed: source database busy\x00?DATABASE?\x00(step|sort|autoindex)\x00sort\x00autoindex\x00vmstep\x00bad argument: should be autoindex, step, sort or vmstep\x00MILLISECONDS\x00?CALLBACK? ?MASK?\x00trace type\x00SAVEPOINT _tcl_transaction\x00[TYPE] SCRIPT\x00transaction type\x00BEGIN EXCLUSIVE\x00BEGIN IMMEDIATE\x00?SCRIPT?\x00SUB-COMMAND ?ARGS?\x00hook ?SCRIPT?\x00INDEX\x00-use-legacy-prepare\x00-last-stmt-ptr\x00%p\x00unknown argument: \x00authorizer\x00backup\x00bind_fallback\x00busy\x00cache\x00changes\x00collate\x00collation_needed\x00commit_hook\x00complete\x00config\x00copy\x00deserialize\x00enable_load_extension\x00errorcode\x00exists\x00function\x00interrupt\x00last_insert_rowid\x00nullvalue\x00onecolumn\x00preupdate\x00profile\x00rekey\x00restore\x00rollback_hook\x00serialize\x00status\x00timeout\x00total_changes\x00trace\x00trace_v2\x00transaction\x00unlock_notify\x00update_hook\x00version\x00wal_hook\x00defensive\x00dqs_ddl\x00dqs_dml\x00enable_fkey\x00enable_qpsg\x00enable_trigger\x00enable_view\x00fts3_tokenizer\x00legacy_alter_table\x00legacy_file_format\x00load_extension\x00no_ckpt_on_close\x00reset_database\x00trigger_eqp\x00trusted_schema\x00writable_schema\x00statement\x00row\x00deferred\x00exclusive\x00immediate\x00depth\x00hook\x00new\x00old\x00HANDLE ?FILENAME? ?-vfs VFSNAME? ?-readonly BOOLEAN? ?-create BOOLEAN? ?-nofollow BOOLEAN? ?-nomutex BOOLEAN? ?-fullmutex BOOLEAN? ?-uri BOOLEAN?\x00-version\x00-sourceid\x00-has-codec\x000\x00-key\x00-vfs\x00-create\x00-nofollow\x00-nomutex\x00-fullmutex\x00-uri\x00-translatefilename\x00sqlite3\x00sqlite\x003.35.5\x00if {[llength $argv]>=1} {\nset argv0 [lindex $argv 0]\nset argv [lrange $argv 1 end]\nsource $argv0\n} else {\nset line {}\nwhile {![eof stdin]} {\nif {$line!=\"\"} {\nputs -nonewline \"> \"\n} else {\nputs -nonewline \"% \"\n}\nflush stdout\nappend line [gets stdin]\nif {[info complete $line]} {\nif {[catch {uplevel #0 $line} result]} {\nputs stderr \"Error: $result\"\n} elseif {$result!=\"\"} {\nputs $result\n}\nset line {}\n} else {\nappend line \\n\n}\n}\n}\n\x00SQLITE_DEBUG_BREAK\x00attach debugger to process %d and press any key to continue.\n\x00utf-8\x00argc\x00argv0\x00argv\x00errorInfo\x00%s: %s\n\x00SQLITE-CONNECTION\x00command not found: \x00error code %s (%d) does not match sqlite3_errcode %s (%d)\x00OMIT_MISUSE\x00wrong # args: should be \"\x00 DB FORMAT STRING\x00 DB HEX\x00 DB\x00 DB SQL\x00%z%s%s\x00%s%n\x00abcdefghijklmnopqrstuvwxyz\x00 DB FORMAT STRING ?COUNT?\x00 DB\"\x00 FILENAME\"\x00%02x\x00%04x\x00tkt2213 is not fixed\x00text16\x00bytes\x00bytes16\x00noop\x00x_coalesce\x00hex8\x00hex16\x00tkt2213func\x00pointer_change\x00counter1\x00counter2\x00intreal\x00x_sqlite_exec\x00value of 40 handed to x_count\x00x_count totals to 42\x00x_count\x00legacy_count\x00 TEXT\"\x00 FORMAT INT INT INT\"\x00argument is not a valid 64-bit integer\x00 FORMAT INT INT ?STRING?\"\x00 INT FORMAT INT INT ?STRING?\"\x00N must be non-negative\x00 FORMAT INT INT DOUBLE\"\x00 FORMAT DOUBLE DOUBLE\"\x00 FORMAT STRING\"\x00%08x%08x\x002nd argument should be 16-characters of hex\x00DB BOOLEAN\x00DB dbname tblname colname\x00CHANNEL ROWID\x00DB-HANDLE NAME CMP-PROC DEL-PROC\x00sqlite3_create_collate_v2() failed to detect an invalid encoding\x00utf8\x00utf16\x00utf16le\x00utf16be\x00DB NAME NARG ENC SWITCHES...\x00encoding\x00-func\x00-step\x00-final\x00-destroy\x00switch\x00DB-HANDLE FILE ?PROC?\x00this build omits sqlite3_load_extension()\x00DB-HANDLE ONOFF\x00string\x00value\x00first argument should be one of: int int64 string double null value\x00 DB FUNCTION-NAME\x00 <STMT>\x00STMT PARAMETER RESETFLAG\x00SQLITE_STMTSTATUS_FULLSCAN_STEP\x00SQLITE_STMTSTATUS_SORT\x00SQLITE_STMTSTATUS_AUTOINDEX\x00SQLITE_STMTSTATUS_VM_STEP\x00SQLITE_STMTSTATUS_REPREPARE\x00SQLITE_STMTSTATUS_RUN\x00SQLITE_STMTSTATUS_MEMUSED\x00NBYTE\x00DB DBNAME\x00DB DBNAME SNAPSHOT\x00SNAPSHOT\x00SNAPSHOT1 SNAPSHOT2\x00bad SNAPSHOT\x00FILE\x00PATH\x00 DB STMT\x00 STMT\x00 FROM-STMT TO-STMT\x00 VM IDX VALUE (null|static|normal)\"\x00static\x00static-nbytes\x00normal\x00blob10\x00abc\x00xyz\x00pq\x004th argument should be \"null\" or \"static\" or \"normal\"\x00(%d) \x00test_collate\x00UTF-8\x00UTF-16LE\x00UTF-16BE\x00 <DB> <utf8> <utf16le> <utf16be>\x00utf16bin\x00utf16_unaligned\x00utf16_aligned\x00test_function\x00<error code>\x00STMT IDX N\x00 STMT N VALUE\x00NaN\x00SNaN\x00-NaN\x00-SNaN\x00+Inf\x00-Inf\x00Epsilon\x00-Epsilon\x00NaN0\x00-NaN0\x00 STMT N\x00 STMT N VALUE BYTES\x00 STMT N DATA BYTES\x00cannot use %d blob bytes, have %d\x00-transient\x00-static\x00-int32\x00-int64\x00-double\x00-text\x00--\x00text data must be either -static or -transient\x00cannot be both -static and -transient\x00[OPTIONS] STMT IDX VALUE ...\x00STMT\x00STMT N\x00STMT NAME\x00 DB sql bytes ?tailvar?\x00 DB sql bytes tailvar\x00 DB sql bytes flags tailvar\x00\x00SELECT 1\x00 filename options-list\x00FILENAME FLAGS VFS\x00SQLITE_OPEN_READONLY\x00SQLITE_OPEN_READWRITE\x00SQLITE_OPEN_CREATE\x00SQLITE_OPEN_DELETEONCLOSE\x00SQLITE_OPEN_EXCLUSIVE\x00SQLITE_OPEN_AUTOPROXY\x00SQLITE_OPEN_MAIN_DB\x00SQLITE_OPEN_TEMP_DB\x00SQLITE_OPEN_TRANSIENT_DB\x00SQLITE_OPEN_MAIN_JOURNAL\x00SQLITE_OPEN_TEMP_JOURNAL\x00SQLITE_OPEN_SUBJOURNAL\x00SQLITE_OPEN_SUPER_JOURNAL\x00SQLITE_OPEN_NOMUTEX\x00SQLITE_OPEN_FULLMUTEX\x00SQLITE_OPEN_SHAREDCACHE\x00SQLITE_OPEN_PRIVATECACHE\x00SQLITE_OPEN_WAL\x00SQLITE_OPEN_URI\x00flag\x00<utf-16 sql>\x00 STMT column\x00FLOAT\x00TEXT\x00BLOB\x00 DB MAGIC\x00SQLITE_MAGIC_OPEN\x00SQLITE_MAGIC_CLOSED\x00SQLITE_MAGIC_BUSY\x00SQLITE_MAGIC_ERROR\x00 DB function-name\x00VARIABLE\x00?N?\x001234567890000000\x00__one\x00__two\x00notadatabase\x00Unexpected non-zero errno: \x00DB [DBNAME]\x00%u\x00DB DBNAME SIZE\x00 DB PWD\x00 DB FLAG\x00%d %d\x00 DB ?AUXDB?\x00DB N\x00 DB ID VALUE\x00unknown limit type: \x00SQLITE_LIMIT_LENGTH\x00SQLITE_LIMIT_SQL_LENGTH\x00SQLITE_LIMIT_COLUMN\x00SQLITE_LIMIT_EXPR_DEPTH\x00SQLITE_LIMIT_COMPOUND_SELECT\x00SQLITE_LIMIT_VDBE_OP\x00SQLITE_LIMIT_FUNCTION_ARG\x00SQLITE_LIMIT_ATTACHED\x00SQLITE_LIMIT_LIKE_PATTERN_LENGTH\x00SQLITE_LIMIT_VARIABLE_NUMBER\x00SQLITE_LIMIT_TRIGGER_DEPTH\x00SQLITE_LIMIT_WORKER_THREADS\x00SQLITE_LIMIT_TOOSMALL\x00SQLITE_LIMIT_TOOBIG\x00SEED ?DB?\x00BOOLEAN\x00current\x00max\x00min\x00recyclable\x00DB ?NAME?\x00passive\x00full\x00restart\x00truncate\x00DB MODE ?NAME?\x00mode\x00DB VALUE\x00COMMAND ...\x00command has no objProc: \x00%d %d %d %s\n\x00SQLITE_TESTCTRL_LOCALTIME_FAULT\x00SQLITE_TESTCTRL_SORTER_MMAP\x00SQLITE_TESTCTRL_IMPOSTER\x00SQLITE_TESTCTRL_INTERNAL_FUNCTIONS\x00VERB ARGS...\x00VERB\x00ONOFF\x00DB LIMIT\x00DB dbName onOff tnum\x00ru_utime=%d.%06d ru_stime=%d.%06d ru_minflt=%d ru_majflt=%d\x00DB OPT BOOLEAN\x00unknown optimization - should be one of:\x00all\x00none\x00query-flattener\x00groupby-order\x00factor-constants\x00distinct-opt\x00cover-idx-scan\x00order-by-idx-join\x00transitive\x00omit-noop-join\x00stat4\x00skip-scan\x00push-down\x00DB NAME ...\x00no such extension: \x00initialization of \x00 failed: \x00amatch\x00appendvfs\x00closure\x00fileio\x00nextchar\x00series\x00spellfix\x00totype\x00BOOL\x00DB SQL1 NSTEP SQL2\x00data error: (a!=b)\x00checksum mismatch\x00sql error: \x00TYPE\x00Deliberate panic\x00DB SETTING [VALUE]\x00SQLITE_*\x00DBCONFIG_*\x00ENABLE_*\x00unknown sqlite3_db_config setting\x00FKEY\x00TRIGGER\x00FTS3_TOKENIZER\x00LOAD_EXTENSION\x00NO_CKPT_ON_CLOSE\x00QPSG\x00TRIGGER_EQP\x00RESET_DB\x00DEFENSIVE\x00WRITABLE_SCHEMA\x00LEGACY_ALTER_TABLE\x00DQS_DML\x00DQS_DDL\x00LEGACY_FILE_FORMAT\x00DB ?SCHEMA?\x00icecube\x00DB ?DBNAME?\x00DB OFFSET DATA\x00HEXDB\x00| size %d pagesize %d\x00bad 'pagesize' field\x00bad 'size' field\x00| page %d offset %d\x00| %d: %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\x00sqlite_search_count\x00sqlite_found_count\x00sqlite_sort_count\x00sqlite3_max_blobsize\x00sqlite_like_count\x00sqlite_interrupt_count\x00sqlite_open_file_count\x00sqlite_current_time\x00sqlite3_xferopt_count\x00sqlite3_pager_readdb_count\x00sqlite3_pager_writedb_count\x00sqlite3_pager_writej_count\x00unaligned_string_counter\x00sqlite_last_needed_collation\x00sqlite_query_plan\x00sqlite_opentemp_count\x00sqlite_static_bind_value\x00sqlite_static_bind_nbyte\x00sqlite_temp_directory\x00sqlite_data_directory\x00bitmask_size\x00longdouble_size\x00sqlite_sync_count\x00sqlite_fullsync_count\x00db_enter\x00db_leave\x00sqlite3_mprintf_int\x00sqlite3_mprintf_int64\x00sqlite3_mprintf_long\x00sqlite3_mprintf_str\x00sqlite3_snprintf_str\x00sqlite3_mprintf_stronly\x00sqlite3_mprintf_double\x00sqlite3_mprintf_scaled\x00sqlite3_mprintf_hexdouble\x00sqlite3_mprintf_z_test\x00sqlite3_mprintf_n_test\x00sqlite3_snprintf_int\x00sqlite3_last_insert_rowid\x00sqlite3_exec_printf\x00sqlite3_exec_hex\x00sqlite3_exec\x00sqlite3_exec_nr\x00sqlite3_get_table_printf\x00sqlite3_close\x00sqlite3_close_v2\x00sqlite3_create_function\x00sqlite3_create_aggregate\x00sqlite3_drop_modules\x00sqlite_register_test_function\x00sqlite_abort\x00sqlite_bind\x00breakpoint\x00sqlite3_key\x00sqlite3_rekey\x00sqlite_set_magic\x00sqlite3_interrupt\x00sqlite_delete_function\x00sqlite_delete_collation\x00sqlite3_get_autocommit\x00sqlite3_busy_timeout\x00printf\x00sqlite3IoTrace\x00clang_sanitize_address\x00sqlite3_db_config\x00sqlite3_txn_state\x00bad_behavior\x00register_dbstat_vtab\x00sqlite3_connection_pointer\x00intarray_addr\x00int64array_addr\x00doublearray_addr\x00textarray_addr\x00sqlite3_bind_int\x00sqlite3_bind_zeroblob\x00sqlite3_bind_zeroblob64\x00sqlite3_bind_int64\x00sqlite3_bind_double\x00sqlite3_bind_null\x00sqlite3_bind_text\x00sqlite3_bind_text16\x00sqlite3_bind_blob\x00sqlite3_carray_bind\x00sqlite3_bind_parameter_count\x00sqlite3_bind_parameter_name\x00sqlite3_bind_parameter_index\x00sqlite3_clear_bindings\x00sqlite3_sleep\x00sqlite3_errcode\x00sqlite3_extended_errcode\x00sqlite3_errmsg\x00sqlite3_errmsg16\x00sqlite3_open\x00sqlite3_open16\x00sqlite3_open_v2\x00sqlite3_complete16\x00sqlite3_normalize\x00sqlite3_prepare\x00sqlite3_prepare16\x00sqlite3_prepare_v2\x00sqlite3_prepare_v3\x00sqlite3_prepare_tkt3134\x00sqlite3_prepare16_v2\x00sqlite3_finalize\x00sqlite3_stmt_status\x00sqlite3_reset\x00sqlite3_expired\x00sqlite3_transfer_bindings\x00sqlite3_changes\x00sqlite3_step\x00sqlite3_sql\x00sqlite3_expanded_sql\x00sqlite3_next_stmt\x00sqlite3_stmt_readonly\x00sqlite3_stmt_isexplain\x00sqlite3_stmt_busy\x00uses_stmt_journal\x00sqlite3_release_memory\x00sqlite3_db_release_memory\x00sqlite3_db_cacheflush\x00sqlite3_system_errno\x00sqlite3_db_filename\x00sqlite3_db_readonly\x00sqlite3_soft_heap_limit\x00sqlite3_soft_heap_limit64\x00sqlite3_hard_heap_limit64\x00sqlite3_thread_cleanup\x00sqlite3_pager_refcounts\x00sqlite3_load_extension\x00sqlite3_enable_load_extension\x00sqlite3_extended_result_codes\x00sqlite3_limit\x00dbconfig_maindbname_icecube\x00save_prng_state\x00restore_prng_state\x00reset_prng_state\x00prng_seed\x00extra_schema_checks\x00database_never_corrupt\x00database_may_be_corrupt\x00optimization_control\x00tcl_objproc\x00sqlite3_column_count\x00sqlite3_data_count\x00sqlite3_column_type\x00sqlite3_column_blob\x00sqlite3_column_double\x00sqlite3_column_int64\x00sqlite3_column_text\x00sqlite3_column_name\x00sqlite3_column_int\x00sqlite3_column_bytes\x00sqlite3_column_decltype\x00sqlite3_column_database_name\x00sqlite3_column_table_name\x00sqlite3_column_origin_name\x00sqlite3_column_bytes16\x00sqlite3_column_text16\x00sqlite3_column_name16\x00add_alignment_test_collations\x00sqlite3_column_decltype16\x00sqlite3_column_database_name16\x00sqlite3_column_table_name16\x00sqlite3_column_origin_name16\x00sqlite3_create_collation_v2\x00sqlite3_global_recover\x00working_64bit_int\x00vfs_unlink_test\x00vfs_initfail_test\x00vfs_unregister_all\x00vfs_reregister_all\x00file_control_test\x00file_control_lasterrno_test\x00file_control_lockproxy_test\x00file_control_chunksize_test\x00file_control_sizehint_test\x00file_control_data_version\x00file_control_persist_wal\x00file_control_powersafe_overwrite\x00file_control_vfsname\x00file_control_reservebytes\x00file_control_tempfilename\x00sqlite3_vfs_list\x00sqlite3_create_function_v2\x00add_test_collate\x00add_test_collate_needed\x00add_test_function\x00add_test_utf16bin_collate\x00sqlite3_test_errstr\x00tcl_variable_type\x00sqlite3_enable_shared_cache\x00sqlite3_shared_cache_report\x00sqlite3_libversion_number\x00sqlite3_table_column_metadata\x00sqlite3_blob_reopen\x00pcache_stats\x00sqlite3_unlock_notify\x00sqlite3_wal_checkpoint\x00sqlite3_wal_checkpoint_v2\x00sqlite3_wal_autocheckpoint\x00test_sqlite3_log\x00print_explain_query_plan\x00sqlite3_test_control\x00getrusage\x00load_static_extension\x00sorter_test_fakeheap\x00sorter_test_sort4_helper\x00vfs_current_time_int64\x00sqlite3_snapshot_get\x00sqlite3_snapshot_open\x00sqlite3_snapshot_free\x00sqlite3_snapshot_cmp\x00sqlite3_snapshot_recover\x00sqlite3_snapshot_get_blob\x00sqlite3_snapshot_open_blob\x00sqlite3_snapshot_cmp_blob\x00sqlite3_delete_database\x00atomic_batch_write\x00sqlite3_mmap_warm\x00sqlite3_config_sorterref\x00decode_hexdb\x00test_write_db\x00sqlite3_register_cksumvfs\x00sqlite3_unregister_cksumvfs\x00*** OBSOLETE VARIABLE ***\x00 FILENAME N-PAGE\"\x00 ID\"\x00ref\x00page\x00err\x00hit\x00miss\x00ovfl\x00 ID PGNO\"\x00 PAGE\"\x00 PAGE DATA\"\x00 N-MEGABYTES FILE\"\x00open failed: \x00Hello, World!\x00write failed: \x00 PENDING-BYTE\"\x00fault simulator script failed: [%s]\x00 SCRIPT\"\x00 SIZE PROGRAM\"\x00sqlite_io_error_pending\x00sqlite_io_error_persist\x00sqlite_io_error_hit\x00sqlite_io_error_hardhit\x00sqlite_diskfull_pending\x00sqlite_diskfull\x00sqlite_pending_byte\x00pager_open\x00pager_close\x00pager_commit\x00pager_rollback\x00pager_stmt_begin\x00pager_stmt_commit\x00pager_stmt_rollback\x00pager_stats\x00pager_pagecount\x00page_get\x00page_lookup\x00page_unref\x00page_read\x00page_write\x00page_number\x00pager_truncate\x00fake_big_file\x00sqlite3BitvecBuiltinTest\x00sqlite3_test_control_pending_byte\x00sqlite3_test_control_fault_install\x00 FILENAME NCACHE FLAGS\"\x00read\x00write\x00 ID TABLENUM WRITEABLE\"\x00 START MULTIPLIER COUNT INCREMENT\"\x00putVarint returned %d - should be between 1 and 9\x00putVarint returned %d and getVarint returned %d\x00Wrote 0x%016llx and got back 0x%016llx\x00putVarint returned %d and GetVarint32 returned %d\x00Wrote 0x%016llx and got back 0x%016llx from GetVarint32\x00 DB-HANDLE ?N?\"\x00No such db-handle: \"\x00 BT NCACHE\"\x00?-intkey? CSR KEY VALUE\x00btree_insert\x00btree_open\x00btree_close\x00btree_begin_transaction\x00btree_pager_stats\x00btree_cursor\x00btree_close_cursor\x00btree_next\x00btree_eof\x00btree_payload_size\x00btree_first\x00btree_varint_test\x00btree_from_db\x00btree_ismemdb\x00btree_set_cache_size\x00thread ID must be an upper case letter\x00 ID FILENAME\x00thread \x00 is already running\x00failed to create the thread\x00 ID\x00no such thread\x00 ID N\x00column number out of range\x00no database is open\x00 ID SQL\x00no virtual machine available\x00 IDL\x00 ID1 ID2\x00 ID DB\x00thread_create\x00thread_wait\x00thread_halt\x00thread_argc\x00thread_argv\x00thread_colname\x00thread_result\x00thread_error\x00thread_compile\x00thread_step\x00thread_finalize\x00thread_swap\x00thread_db_get\x00thread_db_put\x00thread_stmt_get\x00 <repeat-count> <do-calls>\x00hello world\x00UTF8\x00UTF16LE\x00UTF16BE\x00UTF16\x00No such encoding: \x00 <string/blob> <from enc> <to enc>\x00binarize\x00test_value_overhead\x00test_translate\x00translate_selftest\x00out of memory in the crash simulator\n\x00atomic\x00atomic512\x00atomic1k\x00atomic2k\x00atomic4k\x00atomic8k\x00atomic16k\x00atomic32k\x00atomic64k\x00sequential\x00safe_append\x00powersafe_overwrite\x00batch-atomic\x00-sectorsize\x00-characteristics\x00Bad option: \"\x00\" - must be \"-characteristics\" or \"-sectorsize\"\x00Option requires an argument: \"\x00no such flag\x00ENABLE ?DEFAULT?\x00crash\x00?OPTIONS? DELAY CRASHFILE\x00Filename is too long: \"\x00NWRITE\x00?-default? PARENT-VFS\x00-default\x00\": must be -default\x00Error in jt_register\x00sqlite3_crash_enable\x00sqlite3_crashparams\x00sqlite3_crash_now\x00sqlite3_simulate_device\x00sqlite3_crash_on_write\x00unregister_devsim\x00register_jt_vfs\x00unregister_jt_vfs\x00client_create\x00client_wait\x00client_halt\x00client_argc\x00client_argv\x00client_colname\x00client_result\x00client_error\x00client_compile\x00client_step\x00client_reset\x00client_finalize\x00client_swap\x00echo_module_fail(%s,%s)\x00echo-vtab-error: %s\x00SELECT * FROM %Q\x00PRAGMA index_list(%s)\x00PRAGMA index_info(%s)\x00echo_module\x00SELECT sql FROM sqlite_schema WHERE type = 'table' AND name = ?\x00%s%s\x00xCreate\x00CREATE TABLE %Q(logmsg)\x00xConnect\x00xDisconnect\x00xDestroy\x00DROP TABLE %Q\x00xOpen\x00xNext\x00xColumn\x00xFilter\x00, *\x00%z, %s\x00%z, NULL\x00echo_module_ignore_usable\x00xBestIndex\x00echo_module_cost\x00SELECT count(*) FROM %Q\x00SELECT rowid%z FROM %Q\x00rowid\x00=\x00<\x00>\x00<=\x00>=\x00LIKE\x00like\x00glob\x00 %s %s LIKE (SELECT '%%'||?||'%%')\x00 %s %s %s ?\x00DESC\x00ASC\x00 ORDER BY %s %s\x00xUpdate\x00 SET\x00UPDATE %Q\x00 SET rowid=?1 \x00%s %Q=?%d\x00 WHERE rowid=?%d\x00DELETE FROM %Q WHERE rowid = ?1\x00INSERT INTO %Q (\x00%s%Q\x00%s?%d\x00) VALUES(\x00echo(%s)\x00xBegin\x00echo_module_begin_fail\x00xSync\x00echo_module_sync_fail\x00xCommit\x00xRollback\x00::echo_glob_overload\x00xRename\x00ALTER TABLE %s RENAME TO %s%s\x00echo\x00echo_v2\x00DB SQL\x00register_echo_module\x00sqlite3_declare_vtab\x00N/A\x00sqlite3_create_collation\x00Error testing function: \x00sqlite3_malloc\x00sqlite3_realloc\x00c_misuse_test\x00c_realloc_test\x00c_collation_test\x00sqlite3_reset_auto_extension\x00npage\x00finish\x00remaining\x00pagecount\x00CMDNAME DESTHANDLE DESTNAME SRCHANDLE SRCNAME\x00sqlite3_backup_init() failed\x00sqlite3_backup\x00wrong number of arguments\x00unexpected: %s\x00eq\x00gt\x00le\x00lt\x00ge\x00match\x00ne\x00isnot\x00isnotnull\x00isnull\x00op\x00column\x00usable\x00desc\x00cost\x00orderby\x00idxnum\x00idxstr\x00rows\x00use\x00omit\x00unexpected: %d\x00tcl\x00register_tcl_module\x00incrblob_\x00DB DATABASE TABLE COLUMN ROWID FLAGS VARNAME\x00HANDLE\x00CHANNEL OFFSET N\x00out of memory in testdata/sqlite-src-3350500/src/test_blob.c\x00HANDLE OFFSET DATA ?NDATA?\x00sqlite3_blob_open\x00sqlite3_blob_close\x00sqlite3_blob_bytes\x00sqlite3_blob_read\x00sqlite3_blob_write\x00sqlite_options\x00malloc_usable_size\x001\x00rowid32\x00casesensitivelike\x00curdir\x00win32malloc\x00debug\x00default_ckptfullfsync\x00direct_read\x00dirsync\x00lfs\x00pagecache_overflow_stats\x00mmap\x00worker_threads\x008\x00memdebug\x008_3_names\x00cursorhints\x00hiddencolumns\x00mathlib\x00mem3\x00mem5\x00offset_sql_func\x00snapshot\x00mutex\x00mutex_noop\x00altertable\x00api_armor\x00atomicwrite\x00json1\x00has_codec\x00like_match_blobs\x00attach\x00auth\x00autoinc\x00autoreset\x00autovacuum\x00default_autovacuum\x00between_opt\x00builtin_test\x00bloblit\x00cast\x00check\x00cte\x00columnmetadata\x00oversize_cell_check\x00compileoption_diags\x00compound\x00conflict\x00crashtest\x00datetime\x00decltype\x00deprecated\x00diskio\x00floatingpoint\x00foreignkey\x00fts1\x00fts2\x00fts3\x00fts5\x00fts3_unicode\x00fts4_deferred\x00gettable\x00icu\x00icu_collations\x00integrityck\x00legacyformat\x00like_opt\x00load_ext\x00localtime\x00lookaside\x00long_double\x00memorydb\x00memorymanage\x00mergesort\x00null_trim\x00or_opt\x00rbu\x00pager_pragmas\x00pragma\x00reindex\x00rtree\x00rtree_int_only\x00schema_pragmas\x00schema_version\x00session\x00stmtvtab\x00scanstatus\x00lock_proxy_pragmas\x00prefer_proxy_locking\x00shared_cache\x00subquery\x00tclvar\x00threadsafe\x00threadsafe1\x00threadsafe2\x00tempdb\x00trigger\x00truncate_opt\x00vacuum\x00view\x00vtab\x00wal\x00wsd\x00update_delete_limit\x00fast_secure_delete\x00secure_delete\x00userauth\x00multiplex_ext_overwrite\x00yytrackmaxstackdepth\x00sqllog\x00uri_00_error\x00normalize\x00windowfunc\x00SQLITE_MAX_LENGTH\x00SQLITE_MAX_COLUMN\x00SQLITE_MAX_SQL_LENGTH\x00SQLITE_MAX_EXPR_DEPTH\x00SQLITE_MAX_COMPOUND_SELECT\x00SQLITE_MAX_VDBE_OP\x00SQLITE_MAX_FUNCTION_ARG\x00SQLITE_MAX_VARIABLE_NUMBER\x00SQLITE_MAX_PAGE_SIZE\x00SQLITE_MAX_PAGE_COUNT\x00SQLITE_MAX_LIKE_PATTERN_LENGTH\x00SQLITE_MAX_TRIGGER_DEPTH\x00SQLITE_DEFAULT_CACHE_SIZE\x00SQLITE_DEFAULT_PAGE_SIZE\x00SQLITE_DEFAULT_FILE_FORMAT\x00SQLITE_DEFAULT_SYNCHRONOUS\x00SQLITE_DEFAULT_WAL_SYNCHRONOUS\x00SQLITE_MAX_ATTACHED\x00SQLITE_MAX_DEFAULT_PAGE_SIZE\x00SQLITE_MAX_WORKER_THREADS\x00TEMP_STORE\x00__GNUC__\x00%s-journal\x00%s-wal\x00%s-shm\x00%s%03d\x00%s-journal%03d\x00%s-wal%03d\x00devsym\x00writecrash\x00CREATE TABLE xyz(dir, name);\x00CREATE TABLE xyz(path, size, data);\x00WITH r(d) AS ( SELECT CASE WHEN dir=?2 THEN ?3 ELSE dir END || '/' || name FROM fsdir WHERE dir=?1 AND name NOT LIKE '.%' UNION ALL SELECT dir || '/' || name FROM r, fsdir WHERE dir=d AND name NOT LIKE '.%') SELECT d FROM r;\x00/\x00CREATE TABLE x(path TEXT, data TEXT)\x00SELECT * FROM %Q.%Q WHERE rowid=?\x00fs\x00fstree\x00register_fs_module\x00abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-!,:*^+=_|?/<> \x00sqlite3_prepare_v2() error: %s\x000123456789abcdef\x00x'\x00test_agg_errmsg16\x00randstr\x00test_destructor\x00test_destructor16\x00hex_to_utf16be\x00hex_to_utf16le\x00hex_to_utf8\x00test_destructor_count\x00test_auxdata\x00test_error\x00test_eval\x00test_isolation\x00test_counter\x00real2hex\x00test_decode\x00test_extract\x00test_zeroblob\x00test_getsubtype\x00test_setsubtype\x00test_frombind\x00tx\x00funcxx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789\x00nullx_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789\x00sqlite3_create_function abused test failed\x00invalid matchinfo blob passed to function rank()\x00wrong number of arguments to function rank()\x00rank\x00autoinstall_test_functions\x00abuse_create_function\x00install_fts3_rank_function\x000123456789ABCDEF\x00FILENAME OFFSET AMT\x00r\x00cannot open input file \x00FILENAME OFFSET HEXDATA\x00r+b\x00r+\x00cannot open output file \x00HEXDATA\x00[utf8_to_utf8] unavailable - SQLITE_DEBUG not defined\x00BLOB VARNAME\x00LIST\x00hexio_read\x00hexio_write\x00hexio_get_int\x00hexio_render_int16\x00hexio_render_int32\x00utf8_to_utf8\x00read_fts3varint\x00make_fts3record\x00mem\x00pcache\x00Unknown argument: \"\x00init_wrapper_install\x00init_wrapper_query\x00init_wrapper_uninstall\x00init_wrapper_clear\x00CREATE TABLE x(value INTEGER PRIMARY KEY)\x00CREATE VIRTUAL TABLE temp.%Q USING %Q\x00INTARRAY\x00SQLITE_NOMEM\x00sqlite3_intarray_create\x00sqlite3_intarray_bind\x00jt\x00-journal\x00NBYTES\x00PRIOR NBYTES\x00bad pointer: \x00PRIOR\x00ADDRESS SIZE HEX\x00size must be positive\x00no data\x00ADDRESS SIZE\x00?RESET?\x00DEPT\x00FILENAME\x00COUNTER ?OPTIONS?\x00-repeat\x00-benigncnt\x00TITLE\x00SUB-COMMAND ...\x00start\x00stop\x00dump\x00clear\x00sync\x00SIZE N\x00INSTALLFLAG DISCARDCHANCE PRNGSEEED HIGHSTRESS\x00discard-chance should be between 0 and 100\x00SIZE COUNT\x00BUFID SIZE COUNT\x00illegal arguments - see documentation\x00NBYTE NMINALLOC\x00[DB]\x00sqlite3_db_config(db, 99999) does not return SQLITE_ERROR\x00sqlite3_config(99999) does not return SQLITE_ERROR\x00PARAMETER RESETFLAG\x00SQLITE_STATUS_MEMORY_USED\x00SQLITE_STATUS_MALLOC_SIZE\x00SQLITE_STATUS_PAGECACHE_USED\x00SQLITE_STATUS_PAGECACHE_OVERFLOW\x00SQLITE_STATUS_PAGECACHE_SIZE\x00SQLITE_STATUS_SCRATCH_USED\x00SQLITE_STATUS_SCRATCH_OVERFLOW\x00SQLITE_STATUS_SCRATCH_SIZE\x00SQLITE_STATUS_PARSER_STACK\x00SQLITE_STATUS_MALLOC_COUNT\x00DB PARAMETER RESETFLAG\x00SQLITE_\x00DBSTATUS_\x00LOOKASIDE_USED\x00CACHE_USED\x00SCHEMA_USED\x00STMT_USED\x00LOOKASIDE_HIT\x00LOOKASIDE_MISS_SIZE\x00LOOKASIDE_MISS_FULL\x00CACHE_HIT\x00CACHE_MISS\x00CACHE_WRITE\x00DEFERRED_FKS\x00CACHE_USED_SHARED\x00CACHE_SPILL\x00?INTEGER?\x00sqlite3_free\x00memset\x00memget\x00sqlite3_memory_used\x00sqlite3_memory_highwater\x00sqlite3_memdebug_backtrace\x00sqlite3_memdebug_dump\x00sqlite3_memdebug_fail\x00sqlite3_memdebug_pending\x00sqlite3_memdebug_settitle\x00sqlite3_memdebug_malloc_count\x00sqlite3_memdebug_log\x00sqlite3_config_pagecache\x00sqlite3_config_alt_pcache\x00sqlite3_status\x00sqlite3_db_status\x00install_malloc_faultsim\x00sqlite3_config_heap\x00sqlite3_config_heap_size\x00sqlite3_config_memstatus\x00sqlite3_config_lookaside\x00sqlite3_config_error\x00sqlite3_config_uri\x00sqlite3_config_cis\x00sqlite3_config_pmasz\x00sqlite3_db_config_lookaside\x00sqlite3_dump_memsys3\x00sqlite3_dump_memsys5\x00sqlite3_install_memsys3\x00sqlite3_memdebug_vfs_oom_test\x00%05u\x00 FILENAME [OFFSET AMT]\"\x00unable to open file \"\x00\" for reading\x00md5\x00md5-10x8\x00md5file\x00md5file-10x8\x00md5sum\x00%03d\x00multiplexor.xAccess failure on %s\x00multiplexor.xOpen failure on %s\x00multiplex_control\x00chunksize\x00multiplex_truncate\x00multiplex/%z\x00multiplex\x00NAME MAKEDEFAULT\x00-force\x00?-force?\x00enable\x00chunk_size\x00max_chunks\x00HANDLE DBNAME SUB-COMMAND INT-VALUE\x00expected database handle, got \"\x00sqlite3_multiplex_initialize\x00sqlite3_multiplex_shutdown\x00sqlite3_multiplex_control\x00fast\x00recursive\x00static_main\x00static_mem\x00static_open\x00static_prng\x00static_lru\x00static_pmem\x00static_app1\x00static_app2\x00static_app3\x00static_vfs1\x00static_vfs2\x00static_vfs3\x00mutex counters are \x00already installed\x00not installed\x00singlethread\x00multithread\x00serialized\x00mutex name\x00disable_mutex_init\x00disable_mutex_try\x00sqlite3_shutdown\x00sqlite3_initialize\x00sqlite3_config\x00enter_static_mutex\x00leave_static_mutex\x00enter_db_mutex\x00leave_db_mutex\x00alloc_dealloc_mutex\x00install_mutex_counters\x00read_mutex_counters\x00clear_mutex_counters\x00\x00\x00\x00\x00\x00\x00\x00vfslog/%z\x00sqlite_ostrace1.....\x00xClose\x00xRead\x00xWrite\x00xTruncate\x00xFilesize\x00xLock\x00xUnlock\x00xCheckResLock\x00xFileControl\x00xSectorSize\x00xDeviceChar\x00xDelete\x00xAccess\x00xFullPathname\x00xRandomness\x00xSleep\x00xCurrentTime\x00xShmUnmap\x00xShmLock\x00xShmBarrier\x00xShmMap\x00annotation\x00CREATE TABLE xxx(event, file, click, rc, size, offset)\x00vfslog\x00VFS\x00failed\x00VFS PARENT LOGFILE\x00bad sqlite3 handle: \x00annotate\x00finalize\x00register\x00quota/%z\x00quota\x00::piLimit_\x00PATTERN LIMIT SCRIPT\x00FILENAME MODE\x00HANDLE SIZE NELEM\x00HANDLE SIZE NELEM CONTENT\x00HANDLE ?HARDSYNC?\x00HANDLE OFFSET WHENCE\x00SEEK_SET\x00SEEK_CUR\x00SEEK_END\x00WHENCE should be SEEK_SET, SEEK_CUR, or SEEK_END\x00HANDLE SIZE\x00PATTERN TEXT\x00sqlite3_quota_initialize\x00sqlite3_quota_shutdown\x00sqlite3_quota_set\x00sqlite3_quota_file\x00sqlite3_quota_dump\x00sqlite3_quota_fopen\x00sqlite3_quota_fread\x00sqlite3_quota_fwrite\x00sqlite3_quota_fclose\x00sqlite3_quota_fflush\x00sqlite3_quota_fseek\x00sqlite3_quota_rewind\x00sqlite3_quota_ftell\x00sqlite3_quota_ftruncate\x00sqlite3_quota_file_size\x00sqlite3_quota_file_truesize\x00sqlite3_quota_file_mtime\x00sqlite3_quota_remove\x00sqlite3_quota_glob\x00sqlite3_quota_file_available\x00sqlite3_quota_ferror\x00cube\x00circle\x00Qcircle\x00breadthfirstsearch\x00register_cube_geom\x00register_circle_geom\x00CREATE TABLE x(database,tablename,cid,name,type,not_null,dflt_value,pk)\x00SELECT name FROM sqlite_temp_schema WHERE type='table'\x00SELECT name FROM %Q.sqlite_schema WHERE type='table'\x00PRAGMA %Q.table_info(%Q)\x00PRAGMA database_list\x00register_schema_module\x00PRAGMA main.journal_mode\x00CMDNAME PATH ?VFS? ?BUSY-HANDLER-SCRIPT?\x00sqlite3demo_superlock\x00open\x00access\x00getcwd\x00stat\x00fstat\x00ftruncate\x00fcntl\x00pread\x00pread64\x00pwrite\x00pwrite64\x00fchmod\x00fallocate\x00mremap\x00SYSCALL-LIST\x00system-call\x00?COUNT PERSIST?\x00EACCES\x00EINTR\x00EIO\x00EOVERFLOW\x00ENOMEM\x00EAGAIN\x00ETIMEDOUT\x00EBUSY\x00EPERM\x00EDEADLK\x00ENOLCK\x00SYSCALL ERRNO\x00errno\x00PGSZ\x00getpagesize\x00pgsz out of range\x00fault\x00install\x00uninstall\x00list\x00defaultvfs\x00pagesize\x00VFS does not support xSetSystemCall\x00test_syscall\x00load_testfixture_extensions\x00SLAVE\x00CREATE TABLE x( name TEXT, arrayname TEXT, value TEXT, fullname TEXT PRIMARY KEY) WITHOUT ROWID\x00array names\x00tclvar_filter_cmd\x00%s(%s)\x00expr {[info exists ::tclvar_set_omit] && $::tclvar_set_omit}\x00the 'fullname' column must be TEXT\x00prohibited TCL variable change\x00proc like {pattern str} {\n set p [string map {% * _ ?} $pattern]\n string match $p $str\n}\nproc tclvar_filter_cmd {eq match glob regexp like} {\n set res {}\n set pattern $eq\n if {$pattern=={}} { set pattern $match }\n if {$pattern=={}} { set pattern * }\n foreach v [uplevel #0 info vars $pattern] {\n if {($glob=={} || [string match $glob [uplevel #0 set $v]])\n && ($like=={} || [like $like [uplevel #0 set $v]])\n && ($regexp=={} || [regexp $regexp [uplevel #0 set $v]])\n } {\n lappend res $v\n }\n }\n set res\n}\n\x00register_tclvar_module\x00clock_seconds\x00sqlthread\x00sqlite3_blocking_step\x00sqlite3_blocking_prepare_v2\x00sqlite3_nonblocking_prepare_v2\x00set\x00Error in Tcl_CreateThread()\x00no parent thread\x00parent\x00spawn\x00VARNAME SCRIPT\x00DBNAME\x00id\x00%s \x00SQLITE_IOERR\x00SQLITE_LOCKED\x00SQLITE_BUSY\x00SQLITE_READONLY\x00SQLITE_READONLY_CANTINIT\x00SQLITE_NOTFOUND\x00SQLITE_OMIT\x00normal|dataonly\x00full|dataonly\x00xCheckReservedLock\x00BEGIN_ATOMIC_WRITE\x00COMMIT_ATOMIC_WRITE\x00ZIPVFS\x00anon\x00SQLITE_ACCESS_EXISTS\x00SQLITE_ACCESS_READWRITE\x00SQLITE_ACCESS_READ\x00xShmOpen\x00 lock\x00 unlock\x00 shared\x00 exclusive\x00shm\x00delete\x00filter\x00ioerr\x00fullerr\x00cantopenerr\x00script\x00devchar\x00sectorsize\x00subcommand\x00FILE ?VALUE?\x00failed to get full path: \x00no such file: \x00unknown method: \x00?CNT PERSIST?\x00default\x00undeletable_when_open\x00immutable\x00?ATTR-LIST?\x00bad flags: \x00?VALUE?\x00-noshm\x00-szosfile\x00-mxpathname\x00-iversion\x00-fullshm\x00VFSNAME ?-noshm BOOL? ?-fullshm BOOL? ?-default BOOL? ?-mxpathname INT? ?-szosfile INT? ?-iversion INT?\x00shared\x00lock\x00unlock\x00DB DBNAME (shared|exclusive) (lock|unlock) OFFSET N\x00ARG\x00DB DBNAME SLOT ?VALUE?\x00*-shm is not yet mapped\x00testvfs\x00vfs_shmlock\x00vfs_set_readmark\x00DB NAME XSTEP XFINAL XVALUE XINVERSE\x00fff\x00misuse test error\x00invalid argument\x00sumint\x00sum\x00sqlite3_create_window_function\x00test_create_window_function_misuse\x00test_create_sumint\x00test_override_sum\x00" 80771 var ts = (*reflect.StringHeader)(unsafe.Pointer(&ts1)).Data